Skip to content

Commit

Permalink
stun_gun fix #44
Browse files Browse the repository at this point in the history
  • Loading branch information
KurimuzonAkuma authored and Guilhem-Pech committed Oct 14, 2022
1 parent 626fe86 commit 6a452de
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions entities/weapons/tfa_bash_base/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function SWEP:AltAttack()
self:SetHolstering(false)
end
end

if (self:GetReloading() and self.Shotgun and !self:GetShotgunPumping() and !self:GetShotgunNeedsPump()) then
self:SetShotgunCancel( true )
--[[
Expand All @@ -36,33 +36,33 @@ function SWEP:AltAttack()
]]--
return
end

if self:IsSafety() then return end

if (self:GetChangingSilence()) then return end

if self:GetNextSecondaryFire()>CurTime() then return end

if self:GetReloading() then
self:CompleteReload()
end

local vm = self.Owner:GetViewModel()

--if SERVER then
self:SendWeaponAnim(ACT_VM_HITCENTER)
--else
self:SendWeaponAnim(ACT_VM_HITCENTER)
--end


if !game.SinglePlayer() then
timer.Simple(vm:SequenceDuration()-0.05,function()
if IsValid(self) and self:OwnerIsValid() then
self:SendWeaponAnim(ACT_VM_IDLE)
end
end)

timer.Simple(vm:SequenceDuration()-0.01,function()
if IsValid(self) and self:OwnerIsValid() then
if lastresortanim and lastresortanim>-2 then
Expand All @@ -71,22 +71,22 @@ function SWEP:AltAttack()
end
end)
end

self.tmptoggle = !self.tmptoggle

self:SetNextPrimaryFire(CurTime()+(self.SequenceLengthOverride[ACT_VM_HITCENTER] or vm:SequenceDuration()))
self:SetNextSecondaryFire(CurTime()+(self.SequenceLengthOverride[ACT_VM_HITCENTER] or vm:SequenceDuration()))

if CLIENT then
self:EmitSound(self.Secondary.BashSound )
end

timer.Simple(self.Secondary.BashDelay,function()
if IsValid(self) and self.OwnerIsValid and self:OwnerIsValid() then
if (SERVER) then
local pos = self.Owner:GetShootPos()
local av = self.Owner:EyeAngles():Forward()

local slash = {}
slash.start = pos
slash.endpos = pos + (av * self.Secondary.BashLength)
Expand All @@ -95,36 +95,36 @@ function SWEP:AltAttack()
slash.maxs = Vector(10, 5, 5)
local slashtrace = util.TraceHull(slash)
local pain = self.Secondary.BashDamage



if slashtrace.Hit then
/*if slashtrace.Entity:GetClass() == "func_door_rotating" or slashtrace.Entity:GetClass() == "prop_door_rotating" then
local ply = self.Owner
ply:EmitSound("ambient/materials/door_hit1.wav", 100, math.random(80, 120))
ply.oldname = ply:GetName()
ply:SetName( "bashingpl" .. ply:EntIndex() )
slashtrace.Entity:SetKeyValue( "Speed", "500" )
slashtrace.Entity:SetKeyValue( "Open Direction", "Both directions" )
slashtrace.Entity:SetKeyValue( "Open Direction", "Both directions" )
slashtrace.Entity:SetKeyValue( "opendir", "0" )
slashtrace.Entity:Fire( "unlock", "", .01 )
slashtrace.Entity:Fire( "openawayfrom", "bashingpl" .. ply:EntIndex() , .01 )
slashtrace.Entity:Fire( "openawayfrom", "bashingpl" .. ply:EntIndex() , .01 )
timer.Simple(0.02, function()
if IsValid(ply) then
ply:SetName(ply.oldname)
end
end)
timer.Simple(0.3, function()
if IsValid(slashtrace.Entity) then
slashtrace.Entity:SetKeyValue( "Speed", "100" )
end
end)
end*/
self:EmitSound( (slashtrace.MatType == MAT_FLESH or slashtrace.MatType == MAT_ALIENFLESH) and self.Secondary.BashHitSound_Flesh or self.Secondary.BashHitSound )
if game.GetTimeScale()>0.99 then
Expand All @@ -151,28 +151,28 @@ function SWEP:AltAttack()
dmg:SetDamage(pain)
dmg:SetDamageType(self.Secondary.BashDamageType)
slashtrace.Entity:TakeDamageInfo(dmg)
end
end

local ent = slashtrace.Entity
if IsValid(ent) and ent.GetPhysicsObject then

local phys

if ent:IsRagdoll() then
phys = ent:GetPhysicsObjectNum(slashtrace.PhysicsBone or 0)
else
else
phys = ent:GetPhysicsObject()
end

if IsValid(phys) then
if ent:IsPlayer() or ent:IsNPC() then
ent:SetVelocity(ent:GetVelocity()+self.Owner:GetAimVector()*self.Secondary.BashDamage*40)
phys:SetVelocity(phys:GetVelocity()+self.Owner:GetAimVector()*self.Secondary.BashDamage*40)
ent:SetVelocity(ent:GetVelocity()+self.Owner:GetAimVector()*self.Secondary.BashDamage)
phys:SetVelocity(phys:GetVelocity()+self.Owner:GetAimVector()*self.Secondary.BashDamage)
else
phys:ApplyForceOffset(self.Owner:GetAimVector()*self.Secondary.BashDamage/4,slashtrace.HitPos)
end
end

end
end
end
Expand All @@ -183,11 +183,11 @@ end
function SWEP:GetBashing()
if !self:OwnerIsValid() then return false end
local bash,vm,seq,actid

vm = self.Owner:GetViewModel()
if !IsValid(vm) then return end
seq = vm:GetSequence()
actid = vm:GetSequenceActivity(seq)
bash = (actid==ACT_VM_HITCENTER) and vm:GetCycle()>0 and vm:GetCycle()<0.65
return bash
end
end

0 comments on commit 6a452de

Please sign in to comment.