mirror of
https://gitlab.com/hoggit/developers/hoggit.git
synced 2025-11-10 15:43:28 +00:00
Added CRASH event to dead check to catch planes getting killed as well
This commit is contained in:
parent
2b54280fd2
commit
f09435fc72
@ -193,63 +193,64 @@ HOGGIT.setZombie = function(group, spawner, state)
|
||||
end
|
||||
|
||||
HOGGIT._deathHandler = function(event)
|
||||
if event.id ~= world.event.S_EVENT_DEAD then return end
|
||||
HOGGIT.debug_text("SOMETHING DEAD YO", 10)
|
||||
if not event.initiator then return end
|
||||
if not event.initiator.getGroup then return end
|
||||
|
||||
local grp = event.initiator:getGroup():getName()
|
||||
if grp then
|
||||
HOGGIT.debug_text("FOUND GROUP", 10)
|
||||
if HOGGIT.zombies[grp] then
|
||||
HOGGIT.debug_text("CONFIRMED ZOMBIE", 10)
|
||||
local spawner = HOGGIT.zombies[grp]
|
||||
HOGGIT.debug_text("FOUND SPAWNER", 10)
|
||||
if HOGGIT.zombie_checks[spawner] then
|
||||
HOGGIT.debug_text("FOUND SPAWNER CHECK", 10)
|
||||
local s_func_id = HOGGIT.zombie_checks[spawner]
|
||||
mist.removeFunction(s_func_id)
|
||||
HOGGIT.debug_text("Removing dead check id ".. s_func_id .." for group: " .. grp, 10)
|
||||
end
|
||||
local new_func_id = mist.scheduleFunction(function()
|
||||
HOGGIT.debug_text("STARTING DEAD CHECK", 10)
|
||||
local needs_respawn = false
|
||||
local partial_respawn = false
|
||||
if not HOGGIT.GroupIsAlive(grp) then
|
||||
needs_respawn = true
|
||||
HOGGIT.debug_text("THEY DEAD, RESPAWNIN", 10)
|
||||
elseif spawner:GetPartialDeathThresholdPercent() then
|
||||
HOGGIT.debug_text("CHECKING PERCENT", 10)
|
||||
local group_obj = Group.getByName(grp)
|
||||
local group_size = group_obj:getSize()
|
||||
local initial_size = group_obj:getInitialSize()
|
||||
local percent_alive = group_size / initial_size * 100
|
||||
HOGGIT.debug_text(percent_alive .. " percent alive. Threshold is " .. spawner:GetPartialDeathThresholdPercent(), 10)
|
||||
if (100 - percent_alive) >= spawner:GetPartialDeathThresholdPercent() then
|
||||
HOGGIT.debug_text("TRIGGERING PARTIAL RESPAWNING", 10)
|
||||
if event.id == world.event.S_EVENT_CRASH or event.id == world.event.S_EVENT_DEAD then
|
||||
HOGGIT.debug_text("SOMETHING DEAD YO", 10)
|
||||
if not event.initiator then return end
|
||||
if not event.initiator.getGroup then return end
|
||||
|
||||
local grp = event.initiator:getGroup():getName()
|
||||
if grp then
|
||||
HOGGIT.debug_text("FOUND GROUP", 10)
|
||||
if HOGGIT.zombies[grp] then
|
||||
HOGGIT.debug_text("CONFIRMED ZOMBIE", 10)
|
||||
local spawner = HOGGIT.zombies[grp]
|
||||
HOGGIT.debug_text("FOUND SPAWNER", 10)
|
||||
if HOGGIT.zombie_checks[spawner] then
|
||||
HOGGIT.debug_text("FOUND SPAWNER CHECK", 10)
|
||||
local s_func_id = HOGGIT.zombie_checks[spawner]
|
||||
mist.removeFunction(s_func_id)
|
||||
HOGGIT.debug_text("Removing dead check id ".. s_func_id .." for group: " .. grp, 10)
|
||||
end
|
||||
local new_func_id = mist.scheduleFunction(function()
|
||||
HOGGIT.debug_text("STARTING DEAD CHECK", 10)
|
||||
local needs_respawn = false
|
||||
local partial_respawn = false
|
||||
if not HOGGIT.GroupIsAlive(grp) then
|
||||
needs_respawn = true
|
||||
partial_respawn = true
|
||||
HOGGIT.debug_text("THEY DEAD, RESPAWNIN", 10)
|
||||
elseif spawner:GetPartialDeathThresholdPercent() then
|
||||
HOGGIT.debug_text("CHECKING PERCENT", 10)
|
||||
local group_obj = Group.getByName(grp)
|
||||
local group_size = group_obj:getSize()
|
||||
local initial_size = group_obj:getInitialSize()
|
||||
local percent_alive = group_size / initial_size * 100
|
||||
HOGGIT.debug_text(percent_alive .. " percent alive. Threshold is " .. spawner:GetPartialDeathThresholdPercent(), 10)
|
||||
if (100 - percent_alive) >= spawner:GetPartialDeathThresholdPercent() then
|
||||
HOGGIT.debug_text("TRIGGERING PARTIAL RESPAWNING", 10)
|
||||
needs_respawn = true
|
||||
partial_respawn = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if needs_respawn then
|
||||
HOGGIT.debug_text("GROUP NEEDS RESPAWNING", 10)
|
||||
local delay = spawner:GetRespawnDelay(partial_respawn)
|
||||
HOGGIT.debug_text("DELAY OF " .. delay, 10)
|
||||
HOGGIT.zombies[grp] = nil
|
||||
if needs_respawn then
|
||||
HOGGIT.debug_text("GROUP NEEDS RESPAWNING", 10)
|
||||
local delay = spawner:GetRespawnDelay(partial_respawn)
|
||||
HOGGIT.debug_text("DELAY OF " .. delay, 10)
|
||||
HOGGIT.zombies[grp] = nil
|
||||
|
||||
mist.scheduleFunction(function()
|
||||
spawner.Spawn()
|
||||
end, {}, timer.getTime() + delay)
|
||||
end
|
||||
HOGGIT.zombie_checks[spawner] = nil
|
||||
mist.scheduleFunction(function()
|
||||
spawner.Spawn()
|
||||
end, {}, timer.getTime() + delay)
|
||||
end
|
||||
HOGGIT.zombie_checks[spawner] = nil
|
||||
|
||||
end, {}, timer.getTime() + 10)
|
||||
|
||||
HOGGIT.debug_text("Scheduled NEW dead check id ".. new_func_id .." for group: " .. grp, 10)
|
||||
HOGGIT.zombie_checks[spawner] = new_func_id
|
||||
else
|
||||
|
||||
end, {}, timer.getTime() + 10)
|
||||
|
||||
HOGGIT.debug_text("Scheduled NEW dead check id ".. new_func_id .." for group: " .. grp, 10)
|
||||
HOGGIT.zombie_checks[spawner] = new_func_id
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user