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

Random Bug

Status
Not open for further replies.
Level 3
Joined
May 30, 2012
Messages
29
When a player pick a hero. and other decide go random. randomed hero is same of hero picked.


For Example, i pick Mountain King, my ally decide go random, he wait 60 seconds, because my system is automatic random. The randomed hero is Mountain King. so 2 Mk in game.


Told me where is the bug.

  • Events
    • Map initialization
  • Actions
    • Set HeroType[1] = Paladin
    • Set HeroType[2] = Archmage
    • Set HeroType[3] = Mountain King
    • Set HeroType[4] = Blood Mage
    • Set HeroType[5] = Blademaster
    • Set HeroType[6] = Far Seer
    • Set HeroType[7] = Tauren Chieftain
    • Set HeroType[8] = Shadow Hunter
    • Set HeroType[9] = Death Knight
    • Set HeroType[10] = Lich
    • Set HeroType[11] = Dreadlord
    • Set HeroType[12] = Crypt Lord
    • Set HeroType[13] = Keeper of the Grove
    • Set HeroType[14] = Priestess of the Moon
    • Set HeroType[15] = Demon Hunter
    • Set HeroType[16] = Warden
    • Set HeroType[17] = Alchemist
    • Set HeroType[18] = Naga Sea Witch
    • Set HeroType[19] = Tinker
    • Set HeroType[20] = Dark Ranger
    • Set HeroType[21] = Firelord
    • Set HeroType[22] = Pandaren Brewmaster
    • Set HeroType[23] = Pit Lord
    • Set HeroType[24] = Beastmaster
    • Set RandomCount = 24
    • Set TotalHero = 24
    • For each (Integer A) from 1 to 24, do (Actions)
      • Loop - Actions
        • Set RandomData[(Integer A)] = (Integer A)
    • For each (Integer B) from 1 to 24, do (Actions)
      • Loop - Actions
        • Set RandomData[(Integer B)] = (Integer B)
    • Trigger - Turn off (This trigger)
  • Events
    • Time - Elapsed game time is 61.00 seconds
  • Actions
    • For each (Integer A) from 1 to 5, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Player((Integer A))) slot status) Equal to Is playing
            • (Number of units in (Units owned by (Player((Integer A))) matching (((Matching unit) is A Hero) Equal to True))) Equal to 0
          • Then - Actions
            • Set RandomHero = (Random integer number between 1 and RandomCount)
            • Unit - Create 1 HeroType[RandomData[RandomHero]] for (Player((Integer A))) at (Center of StartPointL <gen>) facing Default building facing degrees
            • Camera - Pan camera for (Owner of (Last created unit)) to (Center of StartPointL <gen>) over 1.00 seconds
            • Set HeroType[RandomHero] = HeroType[RandomCount]
            • Set RandomCount = (RandomCount - 1)
            • Wait 0.30 seconds
          • Else - Actions
    • Wait 2.00 seconds
    • For each (Integer B) from 7 to 11, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Player((Integer B))) slot status) Equal to Is playing
            • (Number of units in (Units owned by (Player((Integer B))) matching (((Matching unit) is A Hero) Equal to True))) Equal to 0
          • Then - Actions
            • Set RandomHero = (Random integer number between 1 and RandomCount)
            • Unit - Create 1 HeroType[RandomData[RandomHero]] for (Player((Integer B))) at (Center of StartPointR <gen>) facing Default building facing degrees
            • Camera - Pan camera for (Owner of (Last created unit)) to (Center of StartPointR <gen>) over 1.00 seconds
            • Set HeroType[RandomHero] = HeroType[RandomCount]
            • Set RandomCount = (RandomCount - 1)
            • Wait 0.30 seconds
          • Else - Actions
    • Countdown Timer - Destroy (Last created timer window)
    • Trigger - Turn off (This trigger)
  • Events
    • Unit - A unit Sells a unit
  • Conditions
    • And - All (Conditions) are true
      • Conditions
        • ((Sold unit) is A Hero) Equal to True
        • Or - Any (Conditions) are true
          • Conditions
            • (Selling unit) Equal to TavernN1 0000 <gen>
            • (Selling unit) Equal to TavernN2 0001 <gen>
            • (Selling unit) Equal to TavernN3 0057 <gen>
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • HeroChosenByPlayer[(Player number of (Owner of (Sold unit)))] Equal to True
      • Then - Actions
        • Unit - Remove (Sold unit) from the game
      • Else - Actions
        • Set HeroChosenByPlayer[(Player number of (Owner of (Sold unit)))] = True
        • Unit - Move (Sold unit) instantly to (Center of StartPointL <gen>)
        • Game - Display to (All players) the text: (((Name of (Owner of (Buying unit))) + has chosen ) + (Name of (Sold unit)))
        • Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
          • Loop - Actions
            • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Picked player)
        • For each (Integer A) from 1 to 24, do (Actions)
          • Loop - Actions
            • Player - Make HeroType[(Integer A)] Unavailable for training/construction by (Owner of (Buying unit))
        • Camera - Pan camera for (Owner of (Sold unit)) to (Center of StartPointL <gen>) over 1.00 seconds
        • Selection - Clear selection for (Owner of (Sold unit))
        • Selection - Add (Sold unit) to selection for (Owner of (Sold unit))
 
Last edited by a moderator:
Level 12
Joined
Oct 16, 2010
Messages
680
On Unit sell event you forgot to remove the sold hero from the HeroType array
which your random trigger uses.

that's how randoms can be heroes already chosen
it's not enough to make the hero unavailable to be trained.

check which hero had been chosen and overwrite it with last one and
decrease randomcount as well ( like you did in random trigger)
 
Level 3
Joined
May 30, 2012
Messages
29
On Unit sell event you forgot to remove the sold hero from the HeroType array
which your random trigger uses.

that's how randoms can be heroes already chosen
it's not enough to make the hero unavailable to be trained.

check which hero had been chosen and overwrite it with last one and
decrease randomcount as well ( like you did in random trigger)


Can you upload a picture? i cant understand.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
  • Events
    • Map initialization
  • Actions
    • Set HeroType[1] = Paladin
    • Set HeroType[2] = Archmage
    • Set HeroType[3] = Mountain King
    • Set HeroType[4] = Blood Mage
    • Set HeroType[5] = Blademaster
    • Set HeroType[6] = Far Seer
    • Set HeroType[7] = Tauren Chieftain
    • Set HeroType[8] = Shadow Hunter
    • Set HeroType[9] = Death Knight
    • Set HeroType[10] = Lich
    • Set HeroType[11] = Dreadlord
    • Set HeroType[12] = Crypt Lord
    • Set HeroType[13] = Keeper of the Grove
    • Set HeroType[14] = Priestess of the Moon
    • Set HeroType[15] = Demon Hunter
    • Set HeroType[16] = Warden
    • Set HeroType[17] = Alchemist
    • Set HeroType[18] = Naga Sea Witch
    • Set HeroType[19] = Tinker
    • Set HeroType[20] = Dark Ranger
    • Set HeroType[21] = Firelord
    • Set HeroType[22] = Pandaren Brewmaster
    • Set HeroType[23] = Pit Lord
    • Set HeroType[24] = Beastmaster
    • Set RandomCount = 24
    • Set TotalHero = 24
    • For each (Integer A) from 1 to 24, do (Actions)
      • Loop - Actions
        • Set RandomData[(Integer A)] = (Integer A)
    • For each (Integer B) from 1 to 24, do (Actions)
      • Loop - Actions
        • Set RandomData[(Integer B)] = (Integer B)
    • Trigger - Turn off (This trigger)
  • Events
    • Time - Elapsed game time is 61.00 seconds
  • Actions
    • For each (Integer A) from 1 to 5, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Player((Integer A))) slot status) Equal to Is playing
            • (Number of units in (Units owned by (Player((Integer A))) matching (((Matching unit) is A Hero) Equal to True))) Equal to 0
          • Then - Actions
            • Set RandomHero = (Random integer number between 1 and RandomCount)
            • Unit - Create 1 HeroType[RandomData[RandomHero]] for (Player((Integer A))) at (Center of StartPointL <gen>) facing Default building facing degrees
            • Camera - Pan camera for (Owner of (Last created unit)) to (Center of StartPointL <gen>) over 1.00 seconds
            • Set HeroType[RandomHero] = HeroType[RandomCount]
            • Set RandomCount = (RandomCount - 1)
            • Wait 0.30 seconds
          • Else - Actions
    • Wait 2.00 seconds
    • For each (Integer B) from 7 to 11, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Player((Integer B))) slot status) Equal to Is playing
            • (Number of units in (Units owned by (Player((Integer B))) matching (((Matching unit) is A Hero) Equal to True))) Equal to 0
          • Then - Actions
            • Set RandomHero = (Random integer number between 1 and RandomCount)
            • Unit - Create 1 HeroType[RandomData[RandomHero]] for (Player((Integer B))) at (Center of StartPointR <gen>) facing Default building facing degrees
            • Camera - Pan camera for (Owner of (Last created unit)) to (Center of StartPointR <gen>) over 1.00 seconds
            • Set HeroType[RandomHero] = HeroType[RandomCount]
            • Set RandomCount = (RandomCount - 1)
            • Wait 0.30 seconds
          • Else - Actions
    • Countdown Timer - Destroy (Last created timer window)
    • Trigger - Turn off (This trigger)
  • Events
    • Unit - A unit Sells a unit
  • Conditions
    • And - All (Conditions) are true
      • Conditions
        • ((Sold unit) is A Hero) Equal to True
        • Or - Any (Conditions) are true
          • Conditions
            • (Selling unit) Equal to TavernN1 0000 <gen>
            • (Selling unit) Equal to TavernN2 0001 <gen>
            • (Selling unit) Equal to TavernN3 0057 <gen>
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • HeroChosenByPlayer[(Player number of (Owner of (Sold unit)))] Equal to True
      • Then - Actions
        • Unit - Remove (Sold unit) from the game
      • Else - Actions
        • Set HeroChosenByPlayer[(Player number of (Owner of (Sold unit)))] = True
        • Unit - Move (Sold unit) instantly to (Center of StartPointL <gen>)
        • Game - Display to (All players) the text: (((Name of (Owner of (Buying unit))) + has chosen ) + (Name of (Sold unit)))
        • Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
          • Loop - Actions
            • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Picked player)
        • For each (Integer A) from 1 to 24, do (Actions)
          • Loop - Actions
            • Player - Make HeroType[(Integer A)] Unavailable for training/construction by (Owner of (Buying unit))
        • Camera - Pan camera for (Owner of (Sold unit)) to (Center of StartPointL <gen>) over 1.00 seconds
        • Selection - Clear selection for (Owner of (Sold unit))
        • Selection - Add (Sold unit) to selection for (Owner of (Sold unit))



Add this after
  • Set HeroChosenByPlayer[(Player number of (Owner of (Sold unit)))] = True
>

  • Set HeroType[RandomCount] = HeroType[(IntegerA)]
  • Set RandomCount = RandomCount - 1
Oh by the way, you can just completely remove RandomData
 
Level 3
Joined
May 30, 2012
Messages
29
men, now randon is 2 same heros, i pick mk, and the random always is 2 same heros, 2 Paladins, 2 lich, 2, dreadlord, 2 blademaster. why it is so hard?
 
Level 3
Joined
May 30, 2012
Messages
29
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • HeroChosenByPlayer[(Player number of (Owner of (Sold unit)))] Equal to True
      • Then - Actions
        • Unit - Remove (Sold unit) from the game
      • Else - Actions
        • Set HeroChosenByPlayer[(Player number of (Owner of (Sold unit)))] = True
        • Set HeroType[RandomCount] = HeroType[(Integer A)]
        • Unit - Move (Sold unit) instantly to (Center of StartPointL <gen>)
        • Game - Display to (All players) the text: (((Name of (Owner of (Buying unit))) + has chosen ) + (Name of (Sold unit)))
        • Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
          • Loop - Actions
            • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Picked player)
        • For each (Integer A) from 1 to 23, do (Actions)
          • Loop - Actions
            • Player - Make HeroType[(Integer A)] Unavailable for training/construction by (Owner of (Buying unit))
        • Camera - Pan camera for (Owner of (Sold unit)) to (Center of StartPointL <gen>) over 1.00 seconds
        • Selection - Clear selection for (Owner of (Sold unit))
        • Selection - Add (Sold unit) to selection for (Owner of (Sold unit))
Where is the problem?
 
Last edited by a moderator:
Okay.
Apparently, you're using the sample from that WorldEditorTutorials site, and you don't understand how your code is doing the randomization via a stack.

Here is the fixed code:

  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • HeroChosenByPlayer[(Player number of (Owner of (Sold unit)))] Equal to True
      • Then - Actions
        • Unit - Remove (Sold unit) from the game
      • Else - Actions
        • For each (Integer A) from 1 to RandomCount, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Unit-type of (Sold unit)) Equal to HeroType[(Integer A)]
              • Then - Actions
                • Set HeroType[(Integer A)] = HeroType[RandomCount]
                • Set RandomCount = (RandomCount - 1)
                • Custom script: exitwhen true
              • Else - Actions
        • Set HeroChosenByPlayer[(Player number of (Owner of (Sold unit)))] = True
        • Unit - Move (Sold unit) instantly to (Center of StartPointL <gen>)
        • Game - Display to (All players) the text: (((Name of (Owner of (Buying unit))) + has chosen ) + (Name of (Sold unit)))
        • Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
          • Loop - Actions
            • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Picked player)
        • For each (Integer A) from 1 to 23, do (Actions)
          • Loop - Actions
            • Player - Make HeroType[(Integer A)] Unavailable for training/construction by (Owner of (Buying unit))
            • Camera - Pan camera for (Owner of (Sold unit)) to (Center of StartPointL <gen>) over 1.00 seconds
            • Selection - Clear selection for (Owner of (Sold unit))
            • Selection - Add (Sold unit) to selection for (Owner of (Sold unit))
I haven't tested a thing, but this should work.
 
Status
Not open for further replies.
Top