• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

One button to train them all.

Status
Not open for further replies.
Level 2
Joined
Dec 7, 2013
Messages
8
Greetings,

Hopefully someone wiser than I has an answer:

I want to use one button, lets say train footman in a barracks, however when this button is pressed it will randomly select one of 3 different units to be trained.

I have been attempting different combinations of triggers to no success and I'm stumped. Anyone have any ideas as how to make this possible? Thanks for any help.
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
If you're using 3 different type of building that will be easy to trigger.
When you press on train unit, using triggers, you could do this :
Event - A unit start training of a unit
Condition - Training unit equal to "Your unit (footman)"
Actions - Order "BuildingA" to train "Unit A"
Order "Building B" to train "Unit B"

That should work.
Notice : Make you have enough resources already.
If you're using the same building to train different units when u train one specified unit. You could do the method I've said before as well. It should work too.
 
Level 2
Joined
Dec 7, 2013
Messages
8
I know it's not the easiest answer but I'm looking for it to be 1 button, 1 building, 3 different possible units.

So far I'm kinda working on replacing the trained unit upon completion with 1 of a random 3. I just have to figure out how to make the 3 units random and make it select one of them but it's not going well.
 
Level 2
Joined
Dec 7, 2013
Messages
8
Yes I understand that but the issue I am having isn't anything to do with replacing a unit with another 1 unit.

This would be an example that might make better sense:
3 types of footman:
Normal Footman
Crusader
Bandit

When the player presses the train button for footman in the barracks I want it to train like normal and cost the same amount of gold as normal but at the end of the wait instead of a predictable footman popping out I am trying to make 1 of these appear.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Yes I understand that but the issue I am having isn't anything to do with replacing a unit with another 1 unit.

This would be an example that might make better sense:
3 types of footman:
Normal Footman
Crusader
Bandit

When the player presses the train button for footman in the barracks I want it to train like normal and cost the same amount of gold as normal but at the end of the wait instead of a predictable footman popping out I am trying to make 1 of these appear.

So you get a random one?

You can put a dummy unit into the barracks. Give it a proper icon, cost, train time, and tooltip. Make a triggers like:

  • Init
  • Events
    • Map Initialisation
  • Conditions
  • Actions
    • set footmenTypes[0] = Footman
    • set footmenTypes[1] = Crusader
    • set footmenTypes[2] = Bandit
  • Random Footman
  • Events
    • Unit - A unit enters <Playable map area>
  • Conditons
    • Unit type of (Triggering Unit) equal to (dummy footman)
  • Actions
    • set tempPoint = Position of (Triggering Unit)
    • set tempInt = Random integer from 0 to 2
    • Unit - Create 1 unit of type footmenTypes[(tempInt)] for (Owner of (Trigger Unit)) at tempPoint facing 0 degrees.
    • Unit - Remove (Triggering Unit) from the game.
    • Custom script call RemoveLocation(udg_tempPoint)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
So you get a random one?

You can put a dummy unit into the barracks. Give it a proper icon, cost, train time, and tooltip. Make a triggers like:

  • Init
  • Events
    • Map Initialisation
  • Conditions
  • Actions
    • set footmenTypes[0] = Footman
    • set footmenTypes[1] = Crusader
    • set footmenTypes[2] = Bandit
  • Random Footman
  • Events
    • Unit - A unit enters <Playable map area>
  • Conditons
    • Unit type of (Triggering Unit) equal to (dummy footman)
  • Actions
    • set tempPoint = Position of (Triggering Unit)
    • set tempInt = Random integer from 0 to 2
    • Unit - Create 1 unit of type footmenTypes[(tempInt)] for (Owner of (Trigger Unit)) at tempPoint facing 0 degrees.
    • Unit - Remove (Triggering Unit) from the game.
    • Custom script call RemoveLocation(udg_tempPoint)

Why didn't you use Replace Unit function ?
Saves you lines of code (variables/function calls).

@OP
I attached a test map for you.
 

Attachments

  • Unpredictable Training.w3x
    13 KB · Views: 36
Last edited:
Status
Not open for further replies.
Top