• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

[Trigger] Add or give random abilities to a unit without repetition

Status
Not open for further replies.
Level 11
Joined
Jun 20, 2017
Messages
380
I have a few rounds in my map,
So if the current level is 4
It should give my unit a random ability between 1 and 3(You can only have 1 of these abilities).
Or when a round reaches 12/20/24/28/30
It should give my unit a random ability between 4 and 8(You can have all of these abilities, but when you reach those levels, 1 per level).

I tried to use @Pyrogasm method! https://www.hiveworkshop.com/threads/adding-random-non-duplicate-abilities.319691/
But the issue is that I cannot have more than one ability!
  • Setup Champion Abilities
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet AbilityCodes_Champion[1] = War Stomp [King]
      • Set VariableSet AbilityCodes_Champion[2] = Shockwave [King]
      • Set VariableSet AbilityCodes_Champion[3] = Permanent Immolation [King]
      • -------- --------
      • Set VariableSet AbilityCodes_Champion[4] = Command Aura [King]
      • Set VariableSet AbilityCodes_Champion[5] = Devotion Aura [King]
      • Set VariableSet AbilityCodes_Champion[6] = Endurance Aura [King]
      • Set VariableSet AbilityCodes_Champion[7] = Critical Strike [King]
      • Set VariableSet AbilityCodes_Champion[8] = Evasion [King]
  • Champion Abilities
    • Events
    • Conditions
    • Actions
      • For each (Integer Integer_ChampionAbilities) from 1 to 1, do (Actions)
        • Loop - Actions
          • Set VariableSet AbilityCodes_Champion[1] = AbilityCodes_Champion[(Random integer number between 1 and 3)]
          • Set VariableSet AbilityCodes_Champion[2] = AbilityCodes_Champion[(Random integer number between 4 and 8)]
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AbilityCodes_Champion[1] Not equal to AbilityCodes_Champion[2]
              • AbilityCodes_Champion[2] Not equal to AbilityCodes_Champion[3]
              • AbilityCodes_Champion[3] Not equal to AbilityCodes_Champion[1]
              • Integer_CurrentLevel Equal to 4
            • Then - Actions
              • Unit - Add AbilityCodes_Champion[1] to West Champion 0448 <gen>
              • Game - Display to (All allies of Player 23 (Emerald).) for 10.00 seconds the text: ((((Name of West Champion 0448 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[1])) + |r ability.)
              • -------- --------
              • Unit - Add AbilityCodes_Champion[1] to East Champion 0447 <gen>
              • Game - Display to (All allies of Player 24 (Peanut).) for 10.00 seconds the text: ((((Name of East Champion 0447 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[1])) + |r ability.)
            • Else - Actions
              • Set VariableSet Integer_ChampionAbilities = (Integer_ChampionAbilities - 1)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AbilityCodes_Champion[4] Not equal to AbilityCodes_Champion[5]
              • AbilityCodes_Champion[5] Not equal to AbilityCodes_Champion[6]
              • AbilityCodes_Champion[6] Not equal to AbilityCodes_Champion[7]
              • AbilityCodes_Champion[7] Not equal to AbilityCodes_Champion[8]
              • AbilityCodes_Champion[8] Not equal to AbilityCodes_Champion[4]
              • Integer_CurrentLevel Equal to 12
            • Then - Actions
              • Unit - Add AbilityCodes_Champion[2] to West Champion 0448 <gen>
              • Game - Display to (All allies of Player 23 (Emerald).) for 10.00 seconds the text: ((((Name of West Champion 0448 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[2])) + |r ability.)
              • -------- --------
              • Unit - Add AbilityCodes_Champion[2] to East Champion 0447 <gen>
              • Game - Display to (All allies of Player 24 (Peanut).) for 10.00 seconds the text: ((((Name of East Champion 0447 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[2])) + |r ability.)
            • Else - Actions
              • Set VariableSet Integer_ChampionAbilities = (Integer_ChampionAbilities - 1)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AbilityCodes_Champion[4] Not equal to AbilityCodes_Champion[5]
              • AbilityCodes_Champion[5] Not equal to AbilityCodes_Champion[6]
              • AbilityCodes_Champion[6] Not equal to AbilityCodes_Champion[7]
              • AbilityCodes_Champion[7] Not equal to AbilityCodes_Champion[8]
              • AbilityCodes_Champion[8] Not equal to AbilityCodes_Champion[4]
              • Integer_CurrentLevel Equal to 20
            • Then - Actions
              • Unit - Add AbilityCodes_Champion[2] to West Champion 0448 <gen>
              • Game - Display to (All allies of Player 23 (Emerald).) for 10.00 seconds the text: ((((Name of West Champion 0448 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[2])) + |r ability.)
              • -------- --------
              • Unit - Add AbilityCodes_Champion[2] to East Champion 0447 <gen>
              • Game - Display to (All allies of Player 24 (Peanut).) for 10.00 seconds the text: ((((Name of East Champion 0447 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[2])) + |r ability.)
            • Else - Actions
              • Set VariableSet Integer_ChampionAbilities = (Integer_ChampionAbilities - 1)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AbilityCodes_Champion[4] Not equal to AbilityCodes_Champion[5]
              • AbilityCodes_Champion[5] Not equal to AbilityCodes_Champion[6]
              • AbilityCodes_Champion[6] Not equal to AbilityCodes_Champion[7]
              • AbilityCodes_Champion[7] Not equal to AbilityCodes_Champion[8]
              • AbilityCodes_Champion[8] Not equal to AbilityCodes_Champion[4]
              • Integer_CurrentLevel Equal to 24
            • Then - Actions
              • Unit - Add AbilityCodes_Champion[2] to West Champion 0448 <gen>
              • Game - Display to (All allies of Player 23 (Emerald).) for 10.00 seconds the text: ((((Name of West Champion 0448 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[2])) + |r ability.)
              • -------- --------
              • Unit - Add AbilityCodes_Champion[2] to East Champion 0447 <gen>
              • Game - Display to (All allies of Player 24 (Peanut).) for 10.00 seconds the text: ((((Name of East Champion 0447 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[2])) + |r ability.)
            • Else - Actions
              • Set VariableSet Integer_ChampionAbilities = (Integer_ChampionAbilities - 1)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AbilityCodes_Champion[4] Not equal to AbilityCodes_Champion[5]
              • AbilityCodes_Champion[5] Not equal to AbilityCodes_Champion[6]
              • AbilityCodes_Champion[6] Not equal to AbilityCodes_Champion[7]
              • AbilityCodes_Champion[7] Not equal to AbilityCodes_Champion[8]
              • AbilityCodes_Champion[8] Not equal to AbilityCodes_Champion[4]
              • Integer_CurrentLevel Equal to 28
            • Then - Actions
              • Unit - Add AbilityCodes_Champion[2] to West Champion 0448 <gen>
              • Game - Display to (All allies of Player 23 (Emerald).) for 10.00 seconds the text: ((((Name of West Champion 0448 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[2])) + |r ability.)
              • -------- --------
              • Unit - Add AbilityCodes_Champion[2] to East Champion 0447 <gen>
              • Game - Display to (All allies of Player 24 (Peanut).) for 10.00 seconds the text: ((((Name of East Champion 0447 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[2])) + |r ability.)
            • Else - Actions
              • Set VariableSet Integer_ChampionAbilities = (Integer_ChampionAbilities - 1)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AbilityCodes_Champion[4] Not equal to AbilityCodes_Champion[5]
              • AbilityCodes_Champion[5] Not equal to AbilityCodes_Champion[6]
              • AbilityCodes_Champion[6] Not equal to AbilityCodes_Champion[7]
              • AbilityCodes_Champion[7] Not equal to AbilityCodes_Champion[8]
              • AbilityCodes_Champion[8] Not equal to AbilityCodes_Champion[4]
              • Integer_CurrentLevel Equal to 30
            • Then - Actions
              • Unit - Add AbilityCodes_Champion[2] to West Champion 0448 <gen>
              • Game - Display to (All allies of Player 23 (Emerald).) for 10.00 seconds the text: ((((Name of West Champion 0448 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[2])) + |r ability.)
              • -------- --------
              • Unit - Add AbilityCodes_Champion[2] to East Champion 0447 <gen>
              • Game - Display to (All allies of Player 24 (Peanut).) for 10.00 seconds the text: ((((Name of East Champion 0447 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[2])) + |r ability.)
            • Else - Actions
              • Set VariableSet Integer_ChampionAbilities = (Integer_ChampionAbilities - 1)
 
Level 2
Joined
Mar 2, 2022
Messages
4
So we need to produce a sequence of six integers, the first one should be random from 1 to 3, and the 2nd to 6th should be from 4 to 8, but non-repeating? If that's right, how about
  • Set Output[0] = Random integer between 1 and 3
and, for the main part
  • For each i from 1 to 5, do
    • Set Temp[i] = Random integer between 0 to 5-i //this is the number of times that Output[i] will "advance"
    • Set Output[i] = 4
    • For each j from 0 to Temp[i] do
      • If j > 0 then //Output[i] advances
        • Set Output[i] = Output[i] + 1
      • For each k from 1 to i-1 do //this loop moves Output[i] to the next unoccupied integer
        • If Output[i] is equal to Output[k] then
          • Set Output[i] = Output[i] + 1
          • Set k = 0 //restart the loop, until no collision happens
 
Last edited:
Level 11
Joined
Jun 20, 2017
Messages
380
Thanks, but honestly, I don't know what is going on here! I have not used such a thing like loop in loop before, so where did I go wrong?
  • Setup Champion Abilities
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet AbilityCodes_Champion[1] = War Stomp [King]
      • Set VariableSet AbilityCodes_Champion[2] = Shockwave [King]
      • Set VariableSet AbilityCodes_Champion[3] = Permanent Immolation [King]
      • -------- --------
      • Set VariableSet AbilityCodes_Champion[4] = Command Aura [King]
      • Set VariableSet AbilityCodes_Champion[5] = Devotion Aura [King]
      • Set VariableSet AbilityCodes_Champion[6] = Endurance Aura [King]
      • Set VariableSet AbilityCodes_Champion[7] = Critical Strike [King]
      • Set VariableSet AbilityCodes_Champion[8] = Evasion [King]
  • Champion Abilities
    • Events
    • Conditions
    • Actions
      • Set VariableSet Integers_ChampionAbilities[1] = (Random integer number between 1 and 3)
      • Set VariableSet Integers_ChampionAbilities[2] = (Random integer number between 4 and 8)
      • Set VariableSet Integers_ChampionAbilities[3] = (Random integer number between 4 and 8)
      • Set VariableSet Integers_ChampionAbilities[4] = (Random integer number between 4 and 8)
      • Set VariableSet Integers_ChampionAbilities[5] = (Random integer number between 4 and 8)
      • Set VariableSet Integers_ChampionAbilities[6] = (Random integer number between 4 and 8)
      • -------- --------
      • For each (Integer Integer_Abilities) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set VariableSet Integers_RandomAbilities[Integer_Abilities] = (Random integer number between 1 and (6 - Integer_Abilities))
          • Set VariableSet Integers_ChampionAbilities[Integer_Abilities] = 4
          • For each (Integer Integer_Abilities2) from 1 to Integers_RandomAbilities[Integer_Abilities], do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Integer_Abilities2 Greater than 0
                • Then - Actions
                  • Set VariableSet Integers_ChampionAbilities[Integer_Abilities] = (Integers_ChampionAbilities[Integer_Abilities] + 1)
                • Else - Actions
              • For each (Integer Integer_Abilities3) from 1 to (Integer_Abilities - 1), do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Integers_ChampionAbilities[Integer_Abilities] Equal to Integers_ChampionAbilities[Integer_Abilities3]
                    • Then - Actions
                      • Set VariableSet Integers_ChampionAbilities[Integer_Abilities] = (Integers_ChampionAbilities[Integer_Abilities] + 1)
                      • -------- --------
                      • Unit - Add AbilityCodes_Champion[Integers_ChampionAbilities[Integer_Abilities]] to West Champion 0448 <gen>
                      • Unit - Add AbilityCodes_Champion[Integers_ChampionAbilities[Integer_Abilities]] to East Champion 0447 <gen>
                      • -------- --------
                      • Set VariableSet Integer_Abilities3 = 0
                    • Else - Actions
      • -------- --------
      • Game - Display to (All allies of Player 23 (Emerald).) for 10.00 seconds the text: ((((Name of West Champion 0448 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[Integers_ChampionAbilities[Integer_Abilities]])) + |r ability.)
      • Game - Display to (All allies of Player 24 (Peanut).) for 10.00 seconds the text: ((((Name of East Champion 0447 <gen>) + learned the |cffffcc00) + (Name of AbilityCodes_Champion[1])) + |r ability.)
 
Status
Not open for further replies.
Top