• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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