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

[Trigger] unit having multiple movement options in TD

Status
Not open for further replies.
Level 2
Joined
May 19, 2008
Messages
8
ok so i made a trigger that basically goes:
Events: Unit enters region
Conditions: (Owner of (triggering unit)) equal to player 12 (brown)
Actions: Unit- order (entering unit) to move to:
Region 2​
Region 3​
Region 4​
but instead of giving the unit a "choice", its just sending the unit to region 4. is there any way to fix this so that the next region the unit goes to is randomly chosen from those 3?
 
Level 2
Joined
Jun 24, 2008
Messages
15
This should work for you, the condition is an integer comparison and the variable is an Integer type.
  • Untitled Trigger 001
    • Events
      • Unit - A unit enters Region 001 <gen>
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 12 (Brown)
    • Actions
      • Set IntegerVar = (Random integer number between 2 and 4)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IntegerVar Equal to 2
        • Then - Actions
          • Unit - Order (Entering unit) to Move To (Center of Region 002 <gen>)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • IntegerVar Equal to 3
            • Then - Actions
              • Unit - Order (Entering unit) to Move To (Center of Region 003 <gen>)
            • Else - Actions
              • Unit - Order (Entering unit) to Move To (Center of Region 004 <gen>)
You can set your integer variable to a random number from the functions drop down menu under math - random number.
If you don't understand that trigger, I put it in one little one using two if / then / else triggers, since it really doesn't have multiple functions.

  • Untitled Trigger 001
    • Events
      • Unit - A unit enters Region 001 <gen>
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 12 (Brown)
    • Actions
      • Set IntegerVar = (Random integer number between 2 and 4)
      • If (IntegerVar Equal to 2) then do (Unit - Order (Entering unit) to Move To (Center of Region 002 <gen>)) else do (If (IntegerVar Equal to 3) then do (Unit - Order (Entering unit) to Move To (Center of Region 003 <gen>)) else do (Unit - Order (Entering unit) to Move To (Center of Region 004 <gen>)))
 
Level 2
Joined
Jun 24, 2008
Messages
15
If you wanted you could leave the else blank and just use another if/then/else, since some people(me a year ago) don't understand the concept of else.

And, when there's two choices you'd only need one.
Because it would be if int = 1 then order to move to region 1, else move to region 2.
 
Status
Not open for further replies.
Top