- Joined
- Feb 22, 2013
- Messages
- 161
JASS:
function SpawnLoop takes nothing returns nothing
local timer spawnInterval = GetExpiredTimer()
local integer i = GetRandomInt(1, 4)
local real x1 = GetRandomReal(GetRectMinX(gg_rct_corruptSpawn1), GetRectMaxX(gg_rct_corruptSpawn1))
local real y1 = GetRandomReal(GetRectMinY(gg_rct_corruptSpawn1), GetRectMaxY(gg_rct_corruptSpawn1))
local real x2 = GetRandomReal(GetRectMinX(gg_rct_corruptSpawn2), GetRectMaxX(gg_rct_corruptSpawn2))
local real y2 = GetRandomReal(GetRectMinY(gg_rct_corruptSpawn2), GetRectMaxY(gg_rct_corruptSpawn2))
local real x3 = GetRandomReal(GetRectMinX(gg_rct_corruptSpawn3), GetRectMaxX(gg_rct_corruptSpawn3))
local real y3 = GetRandomReal(GetRectMinY(gg_rct_corruptSpawn3), GetRectMaxY(gg_rct_corruptSpawn3))
local real x4 = GetRandomReal(GetRectMinX(gg_rct_corruptSpawn4), GetRectMaxX(gg_rct_corruptSpawn4))
local real y4 = GetRandomReal(GetRectMinY(gg_rct_corruptSpawn4), GetRectMaxY(gg_rct_corruptSpawn4))
if LoadInteger(udg_spawnerHash, 1, GetHandleId(spawnInterval)) == 29 then
call PauseTimer(spawnInterval)
call DestroyTimer(spawnInterval)
set spawnInterval = null
return
endif
if i == 1 then
call CreateUnit(Player(10), udg_monsterType[udg_Round], x1, y1, 270.00)
call DisplayTimedTextToPlayer(Player(2), 0, 0, 0., "Unit created, North side. " + I2S(LoadInteger(udg_spawnerHash, 1, GetHandleId(spawnInterval))))
endif
if i == 2 then
call CreateUnit(Player(10), udg_monsterType[udg_Round], x2, y2, 270.00)
call DisplayTimedTextToPlayer(Player(2), 0, 0, 0., "Unit created, East side. " + I2S(LoadInteger(udg_spawnerHash, 1, GetHandleId(spawnInterval))))
endif
if i == 3 then
call CreateUnit(Player(10), udg_monsterType[udg_Round], x3, y3, 270.00)
call DisplayTimedTextToPlayer(Player(2), 0, 0, 0., "Unit created, South side. " + I2S(LoadInteger(udg_spawnerHash, 1, GetHandleId(spawnInterval))))
endif
if i == 4 then
call CreateUnit(Player(10), udg_monsterType[udg_Round], x4, y4, 270.00)
call DisplayTimedTextToPlayer(Player(2), 0, 0, 0., "Unit created, West side. " + I2S(LoadInteger(udg_spawnerHash, 1, GetHandleId(spawnInterval))))
endif
call SaveInteger(udg_spawnerHash, 1, GetHandleId(spawnInterval), LoadInteger(udg_spawnerHash, 1, GetHandleId(spawnInterval)) + 1)
set spawnInterval = null
endfunction
function Trig_Spawn1_Actions takes nothing returns nothing
local timer spawnInterval = CreateTimer()
local integer index = 0
call BJDebugMsg("Spawn1 running.")
call SaveInteger(udg_spawnerHash, 1, GetHandleId(spawnInterval), index)
call TimerStart(spawnInterval, 1.00, true, function SpawnLoop)
set spawnInterval = null
endfunction
//===========================================================================
function InitTrig_Spawn1 takes nothing returns nothing
set gg_trg_Spawn1 = CreateTrigger( )
call TriggerAddAction( gg_trg_Spawn1, function Trig_Spawn1_Actions )
endfunction
So in this script I have here it loops every second and creates a unit and stops at 29, it counts fine up to 29 and everything, but in the DisplayTimedTextToPlayer function, it says it stops counting at 28 but I counted 29 units on the map so that's how I know it works.. So why does it display 28 as the final integer count?