HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How Do You Determine Hero Damage To Use In Triggers

03-26-2006, 10:33 PM#1
MavDoubleGuns
Iv'ed tryed to add it through a custom value, but can't find any trigger that does it. I saw the advanced trigger in the WE Unlimited that determines any bonus damage on a unit, but not one that actually finds the base damage. Is their anyway I could do this?
03-26-2006, 11:52 PM#2
emjlr3
i think the best bet is to epriodically get the damage done to a unit of the attacker, and store it in a global to use, update every minute or so, you could even take averages
03-27-2006, 04:24 AM#3
MavDoubleGuns
Alright, what trigger do I use to get the damage caused? I use WE unlim but I cant find it, lol.
What I'm trying to do is make some hero spells as instant attacks based off of their damage, whitch includes all bonus damage from items ect.
For some reson the Unit - Damage Target trigger wont add in the "Get damage bonus" when I do
((Real((Strenght of (Casting unit)(Include bonuses)))) + ((Real((Get current damage bonus of (Attacking unit))))
for calculating the damage of the spell.
It may only refer to bonus damage from upgrades, I'm not sure
Anyways if you could explain how to get this Global Variable to work it would be alot of help.
03-27-2006, 05:43 AM#4
Jacek
When you are using "Unit xxx takes damage" as event, you have event response Damage Taken which you can use.
03-27-2006, 07:21 AM#5
MavDoubleGuns
Ah ok, I see how it works now. Thanks for the help.
03-27-2006, 07:56 AM#6
MavDoubleGuns
Alright, for some reson this still isnt working. This is how I setup my triggers:

Trigger One -
Events--
Unit- A unit is attacked
Conditions--
(Attacking unit) Equal to Warrior0215
Actions--
Set HeroDamageP3 = (Integer((Damage taken))

Trigger Two -
Events--
Unit- A unit begins casting an ability
Conditions--
(Ability being cast) Equal to Spell One
Actions--
Wait .25 seconds
If (All conditions are true) then do (then actions) else do (else actions)
If--
Level of Spell One for (casting unit) equal to 1
then--
If ((owner of (triggering unit)) Equal to player 3 then do (Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing ((Real(HeroDamageP3)) + 160) attack type normal, damage type normal)

It's only dealing the 160 damage and ignoring the variable (or the variable isnt set up right). Does anyone know how to fix this?
03-27-2006, 08:26 AM#7
Anitarf
It isn't being set up right, the Damage Taken event response only works in combination with a unit takes damage event.

You could explore alternative methods of getting a hero's damage, for example, calculating it yourself, by checking for any damage bonus items/buffs on the unit.
03-27-2006, 08:37 AM#8
MavDoubleGuns
Wow, thats really restrictive. Yea I'm going to have a put a line down for each item lol, their should be a trigger so someone wouldn't have to do that! Thanks again.
03-27-2006, 08:44 AM#9
Anitarf
It's not that hard, just store all the items that give bonus damage into an array, then loop through all item slots and for each one, loop through the array and check if any of those items are in it. Then have another array where you keep the damage bonuses for the items stored in the first array.
03-27-2006, 12:06 PM#10
PipeDream
Anitarf's approach takes time proportional to the number of item types. you can use a hash table to improve this to independence from the number of item types. For example:
Collapse JASS:
//Stash away all the item type bonuses
call StoreInteger(GC(),"itemdamagebonus",I2S(itemid),damagebonus)
//loop through the slots with variable i:
set bonus =  GetStoredInteger(GC(),"itemdamagebonus",I2S(GetItemType(UnitItemInSlot(u,i))))
03-27-2006, 03:15 PM#11
emjlr3
i dont see why not just using my method wouldnt work, it atleast would be a lot less work

for ex.

have a trigger that runs and adds to all units who enter the map the the condition that they take damage

then another trigger that runs when the units take damage, and check if the damaging unit is the one u want to know, if so, get the damage and store it in a global, for use later

granted this isnt MUI, but could be used for different unit types all at once
03-27-2006, 03:29 PM#12
Captain Griffen
Because it is far, far, far less efficient. And less accurate, as the damage takes into account the armour of other targets, not the one he is attacking.
03-27-2006, 04:13 PM#13
emjlr3
true, but less work still