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

[Solved] Random Hero Trigger

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2013
Messages
1,105
Hello, I'm in the midst of making a hero arena map, and I want to have an All Random game mode, meaning that with this choice selected at the start of each round all the players in the game get a random hero from the "bank" of possible heroes, I'm not entirely sure how to do this, and I am looking for some general guidance.

Right now I am putting all the heroes in a unit group and then randomly assigning them (at least I think I am, but maybe not cause when I test it I always "random" hero A).

  • RandomSelected
    • Events
      • Player - Player 1 (Red) types a chat message containing -random as An exact match
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Random Was Selected...
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) controller) Equal to User
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • Player Group - Add (Picked player) to PlayerGroup
            • Else - Actions
      • Game - Display to (All players) the text: Got here
      • Unit Group - Add Hero A <gen> to RandomHero
      • Unit Group - Add Hero B <gen> to RandomHero
      • Unit Group - Add Hero C <gen> to RandomHero
      • Unit Group - Pick every unit in (Random 1 units from RandomHero) and do (Actions)
        • Loop - Actions
          • Unit - Change ownership of (Picked unit) to (Random player from PlayerGroup) and Change color
      • Trigger - Turn off (This trigger)
Also what would be the best way to make this trigger able to happen at the end of every round? (Preferably without player interaction)

Thanks for any help at all! Will definitely +rep!
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I think it would be better if you used a unit-type variable with array to store all those units in, because the unit group loop at the end of your trigger seems fishy.
You do not remove the randomed unit from the unit group, nor do you remove the randomed player from the player group.
Because of this, it's entirely possible that the same player and the same unit will be randomed 3 times, leaving the other players without a hero.


  • Actions
    • Set HeroTypeCount = 3
    • Set HeroType[1] = Hero A
    • Set HeroType[2] = Hero B
    • Set HeroType[3] = Hero C
    • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • -------- Chooses a random hero --------
        • Set RandInt = (Random integer number between 1 and HeroTypeCount)
        • Set TempLoc1 = ((Picked player) start location)
        • Unit - Create 1 HeroType[RandInt] for (Picked player) at TempLoc1 facing Default building facing degrees
        • Custom script: call RemoveLocation(udg_TempLoc1)
        • -------- Removes the hero type from the list (cannot be randomed again) --------
        • Set HeroType[RandInt] = HeroType[HeroTypeCount]
        • Set HeroTypeCount = (HeroTypeCount - 1)
Every time you want to generate a random hero for all players, call these actions.
 
Status
Not open for further replies.
Top