i'm quite new to mapmaking and not very experienced. i created a map, i played a while ago in SC1 -> Total madness.
for those who don't know it: every player has a base to defend and automatically spawns units at his base, no base-building, the more kills you got, the better units will spawn... i've built a basic, working map, but its still quite faulty.
this code i got for all 8 players... so i have to change 96, when i want to make a change... and now i am pretty sure, this can be done much more elegant... :D
thought about an array with all players and a for-loop or something like that... please help
So, first of all that's pseudo code, so it won't look exactly like that, but that's the best I can create by heart.
That's quite a bunch of code though, let's see.
First action is a loop. It tells the game to run the following actions 8 times (1 to 8 ) and everytime it ran through it increases the variable <Inc> by 1. Now we can use <Inc> as our player number. Since it loops from 1 to 8 all players are covered.
Next line is the If-statement whether the player is still playing, just like in your triggers.
Only if that applies we check what unit spawns for the player. You can just add all of your Create-actions behind each other like I did there. Through the conditions only the correct one will run.
Everywhere where the player number usually would be there's the variable <Inc> now.
That should shrink the number of triggers from 96 to.. uhmm.. 1 :)
Hope it's clear enough. Sometimes these nested Ifs are hard to understand.
hi,
i'm quite new to mapmaking and not very experienced. i created a map, i played a while ago in SC1 -> Total madness.
for those who don't know it: every player has a base to defend and automatically spawns units at his base, no base-building, the more kills you got, the better units will spawn... i've built a basic, working map, but its still quite faulty.
now i need help me making better scripts. ^^
example: global variables:
"unit-spawn" scripts (for player 1, for the 1st & 2nd unit). scripts 3-12 look like #2, just other variables and units...
this code i got for all 8 players... so i have to change 96, when i want to make a change... and now i am pretty sure, this can be done much more elegant... :D
thought about an array with all players and a for-loop or something like that... please help
regards, dmo
You're on the right track with using for loops
So, first of all that's pseudo code, so it won't look exactly like that, but that's the best I can create by heart.
That's quite a bunch of code though, let's see.
First action is a loop. It tells the game to run the following actions 8 times (1 to 8 ) and everytime it ran through it increases the variable <Inc> by 1. Now we can use <Inc> as our player number. Since it loops from 1 to 8 all players are covered.
Next line is the If-statement whether the player is still playing, just like in your triggers.
Only if that applies we check what unit spawns for the player. You can just add all of your Create-actions behind each other like I did there. Through the conditions only the correct one will run.
Everywhere where the player number usually would be there's the variable <Inc> now.
That should shrink the number of triggers from 96 to.. uhmm.. 1 :)
Hope it's clear enough. Sometimes these nested Ifs are hard to understand.