--------------------- -- Your Name is Benny --------------------- 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:PlayerNoClip() return true end local PT = FindMetaTable( "Player" ) 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 ) ) ply:SetPoseParameter( "move_x", normal.x * (len2d/200) ) ply:SetPoseParameter( "move_y", normal.y * (len2d/200) ) ply:SetAllowFullRotation( true ) ply:SetAngles( Angle( 0, ply:EyeAngles().y, 0 ) ) --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 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 ) ply:SetHull( Vector( -8, -8, 0 ), Vector( 8, 8, 72 ) ) ply:SetHullDuck( Vector( -8, -8, 0 ), Vector( 8, 8, 16 ) ) if mv:KeyPressed( IN_SPEED ) and !ply:GetInDive() 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 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) 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)