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

Create a random unit of :.....?

Status
Not open for further replies.
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • Actions
    • Set i1 = (Random integer number between 1 and 3)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • i1 Equal to 1
      • Then - Actions
        • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • i1 Equal to 2
          • Then - Actions
            • Unit - Create 1 Knight for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
          • Else - Actions
            • Unit - Create 1 Rifleman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
For the second issue, add the units into a unit group and the pic random units from the group.

Remember to clear leaks: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
To improve Maker's IFs efficiency, do it like this:

  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TypesOfUnit[1] = Footman
      • Set TypesOfUnit[2] = Knight
      • Set TypesOfUnit[3] = Rifleman
  • Create
    • Events
      • Your Event
    • Conditions
      • Your Condition(s)
    • Actions
      • Set RandomInteger = (Random integer number between 1 and 3)
      • Unit - Create 1 TypesOfUnit[RandomInteger] for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
In the setup trigger, you can set as many units as you want without having to do many IFs in the 2nd trigger
 
Ok thanks.Now what if at the end of the trigger i want to reset the variables?Is that possible(lol i know it is but how?)

  • Actions
    • Set i1 = (Random integer number between 1 and 3)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • i1 Equal to 1
      • Then - Actions
        • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • i1 Equal to 2
          • Then - Actions
            • Unit - Create 1 Knight for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
          • Else - Actions
            • Unit - Create 1 Rifleman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
For the second issue, add the units into a unit group and the pic random units from the group.

Remember to clear leaks: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/

Ok thanks a lot ^^!!Now what if at the end of the trigger i want to reset that variable(clear it) ???How can i do that>??
 
Status
Not open for further replies.
Top