• 🏆 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!

vJass+GUI Attack Indexer 1.1.0.4

This bundle is marked as pending. It has not been reviewed by a staff member yet.
Attack Indexer

A plugin for Damage Engine that lets you know if the unit attacked with their primary or secondary attack (boolean DamageFromPrimaryAttack *new), and lets you know if the target (unit DamageEventTarget *from DamageEngine) is the same unit that the source unit had originally attacked (unit DamageEventAttackTarget *new).

In addition to giving you these details, you also have a way to pass your own custom data from the attack event to the damage event:
  • integer array udg_AttackEventHashKey
    • This readonly array is indexed to the custom value of the attacking unit, and it provides a unique hash integer which relates to the attack that's being executed.
  • integer udg_DamageHashKeyForAttack
    • This readonly event response recovers the hash integer which was generated by the attack event which triggered this damage.
The hash keys generated by Attack Indexer can safely be used as TableArray keys for vJass users, or parent key indices for GUI users who can benefit from the following:
  • hashtable udg_AttackIndexerHash
Attack Indexer will automatically handle the data cleanup for TableArrays and the AttackIndexerHash between attacks, and when the attacking unit has been deindexed. Therefore, as a user, you won't have too much to worry about. The main thing to consider is to avoid conflicts with keys inside of the hash tables, so I recommend using string keys that don't overlap with other systems.

Side Effects
  • Discovered by @Wrda:
    • A unit with splash damage that can hit trees/doodads will play an incorrect sound when the doodad was collateral damage and the attack had launched the 'unit is attacked' event.
  • Remarks from Bribe:
    • A siege unit ordered to 'attack ground' will not register with Attack Indexer whatsoever. The 'attack ground' attack event has no distinct triggering moment, so there isn't a simple solution that can be made to index these attacks.

Requirements/installation
Background
Real, actual attack indexing has been achieved

Please see the demo map / attached screenshots for insights.

Git Repo
Previews
Contents

Attack Indexer Demo Map (Map)

Reviews
Wrda
I got confused for a while why the "missed or attacking too quickly" debug scenario was giving me the value of "1" for point variable when the hashkey for the on attack was 11. It sounded like a bug, but i figured it wasn't later. The weapon type is...
Wrda
I tested with mortar team indeed. It's "on attack". The reason I thought the side effect wasn't a big deal was that I couldn't think of a way that would solve that. I'll just set to "awaiting update" since I've also rushed a bit, and to be fair to the...

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
Update to version 1.1.0.0 and hot-patched with 1.1.0.1:

You now have a way to pass your own custom data from the attack event to the damage event:
  • integer array udg_AttackEventHashKey
    • This readonly array is indexed to the custom value of the attacking unit, and it provides a unique hash integer which relates to the attack that's being executed.
  • integer udg_DamageHashKeyForAttack
    • This readonly event response recovers the hash integer which was generated by the attack event which triggered this damage.
The hash keys generated by Attack Indexer can safely be used as TableArray keys for vJass users, or parent key indices for GUI users who can benefit from the following:
  • hashtable udg_AttackIndexerHash
Attack Indexer will automatically handle the data cleanup for TableArrays and the AttackIndexerHash between attacks, and when the attacking unit has been deindexed. Therefore, as a user, you won't have too much to worry about. The main thing to consider is to avoid conflicts with keys inside of the hash tables, so I recommend using string keys that don't overlap with other systems. Another thing is handles: if you store a Location into the hashtable, Attack Indexer will not remove it. You'd therefore only want to store its x/y coordinates instead of the position object itself.
 
Last edited:

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,888
I got confused for a while why the "missed or attacking too quickly" debug scenario was giving me the value of "1" for point variable when the hashkey for the on attack was 11. It sounded like a bug, but i figured it wasn't later.
The weapon type is pretty smart, although it seems it will be always limited to 12, if I understood it well.
There's a side effect: when using mortar team to attack a unit near the trees, different weapon sounds will be played.

A nice plug-in for the massive DDS, expanding the people's horizons.

At the very least, recommended.
Approved
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
Thank you for the review! I hadn't thought about when trees are hit by the mortar team; that's not a side effect that I want.

I'm going to start testing if seeing the DAMAGE_TYPE will achieve the same results. It won't affect doodads if it works the same, and it will allow me to increase the number of allowed attacks to 13.

Are you sure it wasn't a bug with the point variable? Which unit were you testing that with - the mortar team? The -12th attack index is the one that should display that error, but it's on-attack rather than on-damage.

So if you saw the "on attack" event displaying 11 immediately after the point value "1" was recycled, that is then a bug. But if the damage event showed it, it is not a bug.

Edit: Unfortunately, I can't adjust the damage type on a whim like I can the attack type and weapon type. Whoever was handling the new damage natives must've overlooked it or ran out of time. These are the only properties that can be get/potentially set:
JASS:
    // Unit Weapon
    constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_DAMAGE_NUMBER_OF_DICE     = ConvertUnitWeaponIntegerField('ua1d')
    constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_DAMAGE_BASE               = ConvertUnitWeaponIntegerField('ua1b')
    constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_DAMAGE_SIDES_PER_DIE      = ConvertUnitWeaponIntegerField('ua1s')
    constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_MAXIMUM_NUMBER_OF_TARGETS = ConvertUnitWeaponIntegerField('utc1')
    constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_ATTACK_TYPE               = ConvertUnitWeaponIntegerField('ua1t')
    constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_WEAPON_SOUND              = ConvertUnitWeaponIntegerField('ucs1')
    constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_AREA_OF_EFFECT_TARGETS    = ConvertUnitWeaponIntegerField('ua1p')
    constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED           = ConvertUnitWeaponIntegerField('ua1g')

    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_BACKSWING_POINT              = ConvertUnitWeaponRealField('ubs1')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT                 = ConvertUnitWeaponRealField('udp1')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN                = ConvertUnitWeaponRealField('ua1c')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_LOSS_FACTOR           = ConvertUnitWeaponRealField('udl1')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_FACTOR_MEDIUM         = ConvertUnitWeaponRealField('uhd1')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_FACTOR_SMALL          = ConvertUnitWeaponRealField('uqd1')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_SPILL_DISTANCE        = ConvertUnitWeaponRealField('usd1')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_SPILL_RADIUS          = ConvertUnitWeaponRealField('usr1')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED             = ConvertUnitWeaponRealField('ua1z')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC               = ConvertUnitWeaponRealField('uma1')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_AREA_OF_EFFECT_FULL_DAMAGE   = ConvertUnitWeaponRealField('ua1f')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_AREA_OF_EFFECT_MEDIUM_DAMAGE = ConvertUnitWeaponRealField('ua1h')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_AREA_OF_EFFECT_SMALL_DAMAGE  = ConvertUnitWeaponRealField('ua1q')
    constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_RANGE                        = ConvertUnitWeaponRealField('ua1r')

    constant unitweaponbooleanfield UNIT_WEAPON_BF_ATTACK_SHOW_UI                   = ConvertUnitWeaponBooleanField('uwu1')
    constant unitweaponbooleanfield UNIT_WEAPON_BF_ATTACKS_ENABLED                  = ConvertUnitWeaponBooleanField('uaen')
    constant unitweaponbooleanfield UNIT_WEAPON_BF_ATTACK_PROJECTILE_HOMING_ENABLED = ConvertUnitWeaponBooleanField('umh1')
    
    constant unitweaponstringfield UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART             = ConvertUnitWeaponStringField('ua1m')
 
Last edited:

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,888
I tested with mortar team indeed. It's "on attack".
The reason I thought the side effect wasn't a big deal was that I couldn't think of a way that would solve that.
I'll just set to "awaiting update" since I've also rushed a bit, and to be fair to the rest of the spell section.
If the team mortar's side effect appears to have absolutely no solution, then it's no one's fault.
 

Attachments

  • mortar.png
    mortar.png
    4 MB · Views: 8

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
I can definitely see how that would be confusing. I've updated the demo map and the script to 1.1.0.4 to have the debug message show the hashkey instead of the 'point' integer variable. It now looks like this:

1691076780360.png


The mechanics of the code weren't changed, but this does align the debug message with the other data that the demo map is focused on. The 'point' variable is always a number from 0-11, whereas the hashkey is always a negative number.
 
Can this be used along with animation altering triggers to have a tigger based bash/crit ability play the "Attack Slam" animation like the bash and crit abiilties in the object editor? Especially even on ranged missile attacks? If so maybe add that to the demo map as a sample.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
Can this be used along with animation altering triggers to have a tigger based bash/crit ability play the "Attack Slam" animation like the bash and crit abiilties in the object editor? Especially even on ranged missile attacks? If so maybe add that to the demo map as a sample.
Yes that's one example of how this would be used. I'll add myself a note on GitHub for that.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
Is there sample code for this up yet?
No, I'm spread very thinly these days. Everyone keeps asking me to do a million different things, especially in real life, and I have my own separate million different things I want to work on as well.

If you want to build this, you just do your math-random number if/then/else thing and play the animation and set a boolean property in the AttackIndexer hashtable to 'true' under a unique child key like 'is critical' and use the attack hashkey thing as the parent, and then from the damage event load the attack hashkey/string combo from that same hashtable and follow through with enhancing the damage there.

The attack trigger would look something like:
If random number between 0.00 and 100.00 less than crit chance
- then
-- play attack slam animation
-- save True as "Is Critical" to AttackEventHashKey[(Custom value of (Attacking unit))]
- else
-- remove saved boolean from "Is Critical", AttackEventHashKey[(Custom value of (Attacking unit))]

The PreDamageEvent trigger would look like:
if Load "Is Critical" from DamageHashKeyForAttack Equal to True
- then
-- Set DamageEventAmount = DamageEventAmount x CritMultiplier
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
Can this be integrated safely with this system Accurate Attack Stats & Triggers ?
This system does a bit more than that system by correlating that exact missile from the "attacked" event all the way to the "damaged" events. But Antares's system has more readily available custom-build auras/buffs I think. My Lua version of this features those kinds of things to help detect the launch point, but the outcome is frustratingly inconsistent, such as when "slow" is applied mid-attack.
 
This system does a bit more than that system by correlating that exact missile from the "attacked" event all the way to the "damaged" events. But Antares's system has more readily available custom-build auras/buffs I think. My Lua version of this features those kinds of things to help detect the launch point, but the outcome is frustratingly inconsistent, such as when "slow" is applied mid-attack.
What is the event in this system to detect the moment a missile is launched (attack is successful and not animation-cancelled)? I'm kinda excited to see a system (Jass) that can detect an attack being successful because it has interesting applications.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
What is the event in this system to detect the moment a missile is launched (attack is successful and not animation-cancelled)? I'm kinda excited to see a system (Jass) that can detect an attack being successful because it has interesting applications.
I didn't bother to write that stuff in JASS. I only wrote that part in Lua.

@Spacebuns how can you give me that sad face? It was only through the request of @SpasMaster that this even exists. But I don't agree with a half-assed solution that introduces tons of bugs and requires a ton of unpredictable micro-managing to get installed correctly onto a map.
 
Last edited:
Top