diff --git a/gamemodes/benny/entities/weapons/itemhandler.lua b/gamemodes/benny/entities/weapons/itemhandler.lua index b241b00..401952c 100644 --- a/gamemodes/benny/entities/weapons/itemhandler.lua +++ b/gamemodes/benny/entities/weapons/itemhandler.lua @@ -124,7 +124,7 @@ function SWEP:EquipItem( ent ) self:SetDesireR( ent ) ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES ) - ent:AddEffects( EF_BONEMERGE ) + ent:AddEffects( EF_BONEMERGE + EF_BONEMERGE_FASTCULL ) ent:PhysicsInit( SOLID_NONE ) ent:SetMoveType( MOVETYPE_NONE ) ent:SetNoDraw( true ) @@ -162,7 +162,7 @@ function SWEP:DropItem() ent:SetHandler( NULL ) ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES ) - ent:RemoveEffects( EF_BONEMERGE ) + ent:RemoveEffects( EF_BONEMERGE + EF_BONEMERGE_FASTCULL ) ent:PhysicsInit( SOLID_VPHYSICS ) ent:SetMoveType( MOVETYPE_VPHYSICS ) ent:SetCollisionGroup( COLLISION_GROUP_PROJECTILE ) @@ -180,6 +180,8 @@ function SWEP:DropItem() ep:SetVelocity( p:GetAimVector() * 800 ) ep:SetAngleVelocity( Vector( 0, -360*3, 0 ) ) ep:Wake() + + -- Prediction is not actually turned off here, for better throwing --net.Start("AEINV_PredictItem") -- net.WriteEntity( ent ) -- net.WriteBool( false ) @@ -193,23 +195,23 @@ function SWEP:Think() if p:IsValid() then local DesireR = self:GetDesireR() local ActiveR = self:GetActiveR() - local DesireR_Valid = DesireR:IsValid() - local ActiveR_Valid = ActiveR:IsValid() + DesireR = DesireR:IsValid() and DesireR or false + ActiveR = ActiveR:IsValid() and ActiveR or false if DesireR != ActiveR then - if ActiveR_Valid then + if ActiveR then if ActiveR:GetHolsterIn() == 0 then ActiveR:StartHolster() else -- Waiting for holster to finish end else - if DesireR_Valid then + if DesireR then self:SetActive( DesireR ) end end else - if ActiveR_Valid and ActiveR:GetHolsterIn() != 0 then + if ActiveR and ActiveR:GetHolsterIn() != 0 then ActiveR:CancelHolster() end end diff --git a/gamemodes/benny/gamemode/camera.lua b/gamemodes/benny/gamemode/camera.lua index 3bf47b9..ba468f6 100644 --- a/gamemodes/benny/gamemode/camera.lua +++ b/gamemodes/benny/gamemode/camera.lua @@ -88,8 +88,8 @@ function GM:CalcView( ply, pos, ang, fov ) view.origin = bm:GetTranslation() view.origin:Add( vector_up*8 ) - if ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_end_handgun") then - local progress = ply:GetLayerCycle( GESTURE_SLOT_JUMP ) + if ply:GetLayerSequence( BGESTURE_JUMP ) == ply:LookupSequence("dive_end_handgun") then + local progress = ply:GetLayerCycle( BGESTURE_JUMP ) progress = math.TimeFraction( 0.15, 0.7, progress ) progress = math.Clamp( progress, 0, 1 ) diff --git a/gamemodes/benny/gamemode/items/base.lua b/gamemodes/benny/gamemode/items/base.lua index 43edeeb..b608e7b 100644 --- a/gamemodes/benny/gamemode/items/base.lua +++ b/gamemodes/benny/gamemode/items/base.lua @@ -23,7 +23,6 @@ do -- Base ITEM.CancelHolsterSound = bSound("dev/grab.ogg") function ITEM:EntInitialize() - print( self ) for k, v in ipairs(self.DefaultBodygroups) do if v then self:SetBodygroup( k-1, v ) @@ -51,7 +50,7 @@ do -- Base function ITEM:PlayerAnimation( seqname ) local p = self:GetOwner() - p:DoAnimationEvent( p:LookupSequence( seqname ) ) + p:DoCustomAnimEvent( BGESTURE_ITEM1_RIGHT, p:LookupSequence( seqname ) ) end function ITEM:EntThink() end diff --git a/gamemodes/benny/gamemode/player.lua b/gamemodes/benny/gamemode/player.lua index 530571f..6942c6c 100644 --- a/gamemodes/benny/gamemode/player.lua +++ b/gamemodes/benny/gamemode/player.lua @@ -189,10 +189,33 @@ function PT:HandlerCheck() return ( wep:IsValid() and wep:GetClass() == "itemhandler" and wep.GetActiveR ) and wep or false end --- breaks GESTURE_SLOT_ATTACK_AND_RELOAD and I can't fucking have that +BGESTURE_ITEM1_RIGHT = GESTURE_SLOT_ATTACK_AND_RELOAD -- 0 +BGESTURE_ITEM1_LEFT = GESTURE_SLOT_GRENADE -- 1 +BGESTURE_ITEM2_RIGHT = GESTURE_SLOT_JUMP -- 2 +BGESTURE_ITEM2_LEFT = GESTURE_SLOT_SWIM -- 3 +BGESTURE_ACTION_RIGHT = GESTURE_SLOT_FLINCH -- 4 +BGESTURE_ACTION_LEFT = GESTURE_SLOT_VCD -- 5 +BGESTURE_JUMP = GESTURE_SLOT_CUSTOM -- 6 + +-- PLAYERANIMEVENT_ATTACK_PRIMARY = 0 -- Primary attack +-- PLAYERANIMEVENT_ATTACK_SECONDARY = 1 -- Secondary attack +-- PLAYERANIMEVENT_ATTACK_GRENADE = 2 -- Grenade throw +-- PLAYERANIMEVENT_RELOAD = 3 -- Reload +-- PLAYERANIMEVENT_RELOAD_LOOP = 4 -- Looping reload (single-reload shotguns) +-- PLAYERANIMEVENT_RELOAD_END = 5 -- Looping reload end +-- PLAYERANIMEVENT_JUMP = 6 -- Jump + +-- breaks GESTURE_SLOT_ATTACK_AND_RELOAD, so do my own thing +-- 0 through 6 are real hook.Add("DoAnimationEvent", "Benny_DoAnimationEvent_FixAnimations", function( p, event, data ) - if event == PLAYERANIMEVENT_CUSTOM_GESTURE then - p:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, data, 0, true ) + -- 23, PLAYERANIMEVENT_CANCEL_RELOAD, is annoying and breaks animations + if event >= 0 and event <= 6 then + if data == 0 then + -- print("[DoAnimationEvent] Called " .. event .. " with data 0." ) + return ACT_INVALID + end + -- print("running?", event, data ) + p:AddVCDSequenceToGestureSlot( event, math.floor(data), 0, true ) end return ACT_INVALID end) @@ -214,8 +237,8 @@ function GM:UpdateAnimation( ply, vel, maxseqgroundspeed ) 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") + local diveend = ply:GetLayerSequence( BGESTURE_JUMP ) == ply:LookupSequence("dive_end_handgun") + local divestart = ply:GetLayerSequence( BGESTURE_JUMP ) == ply:LookupSequence("dive_start_handgun") if ply:GetInDive() or diveend then speed = 1 end @@ -248,17 +271,17 @@ function GM:UpdateAnimation( ply, vel, maxseqgroundspeed ) ply:SetRenderAngles( Angle( 0, ply:EyeAngles().y, 0 ) ) if diveend then - local magicnumber = ply:GetLayerCycle( GESTURE_SLOT_JUMP ) + local magicnumber = ply:GetLayerCycle( BGESTURE_JUMP ) magicnumber = math.Remap( magicnumber, 0.5, 0.75, 1, 0 ) magicnumber = math.Clamp( magicnumber, 0, 1 ) - ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, magicnumber ) + ply:AnimSetGestureWeight( BGESTURE_JUMP, magicnumber ) elseif divestart then - local magicnumber = ply:GetLayerCycle( GESTURE_SLOT_JUMP ) + local magicnumber = ply:GetLayerCycle( BGESTURE_JUMP ) magicnumber = math.Remap( magicnumber, 0.1, 0.6, 1, 0 ) magicnumber = math.Clamp( magicnumber, 0, 1 ) - ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, magicnumber ) + ply:AnimSetGestureWeight( BGESTURE_JUMP, magicnumber ) else - ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, 1 ) + ply:AnimSetGestureWeight( BGESTURE_JUMP, 1 ) end --local dir = ply:GetVelocity():GetNormalized() @@ -296,10 +319,8 @@ function GM:CalcMainActivity( ply, velocity ) 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 + if w and w:ItemR() then + wpntype = w:ItemR().HoldType end plyTable.CalcSeqOverride = ply:LookupSequence( Animations["idle"][wpntype] ) @@ -393,35 +414,19 @@ hook.Add("Move", "Benny_Move", function( ply, mv ) 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) + ply:HandlerCheck():EmitSound( "weapons/slam/throw.wav", 70, 100, .25 ) + ply:DoCustomAnimEvent( BGESTURE_JUMP, ply:LookupSequence( "dive_start_handgun" ) ) 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 ) + if SERVER or CLIENT and IsFirstTimePredicted() then + ply:HandlerCheck():EmitSound( "npc/combine_soldier/gear1.wav", 70, 100, .25 ) + ply:DoCustomAnimEvent( BGESTURE_JUMP, ply:LookupSequence( "dive_end_handgun" ) ) + end end --if !ply:OnGround() and ply:GetInDive() then -- local da = ply:GetDivedAt()