• 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] -AR Help

Status
Not open for further replies.
Level 13
Joined
Jun 10, 2007
Messages
780
My problem is that this trigger works, but sometimes a hero won't be randomed for a player. I think it's because when a hero is randomed I delete the unit from the variable so it's not picked twice but it doesn't write a new unit to it. Then when a player gets the same integer randomed they get no hero. Can anybody help identify my problem?


  • Gamemode Arem
    • Events
      • Player - Player 2 (Blue) types a chat message containing -arem as An exact match
      • Player - Player 2 (Blue) types a chat message containing -emar as An exact match
      • Player - Player 2 (Blue) types a chat message containing -allrandomeasymode as An exact match
    • Conditions
      • Gamemode[1] Equal to 0
    • Actions
      • Trigger - Turn off Repick <gen>
      • Trigger - Turn off Repick Timeout <gen>
      • Unit - Pause Night Tavern 0002 <gen>
      • Unit - Pause Day Tavern 0003 <gen>
      • Set GamemodeString[1] = All Random Easy Mode
      • Set EM_ON = 1
      • Quest - Change the title of (Last created quest) to All Random Easy Mod...
      • Quest - Change the description of (Last created quest) to All random is a mod...
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Leaderboard - Create a leaderboard for (Player group((Player((Integer A))))) titled All Random 0/0
          • Leaderboard - Add Player 1 (Red) to (Last created leaderboard) with label |CFFFF0303The SENTI... and value 0
          • Leaderboard - Add Player 2 (Blue) to (Last created leaderboard) with label (Name of Player 2 (Blue)) and value 0
          • Leaderboard - Add Player 3 (Teal) to (Last created leaderboard) with label (Name of Player 3 (Teal)) and value 0
          • Leaderboard - Add Player 4 (Purple) to (Last created leaderboard) with label (Name of Player 4 (Purple)) and value 0
          • Leaderboard - Add Player 5 (Yellow) to (Last created leaderboard) with label (Name of Player 5 (Yellow)) and value 0
          • Leaderboard - Add Player 6 (Orange) to (Last created leaderboard) with label (Name of Player 6 (Orange)) and value 0
          • Leaderboard - Add Player 7 (Green) to (Last created leaderboard) with label |CFF20C000The SCOUR... and value 0
          • Leaderboard - Add Player 8 (Pink) to (Last created leaderboard) with label (Name of Player 8 (Pink)) and value 0
          • Leaderboard - Add Player 9 (Gray) to (Last created leaderboard) with label (Name of Player 9 (Gray)) and value 0
          • Leaderboard - Add Player 10 (Light Blue) to (Last created leaderboard) with label (Name of Player 10 (Light Blue)) and value 0
          • Leaderboard - Add Player 11 (Dark Green) to (Last created leaderboard) with label (Name of Player 11 (Dark Green)) and value 0
          • Leaderboard - Add Player 12 (Brown) to (Last created leaderboard) with label (Name of Player 12 (Brown)) and value 0
      • Leaderboard - Show (Last created leaderboard)
      • Trigger - Turn on Give gold <gen>
      • Set Gamemode[1] = 1
      • Cinematic - Clear the screen of text messages for (All players)
      • Game - Display to (All players) for 5.00 seconds the text: All Random Easy Mod...
      • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Hero - Make (Picked player) Heroes gain 150.00% experience from future kills)
      • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Player - Set (Picked player) handicap to 100.00%)
      • Player Group - Pick every player in (All players matching (((Matching player) slot status) Equal to Is playing)) and do (Player - Set (Picked player) handicap to 100.00%)
      • Player Group - Pick every player in (All players controlled by a User player) and do (Player - Set (Picked player) Current gold to 1600)
      • Wait 0.02 seconds
      • For each (Integer B) from 1 to 20, do (Unit Group - Add all units of (Units of type RandomHeroes[(Integer A)]) to AllRandomHeroGroup[1])
      • For each (Integer A) from 2 to 6, do (If (((Player((Integer A))) slot status) Equal to Is playing) then do (Set PlayerRandom[(Player number of (Player((Integer A))))] = True) else do (Do nothing))
      • For each (Integer A) from 8 to 12, do (If (((Player((Integer A))) slot status) Equal to Is playing) then do (Set PlayerRandom[(Player number of (Player((Integer A))))] = True) else do (Do nothing))
      • For each (Integer A) from 2 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
              • Set LeakLocation[7346] = (Center of Sentinal Base <gen>)
              • Set RandomHeroesINTEGER[(Player number of (Player((Integer A))))] = (Random integer number between 1 and 20)
              • Unit - Create 1 RandomHeroes[RandomHeroesINTEGER[(Player number of (Player((Integer A))))]] for (Player((Integer A))) at LeakLocation[7346] facing Default building facing (270.0) degrees
              • Set RandomHeroes[RandomHeroesINTEGER[(Player number of (Player((Integer A))))]] = No unit-type
              • Unit Group - Remove all units of (Units of type RandomHeroes[RandomHeroesINTEGER[(Player number of (Player((Integer A))))]]) from AllRandomHeroGroup[1]
              • Set RandomHeroes[RandomHeroesINTEGER[(Player number of (Player((Integer A))))]] = (Unit-type of (Random unit from AllRandomHeroGroup[1]))
              • Custom script: call RemoveLocation (udg_LeakLocation[7346])
              • Wait 0.02 seconds
            • Else - Actions
      • For each (Integer B) from 8 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
              • Set LeakLocation[7347] = (Center of Scourge Base <gen>)
              • Set RandomHeroesINTEGER[(Player number of (Player((Integer B))))] = (Random integer number between 1 and 20)
              • Unit - Create 1 RandomHeroes[RandomHeroesINTEGER[(Player number of (Player((Integer B))))]] for (Player((Integer B))) at LeakLocation[7347] facing Default building facing (270.0) degrees
              • Set RandomHeroes[RandomHeroesINTEGER[(Player number of (Player((Integer B))))]] = No unit-type
              • If (RandomHeroes[RandomHeroesINTEGER[(Player number of (Player((Integer B))))]] Equal to No unit-type) then do (Do nothing) else do (Do nothing)
              • Unit Group - Remove all units of (Units of type RandomHeroes[RandomHeroesINTEGER[(Player number of (Player((Integer B))))]]) from AllRandomHeroGroup[1]
              • Set RandomHeroes[RandomHeroesINTEGER[(Player number of (Player((Integer B))))]] = (Unit-type of (Random unit from AllRandomHeroGroup[1]))
              • Custom script: call RemoveLocation (udg_LeakLocation[7347])
              • Wait 0.02 seconds
            • Else - Actions


  • AREM HERO POOL
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set RandomHeroes[1] = Attribute Mage
      • Unit Group - Add (Random unit from (Units of type Attribute Mage)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[2] = Battleship
      • Unit Group - Add (Random unit from (Units of type Battleship)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[3] = Demon Witch
      • Unit Group - Add (Random unit from (Units of type Demon Witch)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[4] = Eastern Warlock
      • Unit Group - Add (Random unit from (Units of type Eastern Warlock)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[5] = Goblin
      • Unit Group - Add (Random unit from (Units of type Goblin)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[6] = Juggernaut
      • Unit Group - Add (Random unit from (Units of type Juggernaut)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[7] = Lightning Incarnate
      • Unit Group - Add (Random unit from (Units of type Lightning Incarnate)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[8] = Lightning Revenant
      • Unit Group - Add (Random unit from (Units of type Lightning Revenant)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[9] = Magnataur
      • Unit Group - Add (Random unit from (Units of type Magnataur)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[10] = Mutant
      • Unit Group - Add (Random unit from (Units of type Mutant)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[11] = Nerubian Arachnid
      • Unit Group - Add (Random unit from (Units of type Nerubian Arachnid)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[12] = Northern Warlock
      • Unit Group - Add (Random unit from (Units of type Northern Warlock)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[13] = Obsidian Destroyer
      • Unit Group - Add (Random unit from (Units of type Obsidian Destroyer)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[14] = Ogre Mage
      • Unit Group - Add (Random unit from (Units of type Ogre Mage)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[15] = Royal Guard
      • Unit Group - Add (Random unit from (Units of type Royal Guard)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[16] = Siren of the Depths
      • Unit Group - Add (Random unit from (Units of type Siren of the Depths)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[17] = Sniper
      • Unit Group - Add (Random unit from (Units of type Sniper)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[18] = Stone Giant
      • Unit Group - Add (Random unit from (Units of type Stone Giant)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[19] = Weaponcrafter
      • Unit Group - Add (Random unit from (Units of type Weaponcrafter)) to AllRandomHeroGroup[1]
      • Set RandomHeroes[20] = Witch Doctor
      • Unit Group - Add (Random unit from (Units of type Witch Doctor)) to AllRandomHeroGroup[1]
      • Wait 0.01 seconds
      • For each (Integer A) from 1 to 20, do (Unit Group - Add all units of (Units of type RandomHeroes[(Integer A)]) to AllRandomHeroGroup[1])
      • For each (Integer A) from 1 to 20, do (Unit Group - Add (Random unit from (Units of type RandomHeroes[(Integer A)])) to AllRandomHeroGroup[1])
      • For each (Integer A) from 8 to 12, do (Actions)
        • Loop - Actions
          • Set RandomHeroesINTEGER[(Player number of (Player((Integer A))))] = (Random integer number between 1 and 20)
      • For each (Integer A) from 2 to 6, do (Actions)
        • Loop - Actions
          • Set RandomHeroesINTEGER[(Player number of (Player((Integer A))))] = (Random integer number between 1 and 20)
 
Level 13
Joined
Jun 10, 2007
Messages
780
Still doesn't work.


  • Replace Hero AREM
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 2 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RandomHeroes[(Integer A)] Equal to No unit-type
            • Then - Actions
              • Set RandomHeroes[(Integer A)] = (Unit-type of (Random unit from AllRandomHeroGroup[1]))
            • Else - Actions
 
Level 13
Joined
May 11, 2008
Messages
1,198
hmm... why not just make an array of integers just like you would make an array for units for random and set each part of the array to be a random integer, for the random unit, 1-20, and then do something like the following...


this trigger could probably be in map initialization since it's just setting variables that don't need to be changed once you got them worked out, which the trigger should do for itself.
anyway maybe it doesn't need to be map initialization event, i just figure it's easy to do that since putting in ten numbers isn't a big deal and yet i'm not sure how long that would take so i don't know what you would need for a wait trigger considering that my method asks you to run the trigger over again if any of the randomed numbers are the same.

so you got ARRN for all random random number or change the variable name to whatever you like. i'm assuming you have 20 heroes to pick from.

now when you do the all random function the hero choices will be made even before the player types -ar.

you should already have each hero in an unit type array. then you just take each player who is a user one at a time give him the number for his slot.
ARRH for all random random hero.
so blue, give him ARRH[get integer ARRN[0]]
next guy is ARRH[get integer ARRN[1]]
and so on up until ARRH[get integer ARRN[9]] for brown.

actions
Set ARRN[0] = random number between 1-20
Set ARRN[1] = random number between 1-20
Set ARRN[2] = random number between 1-20
Set ARRN[3] = random number between 1-20
Set ARRN[4] = random number between 1-20
Set ARRN[5] = random number between 1-20
Set ARRN[6] = random number between 1-20
Set ARRN[7] = random number between 1-20
Set ARRN[8] = random number between 1-20
Set ARRN[9] = random number between 1-20
if ANY conditions are true
ARRN[1] = ARRN[0]
ARRN[1] = ARRN[2]
ARRN[2] = ARRN[0]
ARRN[0] = ARRN[3]
ARRN[1] = ARRN[3]
ARRN[2] = ARRN[3]
ARRN[2] = ARRN[4]
ARRN[1] = ARRN[4]
ARRN[4] = ARRN[0]
ARRN[4] = ARRN[3]
ARRN[2] = ARRN[5]
ARRN[3] = ARRN[5]
ARRN[4] = ARRN[5]
ARRN[1] = ARRN[5]
ARRN[5] = ARRN[0]
ARRN[2] = ARRN[6]
ARRN[5] = ARRN[6]
ARRN[4] = ARRN[6]
ARRN[3] = ARRN[6]
ARRN[1] = ARRN[6]
ARRN[6] = ARRN[0]
ARRN[2] = ARRN[7]
ARRN[6] = ARRN[7]
ARRN[5] = ARRN[7]
ARRN[4] = ARRN[7]
ARRN[3] = ARRN[7]
ARRN[1] = ARRN[7]
ARRN[7] = ARRN[0]
ARRN[2] = ARRN[8]
ARRN[7] = ARRN[8]
ARRN[6] = ARRN[8]
ARRN[5] = ARRN[8]
ARRN[4] = ARRN[8]
ARRN[3] = ARRN[8]
ARRN[1] = ARRN[8]
ARRN[8] = ARRN[0]
ARRN[2] = ARRN[9]
ARRN[8] = ARRN[9]
ARRN[7] = ARRN[9]
ARRN[6] = ARRN[9]
ARRN[5] = ARRN[9]
ARRN[4] = ARRN[9]
ARRN[3] = ARRN[9]
ARRN[1] = ARRN[9]
ARRN[9] = ARRN[0]
then - actions
trigger - run this trigger.
else - actions
trigger - destroy this trigger.

some of that is possibly not exact wording since i just typed this stuff out.
 
Last edited:
Level 5
Joined
May 21, 2006
Messages
174
I believe this would be less of a hassle:
  • A Trigger
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 9, do (Actions)
        • Loop - Actions
          • Set ARRN[(Integer A)] = (Random integer number between 1 and 20)
      • For each (Integer A) from 0 to 9, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 0 to 9, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ARRN[(Integer A)] Equal to ARRN[(Integer B)]
                • Then - Actions
                  • Trigger - Run No trigger (checking conditions)
                • Else - Actions
Not entierly sure how good it is to run loops within loops though.
 
Status
Not open for further replies.
Top