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

[Solved] Using only one Id Table for multiple trigger types

Level 5
Joined
Jun 24, 2024
Messages
59
--->Nvm. Got it another way around - Question is outdated.

------------
Hey again!
I'm currently working on an ID Table with Weights that determines rarities of the Objects i set.
Example Entry:

  • TowerID
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet TowerID = 0
      • -------- --- --------
      • Set VariableSet TowerID = (TowerID + 1)
      • Set VariableSet TowerType[TowerID] = Object1
      • Set VariableSet TowerWeight[TowerID] = 50
      • -------- --- --------
      • Set VariableSet TowerIDLegendary = 0
      • -------- --- --------
      • Set VariableSet TowerID = (TowerID + 1)
      • Set VariableSet TowerType[TowerID] = Object2
      • Set VariableSet TowerWeight[TowerID] = 50
      • -------- --- --------
      • Set VariableSet TowerID = (TowerID + 1)
      • Set VariableSet TowerType[TowerID] = Object3
      • Set VariableSet TowerWeight[TowerID] = 50
      • -------- --- --------
... and so on. Lets say, there are 50 objects on this list, categorized into rarities from Common to Legendary.
First all 10 commons will be listed, then the uncommons, then rare, epic and at last all 10 legendary.
I give those id entries weight to their corresponding rarity, making it somewhat balanced in chance - depending on actual ingame balance of course.

Now i want to use this table in multiple spells that act as reroll mechanics, those have different chances for the different rarities or non at all for specific rarities.
The example being the cheapest can roll a rare tower at maximum.

My understanding is, that i have to change the weights of the IDs in the one table per roll (per reroll trigger) accordingly to what chances they should have and reset all weights in the end so other roll triggers don't pick up wrong numbers. The difficulty for me is, when i only use one table, do i have to create insane amount of read/set actions or should i do the one time work and create tables for each rarity and only add towers and weights there according to my calculations (About 100 Towers in 5 different Roll triggers (equals +- 470 x3 entries).

Isn't there an easier way? I'm still very new to the WC3 Editor capabilities and would like to hear your ideas or suggestions :)

SMOrc

Edit
I think i can read the ID number and set the Tower Weight of the called ID, correct?
Could i also create some sort of loop that uses integer like:
"For Each Integer 1 - 10 in Tower ID - Set Weight to 50X"
"For Each Integer 11 - 20 in Tower ID - Set Weight to 25"
and so on.

And this kind of Loop for every rarity? That would make things way easier.
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
You can add variables which are dedicated to handling all things Rarity:
  • TowerID
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Define your different rarity types --------
      • Set VariableSet Rarity_Common = 1
      • Set VariableSet Rarity_Uncommon = 2
      • Set VariableSet Rarity_Epic = 3
      • -------- --- --------
      • Set VariableSet TowerID = 0
      • -------- --- --------
      • Set VariableSet TowerID = (TowerID + 1)
      • Set VariableSet TowerType[TowerID] = TowerA
      • Set VariableSet TowerWeight[TowerID] = 50
      • Set VariableSet TowerRarity[TowerID] = Rarity_Common
      • -------- --- --------
      • Set VariableSet TowerID = (TowerID + 1)
      • Set VariableSet TowerType[TowerID] = TowerB
      • Set VariableSet TowerWeight[TowerID] = 30
      • Set VariableSet TowerRarity[TowerID] = Rarity_Uncommon
      • -------- --- --------
      • Set VariableSet TowerID = (TowerID + 1)
      • Set VariableSet TowerType[TowerID] = TowerC
      • Set VariableSet TowerWeight[TowerID] = 5
      • Set VariableSet TowerRarity[TowerID] = Rarity_Epic
      • -------- --- --------
So first we define the different types of Rarities (which act as Keys) and then we assign them to each of our Towers.

Then if you wanted to store them in categories, for example, you could do something like this:
  • For each Integer (LoopID) from 1 to TowerID do (Actions)
    • Loop - Actions
      • If all conditions are true then do actions
        • If - Conditions
          • TowerRarity[LoopID] Equal to Rarity_Common
        • Then - Actions
          • Set Variable (CommonCount = CommonCount + 1)
          • Set Variable CommonTowers[CommonCount] = TowerID
        • Else - Actions
      • -------- --- --------
      • If all conditions are true then do actions
        • If - Conditions
          • TowerRarity[LoopID] Equal to Rarity_Uncommon
        • Then - Actions
          • Set Variable (UncommonCount = UncommonCount + 1)
          • Set Variable UncommonTowers[UncommonCount] = TowerID
        • Else - Actions
      • -------- --- --------
      • If all conditions are true then do actions
        • If - Conditions
          • TowerRarity[LoopID] Equal to Rarity_Epic
        • Then - Actions
          • Set Variable (EpicCount = EpicCount + 1)
          • Set Variable EpicTowers[EpicCount] = TowerID
        • Else - Actions
You now have Arrays dedicated to each type of Rarity (Common, Uncommon, Epic) with each Array having access to the matching Towers. You also know the size of these Arrays by referencing the Count variables.

But ideally you would use a Hashtable to avoid the need for these If Then Else statements and use the Rarity_ values as the Parent Keys for your database:
  • Loop - Actions
    • Set Variable Rarity = TowerRarity[LoopID] // Set a temporary "shortcut" to the tower's rarity
    • Set Variable RarityCount[Rarity] =(RarityCount[Rarity] + 1) // Increase the total number of towers with this rarity by 1
    • Hashtable - Save TowerID as RarityCount[Rarity] of Rarity in Tower_Data_Hashtable // Save the tower in the Hashtable under it's own rarity category
You could use another For Loop to implement your Weight system, Saving the TowerID among a range of Child Keys. This would allow you to load a random tower from the rarity category of your choice, taking into consideration the different Weights:
  • Actions
    • -------- Let's get a random Epic tower --------
    • Set Variable Rarity = Rarity_Epic
    • Set Variable Random_Key = (Random integer number between 1 and RarityCount[Rarity])
    • Set Variable Random_Tower_ID = (Load Random_Key of Rarity in Tower_Data_Hashtable
    • Unit - Create 1 TowerType[Random_Tower_ID] for Player 1 (Red) at...
 
Last edited:
Top