Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
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.)
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:
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).
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:
Use WarCraft 3 Version 1.32
If you're upgrading from 3.8 or prior, please delete the entire "Damage Engine" category from your map.
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. --------
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.
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
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...
Is this possible with this new update to have a Boolean : IsDamageCleave (like the Boolean IsDamageSpell) so we can detect if the damage is a result of cleave or direct attack?
I don't think so, you can't detect damage from a certain spell unless that spell is unique to the damage source, and Cleaving Attack has the same attack type with the main attack.
Maybe he wants a cleave ability that can deal more damage based on a stat ? (for example)
@ssbbssc2 When a unit takes damage
If attacker has your cleave ability
Deal x damage to
And here comes the "hard" part.
You have to select all units in let's say 200 range ? (range of your hero)
After that you have to check which units from that group are in the sight of the attacker (you do that by checking angle).
Depends on what one wants to achieve. Just filtering spell/physical can be done reliable, so if thats the usecase there is no need to recode every spell.
It also depends on the map. I have used damage amount based filters which can work perfectly fine if your map design allows them (which is of course not always possible).
since you've updated this and i've been currently using the old version of your damage engine in my map. So how can I use/update the damage engine in my map while making any errors? Should I copy-paste the triggers?
There's currently an undeclared local issue when copying into a new map. If you're familiar with JASS you can delete that line if it's unused, or just add the ability.
There's currently an undeclared local issue when copying into a new map. If you're familiar with JASS you can delete that line if it's unused, or just add the ability.
Hey @Bribe , I got a recursion error when using the system and I did try to turn off the trigger before dealing damage and turn it back on when finished. But it still happens sometimes. The damaged units get instant death. What should I do?
Well you've got another trigger in your map which might cause it. If you're using the latest Damage Engine then it's definitely another of your triggers. Care to share your map?
I've just realized I was actually using v3.6. I'll try the latest version and see if the problem still exist.
The problem occured when this trigger fired.
Shadow Blade
Events
Game - DamageEvent becomes Equal to 1.00
Conditions
(Level of Shadow Blade for DamageEventSource) Greater than 0
Actions
Set TempPoint = (Position of DamageEventSource)
Set TempPoint2 = (Position of DamageEventTarget)
For each (Integer A) from 1 to (Level of Shadow Blade for DamageEventSource), do (Actions)
Loop - Actions
Set TempPoint3 = (TempPoint2 offset by ((Real((Integer A))) x 100.00) towards (Angle from TempPoint to TempPoint2) degrees)
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units within 128.00 of TempPoint3) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Picked unit) Not equal to DamageEventTarget
((Picked unit) is alive) Equal to True
((Picked unit) belongs to an enemy of (Owner of DamageEventSource)) Equal to True
Then - Actions
Trigger - Turn off (This trigger)
Unit - Cause DamageEventSource to damage (Picked unit), dealing DamageEventAmount damage of attack type Hero and damage type Normal
Trigger - Turn on (This trigger)
Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Undead\CarrionSwarm\CarrionSwarmDamage.mdl
Special Effect - Destroy (Last created special effect)
Hello. I am experiencing 2 problems in my map that I suspect are related to the Damage Engine. Or rather, I am almost 100% sure one of them is, I am not sure if the second one is as well.
First Problem
So, I have a type of Murloc in the map called "Toxic Gill". When this murloc dies, it is supposed to damage nearby enemies (in this case, the players). However, instead of dealing damage, it sometimes heals them. It is not yet clear to me when and how exactly, but based on my observations, ~85% of the time it heals instead of properly dealing damage.
Here are some important notes:
Heroes do get properly damaged by the same Dummy unit called "Player Damager" in other triggers just fine.
Using the same damage parameters (Attack Type - Spells; Damage Type - Normal) in other triggers has not proven problematic.
In general, the system works just fine for anything and everything except in this scenario.
Here is the trigger:
[trigger=""]
Toxic Explosion
Events
Unit - A unit Dies
Conditions
(Unit-type of (Dying unit)) Equal to Mur'gul Toxic-Gill
Actions
Set Generic_Point = (Position of (Dying unit))
Set Generic_Group = (Units within 225.00 of Generic_Point matching (((Owner of (Matching unit)) Equal to Player 1 (Red)) or (((Owner of (Matching unit)) Equal to Player 2 (Blue)) or ((Owner of (Matching unit)) Equal to Player 3 (Teal)))))
Unit Group - Pick every unit in Generic_Group and do (Actions)
Loop - Actions
Unit - Cause Player Damager 0344 <gen> to damage (Picked unit), dealing (90.00 + (0.08 x (Max life of (Picked unit)))) damage of attack type Spells and damage type Normal
Special Effect - Create a special effect at Generic_Point using Objects\Spawnmodels\Demon\DemonLargeDeathExplode\DemonLargeDeathExplode.mdl
Special Effect - Destroy (Last created special effect)
Custom script: call DestroyGroup(udg_Generic_Group)
Custom script: call RemoveLocation(udg_Generic_Point)
[/trigger]
Second Problem
Before I even go into this, I want to say that I am not sure it's even the Damage Engine being problematic here, but since people have suggested it might be, I come here to look for clues. This one might even be somehow related to the first problem? I dunno.
I will not go into details about it here, since I already made a thread with all necessary information here.
I susspect "(Max life of (Picked unit)"
I personally had problems with calculating "SomeReal * MaxLife of unit" using DDS many months ago. There's custom function to get Unit's max life in LFH's DDS for example, but I'm not sure how it works here, in Bribe's DDS.
I susspect "(Max life of (Picked unit)"
I personally had problems with calculating "SomeReal * MaxLife of unit" using DDS many months ago. There's custom function to get Unit's max life in LFH's DDS for example, but I'm not sure how it works here, in Bribe's DDS.
It's not needed to add a custom Max life function because the max life ability is removed almost instantly. However, in case there is some fuckery going on, he can run the trigger Clear Damage Event (checking conditions) before picking all units.
If that fixes the issue, please let me know and I'll add something to damage engine to fix it up.
[trigger=""]
Toxic Explosion
Events
Unit - A unit Dies
Conditions
(Unit-type of (Dying unit)) Equal to Mur'gul Toxic-Gill
Actions
Set Generic_Point = (Position of (Dying unit))
Set Generic_Group = (Units within 225.00 of Generic_Point matching (((Owner of (Matching unit)) Equal to Player 1 (Red)) or (((Owner of (Matching unit)) Equal to Player 2 (Blue)) or ((Owner of (Matching unit)) Equal to Player 3 (Teal)))))
Trigger - Run ClearDamageEvent (checking conditions)
Unit Group - Pick every unit in Generic_Group and do (Actions)
Loop - Actions
Unit - Cause Player Damager 0344 <gen> to damage (Picked unit), dealing (90.00 + (0.08 x (Max life of (Picked unit)))) damage of attack type Spells and damage type Normal
Special Effect - Create a special effect at Generic_Point using Objects\Spawnmodels\Demon\DemonLargeDeathExplode\DemonLargeDeathExplode.mdl
Special Effect - Destroy (Last created special effect)
Custom script: call DestroyGroup(udg_Generic_Group)
Custom script: call RemoveLocation(udg_Generic_Point)
[/trigger]
The bug kept occuring. Here is a video made by one of my players that showcases our test of the bug. We spawn the Toxic Gills with a command and have them fight a Grunt who has no abilities whatsoever. (And yes, the bug does happen to heroes and other units as well). You can clearly see how sometimes the Grunt takes damage and sometimes he is healed:
My recommendation is to debug the Damage amount to check if it's postive or negative before the damage is even applied. If it's consistent, then there's an issue with one of the modifiers which might be flipping it around via a damage event modifier.
I have seen this problem a few times myself, and after about ~40 minutes of testing, it's not due to DamageEventModifier events themselves, but dealing damage during these events.
@SpasMaster I do not know the abilities/spells your heroes have in that footage, and i do not know the trigger architecture of your map and how widespread your DDS useage is, BUT it is likely that it is your abilities causing problems. I messed around with the DDS test map and came back with the following:
I copied your on-death trigger and made Ghouls "explode" when they die. The damage was dealt through a farm NPC (or "Player Damager") and not the ghouls themselves.
There's a normal Naga Sea Witch; she has no abilities whatsoever. None of the triggers on that map will cause her to do extra damage at anytime.
She has a 100% chance to proc a damaging exploding death, meaning the area-damage-upon-death trigger works flawlessly (for her damage).
There's a custom blademaster on the map. He has 3 abilities:
A modified Acid Bomb that has a DamageModifierEvent trigger to cause it to deal 100 damage when a target takes Spell Damage, has the Acid Bomb Debuff and the damage event source is a Blademaster. It ALWAYS causes the area-damage-upon-death to heal targets.
A modified Finger of Death spell that does no damage itself, but is triggered to deal 10.0x the Caster's strength to the target. It ALWAYS causes the area-damage-upon-death to heal targets if it kills a Ghoul.
A custom "Chance on Attack to deal Damage" ability that's DDS based. In the trigger, there's a 30% chance for the Blademaster to deal 100 spell damage to his target when he does physical damage. When this bonus damage kills a Ghoul, it will cause the area damage to instead heal (surprise). IF a ghoul dies by normal damage (e.g. just a regular attack), the area damage happens as intended.
From what i tested, i can say that the problem seems to arise when the "Player Damager" attempts to deal triggereddamage at the same time as something else, such as an active or passive Hero ability.
I thought this was a sound explanation, but then realised it makes no sense... you can always deal multiple instances of triggered damage at the same time across many triggers and it should work fine. So i checked made up situations of damage triggers firing off after various events (attacked, levels up, sells item) but i couldn't replicate the problem EXCEPT when atrigger deals damage when a unit dies (when that unit died from triggered damage).
So then i turned the DDS off completely, and obviously, everything worked.
I made a situation where there were no DDS triggers involved, just simple GUI stuff. When a Crypt Lord levels up, a Dreadlord will deal 500 damage to a random villager in some fences (1-shot). When a Villager dies, the Dreadlord does 500 damage to the Crypt Lord. If all DDS triggers are turned off except for Damage Engine, Damage Engine Config and Unit Indexer, the Crypt Lord will not take damage. If these are turned off, he does.
From my testing i would say that your problem cannot be fixed because the DDS has a problem with units dying, but adding a delay to the damage should fix it
Okay, I haven't really read through everything, but I saw mention of damaging when damage is detected or a spell is cast, etc. This may not solve the issue, but I consider it to be good practice:
Any damage dealt, unless specified, will return a udg_DamageType of zero. You need to check for that specific value in your conditions to prevent infinite loops and if you need to apply damage then, set udg_NextDamageType to something else (maybe create a custom one in Damage Engine Config called Code or Triggered or something like that that you will use for all your triggered damage), deal the damage, then run Trigger - Run ClearDamageEvent (checking conditions).
Additionally, it would be good if you would have only 1 DamageModifierEvent trigger in your map that check for the different parameters that then runs the corresponding trigger. There can sometimes be conflict with two multiple DamageModifierEvents that do two different things, or one may inadvertently activate the other, etc, etc.
Im having trouble getting the explosive damage to work on unit attacks, it only works on spell damage. In addition, certain units such as zombies dont explode.
Unfortunately, judging by the PTR for 1.29, there are a ton of bugs.
Related to your Damage Engine, so far I noticed two things in my map Sunken City:
1) Very soon into the game many effects based off the Damage Engine stop working. Still haven't had the time to test in detail, but for example I had a summoned unit with an ability that states: "Attacks drain mana to deal additional damage". This is done with the Damage Engine and stops working 2 mins into the game. Needless to say, I've had no such issues on the live patch.
2) Floating Text messages appear to act very weirdly and are not centered properly. This could have to do with UI issues.
Generally, my experience on the PTR has been very bug heavy with various issues, but the two I mentioned above are the only ones I noticed so far that could be result of the new patch breaking the Damage Engine in one way or another.
I will be making a bug report post in the patch thread with screenshots and everything, once I gather all bugs I can find and will mention you with those that I, personally, have suspicions could be affecting the Damage Engine.
No reason for any map not to support 1.29, order IDs can be fixed. 1.26 may still have a couple cornercase benefits over live, but that will quickly change.
@Bribe How can I manipulate spell damage output by a spell's ranks? I did it by giving different buffs to each rank and checking them one by one but I wonder if there's a better way?
@Bribe How can I manipulate spell damage output by a spell's ranks? I did it by giving different buffs to each rank and checking them one by one but I wonder if there's a better way?
Oh you mean spell level? You can just check the spell level of the damage event source. You just need one buff per spell type and the rest you can figure out with booleans.
Users of 1.29 please use the following JASS script replacement as a stop-gap solution to the issue with additional players. Please keep in mind this is not using the new SetEventDamage native yet, and that (for some reason) the AOE and Enhanced damage are not working with 1.29:
JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
//===========================================================================
// Damage Engine lets you detect, amplify, block or nullify damage. It even
// lets you detect if the damage was physical or from a spell. Just reference
// DamageEventAmount/Source/Target or the boolean IsDamageSpell, to get the
// necessary damage event data.
//
// - Detect damage: use the event "DamageEvent Equal to 1.00"
// - To change damage before it's dealt: use the event "DamageModifierEvent Equal to 1.00"
// - Detect damage after it was applied, use the event "AfterDamageEvent Equal to 1.00"
// - Detect spell damage: use the condition "IsDamageSpell Equal to True"
// - Detect zero-damage: use the event "DamageEvent Equal to 2.00" (an AfterDamageEvent will not fire for this)
//
// You can specify the DamageEventType before dealing triggered damage. To prevent an already-improbable error, I recommend running the trigger "ClearDamageEvent (Checking Conditions)" after dealing triggered damage from within a damage event:
// - Set NextDamageType = DamageTypeWhatever
// - Unit - Cause...
// - Trigger - Run ClearDamageEvent (Checking Conditions)
//
// You can modify the DamageEventAmount and the DamageEventType from a "DamageModifierEvent Equal to 1.00" trigger.
// - If the amount is modified to negative, it will count as a heal.
// - If the amount is set to 0, no damage will be dealt.
//
// If you need to reference the original in-game damage, use the variable "DamageEventPrevAmt".
//
//===========================================================================
// Programming note about "integer i" and "udg_DmgEvRecursionN": integer i
// ranges from -1 upwards. "udg_DmgEvRecursionN" ranges from 0 upwards.
// "integer i" is always 1 less than "udg_DmgEvRecursionN"
//
function DmgEvResetVars takes nothing returns nothing
local integer i = udg_DmgEvRecursionN - 2
set udg_DmgEvRecursionN = i + 1
if i >= 0 then
set udg_DamageEventPrevAmt = udg_LastDmgPrevAmount[i]
set udg_DamageEventAmount = udg_LastDmgValue[i]
set udg_DamageEventSource = udg_LastDmgSource[i]
set udg_DamageEventTarget = udg_LastDmgTarget[i]
set udg_IsDamageSpell = udg_LastDmgWasSpell[i]
set udg_DamageEventType = udg_LastDmgPrevType[i]
endif
endfunction
function CheckDamagedLifeEvent takes boolean clear returns nothing
if clear then
set udg_NextDamageOverride = false
set udg_NextDamageType = 0
endif
if udg_DmgEvTrig != null then
call DestroyTrigger(udg_DmgEvTrig)
set udg_DmgEvTrig = null
if udg_IsDamageSpell then
call SetWidgetLife(udg_DamageEventTarget, RMaxBJ(udg_LastDamageHP, 0.41))
if udg_LastDamageHP <= 0.405 then
if udg_DamageEventType < 0 then
call SetUnitExploded(udg_DamageEventTarget, true)
endif
//Kill the unit
call DisableTrigger(udg_DamageEventTrigger)
call UnitDamageTarget(udg_DamageEventSource, udg_DamageEventTarget, -999, false, false, null, DAMAGE_TYPE_UNIVERSAL, null)
call EnableTrigger(udg_DamageEventTrigger)
endif
elseif GetUnitAbilityLevel(udg_DamageEventTarget, udg_DamageBlockingAbility) > 0 then
call UnitRemoveAbility(udg_DamageEventTarget, udg_DamageBlockingAbility)
call SetWidgetLife(udg_DamageEventTarget, udg_LastDamageHP)
endif
if udg_DamageEventAmount != 0.00 and not udg_HideDamageFrom[GetUnitUserData(udg_DamageEventSource)] then
set udg_AfterDamageEvent = 0.00
set udg_AfterDamageEvent = 1.00
set udg_AfterDamageEvent = 0.00
endif
call DmgEvResetVars()
endif
endfunction
function DmgEvOnAOEEnd takes nothing returns nothing
if udg_DamageEventAOE > 1 then
set udg_AOEDamageEvent = 0.00
set udg_AOEDamageEvent = 1.00
set udg_AOEDamageEvent = 0.00
set udg_DamageEventAOE = 1
endif
set udg_DamageEventLevel = 1
set udg_EnhancedDamageTarget = null
call GroupClear(udg_DamageEventAOEGroup)
endfunction
function DmgEvOnExpire takes nothing returns nothing
set udg_DmgEvStarted = false
call CheckDamagedLifeEvent(true)
//Reset things so they don't perpetuate for AoE/Level target detection
call DmgEvOnAOEEnd()
set udg_DamageEventTarget = null
set udg_DamageEventSource = null
endfunction
function PreCheckDamagedLifeEvent takes nothing returns boolean
call CheckDamagedLifeEvent(true)
return false
endfunction
function OnUnitDamage takes nothing returns boolean
local boolean override = udg_DamageEventOverride
local integer i
local integer e = udg_DamageEventLevel
local integer a = udg_DamageEventAOE
local string s
local real prevAmount
local real life
local real prevLife
local unit u
local unit f
call CheckDamagedLifeEvent(false) //in case the unit state event failed and the 0.00 second timer hasn't yet expired
set i = udg_DmgEvRecursionN - 1 //Had to be moved here due to false recursion tracking
if i < 0 then
//Added 25 July 2017 to detect AOE damage or multiple single-target damage
set u = udg_DamageEventTarget
set f = udg_DamageEventSource
elseif i < 16 then
set udg_LastDmgPrevAmount[i]= udg_DamageEventPrevAmt
set udg_LastDmgValue[i] = udg_DamageEventAmount
set udg_LastDmgSource[i] = udg_DamageEventSource
set udg_LastDmgTarget[i] = udg_DamageEventTarget
set udg_LastDmgWasSpell[i] = udg_IsDamageSpell
set udg_LastDmgPrevType[i] = udg_DamageEventType
else
set s = "WARNING: Recursion error when dealing damage! Make sure when you deal damage from within a DamageEvent trigger, do it like this:\n\n"
set s = s + "Trigger - Turn off (This Trigger)\n"
set s = s + "Unit - Cause...\n"
set s = s + "Trigger - Turn on (This Trigger)"
//Delete the next couple of lines to disable the in-game recursion crash warnings
call ClearTextMessages()
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 999.00, s)
return false
endif
set udg_DmgEvRecursionN = i + 2
set prevAmount = GetEventDamage()
set udg_DamageEventTarget = GetTriggerUnit()
set udg_DamageEventSource = GetEventDamageSource()
set udg_DamageEventAmount = prevAmount
set udg_DamageEventType = udg_NextDamageType
set udg_NextDamageType = 0
set udg_DamageEventOverride = udg_NextDamageOverride
set udg_NextDamageOverride = false
if i < 0 then
//Added 25 July 2017 to detect AOE damage or multiple single-target damage
if udg_DamageEventType == 0 then
if f == udg_DamageEventSource then
//Source has damaged more than once
if IsUnitInGroup(udg_DamageEventTarget, udg_DamageEventAOEGroup) then
//Added 5 August 2017 to improve tracking of enhanced damage against, say, Pulverize
set udg_DamageEventLevel = udg_DamageEventLevel + 1
set udg_EnhancedDamageTarget = udg_DamageEventTarget
else
//Multiple targets hit by this source - flag as AOE
set udg_DamageEventAOE = udg_DamageEventAOE + 1
endif
else
//New damage source - unflag everything
set u = udg_DamageEventSource
set udg_DamageEventSource = f
call DmgEvOnAOEEnd()
set udg_DamageEventSource = u
endif
call GroupAddUnit(udg_DamageEventAOEGroup, udg_DamageEventTarget)
endif
if not udg_DmgEvStarted then
set udg_DmgEvStarted = true
call TimerStart(udg_DmgEvTimer, 0.00, false, function DmgEvOnExpire)
endif
endif
if prevAmount == 0.00 then
if not udg_HideDamageFrom[GetUnitUserData(udg_DamageEventSource)] then
set udg_DamageEventPrevAmt = 0.00
set udg_DamageEvent = 0.00
set udg_DamageEvent = 2.00
set udg_DamageEvent = 0.00
endif
call DmgEvResetVars()
else
set u = udg_DamageEventTarget
set udg_IsDamageSpell = prevAmount < 0.00
if udg_IsDamageSpell then
set prevAmount = -udg_DamageEventAmount
set life = 1.00
if IsUnitType(u, UNIT_TYPE_ETHEREAL) and not IsUnitType(u, UNIT_TYPE_HERO) then
set life = life*udg_DAMAGE_FACTOR_ETHEREAL //1.67
endif
if GetUnitAbilityLevel(u, 'Aegr') > 0 then
set life = life*udg_DAMAGE_FACTOR_ELUNES //0.80
endif
if udg_DmgEvBracers != 0 and IsUnitType(u, UNIT_TYPE_HERO) then
//Inline of UnitHasItemOfTypeBJ without the potential handle ID leak.
set i = 6
loop
set i = i - 1
if GetItemTypeId(UnitItemInSlot(u, i)) == udg_DmgEvBracers then
set life = life*udg_DAMAGE_FACTOR_BRACERS //0.67
exitwhen true
endif
exitwhen i == 0
endloop
endif
set udg_DamageEventAmount = prevAmount*life
endif
set udg_DamageEventPrevAmt = prevAmount
set udg_DamageModifierEvent = 0.00
if not udg_DamageEventOverride then
set udg_DamageModifierEvent = 1.00
if not udg_DamageEventOverride then
set udg_DamageModifierEvent = 2.00
set udg_DamageModifierEvent = 3.00
endif
endif
set udg_DamageEventOverride = override
if udg_DamageEventAmount > 0.00 then
set udg_DamageModifierEvent = 4.00
endif
set udg_DamageModifierEvent = 0.00
if not udg_HideDamageFrom[GetUnitUserData(udg_DamageEventSource)] then
set udg_DamageEvent = 0.00
set udg_DamageEvent = 1.00
set udg_DamageEvent = 0.00
endif
call CheckDamagedLifeEvent(true) //in case the unit state event failed from a recursive damage event
//All events have run and the damage amount is finalized.
set life = GetWidgetLife(u)
set udg_DmgEvTrig = CreateTrigger()
call TriggerAddCondition(udg_DmgEvTrig, Filter(function PreCheckDamagedLifeEvent))
if not udg_IsDamageSpell then
if udg_DamageEventAmount != prevAmount then
set life = life + prevAmount - udg_DamageEventAmount
if GetUnitState(u, UNIT_STATE_MAX_LIFE) < life then
set udg_LastDamageHP = life - prevAmount
call UnitAddAbility(u, udg_DamageBlockingAbility)
endif
call SetWidgetLife(u, RMaxBJ(life, 0.42))
endif
call TriggerRegisterUnitStateEvent(udg_DmgEvTrig, u, UNIT_STATE_LIFE, LESS_THAN, RMaxBJ(0.41, life - prevAmount/2.00))
else
set udg_LastDamageHP = GetUnitState(u, UNIT_STATE_MAX_LIFE)
set prevLife = life
if life + prevAmount*0.75 > udg_LastDamageHP then
set life = RMaxBJ(udg_LastDamageHP - prevAmount/2.00, 1.00)
call SetWidgetLife(u, life)
set life = (life + udg_LastDamageHP)/2.00
else
set life = life + prevAmount*0.50
endif
set udg_LastDamageHP = prevLife - (prevAmount - (prevAmount - udg_DamageEventAmount))
call TriggerRegisterUnitStateEvent(udg_DmgEvTrig, u, UNIT_STATE_LIFE, GREATER_THAN, life)
endif
endif
set u = null
set f = null
return false
endfunction
function CreateDmgEvTrg takes nothing returns nothing
set udg_DamageEventTrigger = CreateTrigger()
call TriggerAddCondition(udg_DamageEventTrigger, Filter(function OnUnitDamage))
endfunction
function SetupDmgEv takes nothing returns boolean
local integer i = udg_UDex
local unit u
if udg_UnitIndexEvent == 1.00 then
set u = udg_UDexUnits[i]
if GetUnitAbilityLevel(u, 'Aloc') == 0 and TriggerEvaluate(gg_trg_Damage_Engine_Config) then
set udg_UnitDamageRegistered[i] = true
call TriggerRegisterUnitEvent(udg_DamageEventTrigger, u, EVENT_UNIT_DAMAGED)
call UnitAddAbility(u, udg_SpellDamageAbility)
call UnitMakeAbilityPermanent(u, true, udg_SpellDamageAbility)
endif
set u = null
else
set udg_HideDamageFrom[i] = false
if udg_UnitDamageRegistered[i] then
set udg_UnitDamageRegistered[i] = false
set udg_DamageEventsWasted = udg_DamageEventsWasted + 1
if udg_DamageEventsWasted == 32 then //After 32 registered units have been removed...
set udg_DamageEventsWasted = 0
//Rebuild the mass EVENT_UNIT_DAMAGED trigger:
call DestroyTrigger(udg_DamageEventTrigger)
call CreateDmgEvTrg()
set i = udg_UDexNext[0]
loop
exitwhen i == 0
if udg_UnitDamageRegistered[i] then
call TriggerRegisterUnitEvent(udg_DamageEventTrigger, udg_UDexUnits[i], EVENT_UNIT_DAMAGED)
endif
set i = udg_UDexNext[i]
endloop
endif
endif
endif
return false
endfunction
//===========================================================================
function InitTrig_Damage_Engine takes nothing returns nothing
local unit u = CreateUnit(Player(bj_PLAYER_NEUTRAL_EXTRA), 'uloc', 0, 0, 0)
local integer i = bj_MAX_PLAYERS //Fixed in 3.8
//Create this trigger with UnitIndexEvents in order add and remove units
//as they are created or removed.
local trigger t = CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 1.00)
call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 2.00)
call TriggerAddCondition(t, Filter(function SetupDmgEv))
set t = null
//Run the configuration trigger to set all configurables:
if gg_trg_Damage_Engine_Config == null then
//It's possible this InitTrig_ function ran first, in which case use ExecuteFunc.
call ExecuteFunc("Trig_Damage_Engine_Config_Actions")
else
call TriggerExecute(gg_trg_Damage_Engine_Config)
endif
//Create trigger for storing all EVENT_UNIT_DAMAGED events.
call CreateDmgEvTrg()
//Create GUI-friendly trigger for cleaning up after UnitDamageTarget.
set udg_ClearDamageEvent = CreateTrigger()
call TriggerAddCondition(udg_ClearDamageEvent, Filter(function PreCheckDamagedLifeEvent))
//Disable SpellDamageAbility for every player.
loop
set i = i - 1
call SetPlayerAbilityAvailable(Player(i), udg_SpellDamageAbility, false)
exitwhen i == 0
endloop
//Preload abilities.
call UnitAddAbility(u, udg_DamageBlockingAbility)
call UnitAddAbility(u, udg_SpellDamageAbility)
call RemoveUnit(u)
set u = null
endfunction
so, does this engine support negative or positive changes in health less then or equal to +1/-1 yet?
as in, if a units regeneration is 1 health, or a units damage is 1 damage, does it still not register that? last I remembered it didn't. but it has been a while.
in a map with smaller numbers, it kind of matters. it did to me any way.
regardless its nice to see updates to it even after all these years.
so, does this engine support negative or positive changes in health less then or equal to +1/-1 yet?
as in, if a units regeneration is 1 health, or a units damage is 1 damage, does it still not register that? last I remembered it didn't. but it has been a while.
in a map with smaller numbers, it kind of matters. it did to me any way.
regardless its nice to see updates to it even after all these years.
Does WarCraft 3 detect the original damage? If so, then yes this system would understand what to do. I'm not 100% sure I understand the issue you are describing.
ah don't worry about it, long ago implementing this exact system (but in like 2015?/2016?) I found it did not show floating text (at that time) for negative -1 regeneration, which was simpler to me to use instead of any kind of self damaging aura or damage spell, it simply showed nothing. but you could watch the health go down 1 per second, in the portrait ui area, it just never made any floating text to see. when increased to 2 damage, little red 2's and green 2's would appear, and you could watch the health go down in the portrait ui area, but it would never show any number lower then that. (2)
I asked trigger editors everywhere why this system's floating text didn't work for negative 1 regeneration, but no body really knew why. I never really solved it.
but now floating text is built into sc2, its so awesome.
any way, I was just curious for nostalgia reasons as to if that bug had been fixed yet.
The only plausible explanation I have to what you've identified is that WC3 doesn't trigger a damage event for such small fluctuations in regeneration. But why use a Damage Event plus regeneration to achieve thay when you can just trigger the regeneration and equally the floating text value?
I think the flaws of Runed Bracers can be resolved if you just modify the Defend ability in the Unit Event trigger such that the damage absorbed is negative for spells.
I think the flaws of Runed Bracers can be resolved if you just modify the Defend ability in the Unit Event trigger such that the damage absorbed is negative for spells.
I think the flaws of Runed Bracers can be resolved if you just modify the Defend ability in the Unit Event trigger such that the damage absorbed is negative for spells.
The issue is unchanged. Defend would have the same effect, because it flips the damage negative. Then Runed Bracers or another Defend or Elunes Grace screws it back to defaults.
Ahh, but that is the reason why I suggested using the Defend ability. Unlike Runed Bracers, which causes spell damage reduction to not stack, the Defend ability permits said behavior.
Suppose one carries a Runed bracers item. With the runed bracers ability, the damage reduction will have to be triggered. With defend ability, the damage reduction will be handled by the game.
The restrictions of having Runed Bracers ability as the spell detector ability are such that one will have to trigger all spell damage reduction. With Defend ability, the only restriction is not to have another ability that flips the damage back to being positive.
It requires the Defend ability to be enabled which screws with any other Defend that's in use. Also multiple Runed Bracers don't stack with each other so the best solution is to trigger spell damage reduction that one wants stacked.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.