HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

[script] AttackEvents

10-26-2009, 03:28 AM#1
grim001
AttackEvents provides several attack-related events, as well as the capability for dynamic evasion. In other words, specific attacks can be made to miss, without any chance of other attacks being affected. However, your map must abide by several limitations for it to work properly:
  • You must specify the damage point of all custom unit-types. You will recieve an error message in debug mode if you forgot to specify one.
  • If you edit the damage point of an existing unit-type, you must call SetUnitTypeDamagePoint(unitid, damagepoint) to correct it.
  • If you change the AgiAttackSpeedBonus gameplay constant, you must edit the AgiAttackSpeedBonus configuration constant to the same value.
  • You cannot use any abilities, auras or items that alter the attack speed of units, unless those attack speed changes are triggered using BonusMod.
  • You can still use standard evasion abilities, but OnUnitAttackHit may fire when the attack actually missed.
  • If a unit has two attacks enabled, those attacks should have identical damage points. If they do not, AttackMiss will only work for one of the attacks. Certain units' secondary attacks may not be evadable by default.
  • Units that cannot have active abilities (such as illusions) cannot dodge attacks or have attacks made against them miss.

Two addon libraries have been provided, AttackChance and AttackRatings, which provide completely different APIs for managing units' hit and evasion chances. You can also use AttackEvents to build your own API.

Both AttackChance and AttackEvents can optionally use GetProc to normalize hit/miss streaks. I imagine that most people will want to use AttackChance, since it is easier to understand and matches the way evasion traditionally works. AttackRatings is a completely different approach that treats evasion as a "rating" granting the unit a linear time-to-live increase with each additional point, which is the same way WC3's armor system works.

AttackEvents: requires TimerUtils, optionally requires BonusMod, AutoIndex and AbilityPreload
Expand JASS:

AttackChance: requires AttackEvents, optionally requires GetProc and AutoIndex
Expand JASS:

AttackRatings: requires AttackEvents, optionally requires GetProc and AutoIndex
Expand JASS:
10-26-2009, 03:34 AM#2
Rising_Dusk
You need to link to all libraries you require either optionally or completely.
10-26-2009, 03:43 AM#3
grim001
Yeah, I was working on that while you made that post.
10-26-2009, 04:54 AM#4
fX_
is there any way to detect when a unit attacks in general (even onto destructables and items, and by attack ground)?
or if not generally, then completely?
10-26-2009, 05:14 AM#5
grim001
EVENT_PLAYER_UNIT_ATTACKED and EVENT_PLAYER_UNIT_ATTACKED are the only ways to detect attacks, so there's no way to detect it for non-units.
10-26-2009, 08:35 AM#6
Mr.Malte
Cant you check whether a units current order is 'attack' when it gets an order on any target (event)?
10-26-2009, 09:13 AM#7
Anitarf
Quote:
Originally Posted by Mr.Malte
Cant you check whether a units current order is 'attack' when it gets an order on any target (event)?
Yes, however, there is no guarantee the unit will actually be making an attack right away (since it may not be in range of the target or it's attack may be on cooldown). There is no way to detect subsequent attacks as well.

Edit: GetUnitAttackSpeedFactor seems a bit awkward since for the duration of the attack to be halved the speed would have to be 2.0, not 0.5. Maybe the function should be named GetUnitAttackDurationFactor instead?
10-26-2009, 09:56 AM#8
Viikuna-
So this is like UnitProperties attack module? Looks pretty neat.

You should probably make this support triggered critical strikes too. I believe many people who will use this evasion system, would like to use criticals too, dont you think?

Isnt there any ability that can add 100% miss chance, btw? With this 100% evasion method it is possible for unit to dodge many simultaneous attacks from different attackers, if one of those attackers misses his target.

This probably isnt any real problem in real gameplay situation, though. Its too rare thigny to happen


( Curse could probably be used for adding miss change. I know that it can be casted instantly, even with only one dummy caster, but I havent tested any possible delays between spell casting and unit getting the curse buff. Also some resistance skin and buff removing thingies could probably make it fail, so its not maybe the best option. )
10-26-2009, 10:09 AM#9
grim001
Quote:
Originally Posted by Viikuna-
So this is like UnitProperties attack module?
Well, it lets you make attacks miss and assign miss/evade chances to targets, but that is where the similarities end.

Quote:
Originally Posted by Viikuna-
You should probably make this support triggered critical strikes too.
It is not a do-everything system, critical strikes should be controlled through a damage detection/modification system. It would be possible to write an API similar to AttackChance which lets you assign crit chances to units, but that is kinda trivial and outside the scope of this submission.

Quote:
Originally Posted by Viikuna-
With this 100% evasion method it is possible for unit to dodge many simultaneous attacks from different attackers,
Units don't damage the target at exactly the same time except in rare situations with lots of units attacking the same target. If you get 12 identical archers and tell them to attack the same target, their attacks will not hit the target at the same time, even if they all began firing immediately. If you get 100 archers, it might be possible for attacks to hit at the same time, but at that point it is not really going to affect gameplay at all...

Quote:
Originally Posted by Viikuna-
I know that [curse] can be casted instantly
Even if the spell is cast instantly, it does not affect its target instantly, there would be a problematic 0.0 second delay.
10-26-2009, 10:12 AM#10
Mr.Malte
These things:

Quote:
  • You cannot use any abilities, auras or items that alter the attack speed of units, unless those attack speed changes are triggered using BonusMod.
  • You must specify the damage point of all custom unit-types. You will recieve an error message in debug mode if you forgot to specify one.

Are really bad limitations. I'd have to change lots of stuff of my map, so I will not use this.
10-26-2009, 11:00 AM#11
grim001
Unfortunately there's no other way to do it, so you pretty much have to design your map around this kind of thing from the start. It's best for maps where you trigger most spells to begin with.
10-26-2009, 12:24 PM#12
Viikuna-
Ok, cool.

Although, I think critical attacks should be controlled not through damage detection, but through this kind of systems, because this doesnt only allow you to modify units damage for attack and create a critical texttag, but also allows you to set units critical strike animation and stuff like that.

I know that in wc3 units dont play their critical animation if attack is going to get dodget or misses its target, but it doesnt mean that someone would not need that kind of stuff.

For example, if some archer hero has animation for shooting some critical arrow, he should probably play that animation, even though target dodges the attack few milliseconds later, when arrow misses its target, dont you think?
Its just that only units with critical strike in wc3 are melee guys.
10-26-2009, 12:24 PM#13
Tot
Quote:
Originally Posted by grim001
# You must specify the damage point of all custom unit-types. You will recieve an error message in debug mode if you forgot to specify one.
# If you edit the damage point of an existing unit-type, you must call SetUnitTypeDamagePoint(unitid, damagepoint) to correct it.

a simple gmsi scipt can do all the boring preloading stuff
you've only to execute it everytime you've changed something
10-26-2009, 12:33 PM#14
grim001
Quote:
Originally Posted by Viikuna-
Although, I think critical attacks should be controlled not through damage detection, but through this kind of systems, because this doesnt only allow you to modify units damage for attack and create a critical texttag, but also allows you to set units critical strike animation and stuff like that.
Well, it is possible I will make a script like that in the future, but it would require a damage detection system along with AttackEvents.

Quote:
Originally Posted by Tot
a simple gmsi scipt can do all the boring preloading stuff
you've only to execute it everytime you've changed something
Earth-Fury has been trying to work with some people to make it possible to place GMSI scripts within map code. If that happens I can replace the damage point list with that.
10-26-2009, 12:38 PM#15
Tot
Quote:
Originally Posted by grim001
Earth-Fury has been trying to work with some people to make it possible to place GMSI scripts within map code. If that happens I can replace the damage point list with that.

use script.ini