Name | Type | is_array | initial_value |
Air | integer | No | |
AirBenders | force | No | |
AllBenders | force | No | |
Avatararrive | timer | No | |
CR | gamecache | No | |
Earth | integer | No | |
EarthBenders | force | No | |
Fire | integer | No | |
FireBenders | force | No | |
TheHeroes | group | No | |
TournTime | timer | No | |
Water | integer | No | |
WaterBenders | force | No |
//---Options---
constant function CreepRespawn_Delay takes nothing returns real
return 45.0 //The duration (in seconds) after dying creeps respawn.
endfunction
constant function CreepRespawn_VisibilityBlock takes nothing returns boolean
return true //If this is set to true, creep respawn will be delayed until
//none of the players observe the spawning point.
//(So none of the players can see the creeps spawning.)
endfunction
constant function CreepRespawn_NumberOfSpawns takes nothing returns integer
return 1 //This defines the number of creeps that will spawn after one died.
endfunction
constant function CreepRespawn_SpawnRandomFromLevel takes nothing returns boolean
return false //If set to true, a same-level random creep will spawn.
endfunction
//---Creep Respawn System---
function CR_H2I takes handle h returns integer
return h
return 0
endfunction
function SetCreepRespawnPoints takes nothing returns nothing
local group g = CreateGroup()
local unit u = null
local string s = ""
call GroupEnumUnitsOfPlayer(g,Player(12),null)
loop
set u = FirstOfGroup(g)
call GroupRemoveUnit(g,u)
exitwhen u == null
set s = I2S(CR_H2I(u))
call StoreReal(udg_CR,s,"RespawnX",GetUnitX(u))
call StoreReal(udg_CR,s,"RespawnY",GetUnitY(u))
call StoreReal(udg_CR,s,"RespawnFacing",GetUnitFacing(u))
endloop
call DestroyGroup(g)
set g = null
endfunction
function RespawnCreeps takes nothing returns nothing
local unit u = GetTriggerUnit()
local string s = I2S(CR_H2I(u))
local real x = GetStoredReal(udg_CR,s,"RespawnX")
local real y = GetStoredReal(udg_CR,s,"RespawnY")
local real f = GetStoredReal(udg_CR,s,"RespawnFacing")
local integer a = 0
local integer b = 0
local integer c = 0
call TriggerSleepAction(CreepRespawn_Delay())
if CreepRespawn_VisibilityBlock() then
loop
loop
exitwhen a > 11
if not IsVisibleToPlayer(x,y,Player(a)) then
set c = c + 1
endif
set a = a + 1
endloop
exitwhen c > 11
set a = 0
set c = 0
call TriggerSleepAction(10)
endloop
set a = 0
endif
set c = GetUnitLevel(u)
set b = GetUnitTypeId(u)
call RemoveUnit(u)
loop
exitwhen a >= CreepRespawn_NumberOfSpawns()
if CreepRespawn_SpawnRandomFromLevel() then
set u = CreateUnit(Player(12),ChooseRandomCreep(c),x,y,f)
else
set u = CreateUnit(Player(12),b,x,y,f)
endif
set s = I2S(CR_H2I(u))
call StoreReal(udg_CR,s,"RespawnX",x)
call StoreReal(udg_CR,s,"RespawnY",y)
call StoreReal(udg_CR,s,"RespawnFacing",f)
set a = a + 1
endloop
set u = null
endfunction
//===========================================================================
function InitTrig_CreepRespawn takes nothing returns nothing
set udg_CR = InitGameCache("CR")
call SetCreepRespawnPoints()
set gg_trg_CreepRespawn = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(gg_trg_CreepRespawn, Player(12), EVENT_PLAYER_UNIT_DEATH, null)
call TriggerAddAction(gg_trg_CreepRespawn, function RespawnCreeps)
endfunction