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

Unit spawn trigger

Status
Not open for further replies.
Level 2
Joined
Oct 12, 2017
Messages
7
Hello, so I'm making a 1v1 TD kind of map and I'm trying to make it so units upgrade when a player researches an upgrade!

So basically I have a trigger which spawns 2 Grunts and 2 Headhunters, and there is an upgrade that upgrades the amount of Headhunters spawned to 4. Now here comes the problem.. I have another upgrade which upgrades Headhunters to Warlocks but when it does it only spawns 2 Warlocks!

So what I want to do is essentially have it so if a player researches the Headhunter amount upgrade and THEN researches the Warlock upgrade it will spawn 4 Warlocks instead of 2

Any help is appreciated!
Also sorry for any mistakes in my grammar, English is not my native language!
 
Level 2
Joined
Oct 12, 2017
Messages
7
Orc Spawns

  • OrcSpawn
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Trigger - Turn on (This trigger)
      • Unit - Create 2 Grunt for Player 3 (Teal) at (Center of Orc1 <gen>) facing Default building facing degrees
      • Unit - Create 2 Troll Headhunter for Player 3 (Teal) at (Center of Orc1 <gen>) facing Default building facing degrees
      • Unit - Create 2 Grunt for Player 3 (Teal) at (Center of Orc2 <gen>) facing Default building facing degrees
      • Unit - Create 2 Troll Headhunter for Player 3 (Teal) at (Center of Orc2 <gen>) facing Default building facing degrees
Upgrade

  • OrcUpgrade
    • Events
      • Unit - War Mill 0063 <gen> Finishes research
    • Conditions
      • (Researched tech-type) Equal to Orc Warlocks
    • Actions
      • Trigger - Turn off OrcSpawn <gen>
      • Trigger - Turn on OrcSpawn2 <gen>
Warlock Spawns

  • OrcSpawn2
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Trigger - Turn on (This trigger)
      • Unit - Create 2 Grunt for Player 3 (Teal) at (Center of Orc1 <gen>) facing Default building facing degrees
      • Unit - Create 2 Orc Warlock for Player 3 (Teal) at (Center of Orc1 <gen>) facing Default building facing degrees
      • Unit - Create 2 Grunt for Player 3 (Teal) at (Center of Orc2 <gen>) facing Default building facing degrees
      • Unit - Create 2 Orc Warlock for Player 3 (Teal) at (Center of Orc2 <gen>) facing Default building facing degrees
So what I want to know is how do I make it so that once a player researches an upgrade that adds 4 HH's and THEN researches the Orc Warlocks it makes it so 4 Warlocks spawn instead of 2
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,555
A simple solution would be to use an Integer variable to store how many units will be spawned. Set this to 2 by default then you can increase it when you research your Upgrade. You would want to create two of these variables so you have one for each player, otherwise, both players will spawn 4 units even if only one of them has the upgrade.

However, an even better option would be to use an Array. An Array allows us to use 1 variable for multiple things.

In the triggers below I store the player number of our player inside of an Integer Array. (Note: Player 1's player number is equal to 1, player 2's is equal to 2, etc...) So in the example below if we were Player 1 and we researched the upgrade then the trigger would set SpawnCount[1] = 4. If we were player 2 then it'd set SpawnCount[2] = 4.
  • Research
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • (Researched tech-type) Equal to Increase Spawns
    • Actions
      • Set SpawnCount[player number of triggering player] = 4
Then we can choose SpawnCount as our number of units created. So if SpawnCount[1] = 2 and SpawnCount[2] = 4 then the trigger below would create 2 units for Player 1 and 4 units for Player 2.
  • Spawn
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Create SpawnCount[1] Orc Warlock for Player 3 (Teal) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit - Create SpawnCount[2] Orc Warlock for Player 3 (Teal) at (Center of (Playable map area)) facing Default building facing degrees
I attached some maps below with some mini-systems for spawning units.

Edit: Re-uploaded the map and added another version. Version 3 adds some extra features like allowing you to choose which Units will Spawn.
 

Attachments

  • Spawn Trigger v.2.w3x
    24.8 KB · Views: 21
  • Spawn Trigger v.3.w3x
    27.5 KB · Views: 28
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,555
No problem :)

I updated my last post and added a new map (v.3) which works a bit different from v.2. I'm not entirely sure how you plan on making your map work but I threw in some new stuff that you might be interested in. At the very least it might inspire some ideas :p
 
Status
Not open for further replies.
Top