[General] Can you get ability handles for Hashtables?

Level 9
Joined
Mar 17, 2016
Messages
146
Hello,

I'm trying to make a system where the level of passives on heroes will deal damage based on the ability level and I want it to be MUI


What im trying first is to use a hashtable, get the ability ID and the unit ID as the keys, and the data stored to be the level of the passive ability (the damage will scale off of this stored integer)
I'm having problems because I cannot seem to get the ID, the only event response I can find is "a unit Starts the effect of an ability", but as these will be passives that wont work as they will not ever be casted.

Any tips?

1719450799628.png
 

Uncle

Warcraft Moderator
Level 69
Joined
Aug 10, 2018
Messages
7,166
I'm a little confused, why would you need a Hashtable? As long as you have access to a Unit you will also have access to all of it's Abilities and their Levels.

Here's a trigger that causes a unit to deal 20/40/60 bonus damage based on it's level of Critical Strike:
  • Crit Bonus Damage
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • (Level of Critical Strike for (Damage source)) Greater than 0
    • Actions
      • Set Bonus_Damage = (20 x (Level of Critical Strike for (Damage source)))
      • Event Response - Set Damage of Unit Damaged Event to ((Damage taken) + (Real(Bonus_Damage)))
You can get the level of any ability at any time. It'll return 0 if the unit doesn't have the ability.
 
Last edited:
Level 9
Joined
Mar 17, 2016
Messages
146
I think i was too concerned in finding a way to store the values in a variable so that the computer would only have to do the math one time and then just call on the variable for the bonus damage

Guess I was massively overthinking it.
Thank you for the help!
 

Uncle

Warcraft Moderator
Level 69
Joined
Aug 10, 2018
Messages
7,166
I think i was too concerned in finding a way to store the values in a variable so that the computer would only have to do the math one time and then just call on the variable for the bonus damage

Guess I was massively overthinking it.
Thank you for the help!
Makes sense, and for the sake of answering your Hashtable question for future reference.

You can convert a variable type (Unit Type, Ability Code, Item Type) to an Integer and save it into a Hashtable as an Integer:
  • Set Variable Ability_Code = Avatar
  • Custom script: set udg_ID = udg_Ability_Code
  • Hashtable - Save ID as 1 of 0 in (Last created Hashtable)
So by using Custom Script you can set any Integer variable (ID in this case) to be equal to the Integer Id of your non-Integer variable. You can also reverse this process to convert the Integer back into it's non-Integer form.

This could be useful for all sorts of things, for example keeping track of what abilities a unit has:
  • Set Variable Ability_Code = Holy Light
  • Custom script: set udg_ID = udg_Ability_Code
  • Hashtable - Save ID as 1 of 0 in (Last created Hashtable)
  • Set Variable Ability_Code = Divine Shield
  • Custom script: set udg_ID = udg_Ability_Code
  • Hashtable - Save ID as 2 of 0 in (Last created Hashtable)
  • Set Variable Ability_Code = Devotion Aura
  • Custom script: set udg_ID = udg_Ability_Code
  • Hashtable - Save ID as 3 of 0 in (Last created Hashtable)
Now let's reverse the process, loading the ID, converting it back to an Ability Code, and then referencing it in our Actions:
  • Events
    • Something happens...
  • Conditions
  • Actions
    • Set Variable ID = Load 1 of 0 in (Last created Hashtable)
    • Custom script: set udg_Ability_Code = udg_ID
    • Unit - Add Ability_Code to (Some unit)
^ We added Holy Light to our unit. If we loaded 2 of 0 it would get Divine Shield, and 3 of 0 would get Devotion Aura.

So for instance you could use this in a map where your unit gets a randomized set of abilities, allowing you to track them in an organized manner. Just remember to change 0 to the unit's Handle Id or some Parent Key that makes sense.
 
Last edited:
Level 9
Joined
Mar 17, 2016
Messages
146
Thank you for your help and clarifications :thumbs_up:


Dont know if im overstepping, but could you also help me with this other post i made?
All i really want for this is for someone to send me in the right direction, i dont know if this is something I would need hashtables or whatever else, and im sure I can figure it out if I am steered toward the right path

[General] - Help - Unit Sequence Spawner
 
Top