• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Trigger] All Random problems

Status
Not open for further replies.
Level 9
Joined
Aug 28, 2005
Messages
271
I have all random mode in my aos but it doesn't work. Here are my triggers:

  • setting hero types
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Alliance Heroes --------
      • Set hero_types[1] = Knight
      • Set hero_types[2] = Grey Wolf
      • Set hero_types[3] = Inquisitor
      • Set hero_types[4] = Water Mage
      • Set hero_types[5] = Forest Druid
      • -------- Horde Heroes --------
      • Set hero_types[6] = Forest Witch
      • Set hero_types[7] = Herbalist
      • Set hero_types[8] = Restless Ghost
      • Set hero_types[9] = Fire Imp
      • Set hero_types[10] = Macroscopic Amoeba
      • -------- Other Sets --------
and:

  • all random
    • Events
      • Dialog - A dialog button is clicked for Game_Mode
    • Conditions
      • (Clicked dialog button) Equal to all_random
    • Actions
      • Game - Display to (All players controlled by a User player) for 15.00 seconds the text: Game Mode set to |c...
      • Set hero_choosers_mode_clear = (Units of type Hero chooser)
      • Unit Group - Pick every unit in hero_choosers_mode_clear and do (Unit - Remove (Picked unit) from the game)
      • Custom script: call DestroyGroup(udg_hero_choosers_mode_clear)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) controller) Equal to User
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • Set current_hero_number = (Random integer number between 1 and last_hero_number)
              • If (((Player((Integer A))) is an ally of Player 1 (Red)) Equal to True) then do (Unit - Create 1 hero_types[current_hero_number] for (Player((Integer A))) at Good_revive facing Default building facing degrees) else do (Unit - Create 1 hero_types[current_hero_number] for (Player((Integer A))) at Bad_revive facing Default building facing degrees)
              • Selection - Select (Last created unit) for (Owner of (Last created unit))
              • Game - Display to (All players controlled by a User player) for 10.00 seconds the text: ((Name of (Player((Integer A)))) + ( has randomed + ( + (Name of (Last created unit)))))
              • Set hero_types[current_hero_number] = hero_types[last_hero_number]
              • Set last_hero_number = (last_hero_number - 1)
            • Else - Actions
It doesn't create the hero. I also tried SD_Ryoko's tutorial on the-helper but it also didn't worked (I have no idea why it was copy/pasted)
 
Level 4
Joined
Jun 8, 2004
Messages
66
Does last_hero_number have an initial value?

If it's less than 1 I don't think it'll work, and if it's 1 then you'll just have one player get the knight and nobody else will get anything - if i'm properly reading it anyways.

Are you trying to make it so that no two players have the same hero?
 
Level 9
Joined
Aug 28, 2005
Messages
271
No , you are not reading properly (or maybe I'm not writing properly)

Yes, I'm making it impossible for two players to have the same hero.
last_hero_number have initial value 10. The trigger works(not quite) that way:
The first trigger adds all heroes to the hero_types array. The second gets a random number between 1 and last_hero_number and creates the hero from hero_types who's index is equal to the random number. Then it replaces the last hero from the array with the chosen one(so that the chosen hero disappear from the array and is replaced by the last one.). And finally sets last_hero_number to last_hero_number-1.

I can't find any mistake but it still doesn't create the hero(The text is displayed properly except the hero name). Maybe I should try instead of all those hero replacements to just create one hero_types[random integer between 1 and 10] and then check if there are other units of the same type remove last created unit and do it again. But won't that looks bad in the game(and increase the starting lag).
 
Status
Not open for further replies.
Top