• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Using an upgrade to periodically spawn units?

Status
Not open for further replies.
Level 3
Joined
Aug 6, 2014
Messages
40
Okay, here's the goal: In my map I have re-spawning units going into an endless conflict. The units spawns will have no AI and be allied with player. The player has the ability to collect gold from doing various tasks on the side, or waiting for a period of time. With the gold I'm hoping to make it so the player can buy upgrades from the spawn zones(building in this case) to add more units to the periodic spawns.

So basically
Upgrade at barracks:
Train grunt
This will add one grunt to the periodic spawns
-1 gold

Train Tauren
this will add one tauren to the periodic spawns
-5 gold

etc.
My question is, how do I set up triggers to make this happen? I'm pretty noobish at triggers, right now I just have:
Ever 25 seconds 1 grunt spawns from barracks234,
then an auto-attack for units who enter region.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,192
You use arrays to keep track of spawn numbers. You spawn the number of units dictated by the array. If it is 0 then nothing spawns. Do this for all unit types. If you are smart you can use 2 arrays to do all unit types, one "column" array for the types and a 2D array for the number of each type. If you are less smart you can simply allocate a unique array for each unit type, hard wire in the spawn types for that array and use player index to look up the spawn number.

In response to a finished upgrade event (or research, forget name) then you increment the appropriate spawn amount array. You could use a single trigger which is array fed for all upgrades or make an upgrade per trigger, the choice is yours.

When spawning the units try and distribute them over an area to prevent excessive system resource consumption by the unit displacement algorithm.
 
Status
Not open for further replies.
Top