Dive anims, satchel pack, camera fix

This commit is contained in:
Fesiug 2024-04-07 19:04:18 -04:00
parent 36c8d47b0e
commit a7d0c55142
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
7 changed files with 176 additions and 56 deletions

View File

@ -0,0 +1,29 @@
---------------------
-- Your Name is Benny
---------------------
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_anim"
function ENT:Initialize()
self:SetModel("models/hunter/blocks/cube025x025x025.mdl")
if SERVER then
self:PhysicsInit( SOLID_VPHYSICS )
local phy = self:GetPhysicsObject()
phy:Wake()
end
end
function ENT:Detonate()
local effectdata = EffectData()
effectdata:SetOrigin( self:GetPos() )
util.Effect( "Explosion", effectdata, nil, true )
self:Remove()
end

View File

@ -104,7 +104,7 @@ end
function SWEP:SecondaryAttack()
local p = self:GetOwner()
if self:ItemR() then
--self:ItemR("Attack2")
self:ItemR("AttackAlt")
end
end

View File

@ -21,7 +21,7 @@ function CamSpot( ang, pos )
local tr = {
start = pos,
endpos = pos + (f*cam_f:GetFloat()) + (r*cam_r:GetFloat()) + (u*cam_u:GetFloat()),
filter = ply,
filter = LocalPlayer(), -- ply,
mins = m1,
maxs = m2,
}

View File

@ -40,6 +40,22 @@ local function hRect( x, y, w, h )
surface.DrawRect( x, y, w, h )
end
local function hTRect( x, y, w, h )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
surface.DrawTexturedRect( x, y, w, h )
end
local function hTrRect( x, y, w, h, d )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
surface.DrawTexturedRectRotated( x, y, w, h, d )
end
local function hORect( x, y, w, h, r )
gx, gy = hXY()
x = (x or 0) + gx
@ -105,6 +121,9 @@ local translate_letters = {
["shift"] = "speed",
}
local xhair_dot = Material( "benny/hud/xhair/dotx.png", "mips smooth" )
local xhair_dot_shadow = Material( "benny/hud/xhair/dot_s.png", "mips smooth" )
local function commoncode( set )
for index, letter in ipairs( set ) do
local lettercode = input.GetKeyCode( letter )
@ -161,14 +180,18 @@ function GM:HUDPaint()
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 )
if v.GetClip then
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
end
S_Pop()
end
@ -230,27 +253,17 @@ function GM:HUDPaint()
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()
for i=1, 2 do
local shadowtime = i==1
local traac = shadowtime and trac2 or trac
local cx, cy = traac.x, traac.y
S_Push( cx, cy )
local lol = shadowtime and 0 or 255
surface.SetDrawColor( lol, lol, lol )
surface.SetMaterial( shadowtime and xhair_dot_shadow or xhair_dot )
hTrRect( 0, 0, 64, 64, 0 )
S_Pop()
end
if stack:Size() != 0 then print("Stack unfinished.") end
return

View File

@ -64,6 +64,9 @@ AddItem( "base", {
["Attack"] = function( class, ent, handler )
end,
["AttackAlt"] = function( class, ent, handler )
end,
["Think"] = function( class, ent, handler )
end,
@ -74,23 +77,23 @@ AddItem( "base", {
local AnimationLookup = {
["fire"] = {
["handgun"] = "fire_handgun",
["rifle"] = "fire_rifle",
["rifle"] = "rifle_fire",
},
["reload"] = {
["handgun"] = "reload_handgun",
["rifle"] = "reload_handgun",
["rifle"] = "rifle_reload",
},
["reload_rack"] = {
["handgun"] = "reload_handgun_rack",
["rifle"] = "reload_handgun_rack",
["rifle"] = "rifle_reload_rack",
},
["reload_insert"] = {
["handgun"] = "reload_handgun_insert",
["rifle"] = "reload_handgun_insert",
["rifle"] = "rifle_reload_insert",
},
["deploy"] = {
["handgun"] = "deploy_handgun",
["rifle"] = "deploy_handgun",
["rifle"] = "rifle_deploy",
},
["holster"] = {
["handgun"] = "holster_handgun",
@ -140,6 +143,12 @@ AddItem( "base_firearm", {
BurstAuto = false,
BurstDelay = 0,
FireSound = "benny/weapons/m16a2/01.ogg",
MagOutSound = "benny/weapons/m16a2/magout.ogg",
MagInSound = "benny/weapons/m16a2/magin.ogg",
BoltDropSound = "benny/weapons/m16a2/cock.ogg",
BoltPullSound = "benny/weapons/fnc/cock.ogg",
["Initialize"] = function( class, ent, handler )
ITEMS["base"].Initialize( class, ent, handler )
@ -231,29 +240,29 @@ AddItem( "base_firearm", {
if ent:GetDelay() > CurTime() then return end
ent:SetDelay( CurTime() + 0.5 )
ent:SetDelay( CurTime() + 0.6 )
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 )
handler:EmitSound( class.BoltDropSound, 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 )
handler:EmitSound( class.BoltPullSound, 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 )
handler:EmitSound( class.MagOutSound, 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 )
handler:EmitSound( class.MagInSound, 70, 100, 0.4, CHAN_STATIC )
ent:SetLoaded( true )
ent:SetRefillTime( CurTime() + 0.25 )
ent:SetRefillTime( CurTime() + 0.5 )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["reload_insert"][class.HoldType] ), 0, true )
end
end,
@ -267,6 +276,8 @@ AddItem( "base_firearm", {
end,
["Holster"] = function( class, ent, handler )
ent:SetRefillTime( 0 )
handler:EmitSound( "weapons/m4a1/m4a1_deploy.wav", 70, 125, 0.4, CHAN_STATIC )
ent:SetDelay( CurTime() + 0.25 )
@ -354,6 +365,53 @@ AddItem( "base_firearm_ubgl", {
end,
})
AddItem( "satchels", {
PrintName = "#Item.satchels.Name",
Description = "#Item.satchels.Description",
Category = "utility",
Base = "base",
Model = "models/benny/weapons/testgun.mdl",
HoldType = "handgun",
Vars = {
["Float"] = {
"Delay",
},
},
["Attack"] = function( class, ent, handler )
if ent:GetDelay() > CurTime() then return end
ent:SetDelay( CurTime() + 0.5 )
if SERVER then
for k, v in ipairs( ents.FindByClass( "b-satchel" ) ) do
if v:GetOwner() == ent:GetOwner() then
v:Detonate()
end
end
end
end,
["AttackAlt"] = function( class, ent, handler )
if ent:GetDelay() > CurTime() then return end
ent:SetDelay( CurTime() + 0.5 )
local ply = ent:GetOwner()
if SERVER then
local bomb = ents.Create("b-satchel")
bomb:SetPos( ply:EyePos() + (ply:GetAimVector() * 32) )
bomb:SetAngles( ply:EyeAngles() )
bomb:SetOwner( ply )
bomb:Spawn()
local phy = bomb:GetPhysicsObject()
phy:SetVelocity( ply:GetAimVector() * 400 )
phy:SetAngleVelocity( Vector( 0, 360, 0 ) )
end
end,
})
AddItem( "mk23", {
PrintName = "#Item.mk23.Name",
Description = "#Item.mk23.Description",
@ -370,6 +428,10 @@ AddItem( "mk23", {
"benny/weapons/usp/02.ogg",
"benny/weapons/usp/03.ogg",
},
MagOutSound = "benny/weapons/1911/magout.ogg",
MagInSound = "benny/weapons/1911/magin.ogg",
BoltDropSound = "benny/weapons/1911/slidedrop.ogg",
BoltPullSound = "benny/weapons/glock/cock.ogg",
Accuracy = 5/60,
BurstCount = 1,
@ -383,7 +445,7 @@ AddItem( "fnc", {
Description = "#Item.fnc.Description",
Base = "base_firearm_ubgl",
Model = "models/weapons/w_rif_ar556.mdl",
Model = "models/benny/weapons/testrifle2.mdl",--"models/weapons/w_rif_ar556.mdl",
HoldType = "rifle",
ClipSize = 30,
@ -405,7 +467,7 @@ AddItem( "m16a2", {
Description = "#Item.m16a2.Description",
Base = "base_firearm",
Model = "models/weapons/w_rif_m16a2.mdl",
Model = "models/benny/weapons/testrifle3.mdl",--"models/weapons/w_rif_m16a2.mdl",
HoldType = "rifle",
ClipSize = 30,
@ -443,6 +505,10 @@ AddItem( "spas12", {
"benny/weapons/spas12/02.ogg",
"benny/weapons/spas12/03.ogg",
},
MagOutSound = "benny/weapons/spas12/magout-01.ogg",
MagInSound = "benny/weapons/spas12/magout-02.ogg",
BoltDropSound = "benny/weapons/spas12/magin.ogg",
BoltPullSound = "benny/weapons/glock/magin.ogg",
Accuracy = 8,
Accuracy_Add = 0.4,

View File

@ -14,3 +14,6 @@ L["#Item.m16a2.Description"] = "Rugged burst rifle"
L["#Item.spas12.Name"] = "SPAS-12"
L["#Item.spas12.Description"] = "Chrome-lined autoshotgun"
L["#Item.satchels.Name"] = "Satchels"
L["#Item.satchels.Description"] = "Packs of bombs and a detonator"

View File

@ -142,8 +142,10 @@ function GM:UpdateAnimation( ply, vel, 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) )
local speed = (len2d/200)
ply:SetPoseParameter( "move_x", normal.x * speed )
ply:SetPoseParameter( "move_y", normal.y * speed )
ply:SetAllowFullRotation( true )
ply:SetAngles( Angle( 0, ply:EyeAngles().y, 0 ) )
@ -208,6 +210,10 @@ function GM:CalcMainActivity( ply, velocity )
end
if ply:GetInDive() then
plyTable.CalcSeqOverride = ply:LookupSequence( "dive_idle" )
end
plyTable.m_bWasOnGround = ply:IsOnGround()
plyTable.m_bWasNoclipping = ( ply:GetMoveType() == MOVETYPE_NOCLIP && !ply:InVehicle() )
@ -264,8 +270,8 @@ 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
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
local cool = Vector( mv:GetForwardSpeed(), -mv:GetSideSpeed(), 0 )
cool:Normalize()
cool:Rotate( Angle( 0, mv:GetMoveAngles().y, 0 ) )
@ -275,6 +281,7 @@ hook.Add("Move", "Benny_Move", function( ply, mv )
ply:SetGroundEntity( NULL )
ply:SetInDive( true )
ply:SetDivedAt( CurTime() )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_start" ), 0, true )
if (SERVER) or (CLIENT and IsFirstTimePredicted()) then
local rfil = nil
if SERVER then
@ -296,13 +303,15 @@ hook.Add("Move", "Benny_Move", function( ply, mv )
ply:EmitSound("npc/combine_soldier/gear1.wav", 70, 100, .25, nil, nil, nil, rfil)
end
ply:SetInDive(false)
ply:SetDivedAt( CurTime() )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_end" ), 0, true )
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
--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)