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

Selecting a random unit trigger in GUI

Status
Not open for further replies.
Level 7
Joined
Aug 30, 2008
Messages
347
Im having problems with a trgger
im trying to make a trigger that every 3 minutes of the game a random player controlled hero is either given an award or punishment.

like selects a random unit, that unit has a 35% chance of being given 200 gold and also has a 35% to kill the unit and a 46% chance to do nothing but slow the unit by 50% for 3 seconds.

I am mainly having a problem during the jass part of the trigger the call remove part that removes the variable unit from the variable itself.

Also a trigger that teleports all player controlled units.
for example there are 2 teams, each team has their respective base or regions with team 1 having region A and 2 having region B.
Team 1 goes to region 1 and of course 2 goes to B.

After the last person is defeated they will all be teleported to their previous positions.

Then the timer begins a new.
 
Level 4
Joined
Mar 24, 2009
Messages
67
I think you can do the random by setting the units in a unit group first then do something like this.

  • Player - Add 200 to (Owner of (Random unit from (Last created unit group))) Current gold
Maybe, I'm not sure. I hope this helps.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
I am mainly having a problem during the jass part of the trigger the call remove part that removes the variable unit from the variable itself.

I have had the same problem but then with timers.... When I destroyed a timer after it was finished... I where not allowed to start the timer again because it is destroyed... maybe that has something to do with it? removing a memory leak in some conditions make your variable unusable?

EDIT: the teleport stuff is quite basic.... and easy to do...

you can make it something like this:

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Add Player 1 (Red) to team[1]
      • Player Group - Add Player 2 (Blue) to team[1]
      • Player Group - Add Player 3 (Teal) to team[1]
      • Player Group - Add Player 4 (Purple) to team[1]
      • Player Group - Add Player 5 (Yellow) to team[1]
      • Player Group - Add Player 6 (Orange) to team[2]
      • Player Group - Add Player 7 (Green) to team[2]
      • Player Group - Add Player 8 (Pink) to team[2]
      • Player Group - Add Player 9 (Gray) to team[2]
      • Player Group - Add Player 10 (Light Blue) to team[2]

  • some teleporting stuff 1
    • Events
      • Any event here
    • Conditions
      • Any condition here
    • Actions
      • Set Previous_spot_of_player[1] = (Position of (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is A Hero) Equal to True))))
      • Set Previous_spot_of_player[2] = (Position of (Random unit from (Units owned by Player 2 (Blue) matching (((Matching unit) is A Hero) Equal to True))))
      • Set Previous_spot_of_player[3] = (Position of (Random unit from (Units owned by Player 3 (Teal) matching (((Matching unit) is A Hero) Equal to True))))
      • Set Previous_spot_of_player[4] = (Position of (Random unit from (Units owned by Player 4 (Purple) matching (((Matching unit) is A Hero) Equal to True))))
      • Set Previous_spot_of_player[5] = (Position of (Random unit from (Units owned by Player 5 (Yellow) matching (((Matching unit) is A Hero) Equal to True))))
      • Set Previous_spot_of_player[6] = (Position of (Random unit from (Units owned by Player 6 (Orange) matching (((Matching unit) is A Hero) Equal to True))))
      • Set Previous_spot_of_player[7] = (Position of (Random unit from (Units owned by Player 7 (Green) matching (((Matching unit) is A Hero) Equal to True))))
      • Set Previous_spot_of_player[8] = (Position of (Random unit from (Units owned by Player 8 (Pink) matching (((Matching unit) is A Hero) Equal to True))))
      • Set Previous_spot_of_player[9] = (Position of (Random unit from (Units owned by Player 9 (Gray) matching (((Matching unit) is A Hero) Equal to True))))
      • Set Previous_spot_of_player[10] = (Position of (Random unit from (Units owned by Player 10 (Light Blue) matching (((Matching unit) is A Hero) Equal to True))))
      • Player Group - Pick every player in team[1] and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
            • Loop - Actions
              • Unit - Move (Picked unit) instantly to (Random point in A <gen>)
      • Player Group - Pick every player in team[2] and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units owned by (Picked player)) and do (Actions)
            • Loop - Actions
              • Unit - Move (Picked unit) instantly to (Random point in B <gen>)
  • some teleporting stuff 2
    • Events
      • Any event here
    • Conditions
      • Any condition here
    • Actions
      • Unit - Move (Random unit from (Units owned by Player 1 (Red) matching (((Matching unit) is A Hero) Equal to True))) instantly to Previous_spot_of_player[1]
      • Unit - Move (Random unit from (Units owned by Player 2 (Blue) matching (((Matching unit) is A Hero) Equal to True))) instantly to Previous_spot_of_player[2]
      • Unit - Move (Random unit from (Units owned by Player 3 (Teal) matching (((Matching unit) is A Hero) Equal to True))) instantly to Previous_spot_of_player[3]
      • Unit - Move (Random unit from (Units owned by Player 4 (Purple) matching (((Matching unit) is A Hero) Equal to True))) instantly to Previous_spot_of_player[4]
      • Unit - Move (Random unit from (Units owned by Player 5 (Yellow) matching (((Matching unit) is A Hero) Equal to True))) instantly to Previous_spot_of_player[5]
      • Unit - Move (Random unit from (Units owned by Player 6 (Orange) matching (((Matching unit) is A Hero) Equal to True))) instantly to Previous_spot_of_player[6]
      • Unit - Move (Random unit from (Units owned by Player 7 (Green) matching (((Matching unit) is A Hero) Equal to True))) instantly to Previous_spot_of_player[7]
      • Unit - Move (Random unit from (Units owned by Player 8 (Pink) matching (((Matching unit) is A Hero) Equal to True))) instantly to Previous_spot_of_player[8]
      • Unit - Move (Random unit from (Units owned by Player 9 (Gray) matching (((Matching unit) is A Hero) Equal to True))) instantly to Previous_spot_of_player[9]
      • Unit - Move (Random unit from (Units owned by Player 10 (Light Blue) matching (((Matching unit) is A Hero) Equal to True))) instantly to Previous_spot_of_player[10]
ANOTHER EDIT:

you can also make a random number system quite easy like this:

  • some random stuff 1
    • Events
      • Time - Every 180.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Random 1 units from (Units owned by (Random player from (All players)) matching (((Matching unit) is A Hero) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set random_number = (Random integer number between 1 and 118)
          • Set gold_chance = 35
          • Set kill_chance[1] = 36
          • Set kill_chance[2] = 71
          • Set slow_chance[1] = 72
          • Set slow_chance[2] = 118
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • random_number Greater than or equal to gold_chance
            • Then - Actions
              • add ... amount of gold to the owner of picked unit, or anything else....
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • random_number Greater than or equal to kill_chance[1]
                      • random_number Less than or equal to kill_chance[2]
                • Then - Actions
                  • kill the picked unit or whatever you want...
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • random_number Greater than or equal to slow_chance[1]
                          • random_number Less than or equal to slow_chance[2]
                    • Then - Actions
                      • add some kind of slow aura whatever you want :)
                    • Else - Actions
so now the odds are: 35% to get some gold, 35% chance to get killed and 46% chance to get slow...

now I also made it so that you can not have 2 of the same things at once... for example: your unit get killed and you get 200 gold...
or your unit is slowed and you get 200 gold... etc.. I thought that this was the way you wanted it to be :)
 
Last edited:
Level 7
Joined
Aug 30, 2008
Messages
347
Ok thanks, im gonna be trying this as soon as my WE is up. but i have a question, how do i do this on a continuous timer?
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
you can use timer expires event so that you can make a timer (not a one-shot timer) or you can let it stay like this... it is already somekind of continuous timer...

b.t.w. you where talking about: some random stuff 1 right?
 
Status
Not open for further replies.
Top