Overhaul of a bunch of stuff

This commit is contained in:
Fesiug 2024-04-06 09:30:09 -04:00
parent 42be9ec6ab
commit 36c8d47b0e
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
8 changed files with 637 additions and 71 deletions

View File

@ -35,6 +35,43 @@ local function recurse( modify, includer )
end
end
if SERVER then
util.AddNetworkString("Benny_ItemSlept")
else
net.Receive("Benny_ItemSlept", function()
local ent = net.ReadEntity()
if ent:IsValid() then
ent:SetPredictable( false )
print("CL Stopping prediction on", ent)
end
end)
end
function ENT:Think()
if CLIENT then return end
self.BAsleep = self.BAsleep or false
local ph = self:GetPhysicsObject()
if ph:IsValid() and !self:GetOwner():IsValid() then
if ph:IsAsleep() then
if !self.BAsleep then
net.Start("Benny_ItemSlept")
net.WriteEntity(self)
net.Broadcast()
print("SV Stopping prediction on", self)
self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
self.BAsleep = true
end
elseif self.BAsleep then
-- print(self, "Woke up")
self.BAsleep = false
end
end
end
function ENT:SetupDataTables()
local NWVars = {}
recurse( NWVars, self.ID )

View File

@ -25,6 +25,8 @@ SWEP.Secondary.Automatic = true
function SWEP:SetupDataTables()
self:NetworkVar( "Entity", 0, "ActiveR" )
self:NetworkVar( "Entity", 1, "ActiveL" )
self:NetworkVar( "Entity", 2, "DesireR" )
self:NetworkVar( "Entity", 3, "DesireL" )
end
function SWEP:ItemR( run )
@ -58,9 +60,10 @@ function SWEP:ItemCheckTrace()
p:LagCompensation( true )
tracedef.filter = p
tracedef.start = p:EyePos()
tracedef.endpos = p:EyePos() + (p:GetAimVector() * 72)
tracedef.endpos = p:EyePos() + (p:GetAimVector() * 90)
local trace = util.TraceHull(tracedef)
p:LagCompensation( false )
--print(trace.StartPos:Distance(trace.HitPos))
p:LagCompensation( false )
return trace
end
@ -89,9 +92,6 @@ function SWEP:PrimaryAttack()
local p = self:GetOwner()
if self:ItemR() then
self:ItemR("Attack")
elseif SERVER then
local trace = self:ItemCheckTrace()
self:EquipItem( trace.Entity )
end
end
@ -103,8 +103,8 @@ end
function SWEP:SecondaryAttack()
local p = self:GetOwner()
if p:KeyPressed(IN_ATTACK2) then
self:DropItem()
if self:ItemR() then
--self:ItemR("Attack2")
end
end
@ -115,8 +115,10 @@ else
local ent = net.ReadEntity()
if ent:IsValid() then
ent:SetPredictable( net.ReadBool() )
print("Starting prediction on", ent)
else
print("Tried to make an ent predictable")
print("Tried to make an ent predictable but it wasn't valid.")
debug.Trace()
end
end)
end
@ -174,6 +176,7 @@ function SWEP:DropItem()
ent:RemoveEffects( EF_BONEMERGE )
ent:PhysicsInit( SOLID_VPHYSICS )
ent:SetMoveType( MOVETYPE_VPHYSICS )
ent:SetCollisionGroup( COLLISION_GROUP_PROJECTILE )
ent:SetNoDraw( false )
ent:SetPos( p:EyePos() + p:GetAimVector() * 0 )
@ -185,13 +188,13 @@ function SWEP:DropItem()
inv:Sync()
local ep = ent:GetPhysicsObject()
ep:SetVelocity( p:GetAimVector() * 700 )
ep:SetAngleVelocity( Vector( 0, -360*4, 0 ) )
ep:SetVelocity( p:GetAimVector() * 800 )
ep:SetAngleVelocity( Vector( 0, -360*3, 0 ) )
ep:Wake()
net.Start("AEINV_PredictItem")
net.WriteEntity( ent )
net.WriteBool( false )
net.Send( p )
--net.Start("AEINV_PredictItem")
-- net.WriteEntity( ent )
-- net.WriteBool( false )
--net.Send( p )
end
end
@ -199,11 +202,40 @@ function SWEP:Think()
local p = self:GetOwner()
if p:IsValid() then
if self:ItemR() then
self:ItemR("Think")
if p:KeyDown(IN_WEAPON1) then
if SERVER then
if !self:ItemR() then
local trace = self:ItemCheckTrace()
self:EquipItem( trace.Entity )
end
end
end
if p:KeyReleased(IN_WEAPON1) then
if SERVER then
if self:ItemR() then
self:DropItem()
end
end
end
if p:KeyPressed(IN_WEAPON2) then
end
if p:KeyPressed(IN_ALT1) then
end
if p:KeyPressed(IN_ALT2) then
end
self:SetHoldType( self:ItemR() and (self:ItemR().Class.HoldType or "rpg") or "normal" )
if p:KeyPressed(IN_GRENADE1) then
if self:ItemR() and self:ItemR().Class.Alt then
self:ItemR("Alt")
end
end
if p:KeyPressed(IN_GRENADE2) then
end
if self:ItemR() then
self:ItemR("Think")
end
--self:SetHoldType( self:ItemR() and (self:ItemR().Class.HoldType or "rpg") or "normal" )
else
print( self, "Thinking without an owner." )
end

View File

@ -4,7 +4,7 @@
---------------------
local cam_f = CreateConVar( "b-cam_f", -50 )
local cam_r = CreateConVar( "b-cam_r", 14 )
local cam_r = CreateConVar( "b-cam_r", 12 )
local cam_u = CreateConVar( "b-cam_u", 0 )
local cam_fov = CreateConVar( "b-cam_fov", 75 )
@ -12,9 +12,12 @@ local m = 3
local m2 = Vector( m, m, m )
local m1 = m2:GetNegated()
function GM:CalcView( ply, pos, ang, fov )
local f, r, u = ang:Forward(), ang:Right(), ang:Up()
TPSOverride = TPSOverride or Angle( 0, 0, 0 )
function CamSpot( ang, pos )
if !ang then ang = TPSOverride end
if !pos then pos = LocalPlayer():EyePos() end
local f, r, u = TPSOverride:Forward(), TPSOverride:Right(), TPSOverride:Up()
local tr = {
start = pos,
endpos = pos + (f*cam_f:GetFloat()) + (r*cam_r:GetFloat()) + (u*cam_u:GetFloat()),
@ -23,13 +26,58 @@ function GM:CalcView( ply, pos, ang, fov )
maxs = m2,
}
tr = util.TraceHull(tr)
return tr.HitPos
end
function GM:CalcView( ply, pos, ang, fov )
local view = {
origin = tr.HitPos,
angles = angles,
origin = CamSpot(TPSOverride), -- pos includes the smoothstair offset which looks stupid here
angles = TPSOverride,
fov = cam_fov:GetFloat(),
drawviewer = true
}
return view
end
end
hook.Add( "InputMouseApply", "Benny_InputMouseApply", function( cmd, x, y, ang )
local p = LocalPlayer()
local w = p:HandlerCheck()
if w then--and (y!=0 or x!=0) then
if x != 0 then
TPSOverride.y = TPSOverride.y + (-x*0.022)
end
if y != 0 then
TPSOverride.p = math.Clamp( TPSOverride.p + (y*0.022), -80, 80 )
end
return true
end
end)
hook.Add("CreateMove", "Benny_CreateMove_Camera", function( cmd )
local p = LocalPlayer()
if p:GetMoveType() == MOVETYPE_NOCLIP then
cmd:SetViewAngles( TPSOverride )
else
local tr_forward = util.TraceLine( {
start = CamSpot(TPSOverride),
endpos = CamSpot(TPSOverride)+(TPSOverride:Forward()*(2^16)),
filter = p,
mask = MASK_SHOT,
} )
local planner = (tr_forward.HitPos-p:EyePos()):Angle()
planner:Normalize()
cmd:SetViewAngles( planner )
local moveintent = Vector( cmd:GetForwardMove(), cmd:GetSideMove(), 0 )
local fixang = Angle()
fixang.y = cmd:GetViewAngles().y - TPSOverride.y
moveintent:Rotate( fixang )
cmd:SetForwardMove( moveintent.x )
cmd:SetSideMove( moveintent.y )
end
end)

View File

@ -19,6 +19,8 @@ local function dospawn( self )
net.Start( "Benny_DebugMenuSpawn" )
net.WriteString( self.iName )
net.SendToServer()
DebugMenu:Remove()
return
end
local function OpenDebugMenu()
@ -29,14 +31,11 @@ local function OpenDebugMenu()
DebugMenu:MakePopup()
DebugMenu:SetKeyboardInputEnabled( false )
local opt = DebugMenu:Add("DCollapsibleCategory")
opt:Dock( TOP )
local plist = DebugMenu:Add("DScrollPanel")
opt:SetContents( plist )
local opt = DebugMenu:Add("DScrollPanel")
opt:Dock( FILL )
for iname, idata in SortedPairs( ITEMS ) do
local button = plist:Add("DButton")
local button = opt:Add("DButton")
button:Dock( TOP )
button:DockMargin( 4, 4, 4, 0 )
button:SetText( l8( idata.PrintName ) )

View File

@ -62,7 +62,7 @@ end
local sizes = {
8, 10, 16, 24, 48
8, 10, 16, 24, 36, 48
}
local function regenfonts()
@ -87,6 +87,47 @@ local COLOR_DARK = Color( 54, 44, 39 )
local COLOR_BRIGHT = Color( 94, 84, 79 )
local COLOR_MAIN = Color( 255, 238, 169 )
local show_letters = {
{ "q", "w", "e", "r", "t", "y" },
{ "a", "s", "d", "f", "g", "h" },
{ "shift", "z", "x", "c", "v", "b", "n" },
{ "ctrl", "alt", "space" },
}
local translate_letters = {
["e"] = "weapon 1",
["q"] = "weapon 2",
["c"] = "grenade 1",
["z"] = "grenade 2",
["r"] = "alt 1",
["t"] = "alt 2",
["x"] = "bullrush",
["shift"] = "speed",
}
local function commoncode( set )
for index, letter in ipairs( set ) do
local lettercode = input.GetKeyCode( letter )
local keydown = input.IsKeyDown( lettercode )
local thecolor = keydown and COLOR_MAIN or COLOR_DARK
local fakecolor = ColorAlpha( COLOR_BRIGHT, 60)
hCol( fakecolor )
hRect( (index-1)*(60+4), 0, 60, 40, 2 )
hCol( thecolor )
hORect( (index-1)*(60+4), 0, 60, 40, 2 )
local x, y = hXY( (index-1)*(60+4) + 30, 20+3 )
draw.SimpleText( letter:upper(), "HUD_36", x, y, thecolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
local tlated = translate_letters[letter]
if tlated then
local x, y = hXY( (index-1)*(60+4) + 30, 20 + 6 )
draw.SimpleText( tlated, "HUD_16", x, y, thecolor, TEXT_ALIGN_CENTER )
end
end
end
-- Drawing
function GM:HUDPaint()
local p = LocalPlayer()
@ -102,9 +143,9 @@ function GM:HUDPaint()
draw.SimpleText( "BENNY", "HUD_48", x, y, COLOR_MAIN )
hCol( COLOR_MAIN )
hRect( 4, 4, (320-4-4) * math.abs( math.sin(CurTime()) ), 40-4-4 )
hRect( 4, 4, (320-4-4) * p:GetHealth_Blood()/1000, 40-4-4 )
hScis( 4, 4, (320-4-4) * math.abs( math.sin(CurTime()) ), 40-4-4 )
hScis( 4, 4, (320-4-4) * p:GetHealth_Blood()/1000, 40-4-4 )
local x, y = hXY( 6, 0 )
draw.SimpleText( "BENNY", "HUD_48", x, y, COLOR_DARK )
hScisoff()
@ -117,11 +158,100 @@ function GM:HUDPaint()
hRect( (i-1)*(120+10), 0, 120, 60 )
local x, y = hXY( (i-1)*(120+10), 0 )
draw.SimpleText( l8( v.Class.PrintName ), "HUD_24", x + 120/2, y + 60/2 - (10), COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
draw.SimpleText( "[ " .. v:GetClip() .. "/" .. v.Class.ClipSize .. " ]", "HUD_24", x + 120/2, y + 60/2 + (10), COLOR_MAIN, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
if v.GetClip2 then
draw.SimpleText( v:GetClip2() .. "/" .. v.Class.ClipSize2, "HUD_16", x + 10, y + 60/2 + (4), COLOR_MAIN, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
end
local drawer = ""
drawer = drawer .. v:GetClip()
drawer = drawer .. "+" .. (v:GetSlideState() == SLIDE_FORWARD and 1 or 0)
drawer = drawer .. "/"
drawer = drawer .. v.Class.ClipSize
draw.SimpleText( drawer, "HUD_16", x + 10, y + 60/2 + (16), COLOR_MAIN, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
draw.SimpleText( v:GetFiremode(), "HUD_16", x + 120 - 10, y + 60/2 + (16), COLOR_MAIN, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER )
end
S_Pop()
end
if false then
S_Push( 20, h - (20 + 40 + 4 + 40 + 4 + 40) )
S_Push( 0, 0 )
commoncode( show_letters[1] )
S_Pop()
S_Push( 18, 40+4 )
commoncode( show_letters[2] )
S_Pop()
S_Push( 18+24 - (40+24), 40+4+40+4 )
commoncode( show_letters[3] )
S_Pop()
S_Push( 0, 40+4+40+4+40+4 )
commoncode( show_letters[4] )
S_Pop()
S_Pop()
end
local itemcheck = handler:ItemCheckTrace()
if true then
S_Push( w - 20, h - 20 )
local hints = {}
table.insert( hints, { "[SHIFT]", "DIVE" } )
table.insert( hints, { "", "INTO PRONE", "HOLD" } )
if handler:ItemR() then
table.insert( hints, { "", "- - - - - - - - - - - -" } )
table.insert( hints, { "[M1]", "FIRE" } )
table.insert( hints, { "[C]", "FIREMODE" } )
table.insert( hints, { "[E]", "THROW" } )
table.insert( hints, { "[R]", "RELOAD" } )
table.insert( hints, { "", "RETAIN MAG", "HOLD" } )
elseif itemcheck.Entity:IsValid() and itemcheck.Entity.BennyItem then
table.insert( hints, { "", "- - - - - - - - - - - -" } )
table.insert( hints, { "[E]", "PICK UP" } )
end
local x, y = hXY( 0, (#hints-1)*(-24) )
for i, v in ipairs( hints ) do
draw.SimpleText( v[1], "HUD_24", x - 150, y - 24 + (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_CENTER )
draw.SimpleText( v[2], "HUD_24", x, y - 24 + (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_RIGHT )
if v[3] then
draw.SimpleText( v[3], "HUD_16", x - 150, y - 24+3 + (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_CENTER )
end
end
S_Pop()
end
local trac = p:GetEyeTrace().HitPos:ToScreen()
local trac2 = util.TraceLine( {
start = CamSpot(),
endpos = CamSpot() + TPSOverride:Forward()*(2^16),
filter = p,
} ).HitPos:ToScreen()
local cx, cy = trac.x, trac.y
S_Push( cx, cy )
local size = 8
surface.SetDrawColor( color_white )
hRect( -size/2, -size/2, size, size )
local wep = handler:ItemR()
if wep and wep.Class.FirearmHelper then
local x, y = hXY( 0, 16 )
draw.SimpleText( (!wep:GetLoaded() and "Unloaded") or ((wep:GetSlideState() != SLIDE_FORWARD) and "Cycle") or "", "HUD_24", x, y, COLOR_MAIN, TEXT_ALIGN_CENTER )
end
S_Pop()
local cx, cy = trac2.x, trac2.y
S_Push( cx, cy )
local size = 4
surface.SetDrawColor( 255, 127, 127 )
hRect( -size/2, -size/2, size, size )
S_Pop()
if stack:Size() != 0 then print("Stack unfinished.") end
return
end

View File

@ -46,6 +46,7 @@ AddItem( "base", {
Vars = {
["Float"] = {
"Acquisition",
"HolsterIn",
},
},
HoldType = "slam",
@ -70,16 +71,54 @@ AddItem( "base", {
end,
})
local AnimationLookup = {
["fire"] = {
["handgun"] = "fire_handgun",
["rifle"] = "fire_rifle",
},
["reload"] = {
["handgun"] = "reload_handgun",
["rifle"] = "reload_handgun",
},
["reload_rack"] = {
["handgun"] = "reload_handgun_rack",
["rifle"] = "reload_handgun_rack",
},
["reload_insert"] = {
["handgun"] = "reload_handgun_insert",
["rifle"] = "reload_handgun_insert",
},
["deploy"] = {
["handgun"] = "deploy_handgun",
["rifle"] = "deploy_handgun",
},
["holster"] = {
["handgun"] = "holster_handgun",
["rifle"] = "holster_handgun",
},
}
SLIDE_FORWARD = 0 -- loaded
SLIDE_EMPTY = 1 -- empty
SLIDE_BACK = 2 -- back
AddItem( "base_firearm", {
PrintName = "Base Firearm",
Description = "Item base for firearms.",
Category = "base",
Base = "base",
FirearmHelper = true,
Vars = {
["Bool"] = {
"Loaded",
},
["Int"] = {
"Clip",
"BurstCount",
"Firemode",
"SlideState", -- 0 = forward and loaded, 1 = forward and empty, 2 = back and empty
},
["Float"] = {
"Delay",
@ -105,6 +144,7 @@ AddItem( "base_firearm", {
ITEMS["base"].Initialize( class, ent, handler )
ent:SetClip( class.ClipSize )
ent:SetLoaded(true)
print( class, "Initialized a firearm" )
end,
@ -129,13 +169,18 @@ AddItem( "base_firearm", {
ent:SetDelayBurst( CurTime() + class.BurstDelay )
end
end
if ent:GetRefillTime() != 0 and ent:GetRefillTime() <= CurTime() then
ent:SetClip( class.ClipSize )
ent:SetRefillTime( 0 )
end
end,
["Attack"] = function( class, ent, handler )
if ent:GetClip() <= 0 then return end
--if ent:GetClip() <= 0 then return end
if ent:GetDelay() > CurTime() then return end
if ent:GetDelayBurst() > CurTime() then return end
if ent:GetBurstCount() >= class.BurstCount then return end
if ent:GetSlideState() != SLIDE_FORWARD then handler:EmitSound( "benny/weapons/noammo.ogg", 70, 150, 0.4, CHAN_STATIC ) ent:SetDelay( CurTime() + 0.25 ) ent:SetBurstCount( 0 ) return end
local Runaway = class.BurstRunaway
local BAuto = class.BurstAuto
@ -146,7 +191,19 @@ AddItem( "base_firearm", {
ent:SetBurstCount( 0 )
end
end
ent:SetClip( ent:GetClip() - 1 )
ent:SetSlideState( SLIDE_BACK )
--if ent:GetClip() == 0 then
if ent:GetClip() > 0 then
ent:SetClip( ent:GetClip() - 1 )
ent:SetSlideState( SLIDE_FORWARD )
else
handler:EmitSound( "benny/weapons/1911/slidedrop.ogg", 70, 100, 0.4, CHAN_STATIC )
if !ent:GetLoaded() then
ent:SetSlideState( SLIDE_EMPTY )
end
end
ent:SetDelay( CurTime() + class.Delay )
handler:EmitSound( istable(class.FireSound) and TSelShared(class.FireSound, "FireSound") or class.FireSound, 140, 100, 0.4, CHAN_STATIC )
@ -161,24 +218,139 @@ AddItem( "base_firearm", {
Src = p:GetShootPos(),
Spread = Vector( acc, acc, 0 ),
} )
local ply = handler:GetOwner()
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["fire"][class.HoldType] ), 0, true )
end,
["Reload"] = function( class, ent, handler )
if ent:GetClip() >= class.ClipSize then return end
--if ent:GetClip() >= class.ClipSize then return end
--handler:EmitSound( "weapons/m4a1/m4a1_boltpull.wav", 70, 125, 0.4, CHAN_STATIC )
--ent:SetRefillTime( CurTime() + 0.1 )
--handler:EmitSound( "benny/weapons/basic.ogg", 70, 100, 0.4, CHAN_STATIC )
if ent:GetDelay() > CurTime() then return end
handler:EmitSound( "weapons/m4a1/m4a1_boltpull.wav", 70, 125, 0.4, CHAN_STATIC )
ent:SetDelay( CurTime() + 0.25 )
ent:SetClip( class.ClipSize )
ent:SetDelay( CurTime() + 0.5 )
local ply = handler:GetOwner()
if (ent:GetClip() > 0) and ent:GetSlideState() == SLIDE_BACK then
handler:EmitSound( "benny/weapons/1911/slidedrop.ogg", 70, 100, 0.4, CHAN_STATIC )
ent:SetSlideState( SLIDE_FORWARD )
ent:SetClip( ent:GetClip() - 1 )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["reload_rack"][class.HoldType] ), 0, true )
elseif (ent:GetClip() > 0) and ent:GetSlideState() == SLIDE_EMPTY then
handler:EmitSound( "benny/weapons/glock/cock.ogg", 70, 100, 0.4, CHAN_STATIC )
ent:SetSlideState( SLIDE_FORWARD )
ent:SetClip( ent:GetClip() - 1 )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["reload_rack"][class.HoldType] ), 0, true )
elseif ent:GetLoaded() then
handler:EmitSound( "benny/weapons/1911/magout.ogg", 70, 100, 0.4, CHAN_STATIC )
ent:SetLoaded( false )
ent:SetClip( 0 )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["reload"][class.HoldType] ), 0, true )
else
handler:EmitSound( "benny/weapons/1911/magin.ogg", 70, 100, 0.4, CHAN_STATIC )
ent:SetLoaded( true )
ent:SetRefillTime( CurTime() + 0.25 )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["reload_insert"][class.HoldType] ), 0, true )
end
end,
["Deploy"] = function( class, ent, handler )
handler:EmitSound( "weapons/usp/usp_slideback.wav", 70, 125, 0.4, CHAN_STATIC )
ent:SetDelay( CurTime() + 0.25 )
local ply = handler:GetOwner()
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["deploy"][class.HoldType] ), 0, true )
end,
["Holster"] = function( class, ent, handler )
handler:EmitSound( "weapons/m4a1/m4a1_deploy.wav", 70, 125, 0.4, CHAN_STATIC )
ent:SetDelay( CurTime() + 0.25 )
if ent:GetSlideState() == SLIDE_BACK then ent:SetSlideState( SLIDE_EMPTY ) end
local ply = handler:GetOwner()
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["holster"][class.HoldType] ), 0, true )
end,
})
AddItem( "base_firearm_ubgl", {
PrintName = "Base Firearm w/ UBGL",
Description = "Item base for firearms that include grenade launchers.",
Category = "base",
Base = "base_firearm",
Vars = {
["Int"] = {
"Clip2",
},
["Float"] = {
"Delay2",
"DelayBurst2",
"RefillTime2",
"Accuracy_Reset2",
"Accuracy_Amount2",
},
},
Delay2 = 0.25,
ClipSize2 = 4,
["Initialize"] = function( class, ent, handler )
ITEMS["base_firearm"].Initialize( class, ent, handler )
ent:SetClip2( class.ClipSize2 )
end,
["Attack"] = function( class, ent, handler )
if ent:GetFiremode() == 1 then
class:Attack2( ent, handler )
else
ITEMS["base_firearm"].Attack( class, ent, handler )
end
end,
["Reload"] = function( class, ent, handler )
if ent:GetFiremode() == 1 then
class:Reload2( ent, handler )
else
ITEMS["base_firearm"].Reload( class, ent, handler )
end
end,
["Alt"] = function( class, ent, handler )
ent:SetFiremode( ent:GetFiremode() == 1 and 0 or 1 )
end,
["Think"] = function( class, ent, handler )
ITEMS["base_firearm"].Think( class, ent, handler )
if ent:GetRefillTime2() != 0 and ent:GetRefillTime2() <= CurTime() then
ent:SetClip2( class.ClipSize2 )
ent:SetRefillTime2( 0 )
end
end,
["Reload2"] = function( class, ent, handler )
if ent:GetClip2() >= class.ClipSize2 then return end
if ent:GetDelay2() > CurTime() then return end
handler:EmitSound( "weapons/m4a1/m4a1_boltpull.wav", 70, 125, 0.4, CHAN_STATIC )
ent:SetDelay2( CurTime() + 0.25 )
ent:SetRefillTime2( CurTime() + 0.1 )
end,
["Attack2"] = function( class, ent, handler )
if ent:GetClip2() <= 0 then return end
if ent:GetDelay2() > CurTime() then return end
if ent:GetDelayBurst2() > CurTime() then return end
if ent:GetBurstCount() >= class.BurstCount then return end
ent:SetClip2( ent:GetClip2() - 1 )
ent:SetDelay2( CurTime() + class.Delay2 )
handler:EmitSound( "weapons/ar2/ar2_altfire.wav", 140, 100, 0.4, CHAN_STATIC )
end,
})
@ -188,8 +360,8 @@ AddItem( "mk23", {
Category = "pistol",
Base = "base_firearm",
Model = "models/weapons/w_pist_usp.mdl",
HoldType = "revolver",
Model = "models/benny/weapons/testgun.mdl",
HoldType = "handgun",
ClipSize = 12,
Delay = (60/350),
@ -209,17 +381,17 @@ AddItem( "mk23", {
AddItem( "fnc", {
PrintName = "#Item.fnc.Name",
Description = "#Item.fnc.Description",
Base = "base_firearm",
Base = "base_firearm_ubgl",
Model = "models/weapons/w_rif_ar556.mdl",
HoldType = "rpg",
HoldType = "rifle",
ClipSize = 30,
Delay = (60/750),
FireSound = {
"benny/weapons/m16a2/fire-01.ogg",
"benny/weapons/m16a2/fire-02.ogg",
"benny/weapons/m16a2/fire-03.ogg",
"benny/weapons/m16a2/01.ogg",
"benny/weapons/m16a2/02.ogg",
"benny/weapons/m16a2/03.ogg",
},
Accuracy = 1,
@ -233,8 +405,8 @@ AddItem( "m16a2", {
Description = "#Item.m16a2.Description",
Base = "base_firearm",
Model = "models/weapons/w_rif_ar556.mdl",
HoldType = "rpg",
Model = "models/weapons/w_rif_m16a2.mdl",
HoldType = "rifle",
ClipSize = 30,
Delay = (60/900),
@ -243,9 +415,9 @@ AddItem( "m16a2", {
BurstAuto = true,
BurstDelay = 0.2,
FireSound = {
"benny/weapons/m16a2/fire-01.ogg",
"benny/weapons/m16a2/fire-02.ogg",
"benny/weapons/m16a2/fire-03.ogg",
"benny/weapons/m16a2/01.ogg",
"benny/weapons/m16a2/02.ogg",
"benny/weapons/m16a2/03.ogg",
},
Accuracy = 1,
@ -260,7 +432,7 @@ AddItem( "spas12", {
Base = "base_firearm",
Model = "models/weapons/w_shotgun.mdl",
HoldType = "rpg",
HoldType = "rifle",
ClipSize = 8,
Pellets = 8,

View File

@ -20,6 +20,9 @@ function GM:PlayerSpawn( ply )
ply:SetStepSize( 18 )
ply:SetCanZoom( false )
ply:SetHealth_Blood( 1000 )
ply:SetHealth_Stamina( 1000 )
ply:MakeCharacter()
end
@ -116,13 +119,14 @@ local bgl = {
function PT:MakeCharacter()
local char = "benny"
self:SetModel( "models/player/infoplayerrealism.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
--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()
@ -133,23 +137,81 @@ end
-- Temporary
function GM:UpdateAnimation( ply, vel, maxseqgroundspeed )
local len = vel:Length()
local movement = 1.0
ply:SetPlaybackRate( 1 )
if ( len > 0.2 ) then
movement = ( len / maxseqgroundspeed )
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
local rate = math.min( movement, 2 )
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
-- if we're under water we want to constantly be swimming..
if ( ply:WaterLevel() >= 2 ) then
rate = math.max( rate, 0.5 )
elseif ( !ply:IsOnGround() && len >= 1000 ) then
rate = 0.1
end
ply:SetPlaybackRate( rate )
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 )
@ -166,4 +228,81 @@ end
function GM:HandlePlayerNoClipping( ply, vel )
return false
end
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)

View File

@ -26,14 +26,23 @@ function PLAYER:Init()
self.Player:AddEFlags( EFL_NO_DAMAGE_FORCES )
end
STANCE_STAND = 0
STANCE_DUCK = 1
STANCE_PRONE = 2
function PLAYER:SetupDataTables()
self.Player:NetworkVar( "Bool", 0, "Shoulder" )
self.Player:NetworkVar( "Bool", 1, "InDive" )
self.Player:NetworkVar( "Int", 0, "JumpBoost" )
self.Player:NetworkVar( "Int", 1, "Health_Blood" )
self.Player:NetworkVar( "Int", 2, "Health_Stamina" )
self.Player:NetworkVar( "Int", 3, "Stance" )
self.Player:NetworkVar( "Float", 0, "VaultDebuff" )
self.Player:NetworkVar( "Float", 1, "VaultTransition" )
self.Player:NetworkVar( "Float", 2, "Stamina" )
self.Player:NetworkVar( "Float", 3, "DivedAt" )
self.Player:NetworkVar( "Vector", 0, "VaultPos1")
self.Player:NetworkVar( "Vector", 1, "VaultPos2")