2024-03-07 21:19:30 -05:00
|
|
|
|
|
|
|
---------------------
|
|
|
|
-- 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 )
|
|
|
|
|
2024-04-06 09:30:09 -04:00
|
|
|
ply:SetHealth_Blood( 1000 )
|
|
|
|
ply:SetHealth_Stamina( 1000 )
|
|
|
|
|
2024-03-07 21:19:30 -05:00
|
|
|
ply:MakeCharacter()
|
|
|
|
end
|
|
|
|
|
2024-03-07 22:34:29 -05:00
|
|
|
function GM:PlayerNoClip()
|
|
|
|
return true
|
|
|
|
end
|
2024-03-07 21:19:30 -05:00
|
|
|
|
|
|
|
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"
|
2024-04-06 09:30:09 -04:00
|
|
|
--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
|
2024-03-07 21:19:30 -05:00
|
|
|
end
|
|
|
|
|
2024-03-12 18:43:31 -04:00
|
|
|
function PT:HandlerCheck()
|
2024-03-07 21:19:30 -05:00
|
|
|
local wep = self:GetActiveWeapon()
|
|
|
|
return ( wep:IsValid() and wep:GetClass() == "itemhandler" and wep.GetActiveR ) and wep or false
|
|
|
|
end
|
2024-03-23 21:18:11 -04:00
|
|
|
|
|
|
|
-- Temporary
|
|
|
|
|
|
|
|
function GM:UpdateAnimation( ply, vel, maxseqgroundspeed )
|
2024-04-06 09:30:09 -04:00
|
|
|
ply:SetPlaybackRate( 1 )
|
|
|
|
|
|
|
|
local normal = vel:GetNormalized()
|
|
|
|
local len2d = vel:Length2D()
|
|
|
|
normal:Rotate( Angle( 0, -ply:EyeAngles().y, 0 ) )
|
2024-04-07 19:04:18 -04:00
|
|
|
|
|
|
|
local speed = (len2d/200)
|
|
|
|
ply:SetPoseParameter( "move_x", normal.x * speed )
|
|
|
|
ply:SetPoseParameter( "move_y", normal.y * speed )
|
2024-04-06 09:30:09 -04:00
|
|
|
|
|
|
|
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
|
2024-03-23 21:18:11 -04:00
|
|
|
|
2024-04-06 09:30:09 -04:00
|
|
|
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" )
|
2024-03-23 21:18:11 -04:00
|
|
|
end
|
|
|
|
|
2024-04-06 09:30:09 -04:00
|
|
|
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
|
2024-03-23 21:18:11 -04:00
|
|
|
|
|
|
|
end
|
2024-04-07 19:04:18 -04:00
|
|
|
|
|
|
|
if ply:GetInDive() then
|
|
|
|
plyTable.CalcSeqOverride = ply:LookupSequence( "dive_idle" )
|
|
|
|
end
|
2024-03-23 21:18:11 -04:00
|
|
|
|
2024-04-06 09:30:09 -04:00
|
|
|
plyTable.m_bWasOnGround = ply:IsOnGround()
|
|
|
|
plyTable.m_bWasNoclipping = ( ply:GetMoveType() == MOVETYPE_NOCLIP && !ply:InVehicle() )
|
|
|
|
|
|
|
|
return plyTable.CalcIdeal, plyTable.CalcSeqOverride
|
2024-03-23 21:18:11 -04:00
|
|
|
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
|
2024-04-06 09:30:09 -04:00
|
|
|
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 ) )
|
2024-04-07 19:04:18 -04:00
|
|
|
ply:SetHullDuck( Vector( -8, -8, 0 ), Vector( 8, 8, 32 ) )
|
|
|
|
if mv:KeyDown( IN_SPEED ) and !ply:GetInDive() and (ply:GetDivedAt() + 0.5 <= CurTime()) then
|
2024-04-06 09:30:09 -04:00
|
|
|
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() )
|
2024-04-07 19:04:18 -04:00
|
|
|
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_start" ), 0, true )
|
2024-04-06 09:30:09 -04:00
|
|
|
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)
|
2024-04-07 19:04:18 -04:00
|
|
|
ply:SetDivedAt( CurTime() )
|
|
|
|
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_end" ), 0, true )
|
2024-04-06 09:30:09 -04:00
|
|
|
end
|
2024-04-07 19:04:18 -04:00
|
|
|
--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
|
2024-04-06 09:30:09 -04:00
|
|
|
end)
|