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

Unit variable as key for hashtable

Status
Not open for further replies.
Level 10
Joined
Mar 26, 2017
Messages
376
I am trying to use a DDS for making custom armor types.

I feel like the most efficient way of accomplishing this is to use a hashtable that loads an integer value representing the unit's armor, which can then be used to determine the modification for DamageEventAmount.

Unfortunately, for loading the key of the hashtable, the editor does not allow me to use unit variables (where I would want to point to DamageEventSource)'

I could use a workaround, like adding the DamageEventSource to a unit group and then load the key from 'select random unit' from that unit group, but I feel there may be a more efficient solution.

Any ideas guys?


Edit: My solution for now is to save the DamageEventSource in a simple hashtable, and then load the unit from there. This works, and is probably fairly efficient.
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
You can’t use objects as keys. You use their handle ID instead. Click on the key you want to change and one of the options should say something like “Unit - Handle ID”. Use that one.

Once you’ve done it correctly the line will display as:

Key (Event Damage Source)
 
Level 10
Joined
Mar 26, 2017
Messages
376
Indeed I am trying to refer to the handle ID of that unit using key(). Unfortunately, it appears not possible to select a unit variable.

For instance > (key(triggering unit) is possible. key(EventDamageSource) is not possible, variables are greyed out when choosing input for key().
 
Level 10
Joined
Mar 26, 2017
Messages
376
I assume the function to get unit armor does not return the armor correctly?
JASS:
native BlzGetUnitArmor takes unit whichUnit returns real
This seems far more elegant than a hashtable based solution.

Thanks, but I am not trying to find a unit's armor value, but rather implement custom armor types (using a DDS).


As far as loading a value from a hashtable belonging to a unit variable key, I would need to solve it with a custom script statement that looks a bit like below:
upload_2019-2-7_20-49-40.png


Can anyone help me find the right syntax for the Load from hashtable statement in this Custom Script?
 
JASS:
native  LoadInteger                    takes hashtable table, integer parentKey, integer childKey returns integer
LoadInteger(bj_lastCreatedHashtable, GetHandleId(udg_DamageEventSource),1)

Although you would not even need that. You proably use bribes damage engine(95% sure) . Which requiers his unit indexer. His unit Indexer gives each unit an unique array Index, beeing its custum unit value. So you could use custom value of damage source instead of handle. Then all can be done in GUI.
 
Status
Not open for further replies.
Top