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.
 
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.
 
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.
 
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.
 
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)
 
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

Last edited:
Status
Not open for further replies.
Back
Top