GUI Damage Engine

User avatar
Enalias
Site Admin
Site Admin
Posts: 200
Joined: Sat Sep 15, 2018 1:57 pm
Reputation: 9
Location: Florida, U.S.A.
Website: http://chaosrealm.co/memberlist.php?mod ... rofile&u=2
Discord: https://discord.gg/BUEZkef
Twitch: https://www.twitch.tv/enalias
Contact:
United States of America

GUI Damage Engine

#1

Post by Enalias » Mon Nov 05, 2018 12:16 pm

GUI Damage Engine
by Bribe

Damage Detection, damage amount modifying (blocking/enhancing/reducing), all in intuitive GUI format that needs no JassHelper.
Trigger
Show
Damage Engine
Events
Game - UnitIndexEvent becomes Equal to 1.00
Game - UnitIndexEvent becomes Equal to 2.00
Conditions
Actions
-------- Copy the Cheat Death Ability from Object Editor into your map and set the following variable respectively: --------
Set DamageBlockingAbility = Cheat Death Ability (+500,000)
-------- - --------
Set DamageTypeSpell = 1
Set DamageTypeDOT = 2
Set DamageTypeRanged = 3
-------- - --------
Custom script: call ExecuteFunc("InitDamageEvent")
Custom script: endfunction
Custom script:
Custom script: function DmgEvFilter takes nothing returns boolean
-------- - --------
-------- The next conditions let you filter out unwanted units. By default, units with Locust will not pass the check. --------
-------- - --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(TempUnit is A structure) Equal to False
Then - Actions
Custom script: return true
Else - Actions
Custom script: return false
Custom script: endfunction
Custom script:
Custom script: function DmgEvRemoveAbilities takes nothing returns nothing
Custom script: local real r
Custom script: loop
Set DmgEvN = (DmgEvN - 1)
Custom script: set r = GetWidgetLife(udg_DmgEvStack[udg_DmgEvN])
Unit - Remove DamageBlockingAbility from DmgEvStack[DmgEvN]
Custom script: call SetWidgetLife(udg_DmgEvStack[udg_DmgEvN], r)
Set DmgEvStack[DmgEvN] = No unit
Custom script: exitwhen udg_DmgEvN == 0
Custom script: endloop
Custom script: endfunction
Custom script:
Custom script: function DmgEvSetVars takes nothing returns nothing
Set DamageEventAmount = (Damage taken)
Set DamageEventSource = (Damage source)
Set DamageEventTarget = (Triggering unit)
Custom script: endfunction
Custom script:
Custom script: function FireDmgEv takes nothing returns nothing
Custom script: local boolean b = GetUnitAbilityLevel(udg_DamageEventTarget, udg_DamageBlockingAbility) > 0
Custom script: local real life = 0
Custom script: local real pain = 0
Custom script: if b then
Custom script: set life = GetWidgetLife(udg_DamageEventTarget)
Unit - Remove DamageBlockingAbility from DamageEventTarget
Custom script: call SetWidgetLife(udg_DamageEventTarget, life)
Custom script: set pain = GetWidgetLife(udg_DamageEventTarget)
Custom script: endif
Set DamageEventPrevAmt = DamageEventAmount
Set DamageEventExplodesUnit = False
Set DamageEventOverride = False
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DamageEventAmount Equal to 0.00
Then - Actions
Set DamageEvent = 2.00
Else - Actions
Set DamageModifierEvent = 1.00
Set DamageEvent = 1.00
Custom script: if b then
Unit - Add DamageBlockingAbility to DamageEventTarget
Custom script: call SetWidgetLife(udg_DamageEventTarget, life + GetWidgetLife(udg_DamageEventTarget) - pain)
Custom script: endif
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DamageEventAmount Not equal to DamageEventPrevAmt
Then - Actions
Set DmgEvLife = ((Life of DamageEventTarget) + (DamageEventPrevAmt - DamageEventAmount))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DamageEventAmount Greater than DamageEventPrevAmt
Then - Actions
Unit - Set life of DamageEventTarget to (Max(0.41, DmgEvLife))
Custom script: if udg_DmgEvLife <= .405 then
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DamageEventExplodesUnit Equal to True
Then - Actions
Unit - Make DamageEventTarget Explode on death
Else - Actions
Trigger - Turn off DamageEventTrigger
Custom script: call UnitDamageTarget(udg_DamageEventSource, udg_DamageEventTarget, 999, false, false, null, null, null)
Trigger - Turn on DamageEventTrigger
Custom script: endif
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Max life of DamageEventTarget) Less than DmgEvLife
Then - Actions
Unit - Add DamageBlockingAbility to DamageEventTarget
Set DmgEvStack[DmgEvN] = DamageEventTarget
Set DmgEvN = (DmgEvN + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DmgEvN Equal to 1
Then - Actions
Custom script: call TimerStart(udg_DmgEvTimer, 0, false, function DmgEvRemoveAbilities)
Else - Actions
Else - Actions
Unit - Set life of DamageEventTarget to DmgEvLife
Else - Actions
Custom script: endfunction
Custom script:
Custom script: function FireRecursiveDmgEv takes nothing returns nothing
Custom script: local real d = udg_DamageEventAmount
Custom script: local unit s = udg_DamageEventSource
Custom script: local unit t = udg_DamageEventTarget
Custom script: local integer ptype = udg_DmgTypPrev
Custom script: local boolean explode = udg_DamageEventExplodesUnit
Custom script: local boolean override = udg_DamageEventOverride
Custom script: local real prev = udg_DamageEventPrevAmt
Custom script: call DmgEvSetVars()
Custom script: if udg_DamageEventTarget != t or udg_DamageEventSource != s or udg_DamageEventAmount != d or udg_DamageEventType != ptype then
Set DamageEvent = 0.00
Set DamageModifierEvent = 0.00
Custom script: call FireDmgEv()
-------- - --------
-------- Delete the next three lines to disable the in-game recursion crash warnings --------
-------- - --------
Custom script: else
Cinematic - Clear the screen of text messages for (All players)
Game - Display to (All players) for 999.00 seconds the text: WARNING: Recursion ...
-------- - --------
Custom script: endif
Custom script: set udg_DamageEventOverride = override
Custom script: set udg_DamageEventExplodesUnit = explode
Custom script: set udg_DamageEventPrevAmt = prev
Custom script: set udg_DmgTypPrev = ptype
Custom script: set udg_DamageEventAmount = d
Custom script: set udg_DamageEventSource = s
Custom script: set udg_DamageEventTarget = t
Custom script: set s = null
Custom script: set t = null
Custom script: endfunction
Custom script:
Custom script: function OnDmgEv takes nothing returns boolean
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DamageEvent Equal to 0.00
Then - Actions
Set DmgTypPrev = DamageEventType
Custom script: call DmgEvSetVars()
Custom script: call FireDmgEv()
Set DamageModifierEvent = 0.00
Set DamageEvent = 0.00
Set DamageEventType = 0
Else - Actions
Custom script: call FireRecursiveDmgEv()
Custom script: return false
Custom script: endfunction
Custom script:
Custom script: function CreateDmgEv takes nothing returns nothing
Custom script: set udg_DamageEventTrigger = CreateTrigger()
Custom script: call TriggerAddCondition(udg_DamageEventTrigger, Filter(function OnDmgEv))
Custom script: endfunction
Custom script:
Custom script: function SetupDmgEv takes nothing returns boolean
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
UnitIndexEvent Equal to 1.00
Then - Actions
Set TempUnit = UDexUnits[UDex]
Custom script: if GetUnitAbilityLevel(udg_TempUnit, 'Aloc') == 0 and DmgEvFilter() then
Set UnitDamageRegistered[UDex] = True
Trigger - Add to DamageEventTrigger the event (Unit - TempUnit Takes damage)
Custom script: endif
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
UnitDamageRegistered[UDex] Equal to True
Then - Actions
Set UnitDamageRegistered[UDex] = False
Set DamageEventsWasted = (DamageEventsWasted + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
DamageEventsWasted Equal to 15
Then - Actions
Set DamageEventsWasted = 0
Custom script: call DestroyTrigger(udg_DamageEventTrigger)
Custom script: call CreateDmgEv()
Set UDex = UDexNext[0]
Custom script: loop
Custom script: exitwhen udg_UDex == 0
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
UnitDamageRegistered[UDex] Equal to True
Then - Actions
Trigger - Add to DamageEventTrigger the event (Unit - UDexUnits[UDex] Takes damage)
Else - Actions
Set UDex = UDexNext[UDex]
Custom script: endloop
Else - Actions
Else - Actions
Custom script: return false
Custom script: endfunction
Custom script:
Custom script: function InitDamageEvent takes nothing returns nothing
Custom script: call CreateDmgEv()
Custom script: call TriggerAddCondition(GetTriggeringTrigger(), Filter(function SetupDmgEv))
Set UnitIndexerEnabled = False
Custom script: set udg_TempUnit = CreateUnit(Player(15), 'uloc', 0, 0, 0)
Set UnitIndexerEnabled = True
Unit - Add DamageBlockingAbility to TempUnit
Unit - Remove TempUnit from the game
Trigger - Run (This trigger) (checking conditions)
How to install
Copy & paste the Unit Indexer trigger into your map (I recommend replacing it if you have an older version of it as it has new features)
Copy & paste the Damage Engine trigger into your map
Copy the Cheat Death Ability from Object Editor, and set it to the variable DamageBlockingAbility.
It's installed

NEW - Users who want to enjoy the features and efficiencies of this system but don't want to edit every spell in their map that uses Weeps' Damage Detection can take advantage of the following:
How to use
Show
Damage Engine lets you detect, amplify, block or nullify damage, and lets you cause special or undetectable damage. Just reference DamageEventAmount/Source/Target, to get the necessary damage event data.


Detect damage: use the event "DamageEvent Equal to 1.00"
Detect zero-damage: use the event "DamageEvent Equal to 2.00"
To change damage before it's dealt: use the event "DamageModifierEvent Equal to 1.00"


Modify DamageEventAmount/ExplodesUnit/Override from a "DamageModifierEvent Equal to 1.00" trigger. To prevent your script's damage stacking with others, include the condition "DamageEventOverride Equal to false".

Likewise, set "DamageEventOverride" to true if you don't want other scripts to stack with it.

If you need to reference the original in-game damage, use the variable "DamageEventPrevAmt".


If you trigger all non-attack damage in the game, you can tell the difference between in-game damage and triggered damage, and you can customize the type of triggered damage as well. You set the variable "DamageEventType" accordingly, <before> triggering the damage.

DamageEventType will be 0 if the damage was dealt in-game or if you didn't set it right before causing the damage. You can create your own special damage types and add them to the list, and/or you can reference the existing ones (DamageTypeSpell/DOT/Ranged).
Notes
This is largely inspired by Weep's GUI Damage Detection Engine and the Damage Event project Nestharus and I worked on. It's built to be a customizable, intuitive, leakless and extensible damage detection engine for people who have no knowledge of JASS.
You do not have the required permissions to view the files attached to this post.

Return to “Systems”

×