Skip to content

Commit

Permalink
Kill hegrenade projectile on team change (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
EasterLee authored Nov 10, 2023
1 parent 07d4dc2 commit 4f7bb10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
8 changes: 8 additions & 0 deletions scripts/vscripts/ZombieReborn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ end
function OnPlayerTeam(event)
--__DumpScope(0, event)
local hPlayer = EHandleToHScript(event.userid_pawn)

local tThrewnNades = Entities:FindAllByClassname("hegrenade_projectile")
for __, hProjectile in ipairs(tThrewnNades) do
if hProjectile and hProjectile:GetOwner() == hPlayer then
DoEntFireByInstanceHandle(hProjectile, "Kill", "", 0.02, nil, nil)
end
end

if ZR_ZOMBIE_SPAWNED and event.team == CS_TEAM_CT and tCureList[hPlayer] == nil then
--SetTeam doesn't work on the same tick as well :pepemeltdown:
DoEntFireByInstanceHandle(hPlayer, "runscriptcode", "thisEntity:SetTeam(CS_TEAM_NONE); thisEntity:SetTeam(CS_TEAM_T)", 0.01, nil, nil)
Expand Down
14 changes: 0 additions & 14 deletions scripts/vscripts/ZombieReborn/Infect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ function Infect(hInflictor, hInfected, bKeepPosition, bDead)
end
end

local tThrewnNades = Entities:FindAllByClassname("hegrenade_projectile")
for __, hProjectile in ipairs(tThrewnNades) do
if hProjectile and hProjectile:GetOwner() == hInfected then
DoEntFireByInstanceHandle(hProjectile, "Kill", "", 0.02, nil, nil)
end
end

DebugPrint("Setting regular zombie class")
InjectPlayerClass(PickRandomZombieDefaultClass(), hInfected)

Expand Down Expand Up @@ -82,13 +75,6 @@ function InfectMotherZombie(hInfected, bKeepPosition)
end
end

local tThrewnNades = Entities:FindAllByClassname("hegrenade_projectile")
for __, hProjectile in ipairs(tThrewnNades) do
if hProjectile and hProjectile:GetOwner() == hInfected then
DoEntFireByInstanceHandle(hProjectile, "Kill", "", 0.02, nil, nil)
end
end

DebugPrint("Setting mother zombie class")
InjectPlayerClass(ZRClass.Zombie.MotherZombie, hInfected)

Expand Down

0 comments on commit 4f7bb10

Please sign in to comment.