• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[Trigger] Problems with Randomizing Heroes

Status
Not open for further replies.
Level 19
Joined
Oct 17, 2012
Messages
856
The problem is that when I restart this trigger to give each player a new hero, some players may not get a hero.

  • Random Hero
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set RH_PlayerChooser[1] = Player 1 (Red)
      • Set RH_PlayerChooser[2] = Player 2 (Blue)
      • Set RH_PlayerChooser[3] = Player 3 (Teal)
      • Set RH_PlayerChooser[4] = Player 4 (Purple)
      • Set RH_PlayerChooser[5] = Player 5 (Yellow)
      • Set RH_PlayerChooser[6] = Player 6 (Orange)
      • Set RH_PlayerChooser[7] = Player 7 (Green)
      • Set RH_PlayerChooser[8] = Player 8 (Pink)
      • Set RH_PlayerChooser[9] = Player 9 (Gray)
      • Set RH_PlayerChooser[10] = Player 10 (Light Blue)
      • Set RH_PlayerChooser[11] = Player 11 (Dark Green)
      • Set RH_PlayerChooser[12] = Player 12 (Brown)
        • Do Multiple ActionsFor each (Integer RH_PlayerNumber) from 1 to 6, do (Actions)
          • Loop - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (RH_PlayerChooser[RH_PlayerNumber] slot status) Equal to (==) Is playing
              • Then - Actions
                • Player Group - Add RH_PlayerChooser[RH_PlayerNumber] to DS_Team
              • Else - Actions
        • Do Multiple ActionsFor each (Integer RH_PlayerNumber) from 7 to 12, do (Actions)
          • Loop - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (RH_PlayerChooser[RH_PlayerNumber] slot status) Equal to (==) Is playing
              • Then - Actions
                • Player Group - Add RH_PlayerChooser[RH_PlayerNumber] to DS_Team2
              • Else - Actions
      • Player Group - Make DS_Team treat DS_Team as an Ally with shared vision
      • Player Group - Make DS_Team2 treat DS_Team2 as an Ally with shared vision
      • -------- Heroes --------
      • Set RH_Hero[1] = Warden 0005 <gen>
      • Set RH_Hero[2] = Blood Mage 0012 <gen>
      • Set RH_Hero[3] = Demon Hunter 0002 <gen>
      • Set RH_Hero[4] = Sylvanas Windrunner 0001 <gen>
      • Set RH_Hero[5] = Archmage 0004 <gen>
      • Set RH_Hero[6] = Keeper of the Grove 0003 <gen>
      • Set RH_Hero[7] = Mountain King 0013 <gen>
      • Set RH_Hero[8] = Paladin 0006 <gen>
      • Set RH_Hero[9] = Blademaster 0014 <gen>
      • Set RH_Hero[10] = Shadow Hunter 0015 <gen>
      • Set RH_Hero[11] = Lich 0016 <gen>
      • Set RH_Hero[12] = Crypt Lord 0017 <gen>
      • Set RH_Hero[13] = Dreadlord 0024 <gen>
      • Set RH_Hero[14] = Chen Stormstout 0025 <gen>
      • Set RH_Hero[15] = Rexxar 0026 <gen>
      • Set RH_Int = 15
        • Do Multiple ActionsFor each (Integer RH_PlayerNumber) from 1 to 12, do (Actions)
          • Loop - Actions
            • Set RH_RandomInt = (Random integer number between 1 and RH_Int)
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DS_Hero[RH_PlayerNumber] Not equal to (!=) No unit
                • Then - Actions
                  • Unit - Change ownership of DS_Hero[RH_PlayerNumber] to Neutral Passive and Change color
                  • Set DS_Hero[RH_PlayerNumber] = No unit
                • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (RH_PlayerChooser[RH_PlayerNumber] slot status) Equal to (==) Is playing
                • Then - Actions
                  • Set DS_Hero[RH_PlayerNumber] = RH_Hero[RH_RandomInt]
                  • Unit - Change ownership of DS_Hero[RH_PlayerNumber] to RH_PlayerChooser[RH_PlayerNumber] and Change color
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (RH_PlayerChooser[RH_PlayerNumber] is in DS_Team) Equal to (==) True
                      • Then - Actions
                        • Set RH_StartingLocation = (Random point in StartingArea <gen>)
                        • Unit - Move DS_Hero[RH_PlayerNumber] instantly to RH_StartingLocation
                        • Camera - Pan camera for Player 1 (Red) to RH_StartingLocation over 0.00 seconds
                        • Custom script: call RemoveLocation(udg_RH_StartingLocation)
                      • Else - Actions
                        • Set RH_StartingLocation2 = (Random point in StartingArea Copy <gen>)
                        • Unit - Move DS_Hero[RH_PlayerNumber] instantly to RH_StartingLocation2
                        • Camera - Pan camera for Player 1 (Red) to RH_StartingLocation2 over 0.00 seconds
                        • Custom script: call RemoveLocation(udg_RH_StartingLocation2)
                • Else - Actions
            • Set RH_Hero[RH_RandomInt] = RH_Hero[RH_Int]
            • Set RH_Int = (RH_Int - 1)
 
Level 19
Joined
Oct 17, 2012
Messages
856
Well, I already found a solution, though it is similar to your suggestion. Thanks for the advice, anyway.

Here's what I found out:

When I change ownership of the previous hero to neutral passive, so that players do not get more than one hero, right before I give them a new hero, bugs, such as the overwriting of heroes, pop out.

However, when I change ownership of all previously used heroes at once in another trigger, bugs do not appear.

  • Random Hero
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set RH_Player[1] = Player 1 (Red)
      • Set RH_Player[2] = Player 2 (Blue)
      • Set RH_Player[3] = Player 3 (Teal)
      • Set RH_Player[4] = Player 4 (Purple)
      • Set RH_Player[5] = Player 5 (Yellow)
      • Set RH_Player[6] = Player 6 (Orange)
      • Set RH_Player[7] = Player 7 (Green)
      • Set RH_Player[8] = Player 8 (Pink)
      • Set RH_Player[9] = Player 9 (Gray)
      • Set RH_Player[10] = Player 10 (Light Blue)
      • Set RH_Player[11] = Player 11 (Dark Green)
      • Set RH_Player[12] = Player 12 (Brown)
      • -------- Heroes --------
      • Set RH_Hero[1] = Warden 0005 <gen>
      • Set RH_Hero[2] = Blood Mage 0012 <gen>
      • Set RH_Hero[3] = Demon Hunter 0002 <gen>
      • Set RH_Hero[4] = Sylvanas Windrunner 0001 <gen>
      • Set RH_Hero[5] = Archmage 0004 <gen>
      • Set RH_Hero[6] = Keeper of the Grove 0003 <gen>
      • Set RH_Hero[7] = Mountain King 0013 <gen>
      • Set RH_Hero[8] = Paladin 0006 <gen>
      • Set RH_Hero[9] = Blademaster 0014 <gen>
      • Set RH_Hero[10] = Shadow Hunter 0015 <gen>
      • Set RH_Hero[11] = Lich 0016 <gen>
      • Set RH_Hero[12] = Crypt Lord 0017 <gen>
      • Set RH_Hero[13] = Dreadlord 0024 <gen>
      • Set RH_Hero[14] = Chen Stormstout 0025 <gen>
      • Set RH_Hero[15] = Rexxar 0026 <gen>
      • Set RH_Int = 15
        • Do Multiple ActionsFor each (Integer RH_PlayerNumber) from 1 to 6, do (Actions)
          • Loop - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (RH_Player[RH_PlayerNumber] slot status) Equal to (==) Is playing
              • Then - Actions
                • Player Group - Add RH_Player[RH_PlayerNumber] to DS_Team
                • Set RH_RandomInt = (Random integer number between 1 and RH_Int)
                • Set DS_Hero[RH_PlayerNumber] = RH_Hero[RH_RandomInt]
                • Unit - Change ownership of DS_Hero[RH_PlayerNumber] to RH_Player[RH_PlayerNumber] and Change color
                • Set RH_StartingLocation = (Random point in StartingArea <gen>)
                • Unit - Move DS_Hero[RH_PlayerNumber] instantly to RH_StartingLocation
                • Camera - Pan camera for Player 1 (Red) to RH_StartingLocation over 0.00 seconds
                • Custom script: call RemoveLocation(udg_RH_StartingLocation)
                • Set RH_Hero[RH_RandomInt] = RH_Hero[RH_Int]
                • Set RH_Int = (RH_Int - 1)
              • Else - Actions
        • Do Multiple ActionsFor each (Integer RH_PlayerNumber) from 7 to 12, do (Actions)
          • Loop - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (RH_Player[RH_PlayerNumber] slot status) Equal to (==) Is playing
              • Then - Actions
                • Player Group - Add RH_Player[RH_PlayerNumber] to DS_Team2
                • Set RH_RandomInt = (Random integer number between 1 and RH_Int)
                • Set DS_Hero[RH_PlayerNumber] = RH_Hero[RH_RandomInt]
                • Unit - Change ownership of DS_Hero[RH_PlayerNumber] to RH_Player[RH_PlayerNumber] and Change color
                • Set RH_StartingLocation2 = (Random point in StartingArea Copy <gen>)
                • Unit - Move DS_Hero[RH_PlayerNumber] instantly to RH_StartingLocation2
                • Camera - Pan camera for Player 1 (Red) to RH_StartingLocation2 over 0.00 seconds
                • Custom script: call RemoveLocation(udg_RH_StartingLocation2)
                • Set RH_Hero[RH_RandomInt] = RH_Hero[RH_Int]
                • Set RH_Int = (RH_Int - 1)
              • Else - Actions
      • Player Group - Make DS_Team treat DS_Team as an Ally with shared vision
      • Player Group - Make DS_Team2 treat DS_Team2 as an Ally with shared vision
  • Restart
    • Events
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer RH_PlayerNumber) from 1 to 12, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (RH_Player[RH_PlayerNumber] slot status) Equal to (==) Is playing
            • Then - Actions
              • Set RH_StartingLocation = (Random point in Hero Pick Location <gen>)
              • Unit - Change ownership of DS_Hero[RH_PlayerNumber] to Neutral Passive and Change color
              • Unit - Move DS_Hero[RH_PlayerNumber] instantly to RH_StartingLocation
              • Set DS_Hero[RH_PlayerNumber] = No unit
              • Custom script: call RemoveLocation(udg_RH_StartingLocation)
            • Else - Actions
      • Wait 5.00 seconds
      • Trigger - Run Random Hero <gen> (ignoring conditions)
 
Status
Not open for further replies.
Top