Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add weapon type check before infection & Fix nade cooking issues #85

Merged
merged 4 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/vscripts/ZombieReborn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function OnPlayerHurt(event)

if hAttacker:GetTeam() == CS_TEAM_CT and hVictim:GetTeam() == CS_TEAM_T then
Knockback_Apply(hAttacker, hVictim, event.dmg_health, event.weapon)
elseif hAttacker:GetTeam() == CS_TEAM_T and hVictim:GetTeam() == CS_TEAM_CT then
elseif event.weapon == "knife" and hAttacker:GetTeam() == CS_TEAM_T and hVictim:GetTeam() == CS_TEAM_CT then
Infect(hAttacker, hVictim, true, event.health == 0)
end
end
Expand Down
30 changes: 30 additions & 0 deletions scripts/vscripts/ZombieReborn/Infect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ function Infect(hInflictor, hInfected, bKeepPosition, bDead)

hInfected:SetTeam(CS_TEAM_T)

-- Asynchronously kill any utils held by the infected player AND any nades threwn by said player
local tHeldWeapons = hInfected:GetEquippedWeapons()
for _, hWeapon in ipairs(tHeldWeapons) do
if hWeapon and hWeapon:GetClassname() ~= "weapon_knife" then
DoEntFireByInstanceHandle(hWeapon, "Kill", "", 0.02, nil, nil)
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 @@ -59,6 +74,21 @@ function InfectMotherZombie(hInfected, bKeepPosition)
hInfected:SetTeam(CS_TEAM_NONE)
hInfected:SetTeam(CS_TEAM_T)

-- Asynchronously kill any utils held by the infected player AND any nades threwn by said player
local tHeldWeapons = hInfected:GetEquippedWeapons()
for _, hWeapon in ipairs(tHeldWeapons) do
if hWeapon and hWeapon:GetClassname() ~= "weapon_knife" then
DoEntFireByInstanceHandle(hWeapon, "Kill", "", 0.02, nil, nil)
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