• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Help! Create dynamic spawn party via template lists

Sep 18, 2018
54
12
70
31
#1
Dear Map Makers,

I am trying to create spawn waves with random units in it (via template lists). Can somebody give a hint on how this would be done (if possible). Here is my current workflow, but it only spawns 1 Arcanist in the 1st wave, 2 Arcanists in the 2nd wave, 3 Arcanists in the 3rd wave, instead of spawning 1 sapper and 1 arcanist in the 1st wave, 1 Arcanist and 1 Arcane Templar in the 2nd wave, ...:

1) I setup an empty party which will later be used in the action "spawn party".
01_party.jpg


2) I create an empty template list in which the randomized units will be added via action "pick from list"
02_templatelist.jpg


3) I create another template list, which holds all the possible units to spawn (via adding them to the empty template, that is used in the empty party later on)
03_templateunits.jpg


4) I create a script that is looped each 6 seconds by a timer. First it clears the (empty) template list, since the script is looped and units in the list would otherwise stack.
Then it creates a random number between 0 and 2 which is stored in a number (this will be used in the next step).
04_action1.jpg


5) Now it picks (via the random number) the position from my possible units to spawn from the arcanist list (0 - Arcane Templar / 1 - Arcanist / 2 - Sapper) and puts it into the empty template list. Then it randomizes the number again.
05_action2.jpg


6) With the again shuffled number between 0 - 2 it saves another unit to the list. Finally this list is now added to the empty Party1, which will be spawned now.
06_spawnparty.jpg


7) Now after 6 seconds the timer fires the event again.

But as I said in the beginning, the template list seems not to be cleared correctly (1 wave spawns 1 unit, 2 wave spawns 2 units, ...) and also the units are not randomly picked and added to the list, but it's always the Arcanist which is spawned.

Please, if you have ideas / corrections on my method, or some hints on how to debug it properly, please leave a note. As always, thank you for your help and thoughts! :)
 

Nutter

Frost Weaver
WFTO Founder
Jan 19, 2013
2,453
1,092
615
29
Huddersfield, UK
nutter666.tumblr.com
#2
Let me just check I understand everything here:

You always want one unit to be spawned each time it runs? (Or is it two units ech time)
And that one unit can be 1 of 3 different types of unit and should be randomly selected?
 
Sep 18, 2018
54
12
70
31
#3
Thank you for your answer. Yes, in this example there should be always two units that spawn in each wave. They should be selected out of three different types. This is just an example. What I finally wanted to do is, make a list of available units (all standard Empire units) then pick out let's say 5 unit types of that list and spawn them. This way I would not have to manually setup waves in which there are fixed unit types, but in each wave a random force incoming with always 5 members.

There seems to be something odd with the random number generation. When I have 3 types, I need to set the random number from 0 to 3. Then all 3 different types will spawn. If I set it to 0 - 2 or 1 - 3 whether the first or the last unit is missing. Still the amount of possible results with 0 to 3 would be 4. Or am I thinking wrong?

What I am not able to fix is the amount of units spawning. The list is not cleared, so the first unit that spawned in wave 1, will be the first unit in wave 2 again to which the next unit will be added and so on. So I am doing something wrong when clearing the list.

Also the units stacking (1 unit in wave 1, 2 units in wave 2 and so on) I cannot explain, since there should be always 2 units in each wave - not a ++1.

Maybe the way how I am doing this is too stupid. Could you think of an easier solution or am I using the mighty script wrongly? I am thankful for any hints, since I want to understand lists and templates by using them to create dynamic spawn waves and I am also very sorry if I am doing something stupid. But I am grateful that you find the time to answer. Maybe the solution could go in an advanced Mighty Script Tutorial 2.0 :)
 
Last edited:

Nutter

Frost Weaver
WFTO Founder
Jan 19, 2013
2,453
1,092
615
29
Huddersfield, UK
nutter666.tumblr.com
#4
If you're making a random "Number" between 0 and 3, it is actually an Int(eger) rather than a number.. which means it is always a whole number that is rounded up (or down, don't remember which), which basically means 0-3 is always 1,2,3 or 0,1,2 (depending if it rounds up or down). It was just decided by the devs that calling it a Number would be easier to understand for "non-coders" to understand instead of an Int.

As for your actual example. The reason you're getting duplicates is because your "template wave" list is not reset to empty after the first wave is spawned, meaning that you're just adding more and more units into the list.

If I was doing it myself, rather than trying to create a "template" list like that, I would simplify it and create a SpawnTemplate containing 1 of each unit type, and then just spawn that template in place of trying to add stuff to a list which you spawn afterwards.

During Map Creation:
Create 3 Parties with the following:
Arcane Templar Template (A party containing just a Arcane Templar)
Arcanist Template (A party containing just an Arcanist)
Sapper Template (A party containing just a Sapper)

Then when you're doing the random number stuff, rather than the "trying to add stuff into a template" way you were attempting, you can just spawn those template parties in the intended location instead. Because it all happens so quickly, you can follow it up with generating a second number and spawning a second unit using the parties and they'll both appear together.

That removes the whole "trying to clear your template list" problem out of the picture entirely. In theory of course, I haven't tested this kind of thing i'm afraid.
 
Last edited:
Likes: SeriousToni
Sep 18, 2018
54
12
70
31
#5
Thank you very much for this detailed thoughts! I will test it and see if I can adapt it accordingly! I will respond after I tried this out! Thanks again! :)
 
Sep 18, 2018
54
12
70
31
#6
I like your example, since I can skip the template stuff. But I would need to setup many loops for spawning multiple one-man-armies and set them to the same patrol route. So I tested my previous work also a little more:

My error with the +1 unit added per wave was, that I did add more units to the party than I removed via trigger. So I set up more triggers "remove from party" (sadly you can only pick one position per remove trigger, so I need a remove action for each unit in the party). Then there was only one unit spawning.

Another error seems to be either that I don't understand how list templates and their corresponding trigger actions work, or they seem to be buggy when using them with units. So instead of picking multiple units off of a template, adding them to a new list, I just pick one unit type, add it to the empty party shuffle the number again, add it again, and so on. When this trigger loops, all units are (or should be) removed both from the "helper template list" and the party, but still I end up having 6 units spawn instead of 3 per wave. Nevertheless the too many units, the rest of the script seems to work: Every 10 seconds there are random units spawned from my unit pool template. So I kind of achieved what I was trying since the last days. Still I hope for a "How to use templates / lists and triggers" tutorial in the future, since either this feature is (at least for me) a bit hard to understand or even buggy when it comes to adding / removing elements from a list. (could also be that the action "add to party" takes only list templates with one unit in it ignoring the other units in the list, which is what I partly seemed to fix with my current changes on the script).

I hope this helps anyone who is trying to do the same like me - maybe we can get some more light into this in the future by more experienced mappers like you are :)
 

Nutter

Frost Weaver
WFTO Founder
Jan 19, 2013
2,453
1,092
615
29
Huddersfield, UK
nutter666.tumblr.com
#7
Lists were a kinda last minute addition to the editor (by the devs) at my request, intended for doing this kind of wave based stuff and could quite easily be a bit bugged. You're probably the first person (other than me) to really dive deep into trying to use lists like this.
 
Sep 18, 2018
54
12
70
31
#8
Oh I did not know this. Should I submit my test map to the bugtracker then? It contains not really more than the portal and this script, because it's just for testing.
 
Sep 18, 2018
54
12
70
31
#9
Last edited:
Top Bottom