- Joined
- Nov 30, 2007
- Messages
- 1,202
The Trigger is running, I've checked that. Also if I use this method for about 50 "Towns" Should I create them periodically so to reduce lagg?
JASS:
function SetupBases takes nothing returns nothing
local real array tx // *** Town Location
local real array ty // ***
local real array rx // *** Resource Location
local real array ry // ***
local integer array p // *** Town Owning Player
local integer array br // *** inds Resource to Town
local integer array res // *** Resource Unit-Type
local integer array rac // *** Race Town Unit-Type
local unit u
local integer a = 0
local integer random
// Resource and Town Setup
set tx [ 0 ] = GetRectCenterX(gg_rct_TL_000)
set ty [ 0 ] = GetRectCenterX(gg_rct_TL_000)
set p [ 0 ] = 0
set rac [ 0 ] = 'htow'
set rx [ 0 ] = GetRectCenterX(gg_rct_RL000_0)
set ry [ 0 ] = GetRectCenterY(gg_rct_RL000_0)
set rx [ 1 ] = GetRectCenterX(gg_rct_RL001_0)
set ry [ 1 ] = GetRectCenterY(gg_rct_RL001_0)
set rx [ 2 ] = GetRectCenterX(gg_rct_RL002_0)
set ry [ 2 ] = GetRectCenterY(gg_rct_RL002_0)
set br [ 0 ] = 0
set br [ 1 ] = 0
set br [ 2 ] = 0
set tx [ 1 ] = GetRectCenterX(gg_rct_TL_001)
set ty [ 1 ] = GetRectCenterX(gg_rct_TL_001)
set p [ 1 ] = 0
set rac [ 1 ] = 'htow'
set rx [ 3 ] = GetRectCenterX(gg_rct_RL003_1)
set ry [ 3 ] = GetRectCenterY(gg_rct_RL003_1)
set rx [ 4 ] = GetRectCenterX(gg_rct_RL004_1)
set ry [ 4 ] = GetRectCenterY(gg_rct_RL004_1)
set rx [ 5 ] = GetRectCenterX(gg_rct_RL005_1)
set ry [ 5 ] = GetRectCenterY(gg_rct_RL005_1)
set br [ 3 ] = 1
set br [ 4 ] = 1
set br [ 5 ] = 1
// Resource Unit-Type
set res[0] = 'n000' // Lumber
set res[1] = 'n001' // Food
set res[2] = 'n002' // Gold
set res[3] = 'n003' // Iron
// Create Town
loop
exitwhen a > 1 // Number of Town Location Arrays Used
set u = CreateUnit(Player(p[a]), rac[a], tx[a], ty[a], bj_UNIT_FACING )
call indexUnit(u)
set u = null
set a = a + 1
endloop
set a = 0
// Create Resources
loop
exitwhen a > 5 // Number of Resource Location Arrays
set random = GetRandomInt(0,3)
set u = CreateUnit(Player(p[a]), res[random], rx[a], ry[a], bj_UNIT_FACING )
call GroupAddUnit(udg_indexedUnit_g[br[a]], u)
call indexUnit(u)
set u = null
set a = a + 1
endloop
call DestroyTrigger(gg_trg_SetupBases)
endfunction
//===========================================================================
function InitTrig_SetupBases takes nothing returns nothing
local trigger t = CreateTrigger()
set gg_trg_SetupBases = t
call TriggerAddAction(t, function SetupBases)
set t = null
endfunction
Last edited: