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

Damage Engine 5.A.0.0

This bundle is marked as director's cut. It exceeds all expectations and excels in every regard.
Damage Engine

Three GUI Damage systems for the community of The Hive,
Seven vJass Damage systems for the JASS-heads on their pedestals high,
Nine competing Damage systems, doomed to die,
One for Bribe on his dark throne
In the Land of the Hive where the Workshop lies.
One Damage Engine to rule them all, One Damage Engine to find them,
One Damage Engine to bring them all and in cross-compatibility unite them.


Whether you're looking for a simple DDS (Damage Detection System), need to modify damage or even if you want a complex network of damage pre-and post-processing, this resource is for you. Damage Engine is the most adapted DDS in existence to take full advantage of the new damage detection natives, and is constantly evaluated and scrutinized by both the community and myself for performance improvements, bug fixes and new features alike.

What started with humble beginnings to bring a Unit Indexer-based version of DDS to GUI users to improve on the previous standard (at the time it was Weep's GDDS) would eventually evolve to incorporate other aspects of damage systems out there. @looking_for_help had identified an extremely useful technique with negative spell resistance being used to detect spell damage, and for a time his Physical Damage Detection system became the new standard. It wouldn't be until much later when Damage Engine would resurface and use the same technique in order to be more useful for the community.

Fast forward to 2020, and you'll find not only that cross-compatibility with Weep's and LFH's systems are incorporated, but the most popular DDS systems in existence - even vJass ones - are fully supported via stripped-down API wrappers. All of the functionality of prior DDS systems has been infused into Damage Engine 5.7, and as such the transition to a "one size fits all" DDS is complete. I hope you find this to be useful, and I also hope that it will help you in developing your map to be more dynamic what than you had previously thought possible.

Features

Legacy Code & Requirements

How it works

How to install/upgrade

Video Guides

FAQs

Thanks


  • Damage Type, Attack Type, Weapon Type, Armor Type and Defense Type detection and modification to alter/understand the fundamentals of WarCraft 3's damage processing;
  • Access to the view and change the damage amount before and/or after reduction by armor, armor type and shields.
  • Fully cross-compatible with every major DDS - vJass and GUI alike.
  • Correctly distribute/negate Spirit Link damage.
  • Differentiate between Ranged, Melee, Spell or other types of attack.
  • Does not require any Object Editor data nor Unit Indexer.
  • As of 5.4, it is now completely recursion-proof.
  • Other features:
    • Damage Blocking, reducing, amplifying and/or conversion to healing
    • Does not require you to know nor use Jass NewGen Pack nor any custom script
    • Custom DamageType association available to be set before and/or during damage event
    • Detect when multiple targets were hit simultaneously via DamageEventAOE > 1.
    • Detect when the same unit was hit simultaneously by the same source via DamageEventLevel > 1.
  • Detect damage: use the event "OnDamageEventEqual to <any value>". You have access to the following variables for reference:
    • DamageEventSource - the unit dealing the damage
    • DamageEventTarget - the unit receiving the damage
    • DamageEventAmount - the amount of damage the unit will receive
    • DamageEventPrevAmt - the amount of damage prior to being modified by the game engine.
    • DamageEventAttackT - the attack type (Chaos, Spells, Pierce, etc.)
    • DamageEventDamageT - the damage type - for comprehensive info, click here.
    • DamageEventWeaponT - the weapon type determines if an attack plays some kind of sound on attack (ie. Metal Heavy Bash). It is always NONE for spells and almost always NONE for ranged attacks.
    • DamageEventArmorT - the armor type (Flesh, Stone, Ethereal, etc.)
    • DamageEventDefenseT - the defense type (Hero, Fortified, Unarmored, etc.)
    • DamageEventArmorPierced - if DAMAGE_TYPE_NORMAL, how much armor was set to be ignored by the user.
    • IsDamageSpell, IsDamageRanged, IsDamageMelee - determine the source category of damage dealt.
    • IsDamageCode - Determine if the damage was dealt natively or by the user. This can give incorrect readings if the user has not identified to Damage Engine that it is code damage. Therefore I recommend setting NextDamageType prior to dealing damage.
    • DamageEventType - An integer identifier that can be referenced by you for whatever extra differentiation you need. You can also create your own special damage types and add them to the definitions in the Damage Event Config trigger. If you the unit should explode on death by that damage, use a damage type integer less than 0. If you want the damage to ignore all modifications, use DamageTypePure.
  • To change damage before it's processed by the WarCraft 3 engine: use the event "PreDamageEvent Becomes Equal to <any value>". Whether you just want to use one monolithic trigger for all damage modification like I do in the demo map, or use the different modifier events here, is up to you.
  • To interact with damage after it's been factored for armor and resistances, use "ArmorDamageEvent Becomes Equal to <any value>". This is typically useful for custom shields. If you fully block or absorb DamageEventAmount (setting it to 0 or less), this event doesn't run.
  • To set the DamageEventType before dealing triggered Damage, use:
    - Set NextDamageType = DamageTypeWhatever
    - Unit - Cause...
  • You can modify the following variables from a "PreDamageEvent" trigger:
    • DamageEventAmount
    • DamageEventAttackT/DamageT/WeaponT/ArmorT/DefenseT
    • DamageEventArmorPierced
    • DamageEventType
    • DamageEventOverride - You can set this if you want to remind yourself not to modify the damage further. If you use the UNKOWN damage type from a Unit - Damage Target native or set "NextDamageType = DamageTypePure" before that function, damage modification is skipped.
  • To catch a unit the moment before it would die from damage, use LethalDamageEvent Becomes Equal to 1.00. Instead of modifying the DamageEventAmount here, modify LethalDamageHP to let the system know how much life to keep the unit alive with. Or you can just reference that LethalDamageHP value in order to know how much "overkill" damage was dealt.
  • To catch a unit as soon as the damage is applied against its Hit Points, use AfterDamageEvent Equal to 1.00.
  • Usage of the "<Event> becomes EQUAL to <value>" can be extrapolated as per the below:
    • EQUAL works as it always has - will run for any damage.
    • NOT EQUAL only runs for code damage.
    • LESS THAN only runs for damage from attacks but not coded attacks.
    • LESS THAN OR EQUAL only runs for melee attacks but not coded attacks.
    • GREATER THAN OR EQUAL only runs for ranged attacks but not coded attacks.
    • GREATER THAN only runs for Spell damage but not coded spell damage.

  • Damage Engine 5 and higher requires the latest Warcraft 3 patch (currently 1.32).
  • For people who did not update their game to Reforged / have not updated to Reforged yet. Alternatively, adding the below JASS script to the top of the DamageEngine library SHOULD enable it to work too:

    JASS:
    function BlzGetEventIsAttack takes nothing returns boolean
         return BlzGetEventDamageType() == DAMAGE_TYPE_NORMAL
    endfunction
  • I have created a Pastebin for all information pertaining to Damage Engine 3.8, including the link to download it, via: Damage Engine 3.8.0.0 | HIVE.
  • As of 20 June 2020, JNGP users who are still on WarCraft 3 1.26 can benefit from Damage Engine 3A, which integrates many of the design choices added in various stages of Damage Engine 5. This is a special update which only requires the JASS script be replaced (no new GUI variables added). Can be found here: Damage Engine 3A.0.0.0 and 3.8.0.0 | HIVE

1
Unit attacks or casts a spell. The pure damage is assessed at this point - damage dice, evasion, critical strike. There is currently no event to affect or modify these at source.
→ →
2
The projectile or weapon hits the target unit
→ →
3
EVENT_UNIT_DAMAGING is fired before any modifications to the damage are made.
→ ↓
↓ ←
6
User changes to DamageEventAmount and/or to DamageEventDamageT/AttackT/WeaponT are saved into the WC3 engine.
← ←
5
If any recursive damage is detected from any of those events, it is postponed and the current damage will continue first.
← ←
4
Damage Engine deploys the PreDamageEvent
7
WarCraft 3 processes the user damage.
→ →
8
WarCraft 3 then distributes the user damage into Spirit Link (before armor)
→ →
9
WarCraft 3 runs any interrupting events, such as spirit link or defensive damage like Thorns Aura
→ ↓
↓ ←
12
The EVENT_UNIT_DAMAGED event runs. This is the original event we have always had access to. Damage Engine will either keep using the original variables from the DAMAGING event, or if there was Spirit Link/defensive damage it will freshly retrieve the event values from WC3 and only retain DamageEventPrevAmt.
← ←
11
Once any potential recursive WarCraft 3 damage is processed, the armor/mana shield modifications to the damage are performed.
← ←
10
If such events such as Spirit Link were detected, they fire their own EVENT_UNIT_DAMAGING & EVENT_UNIT_DAMAGED, and DamageEngine processes it along the way for the user.
13
If the damage is above zero, ArmorDamageEvent will run. If any recursive damage is detected, it is postponed.
→ →
14
The user can make modification to the damage here with the after-damage amount.
→ →
15
The user can access DamageEventPrevAmount if they want to know the damage amount before user changes/WarCraft 3 changes.
→ ↓
↓ ←
18
The user can specify whether or not to change LethalDamageHP in order to stop the unit from dying.
← ←
17
If the damage is still above zero, check if the damage is lethal. If so, run LethalDamageEvent 1.00. If any recursive damage is detected, it is postponed.
← ←
16
If the user wants the value that DamageEngine used to have with DamageEventPrevAmt (after WarCraft 3 processing but before user changes) they multiply DamageEventPrevAmt x DamageScalingWC3.
19
Once all modification is done, run OnDamageEvent. If any recursive damage is detected, it is postponed.
→ →
20
After a new damage instance is detected, or the 0.00 timer expires, run AfterDamageEvent. If any recursive damage is detected, it is postponed.
→ →
21
Run all potential recursive Unit - Damage Target function calls in chronological order (first in, first out).

How to install Damage Engine:
  1. Use WarCraft 3 Version 1.32
  2. If you're upgrading from 3.8 or prior, please delete the entire "Damage Engine" category from your map.
  3. Copy & Paste the Damage Engine category from the attached map to your own map.
How do I upgrade to the latest Damage Engine?
- Depending on the complexity, you'll either need to re-copy the Damage Engine category or just the Damage Engine script. Generally, you can use this as a guide:

  • Damage Engine _._._.x - only requires copying of the JASS script
  • Damage Engine _._.x._ - generally only needs copying of the JASS script, but read the patch notes in case there are changes you may want to make to your own code in order to utilize the changes.
  • Damage Engine _.x._._ - delete your current Damage Engine category or manually add the missing variables to your Variable Editor, and update your JASS script.
  • Damage Engine x._._._ - this occurs very infrequently. Typically requires changes to the way Damage Engine needs to be installed and used.

Notes about upgrading from Damage Engine 4.0 or prior:
  • Revert any custom Object Editor changes made (such as Life Drain reversal, Spell Damage Reduction inversion, etc).
  • You can safely delete the custom spells "Spell Damage Detection" and "Cheat Death Ability"
  • You can delete the Unit Indexer trigger if you do not use it or would prefer to use a different indexer.
  • You should delete any "Mana Shield fix" or "Finger of Death fix" you may have imported, as well as revert any Object Editor data that was required to make it work, as these are no longer needed.
  • !!!DEPRECATED FEATURE!!! As of 5.4, do not bother to take any recursive damage mitigation - Damage Engine will now handle all of that for you!
  • !!!DEPRECATED FEATURE!!! Do not use "ClearDamageEvent" - it does nothing. Just delete it.
  • !!!DEPRECATED FEATURE!!! Do not use "NextDamageOverride" - set NextDamageType = DamageTypePure instead.
  • !!!CHANGED FEATURE!!! If the system detects code damage and the user did not specify it as any particular DamageEvenType, the system will assign it DamageTypeCode automatically.
  • !!!CHANGED FEATURE!!! DamageModifierEvent 1.00-3.00 now run prior to armor reduction. This enables the user to modify the damage before armor and resistance changes are applied - also before Mana Shield and Anti-Magic shell kick in, so no more need for special triggers.


  • Q: Why am I getting a bunch of 'trigger was disabled' errors when I save my map?
  • A: This issue is not unique to Damage Engine, but to all vJass resources. Blizzard has taken the very confusing decision to make JassHelper 'disabled' by default, meaning that every new map that uses a vJass resource has to manually enable JassHelper. Please see this thread if you want to know where to find the Enable JassHelper option.
    .
  • Q: How can I detect when a unit gets damaged?
  • A: Create a trigger with the event: "Game - Value of Real Variable <DamageEvent> becomes Equal to 1.00".
    • Use the following custom variables to reference the event responses:
      • DamageEventSource - the unit dealing the damage
      • DamageEventTarget - the unit getting damaged
      • DamageEventAmount - how much damage is being dealt
      • DamageEventAttackT - which attack type was used by DamageEventSource to damage DamageEventTarget
      • DamageEventDamageT - which damage type was used to damage the target (ie. UNIVERSAL for ultimate damage, or NORMAL for damage that gets reduced by armor).
      • DamageEventDefenseT - which defense type does the target unit have (ie. Hero, Fortified, Unarmored).
      • DamageEventArmorT - which armor type does the target unit have (ie. Flesh, Ethereal, Stone).
      • DamageEventPrevAmt - what the value of the damage was before being modified by armor, ethereal/item bonuses or user changes.
        .
  • Q: How do I modify the damage that is dealt to a unit?
  • A: Create a trigger with the event: "Game - Value of Real Variable <PreDamageEvent> becomes Equal to <any value>".
    • You can change the following variables to affect the damage that will be dealt:
      • DamageEventAmount - how much damage will be dealt (before armor reductions)
      • DamageEventAttackT - which attack type will be used by DamageEventSource to damage DamageEventTarget
      • DamageEventDamageT - which damage type will be used to damage the target.
      • DamageEventDefenseT - which defense type should the target unit have during this attack.
      • DamageEventArmorT - which armor type should the target unit have during this attack.
      • DamageEventArmorPierced - how much armor value to ignore when dealing this damage (applies to DAMAGE_TYPE_NORMAL only, otherwise all armor is ignored).
        .

  • Q: How do I deal Pure damage to a unit (bypassing armor/skipping user modification)?
  • A: Use the following actions:
    • Set NextDamageType = DamageTypePure
    • Unit - Cause Source to damage Target for Amount using attack type Spells and damage type Universal
      .

  • Q: How do I protect against recursive damage?
  • A: Damage Engine 5.4 and above is completely recursion-proof, using vJass hooks to detect registered Damage Event triggers.
    .

  • Q: I've been using <insert Damage system here>. Can I use those with Damage Engine?
  • A: Better - Damage Engine has integrated cross-compatibility with all other approved Damage systems and even the major ones from outside of Hiveworkhop.
    .

  • Q: Can I cause an attack to 'Miss' its target?
  • A: Kind of. Ranged attacks will still explode on the target, and on-hit effects will still apply, but you can do the following:
    • Use the event "PreDamageEvent becomes Equal to 1.00"
    • Use the following actions:
      • Set DamageEventAmount = 0.00
      • Set DamageEventArmorT = ARMOR_TYPE_NONE
      • Set DamageEventWeaponT = WEAPON_TYPE_NONE
    • Setting the weapon type and armor type to none like the above will stop any on-hit sounds from playing. When the Peasant attacks in the demo map, this is the trick I'm using. Instead of saying "MISSED!" I have the Floating Text saying "FAIL!" because - again - it's not exactly a "miss".

Thank you to Blizzard for continuing to work on this amazing game to give us awesome new natives that have the best possible control over incoming damage. Damage Engine brings that power to GUI. Also, a very special thank you to @KILLCIDE for getting me motivated to start up the 5.0 project in the first place.

Thank you to the users of this system who have helped me mold this project into the stable, powerful form it is in today!

For versions 3.8 and prior:

Thank you @looking_for_help for finding the spell damage detection method used in Damage Engine 3 - it was the greatest find since the undefend bug.

Thanks to Jesus4Lyf and @Nestharus for building the inspiration that originally led me to create DamageEngine.

Thank you Wietlol and looking_for_help for challenging me on this project to integrate solutions to problems I had not been made aware of, such as the importance of an After-Damage Event.

Thanks to @Spellbound for several crucial bug reports.


Damage Engine Config

Damage Engine vJass

Damage Engine Lua

Changelog


  • Damage Engine Config
    • Events
      • Map initialization
      • Game - DamageModifierEvent becomes Greater than 0.00
      • Game - LethalDamageEvent becomes Less than or equal to 0.00
      • Game - DamageEvent becomes Not equal to 0.00
      • Game - AfterDamageEvent becomes Less than 0.00
      • Game - AOEDamageEvent becomes Greater than or equal to 0.00
      • Game - SourceDamageEvent becomes Equal to 0.00
      • Game - PreDamageEvent becomes Equal to 0.00
      • Game - ArmorDamageEvent becomes Equal to 0.00
      • Game - ZeroDamageEvent becomes Equal to 0.00
    • Conditions
    • Actions
      • -------- You can add extra classifications here if you want to differentiate between your triggered damage --------
      • -------- Use DamageTypeExplosive (or any negative value damage type) if you want a unit killed by that damage to explode --------
      • -------- - --------
      • -------- The pre-defined type Code might be set by Damage Engine if Unit - Damage Target is detected and the user didn't define a type of their own. --------
      • -------- "Pure" is especially important because it overrides both the Damage Engine as well as WarCraft 3 damage modification. --------
      • -------- I therefore gave the user "Explosive Pure" in case one wants to combine the functionality of the two. --------
      • -------- - --------
      • Set VariableSet DamageTypePureExplosive = -2
      • Set VariableSet DamageTypeExplosive = -1
      • Set VariableSet DamageTypeCode = 1
      • Set VariableSet DamageTypePure = 2
      • -------- - --------
      • Set VariableSet DamageTypeHeal = 3
      • Set VariableSet DamageTypeBlocked = 4
      • Set VariableSet DamageTypeReduced = 5
      • -------- - --------
      • Set VariableSet DamageTypeCriticalStrike = 6
      • -------- - --------
      • Custom script: call DamageEngine_DebugStr()

BribeFromTheHive/DamageEngine

Lua 1.0.2.3 - Fixed to match adjustment made in vJass version 5.4.2.3.
Lua 1.0.2.2 - Fixed to match adjustment made in vJass version 5.4.2.2.
Lua 1.0.2.1 - Fixed to match adjustment made in vJass version 5.4.2.1.
Lua 1.0.2.0 - Added support for Lua Fast Triggers ([Lua] Ridiculously Fast Triggers). Fixed an issue where the AfterDamageEvent wasn't always timed the correct way like it was in the JASS verion.
Lua 1.0.1.0 - Fixed encapsulation issue and recursion issue with DamageEngine_inception. Now hooks UnitDamageTarget.
Lua 1.0.0.0 - Release based on Damage Engine 5.4.2.0

5.9.0.0 - Added the following clearer event names to make things less confusing for new users:
  • PreDamageEvent - can be used in place of DamageModifierEvent pre-armor modification
  • ArmorDamageEvent - can be used in place of DamageModifierEvent post-armor modification
  • OnDamageEvent - can be used instead of a non-zero DamageEvent
  • ZeroDamageEvent - can be used instead of a zero damage DamageEvent
  • SourceDamageEvent - runs at the same time as AOEDamageEvent, but doesn't need to hit multiple units.
Added "DamageFilterRunChance" - odds for the trigger to BE run (works inversely to DamageFilterFailChance).
Shortened the Configuration trigger so that it focuses primarily on what the user can modify.
Organized all variables into categories to help users better understand what does what.
Installation or updating from a previous version will require re-copying the entire Damage Engine folder.
Updated the demo map's text tag production to include a new custom update for ArcingTextTag, thanks to @Ugabunda and @Kusanagi Kuro.
Side note - the Demo Map's triggers have been heavily cleaned up and will now no longer cause crashes when being imported into a new map.
5.8.0.0 -
  • Added a new functionality to the AOEDamageEvent, which allows it to fire even when only one unit is hit, if the AOEDamageEvent is registered as "Not Equal" instead of "Equal to". This is useful in a very specific scenario where an AfterDamageEvent may not be able to be relied upon to properly deallocate data from a running instance that needs to be able to function when multiple units are hit, but also needs to not fail when only one unit is hit.
  • Added additional filters for GUI users to avoid using trigger conditions in even more scenarios:
    • DamageFilterSource/TargetI (has item)
    • DamageFilterSource/TargetA (has ability)
    • DamageFilterSource/TargetC (has a certain classification, like hero or Tauren)
    • DamageFilterFailChance - odds for the trigger to not be run (ideal for critical strike or evasion)
  • Provided a way for GUI to un-register a Damage Event by setting "RemoveDamageEvent" to true from within their trigger's actions.
  • Moved the CreateTimer/CreateTrigger/CreateGroup calls that had been included in the globals block down to the onInit block as per request of @Ricola3D
  • Minor performance improvements thanks to @BLOKKADE
5.7.1.2 - Fixed an issue with armor penetration sometimes bugging out.
5.7.1.1 - Fixed an issue with the eventFilter not retaining its value during an AOE event. Fixed an issue with eventFilter when USE_MELEE_RANGE was set to false. Both issues reported by @lolreported
5.7.1.0 -
I have fixed several potential points of failure reported by multiple users that stopped Damage Engine from working for the rest of the game. In any case there should no longer be ANY SITUATION where Damage Engine just "stops working", even in ways I can't predict. The most likely issue was with DamageScalingWC3/User having possible 0-division errors.​
Fixed the "configured" issue reported by @lolreported where manual configuration didn't work unless the damage and attack type checks were initialized tto -1.​
In addition to these fixed bugs, I have added several more static ifs so that advanced users have more control over getting rid of features they might not care about.​

5.7.0.3 - Fixed the issue reported by @KitsuneTailsPrower wherein the DamageInterface extension wasn't working. This needed to be fixed both in the Damage Engine source as well as the DamageInterface plugin itself.
5.7.0.2 - Fixed the issue reported by @Wazzz where the armor reduction wasn't taken into consideration. Actually there was a much bigger flaw that I had overlooked that was prompting this.
5.7.0.1 - Improved the logic of the 0 damage event.
5.7.0.0:

  • Usage of the "DamageEvent becomes EQUAL to 1.00" now can be extrapolated further than ever before:
    • EQUAL works as it always has.
    • NOT EQUAL only runs for code damage.
    • LESS THAN only runs for damage from attacks.
    • LESS THAN OR EQUAL only runs for melee attacks.
    • GREATER THAN OR EQUAL only runs for ranged attacks.
    • GREATER THAN only runs for Spell damage.
  • Fully adapted Damage Engine to work with every other major DDS
  • Rewrote the internal script to use vJass structs: Damage and DamageTrigger.
  • Changed some of the vJass API. You can find the API listed in the Damage Engine trigger. Notably:
    • I removed UnitDamageTargetEx. You can replace this with Damage.apply.
      • The reason for this change is because of cross-compatibility. Rising Dusk's IDDS uses a different set of parameters for this function, so I removed it from my library to allow this to work seamlessly.
    • TriggerRegisterDamageEvent -> TriggerRegisterDamageEngine
    • RegisterDamageEvent -> RegisterDamageEngine
      • The reason for the above two changes is, like for UnitDamageTargetEx, because Rising Dusk's IDDS uses them. I don't want to make the same mistake I did with Table's API and preferred to walk back my API choices before things got out of hand again.
  • Various performance tweaks, bug fixes and re-commenting of variables.
  • Recursive damage is now processed more intelligently and possibly be more performance-friendly.
  • Adapted the cross-compatibility libraries for Weep and LFH's systems to use textmacros to insert themselves into Damage Engine (this might have been in the 5.6 update, but these two updates were both tailored to achieve similar goals).
5.6.2.0 - Fixed a bug with Damage modification and laid groundwork for a bunch of optional vJass compatibility addons.
5.6.1.0 - Patchwork on Melee/Ranged detection, recursion tracking. Also added the ability to modify damage from a DamageEvent to make it easier on beginners.
5.6.0.1 - Fixed an issue where the DamageEventType for recursive damage that used NextDamageType would always default to DamageTypeCode.
5.6.0.0
Rewrote a significant amount of the internal code so that struct and GUI syntax both work - and are synchronized with each other. vJass-exclusive users can disable the GUI synchronization if they don't use any GUI damage events in their maps.​
Four new variables must be added to your variable editor:​
  • boolean NextDamageIsAttack
  • boolean NextDamageIsMelee
  • boolean NextDamageIsRanged
  • integer NextDamageWeaponT
Struct syntax should not need too much introduction - Damage.index is the triggering event ID, and the syntax is Damage.index.amount/source/target/etc. To initialize a JASS damage event, use:​
JASS:
function RegisterDamageEvent takes code c, string eventName, real value returns nothing
The string is simplified: "Modifier", "" (for simple DamageEvent), "After", "Lethal", "AOE"​
Finally, a neat QOL improvement is that I have assigned weight to each of the events. When registering an event, you can include numbers different than 1, 2, 3 or 4 (for modification) or just the plain "1" for the others. Now you can set your own sequencing and use 1.5, 3.14 or even -1 to give an even more extreme priority to something. Lower numbers run first, higher ones last.​
5.5.0.0 - Added support for the new native BlzGetEventIsAttack via "IsDamageAttack". Also updated the Config trigger to make importing a bit easier
5.4.2.3 - Fixed a mis-flag of the IsDamageSpell value when not being actual spell damage.
5.4.2.2 - Actually fixed the Cold Arrows issue (division by 0.00001 or something ...somehow... either way, it is fixed).
5.4.2.1 - A fix which should hopefully quell the recent reports of damage events failing in complex situations involving Cold Arrows.
5.4.2.0 - A ton of fixes to repair the issues plaguing Sunken City and anyone else who might be pushing this engine well beyond what I imagined it would be used for. Also added a couple of variables intended to be used to ricochet damage: CONVERTED_ATTACK_TYPE and CONVERTED_DAMAGE_TYPE. Check the demo map for how they can be used in a Unit - Damage Target action.
5.4.1.0 - The "Inception" update. Advanced users can interact with Damage Engine via custom script to set DamageEvent_inception = true to allow their damage to potentially go recursive (to a fixed extent).
5.4.0.1 - Hotfixed that modifiers 2 and 3 weren't running.
5.4.0.0 - By using an innovative approach of hooking TriggerRegisterVariableEvent, I've permanently eliminated all risks of recursion in the engine.
5.3.0.1 - Fixed unexpected behavior with DamageTypePure when it is affected by Anti-Magic Shell or Mana Shield. DamageTypePure now no longer ignores DamageScalingWC3.
5.3.0.0 - Fixed an issue with AfterDamageEvent sometimes being delayed. Added DamageScalingUser to track the ratio of user modified damage, as well as DamageEventArmorPierced which allows the user to define how much armor to ignore when working with DAMAGE_TYPE_NORMAL.
5.2.0.1 - Fixed an issue where with the final unit in a Spirit Link chain or the retaliating damage of Thorns/Carapace would not deploy an AfterDamageEvent. Also fixed an issue where AfterDamageEvent would still fire from DAMAGE_TYPE_UNKNOWN if it was greater than 0. Simply copy over the JASS from this post in order to update your own implementation.
5.2.0.0

  • Now features DamageEventArmorT and DamageEventDefenseT, which pull from the target unit's Object Editor data in order to allow you more complete access to detect and even MODIFY those defenses. Changes must be made in a DamageModifierEvent, and they are reverted as soon as armor is calculated.
  • Re-introduced AfterDamageEvent, which is the moment after the unit's life is changed, but before any recursive damage has run.

5.1.3.1 - Bug fixes and performance improvements. No, really. Fixed an issue with the DAMAGED event running even though it was turned off (who would've guessed that?)
5.1.3.0 - Engine re-tooling to improve accuracy and get Spirit Link/Defensive damage out of hardcoded mode - it will now work even in circumstances I haven't tested for (in case those weren't the only issues). Also fixed the Is Unit Moving resource.
5.1.2.1 - Fixed an issue with Spiked Carapace and Thorns Aura where the melee attacker would not get recorded correctly. This required the same fix as I needed to apply for the initial target in a spirit link chain.
5.1.2.0 - Tweaked recursion and fixed a few bugs. Re-introduced the zero damage event now that patch 1.31.1 brought it back.
5.1.1.1 - Minor tweak to Spirit Link in rare situation.
5.1.1.0 - Fixed issues related to Spirit Link. Now works intuitively as expected.
5.1.0.0 - Crazy improvements - check out the details in "How to upgrade from Damage Engine 4.0 or earlier" and "How to use Damage Engine 5.1"
5.0.0.0 - Oh man. Where do I even start?
  • You can now set/compare DamageEventDamageT, DamageEventAttackT or DamageEventWeaponT
  • No longer needs Unit Indexer nor any custom Object Editor data nor modifications.
  • Requires WarCraft 3 1.31 or higher.
  • Changed vanilla JASS code to vJass to clean up a lot of things such as making certain variables private.
  • Look for more details in "How to upgrade from Damage Engine 4.0 or earlier"

4.0.0.0 - Never officially released, but was the first iteration which used SetEventDamage.
For 3.8.0.0 and prior, see: Damage Engine 3.8.0.0 | HIVE


Cross-Compatibility:

BribeFromTheHive/DamageEngine

Keywords:unit indexer, damage detection, damage event, weep, nestharus, looking_for_help, EVENT_PLAYER_UNIT_DAMAGED, damage engine, spell, physical, EVENT_PLAYER_UNIT_DAMAGED, attacktype, damagetype, weapontype, armortype, defensetype, BlzSetEventDamage
Previews
Contents

Damage Engine Demo Map (Map)

Lua Damage Engine 2.0.0.0 (Map)

Reviews
23:20, 11th Jan 2015, BPower Criticism: On the one hand Damage Engine offers extremely high utility to every spell, system and map maker independent of the coding style ( GUI, JASS, vJass, .... ) on the other hand it's very easy to import and...
Level 6
Joined
Jul 12, 2017
Messages
139
Third, I recommend not using a (Matching conditions) in the pick, instead check the conditions of the group inside an if/else/then block inside the multiple actions of the group pick itself. Refer to said unit as (Picked unit)

Sorry, but I don't quite get what you said, you mean put another if/then/else inside then change the unit group to just unit within 250 of point 1 (with no condition) ?

upload_2019-8-11_15-19-14.png
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Ok you have 383 triggers in your map where you utilize Damage Engine events. That is a ridiculously high number, and my little laptop has an incredibly difficult time navigating it. Your map is absolutely enormous!

You may want to talk to @SpasMaster as what he did for Sunken City's Damage Engine implementation was to split the event drivers into a centralized hub of events.

So instead of having 194 Attribute Based abilities each with their own events, try to lessen the number of total conditions/events by branching your conditions from root events.

A very good starting point is to merge all the duplicate triggers you made with 10 levels so there is just one root trigger per ability and you can use an if/else multiple conditions block to filter out the level-specific stuff. This cuts down on the evaluations significantly and will probably get rid of the lag all on its own.

Again, you investing your time analyzing your code to figure out how you can simplify the logic of your damage processing will go a long way towards both improving efficiency while making code maintenance less of a chore.
 
Level 2
Joined
May 19, 2018
Messages
11
Ok you have 383 triggers in your map where you utilize Damage Engine events. That is a ridiculously high number, and my little laptop has an incredibly difficult time navigating it. Your map is absolutely enormous!

You may want to talk to @SpasMaster as what he did for Sunken City's Damage Engine implementation was to split the event drivers into a centralized hub of events.

So instead of having 194 Attribute Based abilities each with their own events, try to lessen the number of total conditions/events by branching your conditions from root events.

A very good starting point is to merge all the duplicate triggers you made with 10 levels so there is just one root trigger per ability and you can use an if/else multiple conditions block to filter out the level-specific stuff. This cuts down on the evaluations significantly and will probably get rid of the lag all on its own.

Again, you investing your time analyzing your code to figure out how you can simplify the logic of your damage processing will go a long way towards both improving efficiency while making code maintenance less of a chore.
Im currently running 493 DamageEngine events, no lag at all. merged all into one trigger, and using a table/map to the grab EventSources table from that, extremely fast: Promises/Warcraft-Maul-Buildtools
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Im currently running 493 DamageEngine events, no lag at all. merged all into one trigger, and using a table/map to the grab EventSources table from that, extremely fast: Promises/Warcraft-Maul-Buildtools

What I do in Lua Damage Engine is very similar. I use function calls to query the conditions and actions rather than allowing them to open up their own threads and cost performance. Obviously the user structuring their code like you have done can improve even on that performance.
 
Level 6
Joined
Jul 12, 2017
Messages
139
Ok you have 383 triggers in your map where you utilize Damage Engine events. That is a ridiculously high number, and my little laptop has an incredibly difficult time navigating it. Your map is absolutely enormous!

You may want to talk to @SpasMaster as what he did for Sunken City's Damage Engine implementation was to split the event drivers into a centralized hub of events.

So instead of having 194 Attribute Based abilities each with their own events, try to lessen the number of total conditions/events by branching your conditions from root events.

A very good starting point is to merge all the duplicate triggers you made with 10 levels so there is just one root trigger per ability and you can use an if/else multiple conditions block to filter out the level-specific stuff. This cuts down on the evaluations significantly and will probably get rid of the lag all on its own.

Again, you investing your time analyzing your code to figure out how you can simplify the logic of your damage processing will go a long way towards both improving efficiency while making code maintenance less of a chore.

Oh I understand that I need 1 trigger per ability but I don't know how to use if/else multiple conditions block to filter out. Maybe that will really help a out. Can you teach me or give me an example on how to do it though?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Oh I understand that I need 1 trigger per ability but I don't know how to use if/else multiple conditions block to filter out. Maybe that will really help a out. Can you teach me or give me an example on how to do it though?

Basically instead of checking the same conditions multiple times, check the common conditions just once and the only variation in the conditions are what the ability level is.

So instead of checking if the unit is a hero, IsDamageSpell, etc. for each level, just check it once and change your condition blocks within the if/else based on just the level of the ability itself.
 
Level 6
Joined
Jul 12, 2017
Messages
139
  • Terror Aura Mannoroth Test
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsDamageSpell Equal to False
          • (Level of Terror Aura (Mannoroth) for DamageEventSource) Greater than or equal to 1
        • Then - Actions
          • Set NextDamageType = DamageTypePure
          • Set Real1 = (Real((Strength of DamageEventSource (Include bonuses))))
          • Set Point1 = (Position of DamageEventTarget)
          • Set UnitGroup1 = (Units within 250.00 of Point1)
          • Unit Group - Pick every unit in UnitGroup1 and do (Actions)
            • Loop - Actions
              • Unit - Cause DamageEventSource to damage (Picked unit), dealing (((Real((Base Damage of DamageEventSource for weapon index 0))) x 0.50) + (Real1 x (0.50 x (Real((Level of Terror Aura (Mannoroth) for DamageEventSource)))))) damage of attack type Magic and damage type Normal
          • Custom script: call RemoveLocation(udg_Point1)
          • Custom script: call DestroyGroup(udg_UnitGroup1)
        • Else - Actions
Like this?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
  • Terror Aura Mannoroth Test
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsDamageSpell Equal to False
          • (Level of Terror Aura (Mannoroth) for DamageEventSource) Greater than or equal to 1
        • Then - Actions
          • Set NextDamageType = DamageTypePure
          • Set Real1 = (Real((Strength of DamageEventSource (Include bonuses))))
          • Set Point1 = (Position of DamageEventTarget)
          • Set UnitGroup1 = (Units within 250.00 of Point1)
          • Unit Group - Pick every unit in UnitGroup1 and do (Actions)
            • Loop - Actions
              • Unit - Cause DamageEventSource to damage (Picked unit), dealing (((Real((Base Damage of DamageEventSource for weapon index 0))) x 0.50) + (Real1 x (0.50 x (Real((Level of Terror Aura (Mannoroth) for DamageEventSource)))))) damage of attack type Magic and damage type Normal
          • Custom script: call RemoveLocation(udg_Point1)
          • Custom script: call DestroyGroup(udg_UnitGroup1)
        • Else - Actions
Like this?

That's a step in the right direction at least. The if/else blocks give you more control. Basically ask yourself:

How can I avoid duplicating my code so I don't have a bunch of copies of triggers that do very similar things?
 
Level 6
Joined
Jul 12, 2017
Messages
139
Second, I recommend using bj_wantDestroyGroup instead of a custom group variable,

Third, I recommend not using a (Matching conditions) in the pick, instead check the conditions of the group inside an if/else/then block inside the multiple actions of the group pick itself. Refer to said unit as (Picked unit)

I don't understand this. If you said to use set bj_wantDestroyGroup but you also said don't use matching condition, does this mean I have to use 2 unit groups?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
I don't understand this. If you said to use set bj_wantDestroyGroup but you also said don't use matching condition, does this mean I have to use 2 unit groups?

What you did is:

(Units within 250.00 of Point1 matching ...)

What I'm suggesting is:

  • Unit Group - Pick every unit in (Units within 250.00 of Point1) and do (Actions)
    • Loop - Actions
      • Set TempUnit = (Picked unit)
      • If (All conditions are True)
        • (TempUnit belongs to an enemy of (Owner of DamageEventSource)) Equal to True
        • (TempUnit is A structure) Equal to False
        • Then - Actions
          • Unit - Case DamageEventSource to damage TempUnit...
        • Else - Actions
 
Level 6
Joined
Jul 12, 2017
Messages
139
  • Ancient of War Cenarius Damage
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Build Ancient of War (Cenarius)
    • Actions
      • Set Point1 = (Target point of ability being cast)
      • Set Real1 = (Real((Intelligence of (Casting unit) (Include bonuses))))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 350.00 of Point1) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempUnit belongs to an enemy of (Owner of (Casting unit))) Equal to True
              • (TempUnit is alive) Equal to True
              • (TempUnit is A structure) Equal to False
            • Then - Actions
              • Unit - Cause (Casting unit) to damage TempUnit, dealing ((Real1 x (1.50 + (0.50 x (Real((Level of Build Ancient of War (Cenarius) for (Casting unit))))))) + (100.00 x (Real((Level of Build Ancient of War (Cenarius) for (Casting unit)))))) damage of attack type Spells and damage type Normal
              • Special Effect - Create a special effect attached to the origin of TempUnit using Objects\Spawnmodels\NightElf\EntBirthTarget\EntBirthTarget.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
      • Custom script: call RemoveLocation(udg_Point1)
So, it is supposed to be like this?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
  • Ancient of War Cenarius Damage
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Build Ancient of War (Cenarius)
    • Actions
      • Set Point1 = (Target point of ability being cast)
      • Set Real1 = (Real((Intelligence of (Casting unit) (Include bonuses))))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 350.00 of Point1) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempUnit belongs to an enemy of (Owner of (Casting unit))) Equal to True
              • (TempUnit is alive) Equal to True
              • (TempUnit is A structure) Equal to False
            • Then - Actions
              • Unit - Cause (Casting unit) to damage TempUnit, dealing ((Real1 x (1.50 + (0.50 x (Real((Level of Build Ancient of War (Cenarius) for (Casting unit))))))) + (100.00 x (Real((Level of Build Ancient of War (Cenarius) for (Casting unit)))))) damage of attack type Spells and damage type Normal
              • Special Effect - Create a special effect attached to the origin of TempUnit using Objects\Spawnmodels\NightElf\EntBirthTarget\EntBirthTarget.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
      • Custom script: call RemoveLocation(udg_Point1)
So, it is supposed to be like this?
Looks solid!
 

Iph

Iph

Level 2
Joined
Jul 31, 2016
Messages
39
I imported the triggers into a melee map but units periodically lose 1 HP along with the text tag display.

v1.31.1.12164
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
I imported the triggers into a melee map but units periodically lose 1 HP along with the text tag display.

v1.31.1.12164
That's caused by one of the triggers in the demo map. If you only copy over what I've advised to do (the Damage Engine category alone) then you don't run into that problem.
 
I read the whole doc, and also the "SetupEvent" function in your code, but still have a few questions sorry ^^
Here is what I understand of events, but I cannot fill the gaps (in blue)..

Please can you complete and correct if there are mistakes ?

DamageModifierEvent
Equal to:
> 1.00: not null damage will be received, amount not factored, modifiable.
> 2.00: ???
> 3.00: ???
> 4.0: not null damage will be received, amount factored by armor and resistance, modifiable.​
(Do these events all fire sequentially one after another ?)

DamageEvent
Equal to:
> 1.00: not null damage received, not applied yet, not modifiable.
> 2.00: nullified damage received? Code-triggered null damages received? Not modifiable.​

AOEDamageEvent Equal to:
> 1.00: ??? Not modifiable.​

LethalDamageEvent Equal to:
> 1.00: unit is about to die from damages. Possible to cheat death.​

AfterDamageEvent Equal to:
> 1.00: not-null damages have just been applied to hp.​
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
So I have 2 questions
1) What is the difrence between looking_for_help system and yours?
2) I have 1.26 version of wc3. So, I should download 1.0.2.3?

1) Damage Engine 3.8 offers better recursion protection and more control over when events are executed. You also have access to more events. If you were using 5.4.2.3 the differences would be too great to count - essier to list what is similar.

2) Damage Engine 3.8 (linked in the Pastebin) is the one you want.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Is the boolean udg_IsDamageMelee called when the damage is physical damage dealt by a melee unit or physical damage from a melee attack?
A melee attack in all native cases. The only way it would fail is if a unit is ranged, melee and someone modified the Weapon Type (sound) in Object Editor to use a melee sound (this is not an occurrence in standard WC3 though and is almost so unlikely to happen that it's almost not worth mentioning).

Is udg_IsDamageCode called only when damage is dealt by triggers?

In the Lua version, yes, and in cases of recursion with the JASS version, yes, but otherwise the user has to set udg_NextDamageType = something before damaging via triggers.
 
A melee attack in all native cases. The only way it would fail is if a unit is ranged, melee and someone modified the Weapon Type (sound) in Object Editor to use a melee sound (this is not an occurrence in standard WC3 though and is almost so unlikely to happen that it's almost not worth mentioning).



In the Lua version, yes, and in cases of recursion with the JASS version, yes, but otherwise the user has to set udg_NextDamageType = something before damaging via triggers.
So before damaging a target, I set NextDamageType = DamageTypeCode, and the boolean IsDamageCode from another Damage Event trigger will be called for that damage instance?
 
Zero damage event possibly runs twice on 0 damage from single targeted spell?
----------
So I basically have this spell where the Hero shoots a single-target arrow which causes triggered damage and an effect. However, I want the damage and effect to happen only when the arrow hits, so I used the DamageEvent = 2.00 event to detect the instance of the arrow dealing 0 damage before triggering the effect.
  • Knockshot cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to TY - Wind Shot
    • Actions
      • Custom script: local real Sx = GetUnitX(GetTriggerUnit())
      • Custom script: local real Sy = GetUnitY(GetTriggerUnit())
      • Custom script: local unit u = CreateUnit(GetOwningPlayer(GetTriggerUnit()),'ndum',Sx,Sy,GetUnitFacing(GetTriggerUnit()))
      • Custom script: call BJDebugMsg("|cff00ff00"+I2S(GetUnitUserData(u))+"|r is created.")
      • Custom script: call SetUnitScale(u,1.5,1.5,1.5)
      • Custom script: call UnitApplyTimedLife(u,'BTLF',1)
      • Custom script: call UnitAddAbility(u,'Atyg')
      • Custom script: call IssueTargetOrder(u,"thunderbolt",GetSpellTargetUnit())
      • Custom script: set udg_A_KnockShotMaster[GetUnitUserData(u)] = GetTriggerUnit()
      • Custom script: set udg_A_KnockShotLevel[GetUnitUserData(u)] = GetUnitAbilityLevel(GetTriggerUnit(),'Aty3')
  • Knockshot pushback init
    • Events
      • Game - DamageEvent becomes Equal to 2.00
    • Conditions
      • (Level of TY - Windshot Stun for DamageEventSource) Not equal to 0
    • Actions
      • Custom script: local real Sx = GetUnitX(udg_DamageEventSource)
      • Custom script: local real Sy = GetUnitY(udg_DamageEventSource)
      • Custom script: local real Tx = GetUnitX(udg_DamageEventTarget)
      • Custom script: local real Ty = GetUnitY(udg_DamageEventTarget)
      • Custom script: local real DistanceDamage = (0.1+0.05*udg_A_KnockShotLevel[GetUnitUserData(udg_DamageEventSource)])*SquareRoot((Tx-Sx)*(Tx-Sx)+(Ty-Sy)*(Ty-Sy))
      • Custom script: if DistanceDamage > 300 then
      • Custom script: set DistanceDamage = 300
      • Custom script: endif
      • Custom script: set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(udg_DamageEventSource),'ndum',Tx,Ty,Atan2BJ(Ty-Sy,Tx-Sx))
      • Custom script: call BJDebugMsg("|cffffcc00"+I2S(GetUnitUserData(GetLastCreatedUnit()))+"|r is created.")
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Add TY - Windshot Push Movement (Neutral Hostile) to (Last created unit)
      • Unit - Order (Last created unit) to Orc Far Seer - Chain Lightning DamageEventTarget
      • Custom script: call UnitDamageTargetBJ(udg_A_KnockShotMaster[GetUnitUserData(udg_DamageEventSource)],udg_DamageEventTarget,15*udg_A_KnockShotLevel[GetUnitUserData(udg_DamageEventSource)]+DistanceDamage,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC)
The result is thus:
upload_2019-10-17_22-55-25.png

The 1st dummy that casts the stun arrow (green custom value when printed) is created correctly, but the 2nd dummy that causes damage+effect is created twice (yellow custom value when printed), therefore causing double damage and double the effect.

When I use another 0-damage unit target spell like Acid Bomb for the 1st dummy's spell, the issue still happens. When I use a 0-damage AoE like Carrion Swarm for the 1st dummy's spell, the issue doesn't happen.
 

Attachments

  • My project 2.w3x
    3.3 MB · Views: 50
Cause stuns have a 0 event of their own.
Oh wow I didn't know that, thanks
Edit: I tested again with a DamageEventType check, it looks like the DamageEventType for the (Storm Bolt-based) ability return DAMAGE_TYPE_UNKNOWN for both its damage and stun. This goes for both zero damage and above-zero damage Storm Bolt.
  • Knockshot pushback pending
    • Events
      • Game - DamageEvent becomes Equal to 2.00
    • Conditions
      • (Level of TY - Windshot Stun for DamageEventSource) Not equal to 0
    • Actions
      • Custom script: local real Sx = GetUnitX(udg_DamageEventSource)
      • Custom script: local real Sy = GetUnitY(udg_DamageEventSource)
      • Custom script: local real Tx = GetUnitX(udg_DamageEventTarget)
      • Custom script: local real Ty = GetUnitY(udg_DamageEventTarget)
      • Custom script: local real DistanceDamage = (0.1+0.05*udg_A_KnockShotLevel[GetUnitUserData(udg_DamageEventSource)])*SquareRoot((Tx-Sx)*(Tx-Sx)+(Ty-Sy)*(Ty-Sy))
      • Custom script: call BJDebugMsg(I2S(udg_DamageEventType))
      • Custom script: if DistanceDamage > 300 then
      • Custom script: set DistanceDamage = 300
      • Custom script: endif
      • Custom script: set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(udg_DamageEventSource),'ndum',Tx,Ty,Atan2BJ(Ty-Sy,Tx-Sx))
      • Custom script: call BJDebugMsg("|cffffcc00"+I2S(GetUnitUserData(GetLastCreatedUnit()))+"|r is created.")
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Add TY - Windshot Push Movement (Neutral Hostile) to (Last created unit)
      • Unit - Order (Last created unit) to Orc Far Seer - Chain Lightning DamageEventTarget
      • Custom script: call UnitDamageTargetBJ(udg_A_KnockShotMaster[GetUnitUserData(udg_DamageEventSource)],udg_DamageEventTarget,15*udg_A_KnockShotLevel[GetUnitUserData(udg_DamageEventSource)]+DistanceDamage,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC)
upload_2019-10-18_10-24-38.png
 
Last edited:

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Oh wow I didn't know that, thanks
Edit: I tested again with a DamageEventType check, it looks like the DamageEventType for the (Storm Bolt-based) ability return DAMAGE_TYPE_UNKNOWN for both its damage and stun. This goes for both zero damage and above-zero damage Storm Bolt.
  • Knockshot pushback pending
    • Events
      • Game - DamageEvent becomes Equal to 2.00
    • Conditions
      • (Level of TY - Windshot Stun for DamageEventSource) Not equal to 0
    • Actions
      • Custom script: local real Sx = GetUnitX(udg_DamageEventSource)
      • Custom script: local real Sy = GetUnitY(udg_DamageEventSource)
      • Custom script: local real Tx = GetUnitX(udg_DamageEventTarget)
      • Custom script: local real Ty = GetUnitY(udg_DamageEventTarget)
      • Custom script: local real DistanceDamage = (0.1+0.05*udg_A_KnockShotLevel[GetUnitUserData(udg_DamageEventSource)])*SquareRoot((Tx-Sx)*(Tx-Sx)+(Ty-Sy)*(Ty-Sy))
      • Custom script: call BJDebugMsg(I2S(udg_DamageEventType))
      • Custom script: if DistanceDamage > 300 then
      • Custom script: set DistanceDamage = 300
      • Custom script: endif
      • Custom script: set bj_lastCreatedUnit = CreateUnit(GetOwningPlayer(udg_DamageEventSource),'ndum',Tx,Ty,Atan2BJ(Ty-Sy,Tx-Sx))
      • Custom script: call BJDebugMsg("|cffffcc00"+I2S(GetUnitUserData(GetLastCreatedUnit()))+"|r is created.")
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • Unit - Add TY - Windshot Push Movement (Neutral Hostile) to (Last created unit)
      • Unit - Order (Last created unit) to Orc Far Seer - Chain Lightning DamageEventTarget
      • Custom script: call UnitDamageTargetBJ(udg_A_KnockShotMaster[GetUnitUserData(udg_DamageEventSource)],udg_DamageEventTarget,15*udg_A_KnockShotLevel[GetUnitUserData(udg_DamageEventSource)]+DistanceDamage,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC)
View attachment 335462

That's not the damage type. You want DamageEventDamageT. You can also use the DEBUG string arrays that I created to read to you the damage type (like how I do it in the demo map).
 
Level 19
Joined
Aug 16, 2007
Messages
881
I'm currently having an issue making a triggered splash attack for a unit type. The following trigger causes massive lag spikes whenever the unit attacks (and hit a couple of enemies):
  • DamageEvent
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of DamageEventSource) Equal to Splasher
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set TempPoint[0] = (Position of DamageEventSource)
          • Custom script: set udg_TempReal[2] = udg_DamageEventAmount
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 500.00 of TempPoint[0] matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of DamageEventSource)) Equal to True))) and do (Actions)
            • Loop - Actions
              • Custom script: if (UnitAlive(GetEnumUnit()) and GetEnumUnit() != udg_DamageEventTarget) then
              • Set TempPoint[1] = (Position of (Picked unit))
              • Set TempReal[0] = (Distance between TempPoint[0] and TempPoint[1])
              • Custom script: set udg_TempReal[1] = ( udg_TempReal[2] * (0.60 * (1.0 - (udg_TempReal[0] / 500.0))))
              • Unit - Cause DamageEventSource to damage (Picked unit), dealing TempReal[1] damage of attack type Chaos and damage type Normal
              • Custom script: call RemoveLocation(udg_TempPoint[1])
              • Custom script: endif
          • Custom script: call RemoveLocation(udg_TempPoint[0])
          • Trigger - Turn on (This trigger)
        • Else - Actions
Is there another event supposed to be used with an effect like this or any way to make the Damage Engine ignore this?

This trigger causes no lag at all, regardless of how many units are damaged, with Damage Engine enabled:
  • AoEDamageTest
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Set TempPoint[0] = (Position of Dragonspawn 0025 <gen>)
      • Custom script: set udg_TempReal[2] = 150
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 2000.00 of TempPoint[0] matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of Decayed Guardian (Done) 0095 <gen>)) Equal to True))) and do (Actions)
        • Loop - Actions
          • Custom script: if (UnitAlive(GetEnumUnit())) then
          • Set TempPoint[1] = (Position of (Picked unit))
          • Set TempReal[0] = (Distance between TempPoint[0] and TempPoint[1])
          • Custom script: set udg_TempReal[1] = ( udg_TempReal[2] * (0.60 * (1.0 - (udg_TempReal[0] / 500.0))))
          • Unit - Cause Decayed Guardian (Done) 0095 <gen> to damage (Picked unit), dealing TempReal[1] damage of attack type Chaos and damage type Normal
          • Custom script: call RemoveLocation(udg_TempPoint[1])
          • Custom script: endif
      • Custom script: call RemoveLocation(udg_TempPoint[0])
And both triggers are essentially the same, just the event is different.
 
Last edited:
I'm currently having an issue making a triggered splash attack for a unit type. The following trigger causes massive lag spikes whenever the unit attacks (and hit a couple of enemies):
  • DamageEvent
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of DamageEventSource) Equal to Splasher
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set TempPoint[0] = (Position of DamageEventSource)
          • Custom script: set udg_TempReal[2] = udg_DamageEventAmount
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 500.00 of TempPoint[0] matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of DamageEventSource)) Equal to True))) and do (Actions)
            • Loop - Actions
              • Custom script: if (UnitAlive(GetEnumUnit()) and GetEnumUnit() != udg_DamageEventTarget) then
              • Set TempPoint[1] = (Position of (Picked unit))
              • Set TempReal[0] = (Distance between TempPoint[0] and TempPoint[1])
              • Custom script: set udg_TempReal[1] = ( udg_TempReal[2] * (0.60 * (1.0 - (udg_TempReal[0] / 500.0))))
              • Unit - Cause DamageEventSource to damage (Picked unit), dealing TempReal[1] damage of attack type Chaos and damage type Normal
              • Custom script: call RemoveLocation(udg_TempPoint[1])
              • Custom script: endif
          • Custom script: call RemoveLocation(udg_TempPoint[0])
          • Trigger - Turn on (This trigger)
        • Else - Actions
Is there another event supposed to be used with an effect like this or any way to make the Damage Engine ignore this?

This trigger causes no lag at all, regardless of how many units are damaged, with Damage Engine enabled:
  • AoEDamageTest
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Set TempPoint[0] = (Position of Dragonspawn 0025 <gen>)
      • Custom script: set udg_TempReal[2] = 150
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 2000.00 of TempPoint[0] matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of Decayed Guardian (Done) 0095 <gen>)) Equal to True))) and do (Actions)
        • Loop - Actions
          • Custom script: if (UnitAlive(GetEnumUnit())) then
          • Set TempPoint[1] = (Position of (Picked unit))
          • Set TempReal[0] = (Distance between TempPoint[0] and TempPoint[1])
          • Custom script: set udg_TempReal[1] = ( udg_TempReal[2] * (0.60 * (1.0 - (udg_TempReal[0] / 500.0))))
          • Unit - Cause Decayed Guardian (Done) 0095 <gen> to damage (Picked unit), dealing TempReal[1] damage of attack type Chaos and damage type Normal
          • Custom script: call RemoveLocation(udg_TempPoint[1])
          • Custom script: endif
      • Custom script: call RemoveLocation(udg_TempPoint[0])
And both triggers are essentially the same, just the event is different.

:bored: Numerous calls to picked unit instead of storing the picked unit in a variable and a filter function running per unit, plus a distance function (which involves a square root, a relatively costly operation) will slow the trigger down a lot.

AFAIK, this version is supposed to be recursion-safe, so disabling and re-enabling the trigger isn't needed. What could also be problematic is the possibility of other damage triggers interacting with the mini-damage event caused from the unit damage target function. (Probably without DamageOverride or something).
 
Level 19
Joined
Aug 16, 2007
Messages
881
:bored: Numerous calls to picked unit instead of storing the picked unit in a variable and a filter function running per unit, plus a distance function (which involves a square root, a relatively costly operation) will slow the trigger down a lot.

AFAIK, this version is supposed to be recursion-safe, so disabling and re-enabling the trigger isn't needed. What could also be problematic is the possibility of other damage triggers interacting with the mini-damage event caused from the unit damage target function. (Probably without DamageOverride or something).
Yes, it can and will be optimized, this is the first iteration; but this doesn't really answer my question. How come the second trigger causes no lag at all, but the one with the DamageEvent does? The only difference is the event.

I also only use this DamageEvent trigger, no other.
 
:bored: Numerous calls to picked unit instead of storing the picked unit in a variable and a filter function running per unit, plus a distance function (which involves a square root, a relatively costly operation) will slow the trigger down a lot.

AFAIK, this version is supposed to be recursion-safe, so disabling and re-enabling the trigger isn't needed. What could also be problematic is the possibility of other damage triggers interacting with the mini-damage event caused from the unit damage target function. (Probably without DamageOverride or something).
Huh, I didn't know that calling to picked unit a lot can slow the trigger down. But I guess modern computers are not affected much by this problem. As long as we create leakfree functions, we should be mostly fine...
 
Level 19
Joined
Aug 16, 2007
Messages
881
Changing the damage type to Unknown should fix the lag problem.
That didn't solve the problem unfortunately, it still causes heavy stutter every attack.

EDIT: It appears the sutter doesn't start immediately, but after a couple of attacks.

I've attached the map below. The issue is in the "MapGameplay\Towers\TowerAbilities DamageEvent" trigger.
 

Attachments

  • LTWReforged-1.2a.w3x
    259 KB · Views: 38
Last edited:
Level 19
Joined
Aug 16, 2007
Messages
881
Sorry just saw you're using DamageEvent instead of DamageModifierEvent. Switching to DamageModifierEvent should allow that to work more fluidly.
No worries and thanks for the suggestion, but changing the event makes no difference.

I've also noticed my towers stop dealing damage against certain targets after they've killed a couple of creeps and the stutter fades.

Manually changing to another target seems to fix the issue.

EDIT: I think I've found the cause of the stuttering. As soon as the first creep is killed, the lag begins. This is a very weird behaviour and this trigger shouldn't be the cause of this. A possible bug with the engine?
 
Last edited:
Level 19
Joined
Aug 16, 2007
Messages
881
Based on the symptom, I think you need to update your Damage Engine.

The version currently uploaded is pretty bulletproof. I don't see how it could have such an issue like you describe.

Older ones, yeah I get that. I encountered the same problem.
I am using the latest version, Damage Engine 5.4.2.3, unless I've missed a more recent update?

Also worth mentioning, I've made 0 modifications on any code or even the Damage Engine Config trigger.
 
Level 19
Joined
Aug 16, 2007
Messages
881
I am deeply saddened to hear about this. I will look into it tomorrow and download your map.
Thanks. Hopefully it's just an error from my part, but hard to say.

I've tried disabling all other triggers, but that made no difference.

It could just be that my splash trigger is inefficient, but I can't see any other way of making it and either way it's weird my other example works without issues.
 
Level 3
Joined
Aug 29, 2007
Messages
28
Damage Engine causes maps not to load in War3 Reforged (I'm using the latest one, JASS version). The game opens, and right before you're supposed to see the loading screen, you get some warning window but its UI is all broken (you see it in the bottom left of the screen) so you can't really see what it's saying, if you press enter you hear the sound of a button being pressed, and then nothing happens.

I suspect Blizzard changed something in the way Libraries work, if you could take a look, i'd greatly appreciate it.

Quick question, is the LUA version better/faster than the JASS one?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Damage Engine causes maps not to load in War3 Reforged (I'm using the latest one, JASS version). The game opens, and right before you're supposed to see the loading screen, you get some warning window but its UI is all broken (you see it in the bottom left of the screen) so you can't really see what it's saying, if you press enter you hear the sound of a button being pressed, and then nothing happens.

I suspect Blizzard changed something in the way Libraries work, if you could take a look, i'd greatly appreciate it.

Quick question, is the LUA version better/faster than the JASS one?
@MindWorX reported to me that @TriggerHappy found some wonky things with the variable events, which is why this happens. I'm not going to make any changes or experiments myself for the time being, as right now the only solution is to stop using the event altogether.
 
@MindWorX reported to me that @TriggerHappy found some wonky things with the variable events, which is why this happens. I'm not going to make any changes or experiments myself for the time being, as right now the only solution is to stop using the event altogether.

The event should work as long as the registered variable it exists. If the variable doesn't exist, the map won't load.
 
Top