From 8a31b270f0303ce24f22e6441b1bf40a9568a4eb Mon Sep 17 00:00:00 2001 From: Fesiug Date: Sun, 17 Dec 2023 20:47:03 -0500 Subject: [PATCH] Movement penalties! Akimbo effects! More fixes! --- .../entities/effects/benny_muzzleflash.lua | 7 +- .../benny/entities/weapons/benny/cl_wm.lua | 86 ++++++++++++------- .../entities/weapons/benny/sh_firing.lua | 79 +++++------------ .../benny/entities/weapons/benny/sh_inv.lua | 2 +- .../benny/entities/weapons/benny/shared.lua | 7 +- .../modules/player/sh_movement_advanced.lua | 10 +++ .../gamemode/modules/player/sh_player.lua | 4 +- 7 files changed, 103 insertions(+), 92 deletions(-) diff --git a/gamemodes/benny/entities/effects/benny_muzzleflash.lua b/gamemodes/benny/entities/effects/benny_muzzleflash.lua index ef94df4..3f43f0c 100644 --- a/gamemodes/benny/entities/effects/benny_muzzleflash.lua +++ b/gamemodes/benny/entities/effects/benny_muzzleflash.lua @@ -12,8 +12,13 @@ function EFFECT:Init( data ) self.angles = data:GetAngles() self.el = data:GetEntity() self.en = data:GetEntity() - if IsValid(self.en.CWM) then self.en = self.en.CWM end self.ea = data:GetAttachment() + if self.ea > 16 then + if IsValid(self.en.CWM_Left) then self.en = self.en.CWM_Left end + self.ea = self.ea - 16 + else + if IsValid(self.en.CWM) then self.en = self.en.CWM end + end self.particles = 1 self.CreationTime = UnPredictedCurTime() diff --git a/gamemodes/benny/entities/weapons/benny/cl_wm.lua b/gamemodes/benny/entities/weapons/benny/cl_wm.lua index e14a2c1..98eef1f 100644 --- a/gamemodes/benny/entities/weapons/benny/cl_wm.lua +++ b/gamemodes/benny/entities/weapons/benny/cl_wm.lua @@ -1,40 +1,68 @@ function SWEP:DrawWorldModel() local p = self:GetOwner() - local wm = self.CWM - local class = self:BClass( false ) - if class then - if !IsValid(wm) then - wm = ClientsideModel( class.WModel ) - self.CWM = wm + do + local wm = self.CWM + local class = self:BClass( false ) + if class then + if !IsValid(wm) then + wm = ClientsideModel( class.WModel ) + self.CWM = wm + end + wm:SetModel( class.WModel ) + wm:SetNoDraw( true ) + wm:AddEffects( EF_BONEMERGE ) + wm:SetParent( p ) + if true or self:GetUserAim() then wm:DrawModel() end + else + if IsValid(wm) then wm:Remove() end end - wm:SetModel( class.WModel ) - wm:SetNoDraw( true ) - wm:AddEffects( EF_BONEMERGE ) - wm:SetParent( p ) + end + do + local wm = self.CWM_Left + local class = self:BClass( true ) + if class then + if !IsValid(wm) then + wm = ClientsideModel( class.WModel ) + self.CWM_Left = wm + end + wm:SetModel( class.WModel ) + wm:SetNoDraw( true ) + + if IsValid(p) then + -- Specify a good position + wm:SetPos( vector_origin ) + wm:SetAngles( angle_zero ) + wm:SetupBones() - -- if IsValid(p) then - -- -- Specify a good position - -- local offsetVec = Vector(12.8, -1.4, 2.6) - -- local offsetAng = Angle(180 - 10, 180, 0) - -- - -- local boneid = p:LookupBone("ValveBiped.Bip01_R_Hand") -- Right Hand - -- if !boneid then return end + local pv = wm:GetBoneMatrix( wm:LookupBone( "ValveBiped.Bip01_R_Hand" ) ):GetTranslation() + local pa = wm:GetBoneMatrix( wm:LookupBone( "ValveBiped.Bip01_R_Hand" ) ):GetAngles() + pv.x = -pv.x + pv.y = pv.y + pv.z = -pv.z + pa.p = -pa.p + pa.r = pa.r + 180 + + local boneid = p:LookupBone("ValveBiped.Bip01_L_Hand") -- Right Hand + if !boneid then return end - -- local matrix = p:GetBoneMatrix(boneid) - -- if !matrix then return end + local matrix = p:GetBoneMatrix(boneid) + if !matrix then return end - -- local newPos, newAng = LocalToWorld(offsetVec, offsetAng, matrix:GetTranslation(), matrix:GetAngles()) + local newPos, newAng = LocalToWorld(pv, pa, matrix:GetTranslation(), matrix:GetAngles()) - -- wm:SetPos(newPos) - -- wm:SetAngles(newAng) + wm:SetPos(newPos) + wm:SetAngles(newAng) - -- wm:SetupBones() - -- else - -- wm:SetPos(self:GetPos()) - -- wm:SetAngles(self:GetAngles()) - -- wm:SetupBones() - -- end + wm:SetupBones() + else + wm:SetPos(self:GetPos()) + wm:SetAngles(self:GetAngles()) + wm:SetupBones() + end - if self:GetUserAim() then wm:DrawModel() end + if true or self:GetUserAim() then wm:DrawModel() end + else + if IsValid(wm) then wm:Remove() end + end end end \ No newline at end of file diff --git a/gamemodes/benny/entities/weapons/benny/sh_firing.lua b/gamemodes/benny/entities/weapons/benny/sh_firing.lua index 07974e0..b56c4ed 100644 --- a/gamemodes/benny/entities/weapons/benny/sh_firing.lua +++ b/gamemodes/benny/entities/weapons/benny/sh_firing.lua @@ -62,24 +62,20 @@ function SWEP:BFire( hand ) if CLIENT and IsFirstTimePredicted() then - if IsValid(self.CWM) and self.CWM:GetAttachment( 1 ) then - local vStart = self.CWM:GetAttachment( 1 ).Pos - --local vPoint = p:GetEyeTrace().HitPos - --local effectdata = EffectData() - --effectdata:SetStart( vStart ) - --effectdata:SetOrigin( vPoint ) - --util.Effect( "ToolTracer", effectdata ) + -- PROTO: This is shit! Replace it with a function that gets the right model. + if IsValid(hand and self.CWM_Left or self.CWM) and (hand and self.CWM_Left or self.CWM):GetAttachment( 1 ) then + local vStart = (hand and self.CWM_Left or self.CWM):GetAttachment( 1 ).Pos local ed = EffectData() ed:SetOrigin( vStart ) - --ed:SetAngles( Angle() ) ed:SetEntity( self ) - ed:SetAttachment( 1 ) + ed:SetAttachment( (hand and 16 or 0) + 1 ) util.Effect( "benny_muzzleflash", ed ) end end end end +local bc = { effects = false, damage = true } function SWEP:CallFire( hand ) local p = self:GetOwner() local class = self:BClass( hand ) @@ -105,56 +101,27 @@ function SWEP:CallFire( hand ) Force = class.Damage/10, Src = p:EyePos(), Dir = dir:Forward(), + Tracer = 0, IgnoreEntity = p, - Callback = self.BulletCallback, + Callback = function( atk, tr, dmginfo ) + if CLIENT and IsFirstTimePredicted() then + self:FireCL( hand, tr ) + end + return bc + end, } ) - - -- self:FireCL( tr ) - -- self:FireSV( tr ) end end -function SWEP:BulletCallback() - return true -end - - - -function SWEP:FireCL( tr ) - if CLIENT and IsFirstTimePredicted() then - do - local vStart = self.CWM:GetAttachment( 1 ).Pos - local vPoint = tr.HitPos - local effectdata = EffectData() - effectdata:SetStart( vStart ) - effectdata:SetOrigin( vPoint ) - effectdata:SetEntity( self ) - effectdata:SetScale( 1025*12 ) - effectdata:SetFlags( 1 ) - util.Effect( "Tracer", effectdata ) - end - -- util.DecalEx( Material( util.DecalMaterial( "Impact.Concrete" ) ), tr.Entity, tr.HitPos, tr.HitNormal, color_white, 1, 1 ) - do - local effectdata = EffectData() - effectdata:SetOrigin( tr.HitPos ) - effectdata:SetStart( tr.StartPos ) - effectdata:SetSurfaceProp( tr.SurfaceProps ) - effectdata:SetEntity( tr.Entity ) - effectdata:SetDamageType( DMG_BULLET ) - util.Effect( "Impact", effectdata ) - end - end -end - -function SWEP:FireSV( tr ) - local class = self:BClass( false ) - if SERVER and IsValid( tr.Entity ) then - local dmginfo = DamageInfo() - dmginfo:SetDamage( class.Damage ) - dmginfo:SetAttacker( self:GetOwner() ) - dmginfo:SetInflictor( self ) - dmginfo:SetDamageType( DMG_BULLET ) - dmginfo:SetDamagePosition( tr.HitPos ) - tr.Entity:TakeDamageInfo( dmginfo ) - end +function SWEP:FireCL( hand, tr ) + -- PROTO: This is shit! Replace it with a function that gets the right model. + local vStart = (hand and self.CWM_Left or self.CWM):GetAttachment( 1 ).Pos + local vPoint = tr.HitPos + local effectdata = EffectData() + effectdata:SetStart( vStart ) + effectdata:SetOrigin( vPoint ) + effectdata:SetEntity( self ) + effectdata:SetScale( 1025*12 ) + effectdata:SetFlags( 1 ) + util.Effect( "Tracer", effectdata ) end \ No newline at end of file diff --git a/gamemodes/benny/entities/weapons/benny/sh_inv.lua b/gamemodes/benny/entities/weapons/benny/sh_inv.lua index 419756c..a5416d8 100644 --- a/gamemodes/benny/entities/weapons/benny/sh_inv.lua +++ b/gamemodes/benny/entities/weapons/benny/sh_inv.lua @@ -150,7 +150,7 @@ local fallbackstat = { } function SWEP:GetStat( hand, stat ) - local thereturn = (self:BClass( hand )[stat] or fallbackstat[stat]) + local thereturn = (self:BClass( hand ) and self:BClass( hand )[stat] or fallbackstat[stat]) assert( thereturn, "No stat for " .. stat ) return thereturn end diff --git a/gamemodes/benny/entities/weapons/benny/shared.lua b/gamemodes/benny/entities/weapons/benny/shared.lua index 8a1fc25..be1f724 100644 --- a/gamemodes/benny/entities/weapons/benny/shared.lua +++ b/gamemodes/benny/entities/weapons/benny/shared.lua @@ -252,12 +252,13 @@ function SWEP:Think() end local ht = "normal" - if self:GetUserAim() and self:D_GetHolstering( false ) < 0 then - if self:BClass( false ) then + if self:BClass( false ) and self:D_GetHolstering( false ) < 0 then + ht = "passive" + if self:GetUserAim() then if self:BClass( true ) then ht = "duel" else - ht = self:BClass( false ).HoldType or "revolver" + ht = self:GetStat( false, "HoldType" ) end end end diff --git a/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua b/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua index 82e4029..9deb346 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_movement_advanced.lua @@ -148,5 +148,15 @@ hook.Add( "Move", "Benny_Move", function( ply, mv ) ply:SetMoveType( (ply:GetVaultTransition() == 0) and MOVETYPE_WALK or MOVETYPE_NOCLIP ) return true end + + local w = ply:BennyCheck() + if w then + local targetspeed = ply:GetMaxSpeed() + + targetspeed = targetspeed * w:GetStat( false, "Speed_Move" ) + + mv:SetMaxSpeed( targetspeed ) + mv:SetMaxClientSpeed( targetspeed ) + end --debugoverlay.Box( Target+(TargetNor*16), ba, bb, 0, CR ) end) \ No newline at end of file diff --git a/gamemodes/benny/gamemode/modules/player/sh_player.lua b/gamemodes/benny/gamemode/modules/player/sh_player.lua index e291bfe..a2c3387 100644 --- a/gamemodes/benny/gamemode/modules/player/sh_player.lua +++ b/gamemodes/benny/gamemode/modules/player/sh_player.lua @@ -11,8 +11,8 @@ function GM:PlayerSpawn( ply ) ply:SetDuckSpeed( 0.1 ) ply:SetUnDuckSpeed( 0.1 ) ply:SetSlowWalkSpeed( 100 ) - ply:SetWalkSpeed( 160 ) - ply:SetRunSpeed( 220 ) + ply:SetWalkSpeed( 200 ) + ply:SetRunSpeed( 200 ) ply:SetStepSize( 16 ) ply:SetCanZoom( false )