• 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.

Is having Multiple Map initialization Events Bad?

Status
Not open for further replies.
Level 10
Joined
Mar 25, 2008
Messages
339
Just wondering if having 5 individual triggers with Map initialization events has any performance impact or increases liklihood of crashing anymore than if I just merged them all.

I have one dedicated to opening doors across the map (there's like 100 of them) and another one dedicated to setting point variables to zones, there's also like 100 of those inside that trigger.

I notice there's a major lag spike when the game finishes loading, I want to lessen the impact of that because I think it overwhelms some peoples computers or wc3's connection on occasion.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
The main benefit is having full control over how things execute. When working in GUI I use one main Map Init trigger which Runs each other trigger.
Map Init
Setup Players
Setup Units
Setup items
etc...

Players will always be setup first, which could be important for the rest of the triggers if they referenced player-related data.
 
Level 10
Joined
Mar 25, 2008
Messages
339
Half my init trigger is declaring about a hundred positions for boss spawns/item spawns & opening nearly every door in the game, wish I could just default them all to open and close the 1% that actually stay closed ><
Thankfully most of my init is just basic stuff like setting default gold, some visibility and ordering some units to start patroling, nothing really needs to be in order in my init.

Just to test it out i tried to have the Init trigger activate other triggers instead of having those also have events, does not work with map init, the other triggers dont fire.

Is it bad to have a Map Initialization trigger create a point variable for a random location for each player and delete that point after each player followed by it re-using that point variable for each player slot?
I do that just so each player wisp for hero selection does not spawn in the same exact spot.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Maybe you're on an older (buggier) version but Running a trigger from the Map Initialization event works fine. Like I said, I do it all of the time.

Regarding the Doors, couldn't you use the Pick Every Destructible function?

Regarding the Points, that sounds fine to me. The Points won't leak if you Remove them before Setting them again so you've handled the memory leak issue.

Reusing variables between multiple triggers is generally safe to do as long as you manage all of the possible memory leaks. The only other two cases I can think of that would cause problems are 1) You reference a shared variable after a Wait. 2) An action in one of your triggers causes another trigger to run mid-execution AND both of these triggers share one or more of the same variables. Keep in mind VERY few actions are capable of doing that and most of the time triggers will run as their own unique instance that's put into a queue. So in your case it's extremely unlikely that you would have triggers which would cause this problem to happen, especially during the Initialization process.
 
Last edited:
Level 20
Joined
Jan 3, 2022
Messages
364
There's no difference in how many Init triggers you can have. WorldEdit will put all Map Init triggers inside function "RunInitializationTriggers" and run them all at map init (at the end of function main(). I do not know in which order your triggers will be listed there, probably in the same order you place them in trigger editor (top to bottom)
JASS:
function RunInitializationTriggers takes nothing returns nothing
    call ConditionalTriggerExecute(gg_trg_Melee_Initialization)
    call ConditionalTriggerExecute(gg_trg_Next_Init_Trigger_etc)
endfunction
How can you see for yourself? Save the map in WE, get Ladik's MPQ Editor, open the map there and extract war3map.j / war3map.lua. Look inside.

PS: I wonder if there's the thread instruction limit in Jass... in other words if you can cause an error at init time by doing too much stuff there?
 
Status
Not open for further replies.
Top