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

How to pick between 3 random stats from a pool of X stats?

Status
Not open for further replies.
Level 3
Joined
Mar 30, 2020
Messages
12
Hai!
I'm currently making a RPG map where one mechanic is going to be that you can trade in a Spirit Orb for a random stat bonus. These stat bonuses range from attribute bonuses, bonus health, mana, regen, damage etc...

My question is however, how do I make a dialogue or a unit/shop where there are only three of these stats, picked at random, show at a time?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,546
You can manage this with a bunch of arrays.

First define your Stats as Integers (Strength, Agility, etc), then store them in an Integer Array (Stats), and lastly store them in a String Array (StatsNames):
  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Define the stats: --------
      • Set VariableSet StatsTotal = 5
      • Set VariableSet Strength = 1
      • Set VariableSet Agility = 2
      • Set VariableSet Intelligence = 3
      • Set VariableSet Health = 4
      • Set VariableSet Mana = 5
      • -------- Store these stats in an array: --------
      • Set VariableSet Stats[1] = Strength
      • Set VariableSet Stats[2] = Agility
      • Set VariableSet Stats[3] = Intelligence
      • Set VariableSet Stats[4] = Health
      • Set VariableSet Stats[5] = Mana
      • -------- Give these stats names in a String array. It will come in handy for displaying their names in text/dialogues: --------
      • Set VariableSet StatsNames[1] = Strength
      • Set VariableSet StatsNames[2] = Agility
      • Set VariableSet StatsNames[3] = Intelligence
      • Set VariableSet StatsNames[4] = Health
      • Set VariableSet StatsNames[5] = Mana
Now when it comes time to pick 3 of these stats at random we do this:
  • Get Random Stats
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • -------- Define how many Stats are Available to pick from (StatsTotal is always equal to the total number of stats) --------
      • Set VariableSet StatsAvailable = StatsTotal
      • -------- --------
      • -------- Define how many Stats we are going to pick at random: --------
      • Set VariableSet StatsWanted = 3
      • -------- --------
      • -------- Create a copy of your Stats array. We can't use the original Stats array because it must remain unchanged: --------
      • For each (Integer StatsLoop) from 1 to StatsTotal, do (Actions)
        • Loop - Actions
          • Set VariableSet StatsCopy[StatsLoop] = Stats[StatsLoop]
      • -------- --------
      • -------- Now we get our random Stats: --------
      • For each (Integer StatsLoop) from 1 to StatsWanted, do (Actions)
        • Loop - Actions
          • -------- Get a random number (Stat) between 1 and X, X being the total number of Stats available: --------
          • Set VariableSet StatsRandom = (Random integer number between 1 and StatsAvailable)
          • -------- --------
          • -------- Set this random number as one of our Chosen Stats: --------
          • Set VariableSet StatsChosen[StatsLoop] = StatsCopy[StatsRandom]
          • -------- --------
          • -------- This is where we prevent Stats from being chosen more than once: --------
          • -------- First we swap our Chosen Stat in StatsCopy with the last Stat in StatsCopy.Then we reduce StatsAvailable by 1. --------
          • Set VariableSet StatsCopy[StatsRandom] = StatsCopy[StatsAvailable]
          • Set VariableSet StatsAvailable = (StatsAvailable - 1)
          • -------- --------
          • -------- Example: So if we chose StatsCopy[1] (Strength), we would set it's value to StatsCopy[5] (Mana). --------
          • -------- So StatsCopy[5] (which is now Strength) is no longer available to be chosen, while StatsCopy[1] (which is now Mana) remains available. --------
      • -------- --------
      • -------- Our randomly picked stats are now stored in the StatsChosen array, from 1 to StatsWanted. --------
      • For each (Integer StatsLoop) from 1 to StatsWanted, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) for 30.00 seconds the text: (Chosen Stat # + ((String(StatsLoop)) + ( = + StatsNames[StatsChosen[StatsLoop]])))
      • Game - Display to (All players) for 30.00 seconds the text: - - - - - - - - - -...
I didn't provide the Dialogue stuff but it wouldn't be too difficult to do. Once you have the 3 chosen stats all you have to do is make your dialogue display 3 different dialogue buttons, each one using the name of a chosen stat. Then when you press one of the 3 dialogue buttons you're given the corresponding stat. So if you press DialogButton[1] you're given StatsChosen[1].

If the map was multiplayer then StatsChosen would need to be stored in a Hashtable for each player. This way the information doesn't get overwritten (say if two players were given random stats at the same time).
 

Attachments

  • Stats Random.w3m
    19.1 KB · Views: 9
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,546
The stats don't have to be a separate variable but they make your life easier.

Instead of memorizing that Stats[4] = Health, you can just reference the Health variable. IE:
  • Unit - Add StatsAbilities[Health] to Triggering unit
That's a lot easier than having to look things up over and over again.

And I'd recommend looking up some tutorials on Hashtables, they can be a bit confusing at first. Hashtables and MUI


I'll try to simplify Hashtables as best I can:

I like to think of Hashtables as a 2-dimensional Array, which is a standard Array with an extra Index []:
  • Set Variable StatsChosen[1][3] = Strength
I like to make the first Index [] represent the Player's Number. So 1 represents Player 1 (Red), 2 represents Player 2 (Blue), etc.
And the second Index [] represent the data's position in our array. So like we've been doing already in our standard Arrays.
So in that example, Player 1's 3rd Chosen Stat is Strength. StatsChosen[2][3] would represent Player 2's 3rd Chosen Stat.

Now Hashtables function very similar to this, but they offer even greater control. That control is what adds to the complexity of them and is why they look a bit different than a 2-dimensional Array.

In a Hashtable you have a Child key, a Parent key, and the Hashtable variable.

The Hashtable variable is rather self-explanatory:
  • Hashtable - Create a hashtable
  • Set Variable SomeHashtable = (Last created hashtable)
It's like creating any other Variable but with a couple extra steps. You usually create all of these Hashtables at Map Initialization and then Save data to them afterwards.

Data is the value that you want to save, which could be an Integer, Unit, Item, etc.. It's Saved in your desired Hashtable so that it can be Loaded at a later time.
  • Hashtable - Save Data as Child of Parent in SomeHashtable

So if we wanted to save "StatsChosen[1][3] = Strength" in our Stat's Hashtable it could look like this:
  • Hashtable - Save Strength as 3 of 1 in StatsHashtable
The Child (3) and the Parent (1) act as the Indexes, same as the ones in our 2-dimensional Array example I showed you earlier. The Parent key in this case is the Player Number and the Children are all of the different data values that we want to save under that Parent. So each Parent has a bunch of Children stored under it (the names start to make sense now).

This allows us to store unique data for EACH player inside of the same Hashtable. All we have to do is adjust the Parent key. So if we changed the Parent key from 1 to 2 in the above example, we'd now be saving data under Player 2 instead of Player 1.
  • Hashtable - Save Strength as 3 of 2 in StatsHashtable

I won't go into any greater detail for now, but understand that you can take Hashtables even futher by making use of Handles. You can read more about these in some Hashtable tutorials.
 
Last edited:
Level 3
Joined
Mar 30, 2020
Messages
12
Thank you soooo much for your help!!! I got it working rather quickly with dialog's aswell and so far it seems to be working great. I'll need to test the multiplayer component of this later on, but i think it should work. For now i just set StatsChosen as three different variables and checked which player spent the Spirit Orb. I will need some time to study and soak in everything you've taught me so far, and again: THANK YOU!!! This was more help than I could ever have imagined! <3 😁
 
Level 3
Joined
Mar 30, 2020
Messages
12
Oh, and why I chose to make most of the integers into one array is because my map has already alot of variables, so i try to use as few variables as possible! I just label what each array they are in the trigger comment and it works pretty ok for me. :)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,546
No problem, and Hashtables should help keep things more organized. You can probably adapt some of your older stuff to work with Hashtables as well.

And I haven't seen your triggers yet, but the StatsChosen stuff will definitely have problems in multiplayer.

An example of what could go wrong:
  • Player 1 levels up and is given 3 random stats. The player sits there for a minute, thinking about which stat he should choose.
  • Player 2 levels up and is given 3 random stats. The StatsChosen variables are given new values.
  • Player 1 finally decides on a stat and clicks the first Dialogue button. StatsChosen[1] is given to Player 1... But wait, the button said Strength but it added Agility?

This is because the StatsChosen variables were Set to new values when Player 2 gained a level. Player 1 is now referencing the StatsChosen[1] that was Set for Player 2.

This is why things need to be done exclusively for each Player. They can't share the same Variables. Situations in which they can share the same variables require that there's no time delay between the Setting and Using of said variables.

Luckily, we can Save this data in a Hashtable in the very same trigger. So after getting StatsChosen[1] to 3, you would save them in a Hashtable for that Player.

Something like this:
  • Hashtable - Save StatsChosen[1] as 1 of 1 in StatsHashtable
  • Hashtable - Save StatsChosen[2] as 2 of 1 in StatsHashtable
  • Hashtable - Save StatsChosen[3] as 3 of 1 in StatsHashtable
The 1 in "of 1" represents the Player Number, so that value should match the Player Number of whoever leveled up.

Just remember that data in a Hashtable can be overwritten as well, so maybe it'd be wise to save this particular data in a unique Hashtable.
 
Last edited:
Level 3
Joined
Mar 30, 2020
Messages
12
These are my triggers so far. The way it works now is that you "buy" a dummy item from a shop and it opens a dialog. You then get to choose between 3 random stats and if you click on one and have atleast 1 Spirit Orb, you get the stat. If you dont have enough Spirit Orbs, the dialog closes and gives an error message (Not enough spirit orbs) The next time you open the dialog, the same random stats are there so you can't skip the three you are given basically... I hope I explained it rather coherently :p

Still haven't tested in multiplayer yet, but I'll keep and eye out.

StatsIntegers[1] = StatsTotal
StatsIntegers[2] = StatsAvailable
StatsIntegers[3] = StatsWanted
StatsIntegers[4] = StatsLoop
StatsIntegers[5] = StatsRandom

  • Spirit Orb Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet StatsIntegers[1] = 12
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set VariableSet Stats[(Integer A)] = (Integer A)
      • Set VariableSet StatsNames[1] = +2 Strength
      • Set VariableSet StatsNames[2] = +2 Agility
      • Set VariableSet StatsNames[3] = +2 Intelligence
      • Set VariableSet StatsNames[4] = +20 Health
      • Set VariableSet StatsNames[5] = +15 Mana
      • Set VariableSet StatsNames[6] = +0.5 Health Regen
      • Set VariableSet StatsNames[7] = +0.3 Mana Regen
      • Set VariableSet StatsNames[8] = +1 Armor
      • Set VariableSet StatsNames[9] = +12 Movement Speed
      • Set VariableSet StatsNames[10] = +3% Healing Power
      • Set VariableSet StatsNames[11] = +5 Base Attack Damage
      • Set VariableSet StatsNames[12] = -0.2 Base Attack Time
  • Spend Spirit Orb
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Spend |c00399bb6Spirit Orbs|r
    • Actions
      • Set VariableSet StatsPlayer = (Owner of (Buying unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • StatsOn[(Player number of StatsPlayer)] Equal to False
        • Then - Actions
          • Set VariableSet StatsOn[(Player number of StatsPlayer)] = True
          • Set VariableSet StatsIntegers[2] = StatsIntegers[1]
          • For each (Integer StatsIntegers[4]) from 1 to StatsIntegers[1], do (Actions)
            • Loop - Actions
              • Set VariableSet StatsCopy[StatsIntegers[4]] = Stats[StatsIntegers[4]]
          • For each (Integer StatsIntegers[4]) from 1 to 3, do (Actions)
            • Loop - Actions
              • Set VariableSet StatsIntegers[5] = (Random integer number between 1 and StatsIntegers[2])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • StatsPlayer Equal to Player 1 (Red)
                • Then - Actions
                  • Set VariableSet StatsChosen1[StatsIntegers[4]] = StatsCopy[StatsIntegers[5]]
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • StatsPlayer Equal to Player 2 (Blue)
                    • Then - Actions
                      • Set VariableSet StatsChosen2[StatsIntegers[4]] = StatsCopy[StatsIntegers[5]]
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • StatsPlayer Equal to Player 3 (Teal)
                        • Then - Actions
                          • Set VariableSet StatsChosen3[StatsIntegers[4]] = StatsCopy[StatsIntegers[5]]
                        • Else - Actions
              • Set VariableSet StatsCopy[StatsIntegers[5]] = StatsCopy[StatsIntegers[2]]
              • Set VariableSet StatsIntegers[2] = (StatsIntegers[2] - 1)
          • Dialog - Clear StatsDialogue[(Player number of StatsPlayer)]
          • Dialog - Change the title of StatsDialogue[(Player number of StatsPlayer)] to Spend |c00399bb6Spi...
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StatsPlayer Equal to Player 1 (Red)
            • Then - Actions
              • Dialog - Create a dialog button for StatsDialogue[1] labelled StatsNames[StatsChosen1[1]]
              • Set VariableSet StatsDialogueButtons[StatsChosen1[1]] = (Last created dialog Button)
              • Dialog - Create a dialog button for StatsDialogue[1] labelled StatsNames[StatsChosen1[2]]
              • Set VariableSet StatsDialogueButtons[StatsChosen1[2]] = (Last created dialog Button)
              • Dialog - Create a dialog button for StatsDialogue[1] labelled StatsNames[StatsChosen1[3]]
              • Set VariableSet StatsDialogueButtons[StatsChosen1[3]] = (Last created dialog Button)
              • Dialog - Show StatsDialogue[1] for Player 1 (Red)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • StatsPlayer Equal to Player 2 (Blue)
                • Then - Actions
                  • Dialog - Create a dialog button for StatsDialogue[2] labelled StatsNames[StatsChosen2[1]]
                  • Set VariableSet StatsDialogueButtons[StatsChosen2[1]] = (Last created dialog Button)
                  • Dialog - Create a dialog button for StatsDialogue[2] labelled StatsNames[StatsChosen2[2]]
                  • Set VariableSet StatsDialogueButtons[StatsChosen2[2]] = (Last created dialog Button)
                  • Dialog - Create a dialog button for StatsDialogue[2] labelled StatsNames[StatsChosen3[3]]
                  • Set VariableSet StatsDialogueButtons[StatsChosen2[3]] = (Last created dialog Button)
                  • Dialog - Show StatsDialogue[2] for Player 2 (Blue)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • StatsPlayer Equal to Player 3 (Teal)
                    • Then - Actions
                      • Dialog - Create a dialog button for StatsDialogue[3] labelled StatsNames[StatsChosen3[1]]
                      • Set VariableSet StatsDialogueButtons[StatsChosen3[1]] = (Last created dialog Button)
                      • Dialog - Create a dialog button for StatsDialogue[3] labelled StatsNames[StatsChosen3[2]]
                      • Set VariableSet StatsDialogueButtons[StatsChosen3[2]] = (Last created dialog Button)
                      • Dialog - Create a dialog button for StatsDialogue[3] labelled StatsNames[StatsChosen3[3]]
                      • Set VariableSet StatsDialogueButtons[StatsChosen3[3]] = (Last created dialog Button)
                      • Dialog - Show StatsDialogue[3] for Player 3 (Teal)
                    • Else - Actions
        • Else - Actions
          • Dialog - Clear StatsDialogue[(Player number of StatsPlayer)]
          • Dialog - Change the title of StatsDialogue[(Player number of StatsPlayer)] to |c00ffffffSpend |r|...
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • StatsPlayer Equal to Player 1 (Red)
            • Then - Actions
              • Dialog - Create a dialog button for StatsDialogue[1] labelled StatsNames[StatsChosen1[1]]
              • Set VariableSet StatsDialogueButtons[StatsChosen1[1]] = (Last created dialog Button)
              • Dialog - Create a dialog button for StatsDialogue[1] labelled StatsNames[StatsChosen1[2]]
              • Set VariableSet StatsDialogueButtons[StatsChosen1[2]] = (Last created dialog Button)
              • Dialog - Create a dialog button for StatsDialogue[1] labelled StatsNames[StatsChosen1[3]]
              • Set VariableSet StatsDialogueButtons[StatsChosen1[3]] = (Last created dialog Button)
              • Dialog - Show StatsDialogue[1] for Player 1 (Red)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • StatsPlayer Equal to Player 2 (Blue)
                • Then - Actions
                  • Dialog - Create a dialog button for StatsDialogue[2] labelled StatsNames[StatsChosen2[1]]
                  • Set VariableSet StatsDialogueButtons[StatsChosen2[1]] = (Last created dialog Button)
                  • Dialog - Create a dialog button for StatsDialogue[2] labelled StatsNames[StatsChosen2[2]]
                  • Set VariableSet StatsDialogueButtons[StatsChosen2[2]] = (Last created dialog Button)
                  • Dialog - Create a dialog button for StatsDialogue[2] labelled StatsNames[StatsChosen3[3]]
                  • Set VariableSet StatsDialogueButtons[StatsChosen2[3]] = (Last created dialog Button)
                  • Dialog - Show StatsDialogue[2] for Player 2 (Blue)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • StatsPlayer Equal to Player 3 (Teal)
                    • Then - Actions
                      • Dialog - Create a dialog button for StatsDialogue[3] labelled StatsNames[StatsChosen3[1]]
                      • Set VariableSet StatsDialogueButtons[StatsChosen3[1]] = (Last created dialog Button)
                      • Dialog - Create a dialog button for StatsDialogue[3] labelled StatsNames[StatsChosen3[2]]
                      • Set VariableSet StatsDialogueButtons[StatsChosen3[2]] = (Last created dialog Button)
                      • Dialog - Create a dialog button for StatsDialogue[3] labelled StatsNames[StatsChosen3[3]]
                      • Set VariableSet StatsDialogueButtons[StatsChosen3[3]] = (Last created dialog Button)
                      • Dialog - Show StatsDialogue[3] for Player 3 (Teal)
                    • Else - Actions
  • Spend Spirit Orb Stats
    • Events
      • Dialog - A dialog button is clicked for StatsDialogue[1]
      • Dialog - A dialog button is clicked for StatsDialogue[2]
      • Dialog - A dialog button is clicked for StatsDialogue[3]
    • Conditions
    • Actions
      • Dialog - Hide StatsDialogue[(Player number of (Triggering player))] for (Triggering player)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) Current lumber) Greater than or equal to 1
        • Then - Actions
          • Player - Set (Triggering player).Current lumber to (((Triggering player) Current lumber) - 1)
          • Set VariableSet StatsOn[(Player number of (Triggering player))] = False
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[1]
            • Then - Actions
              • Hero - Modify Strength of Hero[(Player number of (Triggering player))]: Add 2.
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[2]
            • Then - Actions
              • Hero - Modify Agility of Hero[(Player number of (Triggering player))]: Add 2.
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[3]
            • Then - Actions
              • Hero - Modify Intelligence of Hero[(Player number of (Triggering player))]: Add 2.
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[4]
            • Then - Actions
              • Unit - Set Max HP of Hero[(Player number of (Triggering player))] to ((Max HP of Hero[(Player number of (Triggering player))]) + 20)
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[5]
            • Then - Actions
              • Unit - Set Max Mana of Hero[(Player number of (Triggering player))] to ((Max Mana of Hero[(Player number of (Triggering player))]) + 15)
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[6]
            • Then - Actions
              • Set VariableSet HeroHealthRegeneration[(Player number of (Triggering player))] = (HeroHealthRegeneration[(Player number of (Triggering player))] + 0.50)
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[7]
            • Then - Actions
              • Set VariableSet HeroManaRegeneration[(Player number of (Triggering player))] = (HeroManaRegeneration[(Player number of (Triggering player))] + 0.30)
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[8]
            • Then - Actions
              • Unit - Set Armor of Hero[(Player number of (Triggering player))] to ((Armor of Hero[(Player number of (Triggering player))]) + 1.00)
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[9]
            • Then - Actions
              • Unit - Set Hero[(Player number of (Triggering player))] movement speed to ((Current movement speed of Hero[(Player number of (Triggering player))]) + 12.00)
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[10]
            • Then - Actions
              • Set VariableSet HealingPower[(Player number of (Triggering player))] = (HealingPower[(Player number of (Triggering player))] + 0.03)
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[11]
            • Then - Actions
              • Unit - Set Base Damage of Hero[(Player number of (Triggering player))] to ((Base Damage of Hero[(Player number of (Triggering player))] for weapon index 0) + 5) for weapon index: 0
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Clicked dialog button) Equal to StatsDialogueButtons[12]
            • Then - Actions
              • Unit - Set Attack Interval of Hero[(Player number of (Triggering player))] to ((Attack Interval of Hero[(Player number of (Triggering player))] for weapon index 0.) - 0.20) for weapon index: 1
              • Game - Display to (Player group((Triggering player))) the text: Spent |c00399bb6Spi...
            • Else - Actions
          • Special Effect - Create a special effect attached to the head of Hero[(Player number of (Triggering player))] using Abilities\Spells\Other\Charm\CharmTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Create a special effect attached to the origin of Hero[(Player number of (Triggering player))] using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) the text: |c00FF0000Note -|r ...
          • Set VariableSet loc = (Position of Hero[(Player number of (Triggering player))])
          • Sound - Play Error <gen> at 100.00% volume, located at loc with Z offset 0.00
          • Custom script: call RemoveLocation(udg_loc)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,546
That looks good. You could put StatsChosen in a Hashtable ridding the need of having StatsChosen1/2/3 (one for each player).

You could then do this at the start of the Spend Spirit Orb trigger:
  • Set Variable PN = Player number of (Triggering player)
And reference PN throughout the trigger. This would rid the need of having to check if it's Player 1/2/3 and make the trigger a lot more efficient/cleaner.
 
Level 3
Joined
Mar 30, 2020
Messages
12
I'm pretty happy with how it works for now. I will probably try and get into Hashtables in a later project or maybe a different system on this map, but since this works, I don't really wanna tinker with it too much. Thanks again for the super help! :)
 
Status
Not open for further replies.
Top