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

Detecting Unit's Damage

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
Before you answer, I don't want to know how much damage the unit did to another unit by attacking him!

I want to know if it's possible to detect the amount of damage a unit actually has.

Example: 29-33 damage.
80-88 damage.

  • Unit - Cause (Triggering unit) to damage (Triggering unit), dealing 500 damage of attack type Spells and damage type Normal
I wanted to use this line of code and somehow input the damage of the unit in there. Can I do this?
 
Well, Malhorne's library will retrieve the last damage the unit dealt to a target. It won't give you an actual range of damage. If the unit hasn't dealt any damage yet, then it will return 0. So I'm not sure it is what you're looking for.

Just store the minimum damage and maximum damage in a hashtable for each unit-type you need to factor in (along with primary attribute if he is a hero).

  • Hashtable - Save 29 as 0 of <Unit-type of SomeUnit> in <Hashtable>
  • Hashtable - Save 33 as 1 of <Unit-type of SomeUnit> in <Hashtable>
Something like that. I don't remember the lines exactly. But you would just load the damage under the same keys. It is the most accurate way to do it, even if it is a little tedious.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Just store the minimum damage and maximum damage in a hashtable for each unit-type you need to factor in (along with primary attribute if he is a hero).

Ahh, I see. I just looked up a hashtable tutorial to understand how to use what your suggesting I do. I didn't think of it before because I didn't know what hash tables are and how they're used. It's a shame there is no way to call a unit's min and max damage or even an average of the two. That would have saved me storing every single unit's damage in a hash table.

I have a question though. All my unit's damage will remain static, except for my hero's which will level up. I am guessing, to prevent leaks, I will need to somehow clear the heroes' damage data within the hash table and resave it, since there is no "update" option in GUI.

It appears if I clear a "child" hash table, it will remove ALL my minimum damages or ALL my maximum damages, since all min damages will be saved under one key and maxes into a second key. Will I need to resave all my min and max values upon a hero levelling up? Or is there a simpler way to "update" a hero's hash table upon levelling?

I hope you understand, I'm new to hash tables so I cant word things any better.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
What do you mean clear? Flush or Remove? Also, integers don't leak.

AFAIK, you flush a child key when you don't need the stuff stored on those childkeys with regards to a parent key (say for example table[c];table contains 10 [c] elements; flushing the childkey of parent will remove all the [c] elements in the table)

I hope that was right lol. If you want to remove a stored data, you use the Remove hashtable functions.
 
Status
Not open for further replies.
Top