• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] unit spawn. leakless? improvements?

Status
Not open for further replies.
Level 3
Joined
Nov 18, 2007
Messages
48
Seeing that the triggers that run the most amount of times are the most important for performance I'm posting this for some advice.
so I have redone a unit spawn which is periodic.
summary:
basically udg_double is set to 0 or 1, the idea is to spawn units twice when it's 1. (local g)
there are four places that spawn units to I made a loop for that ( local b )
udg_spawn (array) is set to 1 after some time to spawn more units
udg_xreg (array) is GetLocationX() from a region
udg_yreg (array) is GetLocationY() from a region
is this ok ?
JASS:
set udg_xreg[0] = GetRectCenterX(gg_rct_Region_000)
set udg_yreg[0] = GetRectCenterY(gg_rct_Region_000)
what can I improve ? (jass, no vjass)
JASS:
function Trig_Units_Actions takes nothing returns nothing
local integer b
local integer g
set g = 0
loop
    exitwhen g > udg_double
set b = 0
loop
    exitwhen b > 3
if udg_humanspawn[b]==1 then
call CreateUnit(Player(0),'hfoo',udg_xreg[b]-45,udg_yreg[b],90)
call CreateUnit(Player(0),'hfoo',udg_xreg[b],udg_yreg[b],90)
call CreateUnit(Player(0),'hfoo',udg_xreg[b]+45,udg_yreg[b],90)
call CreateUnit(Player(0),'nhea',udg_xreg[b]-55,udg_yreg[b]-150,90)
if udg_spawn[0]==1 then
call CreateUnit(Player(0),'nrif',udg_xreg[b]+5,udg_yreg[b]-100,90)
endif
if udg_spawn[1]==1 then
call CreateUnit(Player(0),'hhes',udg_xreg[b]+30,udg_yreg[b]+50,90)
endif
if udg_spawn[2]==1 then
call CreateUnit(Player(0),'eshd',udg_xreg[b]-20,udg_yreg[b]-170,90)
endif
if udg_spawn[3]==1 then
call CreateUnit(Player(0),'hmpr',udg_xreg[b]-75,udg_yreg[b]-120,90)
endif
if udg_spawn[4]==1 then
call CreateUnit(Player(0),'hkni',udg_xreg[b]-10,udg_yreg[b]+100,90)
endif
endif
set b = b + 1
endloop
set g = g + 1
endloop
endfunction
 
Last edited:
Level 9
Joined
Apr 23, 2011
Messages
527
Use [code=jass][/code] for a cleaner look.

Are you setting that point only once in your entire map? If so, you don't need to remove it, the leak will be minimal as it is set just once.
 
Status
Not open for further replies.
Top