• 🏆 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!

In need of Help For a Spawning Issue.

Status
Not open for further replies.
Level 3
Joined
Sep 27, 2008
Messages
18
I am new to triggering but I have been dinkering around with it and have come to a roadblock in what I wish to do with it.

Situation: I have a Castle and a Region in front of the Castle. 4 footmen spawn in the region every 60 seconds. The Castle has the Defend, Improved Bows, and Priest Training upgrades.

Goal: To have 4 footmen spawn every 60 seconds (achieved). Then if Defend is researched, to have a Captain unit spawn alongside the 4 footmen every 60 seconds. And then the same idea with 2 Archer units after researching Improved Bows, and 1 Priest after researching Priest Training. So after all three researches the region would spawn 4 footmen, 1 captain, 2 archers, and 1 priest per 60 seconds. Lastly, the spawning of ANY units, including the original free 4 footmen, ceases if the Castle is destroyed.

Problem: The researching process to unlock other units does not work and I have tried several processes. All it does is spawn 4 new footmen every minute even after researching.

Please pardon my ignorance with Triggering and formating this question, any help at all is greatly appreciated and if you have questions feel free to ask.
 
Level 5
Joined
Sep 1, 2010
Messages
168
Set for each of your abilities that you research an integer array (with the length equal to the number of players in you map).
e.g. 4 players:
defend_count[4]
bow_count[4]
priest_count[4]
  • Event - A unit finishes an upgrade
  • Condition
  • Actions
  • if (researched upgrade equal to defend)
  • set defend_count[playernumber of owner of (triggering unit)-1] = 1
  • else
  • ...(and so on with the other upgrades)
In your spawning trigger, check for each of those variables if they are 1
(
  • ...
  • if (defend_count[0]=1)
  • Unit - Create a Caiptain for Player 1 at location_player1 facing....
  • ...
)

As for your last problem - simply check in your spawning conditions if the castle is alive (and therefore, I recommend a seperate trigger copy of this for each player).

If my explanation wasn't clear enough I could do a test map - dunno though if it would still be today or at the beginning of the upcoming week (kinda busy with uni :vw_death: ).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Create a linked list system that basically is a spawn list. It needs to store the unit type to spawn and the number to spawn.
You then create a spawner unit list which links each spawner unit to a spawn list.
You also create a player to spawn list map.

Then all you do is loop through the spawner unit list and then spawn all units in its spawn list.
You also initilize it so each player has their own spawn list (for the upgrade support) which is accociated with them.
When the techs are reasearched, you use the player to spawn list map to find which spawn list to append to and then append the extra spawn type and number onto it. A separate subsystem could be used for this utalizing hashtables to map a technology to a spawn system appending data if you plan to have a lot of technologies that modify spawn list (otherwise simple multiple selection would probably sufice).
When a castle is created you add it to the spawner unit list and attach it to the owning player's spawn list (via the player to spawn list map).
When a castle dies you use a linear search to to find it in the spawner list and then remove it.
When a player owns no more castles and is unable to build more castles you can remove him from the player to spawn list map and remove is spawn list.

The advantage of such a system is prety good flexibility and maintainability.
 
Level 3
Joined
Nov 14, 2010
Messages
34
u could make something like:

footman trigger
captain trigger
priest trigger
archer trigger

then, add a trigger:
Upgrade "Defend" is comeplete - turn captain On.
etc
etc

then, to the castle destroyed:
<Castle> dies
Turn off Footman Trigger, archer trigger, captain trigger, priest trigger.

note: captain, archer and priest triggers must NOT be enabled at begging.
 
Level 3
Joined
Sep 27, 2008
Messages
18
Akhetaton I have found a way to do something similar to what I originally intended through your method And it works so far, thanks for your help. Thanks to everyone else too, learned some new stuff by messing with each method.
 
Status
Not open for further replies.
Top