--------------------- -- Your Name is Benny --------------------- function GM:PlayerInitialSpawn( ply, transiton ) if BennyGame:GetType() == BG_GTYPE_MP then ply:SetTeam( BennyGame:BestAutoJoinTeam() ) else ply:SetTeam( 7 ) end end function GM:PlayerSpawn( ply ) player_manager.SetPlayerClass( ply, "player_benny" ) ply:SetViewOffset( Vector( 0, 0, 64 ) ) ply:SetViewOffsetDucked( Vector( 0, 0, 50 ) ) ply:Give( "itemhandler" ) ply:SetStamina( 1 ) ply:SetCrouchedWalkSpeed( 0.3 ) ply:SetDuckSpeed( 0.1 ) ply:SetUnDuckSpeed( 0.1 ) ply:SetSlowWalkSpeed( 100 ) ply:SetWalkSpeed( 200 ) ply:SetRunSpeed( 200 ) ply:SetStepSize( 18 ) ply:SetCanZoom( false ) ply:SetHealth_Blood( 1000 ) ply:SetHealth_Stamina( 1000 ) ply:MakeCharacter() end function GM:PlayerPostThink( ply ) if ply:GetTouchedObjective():IsValid() then if ply:GetTouchedObjectiveTime()+0.1 <= CurTime() then ply:SetTouchedObjective( NULL ) end end end function GM:PlayerNoClip() return true end local PT = FindMetaTable( "Player" ) concommand.Add("b-cheat_setxp", function( ply, cmd, args ) if !ply or !ply:IsValid() then return end ply:SetLevel_XP( args[1] ) end) concommand.Add("b-cheat_rewardxp", function( ply, cmd, args ) if !ply or !ply:IsValid() then return end ply:RewardXP( args[1] ) end) function PT:RewardXP( amt ) if CLIENT then return end --self.amountcollected = (self.amountcollected or 0) + amt self:SetLevel_XP( self:GetLevel_XP() + amt ) --self:ChatPrint( "Rewarded " .. amt .. " XP" ) end function PT:RewardScore() if CLIENT then return end end local bgl = { ["benny"] = { [0] = Vector( 0.275, 0.7, 0.7 ), [1] = 17, [2] = 7, [3] = 2, [4] = 11, [5] = 3, [6] = 0, [7] = 0, [8] = 3, [9] = 0, [10] = 0, [11] = 0, [12] = 3, [13] = 0, }, ["nikki"] = { [0] = Vector( 0.9, 0.3, 0.9 ), [1] = 17, [2] = 7, [3] = 2, [4] = 11, [5] = 3, [6] = 0, [7] = 0, [8] = 2, [9] = 1, [10] = 5, [11] = 0, [12] = 3, [13] = 0, }, ["igor"] = { [0] = Vector( 0.776, 0.929, 0.89 ), [1] = 4, [2] = 6, [3] = 2, [4] = 3, [5] = 1, [6] = 0, [7] = 2, [8] = 3, [9] = 3, [10] = 6, [11] = 2, [12] = 1, [13] = 0, }, ["yanghao"] = { [0] = Vector( 0.627, 0.21, 0.186 ), [1] = 13, [2] = 2, [3] = 0, [4] = 3, [5] = 0, [6] = 1, [7] = 3, [8] = 0, [9] = 3, [10] = 4, [11] = 0, [12] = 0, [13] = 0, }, ["mp_cia"] = { [0] = Vector( 1, 1, 1 ) }, ["mp_plasof"] = { [0] = Vector( 1, 1, 1 ) }, ["mp_militia"] = { [0] = Vector( 1, 1, 1 ) }, ["mp_natguard"] = { [0] = Vector( 1, 1, 1 ) }, ["mp_viper"] = { [0] = Vector( 1, 1, 1 ) }, ["mp_halo"] = { [0] = Vector( 1, 1, 1 ) }, } function PT:MakeCharacter() local char = "benny" --self:SetModel( "models/player/infoplayerrealism.mdl" ) self:SetModel( "models/benny/player/benny_placeholder3.mdl" ) --self:SetPlayerColor( bgl[char][0] ) --self:SetBodygroup( 0, 0 ) --self:SetSkin( 3 ) --for i, v in ipairs( bgl[char] ) do -- self:SetBodygroup( i, v ) --end end function PT:HandlerCheck() local wep = self:GetActiveWeapon() return ( wep:IsValid() and wep:GetClass() == "itemhandler" and wep.GetActiveR ) and wep or false end -- Temporary function GM:UpdateAnimation( ply, vel, maxseqgroundspeed ) ply:SetPlaybackRate( 1 ) local normal = vel:GetNormalized() local len2d = vel:Length2D() normal:Rotate( Angle( 0, -ply:EyeAngles().y, 0 ) ) local speed = (len2d/200) --print( string.format( "x: %G, y: %G", normal.x, normal.y )) local biggerone = math.max( math.abs(normal.x), math.abs(normal.y) ) local needer = 1+((1-biggerone)/biggerone) normal.x = normal.x * needer normal.y = normal.y * needer local diveend = ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_end_handgun") local divestart = ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_start_handgun") if ply:GetInDive() or diveend then speed = 1 end ply:SetPoseParameter( "move_x", normal.x * speed ) ply:SetPoseParameter( "move_y", normal.y * speed ) local magic = ply:EyeAngles().y magic = -(magic - ply:GetRenderAngles().y) --magic = magic % 180 if magic < -180 then magic = magic + 360 elseif magic > 180 then magic = magic - 360 end magic = magic * 0.75 ply:SetPoseParameter( "aim_p", -ply:EyeAngles().p/90 ) ply:SetPoseParameter( "aim_y", 0 )--magic/90 ) ply:SetAllowFullRotation( false ) --ply:SetAngles( Angle( 0, ply:EyeAngles().y, 0 ) ) ply:SetRenderAngles( Angle( 0, ply:EyeAngles().y, 0 ) ) if diveend then local magicnumber = ply:GetLayerCycle( GESTURE_SLOT_JUMP ) magicnumber = math.Remap( magicnumber, 0.5, 0.75, 1, 0 ) magicnumber = math.Clamp( magicnumber, 0, 1 ) ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, magicnumber ) elseif divestart then local magicnumber = ply:GetLayerCycle( GESTURE_SLOT_JUMP ) magicnumber = math.Remap( magicnumber, 0.1, 0.6, 1, 0 ) magicnumber = math.Clamp( magicnumber, 0, 1 ) ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, magicnumber ) else ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, 1 ) end --local dir = ply:GetVelocity():GetNormalized() --local dira --if dir:IsZero() or ply:GetVelocity():Length2D() < 50 then -- dira = ply:EyeAngles().y --else -- dira = dir:Angle().y --end --ply:SetAngles( Angle( 0, dira, 0 ) ) end ANIM_IDLE = 0 ANIM_IDLE_RIFLE = 1 ANIM_IDLE_DUCK = 2 ANIM_RUN = 3 ANIM_RUN_RIFLE = 4 local Animations = { ["idle"] = { ["none"] = "idle", ["handgun"] = "idle_handgun", ["rifle"] = "idle_rifle", }, ["run"] = { ["none"] = "run", ["handgun"] = "run_handgun", ["rifle"] = "run_rifle", }, } function GM:CalcMainActivity( ply, velocity ) local plyTable = ply:GetTable() plyTable.CalcIdeal = -1 local w = ply:HandlerCheck() local wpntype = "none" if w then if w:ItemR() and w:ItemR().Class.HoldType then wpntype = w:ItemR().Class.HoldType end end plyTable.CalcSeqOverride = ply:LookupSequence( Animations["idle"][wpntype] ) if ply:Crouching() then plyTable.CalcSeqOverride = ply:LookupSequence( "idle_duck" ) end self:HandlePlayerLanding( ply, velocity, plyTable.m_bWasOnGround ) if true or !( self:HandlePlayerNoClipping( ply, velocity, plyTable ) || self:HandlePlayerDriving( ply, plyTable ) || self:HandlePlayerVaulting( ply, velocity, plyTable ) || self:HandlePlayerJumping( ply, velocity, plyTable ) || self:HandlePlayerSwimming( ply, velocity, plyTable ) || self:HandlePlayerDucking( ply, velocity, plyTable ) ) then local len2d = velocity:Length2D() if ( len2d > 10 ) then plyTable.CalcSeqOverride = ply:LookupSequence( Animations["run"][wpntype] ) end end if ply:GetInDive() then plyTable.CalcSeqOverride = ply:LookupSequence( "dive_idle_handgun" ) end plyTable.m_bWasOnGround = ply:IsOnGround() plyTable.m_bWasNoclipping = ( ply:GetMoveType() == MOVETYPE_NOCLIP && !ply:InVehicle() ) return plyTable.CalcIdeal, plyTable.CalcSeqOverride end function GM:HandlePlayerJumping( ply, vel ) return false end function GM:HandlePlayerVaulting( ply, vel ) return false end function GM:HandlePlayerLanding( ply, vel, onground ) return false end function GM:HandlePlayerNoClipping( ply, vel ) return false end hook.Add( "EntityTakeDamage", "EntityDamageExample", function( target, dmginfo ) if target:IsPlayer() then dmginfo:ScaleDamage( 0 ) end end ) if CLIENT then hook.Add("CreateMove", "Benny_CreateMove_Controls", function( cmd ) if input.IsButtonDown( KEY_E ) then cmd:AddKey( IN_WEAPON1 ) end if input.IsButtonDown( KEY_Q ) then cmd:AddKey( IN_WEAPON2 ) end if input.IsButtonDown( KEY_C ) then cmd:AddKey( IN_GRENADE1 ) end if input.IsButtonDown( KEY_Z ) then cmd:AddKey( IN_GRENADE2 ) end if input.IsButtonDown( KEY_R ) then cmd:AddKey( IN_ALT1 ) end if input.IsButtonDown( KEY_T ) then cmd:AddKey( IN_ALT2 ) end if input.IsButtonDown( KEY_X ) then cmd:AddKey( IN_BULLRUSH ) end end) end hook.Add("Move", "Benny_Move", function( ply, mv ) if mv:KeyDown( IN_SPEED ) and !ply:GetInDive() and (ply:GetDivedAt() + 0.5 <= CurTime()) then local cool = Vector( mv:GetForwardSpeed(), -mv:GetSideSpeed(), 0 ) cool:Normalize() cool:Rotate( Angle( 0, mv:GetMoveAngles().y, 0 ) ) cool:Mul( 250 ) cool.z = 150 mv:SetVelocity( cool )--(Angle( -30, ply:EyeAngles().y, 0 ):Forward()*250) ) ply:SetGroundEntity( NULL ) ply:SetInDive( true ) ply:SetDivedAt( CurTime() ) if SERVER or CLIENT and IsFirstTimePredicted() then ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_start_handgun" ), 0, true ) end if (SERVER) or (CLIENT and IsFirstTimePredicted()) then local rfil = nil if SERVER then rfil = RecipientFilter() rfil:AddPAS(ply:GetPos()) rfil:RemovePlayer( ply ) end ply:EmitSound("weapons/slam/throw.wav", 70, 100, .25, nil, nil, nil, rfil) end end if ply:OnGround() and ply:GetInDive() then if (SERVER) or (CLIENT and IsFirstTimePredicted()) then local rfil = nil if SERVER then rfil = RecipientFilter() rfil:AddPAS(ply:GetPos()) rfil:RemovePlayer( ply ) end ply:EmitSound("npc/combine_soldier/gear1.wav", 70, 100, .25, nil, nil, nil, rfil) end ply:SetInDive(false) ply:SetDivedAt( CurTime() ) if SERVER or CLIENT and IsFirstTimePredicted() then ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_end_handgun" ), 0, true ) end mv:SetVelocity( mv:GetVelocity() + Vector( 0, 0, 120 ) ) ply:SetGroundEntity( NULL ) end --if !ply:OnGround() and ply:GetInDive() then -- local da = ply:GetDivedAt() -- local supertime = math.Remap( CurTime(), da + 0.5, da + 1, 300, 0 ) -- supertime = math.Clamp( supertime, 0, 300 ) -- local vel = mv:GetVelocity() -- vel.z = vel.z + supertime*FrameTime() -- mv:SetVelocity( vel ) --end end)