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

How To Make Stacked Ability?

Status
Not open for further replies.
Level 3
Joined
Apr 5, 2016
Messages
21
i want to make an ability like everytime you use the ability it will add 1 "Holy Wrath", it can release it like (Total of holy wrath stacked x 50)
how do i make something like that?
 
There a 2 practical options like DSG said use a hashtable and save on the units-Handle Id this wrath counter.


  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Create the hashtable, without it won't work --------
      • Hashtable - Create a hashtable
      • Set Hash = (Last created hashtable)
  • Powerup
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Power UP
    • Actions
      • -------- Get HandleId of CastingUnit --------
      • Set UnitId = (Key (Triggering unit))
      • -------- Load Current Power, 11 is a random choosen number, other spells should not use it. --------
      • Set Power = (Load 11 of UnitId from Hash)
      • Set Power = (Power + 50.00)
      • -------- Save New Power --------
      • Hashtable - Save Power as 11 of UnitId in Hash
  • Unleash
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Unleash
    • Actions
      • -------- Load Current Power --------
      • Set UnitId = (Key (Triggering unit))
      • Set Power = (Load 11 of UnitId from Hash)
      • -------- 30 Base Damage --------
      • Set Power = (Power + 30.00)
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing Power damage of attack type Spells and damage type Magic
      • -------- Save 0 as power uped. --------
      • Hashtable - Save 0.00 as 11 of UnitId in Hash
  • Killed
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in Hash


Other option is using an Unit Indexer and saving the Wraith counter on a variable with the index the Indexer gives you.
 
Level 23
Joined
Apr 8, 2017
Messages
1,604
This one too.

  • Stacking
    • Event
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Stack ability
    • Actions
      • Unit - Set the custom value of (Triggering unit) to ((Custom value of (Triggering unit)) + 1)
  • Release
    • Event
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Unleash
    • Actions
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing (YouAmount x (Real((Custom value of (Triggering unit))))) damage of attack type Heroe and damage type Normal
      • Unit - Set the custom value of (Triggering unit) to 0
 
Level 16
Joined
Mar 25, 2016
Messages
1,327
This one too.
Be aware, that this method does not work together with most unit indexers. If you have one of these unit indexers in your map, you can easily use it to achieve the same using an integer array.

So hastables are like "custom values" of units?.
A hashtable is like an array with two indexes. You can store value of any type (integer, real, unit, point,...) in a certain position (row, column) in the table.
The row and column are specified by integers.
There is a function to get the key of an object. This key is a unique integer for every object in the game. This key can then be used in the hashtable. With this key we can store data for a specific object (often times a unit).
For example to store an integer for a unit we can use:
  • Hashtable - Save 4 as (Key (Triggering unit)) of 0 in Table
This is very similar to setting custom value of the Triggering unit to 4. However with the hashtable you can store a basically unlimited number of variables (also non-integer variables) for a unit.
To store a unit as well, we can store it in a different position in the hashtable:
  • Hashtable - Save Handle Of(Target unit of ability being cast) as (Key (Triggering unit)) of 1 in Table
The key function can also be used for other objects, so you can store values for basically every object in the game (destructible, unit type, item, timer, region, player, unit group, point, ...)

For more information check out some of the tutorials on this site. For example:
Hashtables and MUI
A Complete Beginners Guide to Hashtables
 
Status
Not open for further replies.
Top