• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Unit attacknig

Status
Not open for further replies.
Level 4
Joined
Jan 5, 2014
Messages
79
Hello, I would like to ask several questions, as the are concernig on theme.

At first I should introduce you the whole problem. I wanted something to happen when a unit is damaged by an attack of another unit. I did something like this:

1) I save via hashtable unit damage point (thats what should be the time between the point when a unit starts attacking and when it actually deals damage) to each unit.

2) When some unit attacks, I save its damage point in hashtable (with the Key being the same unit) and each 0.02 sec decrease it by 0.02. This way i create some kind of pseudo-timer. The action i want to happen when the attacking unit deals damage starts when this trigger reaches zero.

3) If the unit which is attacking is ordered to do anything else than to attack the unit it is already attacking (coz if you order a unit to attack a unit it is already attacking, it will continue rather than start a new attack), the process will be stopped.

My questions:

1) Mabye I got it wrong and the damage point is used for something else. Please tell me if I am right or wrong.

2) My triggers do not work properly. For example if I have a dreadlord (the undead vampire-like hero), I have to set the triggered damage point to be about 0.1 sec shorter than what is set in the Object Editor (I mean: In Object Editor there is 0.55 damage point, but my triggers have to count with about 0.45). The reason for this is, that if I don't make the change, the events when the dreadlord deals damage and when my pseudo-timer countdown ends are not synchronized (the attacked unit is damaged before the trigger triggers). Could you give me some help? I would like to know whats wrong.

3) Another solution would by some other type of timer attached to each unit. I have tried to do so, but could't find a useful event. (I have tried to use timer with array, but i will probably need some more help, coz I failed)

One last word. Please don't tell me to use the Damage detection system. I maybe end with using it, but before I do so, I want to do it on my own.

Edit: New question: Does anyone know the equation how attack speed influences the damage point?
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,378
DDS is the safest choice.

Damage point is time your unit deals damage after the unit starts attacking (=playing the attack animation). Damage point was add to give some sense to attack animations. Just set Damage point to 0 and you will see that the unit damages the target before it starts playing the attack animation - that looks unrealistically as hell.

However I believe damage point is reduced by attack speed (more like Agility for hero) as these reduce cooldown on hero's attacks and it forces the hero to play attack animation faster -> hence Damage Point has to be reduced as well to catch the unit when it lands the blow (in animation).

That's why I wrote DDS is the safest choice. Else you have to keep track of way too many things and that can make your system inefficient.
Right now, you would need to keep track unit's attack speed and damage point. Whenever unit attacks, you would need to load those datas from hashtable and make some serious calculations to get correct time.

Not to mention, this system would be good only for melee attacks, it would completely bug out for ranged attacks with non-instant projectiles.

So to conclude:
Your system won't work with projectiles.
You need to manually save some data for every unit that uses this system.
You need to know how calculations for melee attacks work to correctly calculate time.
Any change to any aspect of this system (e.g. change attack speed bonus per Agility point) will require you to updateyour whole system to this change => a lot of manual work for little gain.
 
Level 4
Joined
Jan 5, 2014
Messages
79
However I believe damage point is reduced by attack speed (more like Agility for hero) as these reduce cooldown on hero's attacks and it forces the hero to play attack animation faster -> hence Damage Point has to be reduced as well to catch the unit when it lands the blow (in animation).

that makes sence. coz when i did the improvement for my system to suit the dreadlord, it stopped working coretly for other nonhero units. that could be, because the agility attackspeed bonus for heroes influences the real damage point, so it differs from the original one in Object Editor

Not to mention, this system would be good only for melee attacks, it would completely bug out for ranged attacks with non-instant projectiles.

I have made workaround for this via dummy units copying the projectile. This makes no problem =)

Edit: I found the reason why I will probably use the DDS. There is no way how to track units current or default attack speed in GUI. Do you know something in JASS (I mean some way, how to get some unit's current attackspeed and default attackspeed) ?
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
I don't, which is why I think it is inefficient - I can think of only one way where you have to store default attack speed in hashtable and for each attack check if unit has buffs that increase attack speed, etc.


Maybe you could try to find some projectile system and look there - maybe the author made it to calculate attack speed.
 
Status
Not open for further replies.
Top