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

A function to return damage of a unit?

Status
Not open for further replies.
Level 2
Joined
Dec 8, 2005
Messages
14
Is there a way to get the base damage of a non-specific unit for calculation purposes? Like a function that returns the base damage of a unit that causes the trigger to run. How about the bonus damage?

To be more specific:
I am working on a trigger that causes a certain unit damage another unit via. "Damage target" action. BUT the actual damage depends on the damage that a third unit is capable to do(the one that made the trigger to run). Also, if that unit has damage bonuses, those should be taken into account as well.

Is it possibble to do? Perhaps with JASS?
 
Level 2
Joined
Dec 8, 2005
Messages
14
Thanks PurplePoot, I see what you mean.
Unfortunately, I cant use that solution, because the third unit won't cause actual damage. Thats why I would need to get the base damage along with the bonuses (from buffs) to calculate with.

Now, I imagine that the idea of a unit attacking, but not causing damage sounds weird... Well, here's my concept:

In my map, units are organized into "squads". The individual squadmembers cannot be ordered separately, instead, each squad has a "squadleader". When the player orders the leader to do something, the whole squad is ordered to do the same.
Now. When a squad enters combat, I want it to take casualties gradually, say one unit in approximately every 5 seconds (the casualty rate would depend on the opponents' strenght of course).
With the base WC3 combat system, units continually take damage, so casualties occur slowly at first, then at the end, many units die in a short period, sometimes almost simulteniously. In other words, casualties are not distributed along time. This is bad, because players cannot really see, who's winning, and order a retreat in time. So I decided to create the following system.

The squadmembers attack each other, but they don't do any damage. Instead, whenever a squadmember attacks, the squadleader damages the enemy squadleader (Damage target action), with the amount of damage the attacking unit would do. When a squadleader has lost a certain percentage of its HP, a trigger kills one squadmember.

I actually have working triggers, but they are rather complex, and they restrict me to have to have squads with a single unit type each (mixed squads would have mixed damage values). It would be much simpler to just get the data every time a unit attacks, put it into a variable, and use it.

So... I guess the answer to my question is no...

Thx for the help anyway!
 
Level 2
Joined
Jan 27, 2006
Messages
10
im having a similar problem, how can i get the GetDamage Event described before? i searched the reals, integers and strings, all i found was
EventResponse Damage Taken
and when i tested it to check if it worked with this trigger:
----------------
Unit - A unit Is attacked
------------------
Game - Display to (All players) for 30.00 seconds the text: ((String((Damagetaken))) + AGaga)
------------------
The resulting message is 0.00 AGaga
is there anyway you can get the damage taken from attacks?
 
Level 2
Joined
Dec 8, 2005
Messages
14
The Warehouse said:
is there anyway you can get the damage taken from attacks?

I have done extensive search on that topic, here's what I found out:

EventResponse Damage Taken refers to Event: takes damage only. That means you can only refer to the damage taken if the trigger has the above event. Otherwise the function returns zero. Since this event can only be used for specific units, it is not a solution to the problem.
The only GUI solution I managed to find about this topic is described here:
http://www.wc3sear.ch/viewtopic.php?p=107517#107517

However, I don't think that is a good solution in case of many units. If you want to display damage for Heros only, it might work for you.
About the function PurplePoot posted above, I believe, it is a JASS function.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
well, i know what you mean, but my solution should still work.

First, detect the fact that the squadleader was attacked.(i hope you know how to do that, bcause i wont be explaining it here)

Second, order the unit attacking the squadleader to, instead of attacking it, attack the dummy that you create with the stats i described above

Third, register when the dummy takes the damage, and use the JASS function GetEventDamage() (you can use custom script for this) and store it to a real variable

Fourth, use DamageTarget( GetAttacker(), (some var u store the squadleader to ), ( your real var ), ATTACK_TYPE_UNIVERSAL, DAMAGE_TYPE_PIERCE )

that should work

and about JASS, learn it. you won't regret it.
 
Status
Not open for further replies.
Top