1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  5. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Do you have good ideas for new contests? If so, please open new threads in the Contest Submission sub-forum to discuss them.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Trigger Viewer

Bone Armor v1.17.w3x
Variables
Bone Armor (Everything in this folder is required!)
Damage Engine
Damage Engine Config
Damage Engine
Vars
Armor Types
Attack Types
Damage Types
Defense Types
Weapon Types
Bone Armor
Import Instructions
BAmr Config
BAmr Cast
BAmr Block
BAmr Periodic
Bone Armor Variables
Not Required
Triggers unique to this map
Check Shield Value
Commands
Selection
Options
Death
View
DOTD Loop
TUTTM Variables
//TESH.scrollpos=0
//TESH.alwaysfold=0
Name Type Is Array Initial Value
AfterDamageEvent real No
AOEDamageEvent real No
AOEDamageSource unit No
ARMOR_TYPE_ETHEREAL integer No
ARMOR_TYPE_FLESH integer No
ARMOR_TYPE_METAL integer No
ARMOR_TYPE_NONE integer No
ARMOR_TYPE_STONE integer No
ARMOR_TYPE_WOOD integer No
ArmorTypeDebugStr string Yes
ATTACK_TYPE_CHAOS integer No
ATTACK_TYPE_HERO integer No
ATTACK_TYPE_MAGIC integer No
ATTACK_TYPE_NORMAL integer No
ATTACK_TYPE_PIERCE integer No
ATTACK_TYPE_SIEGE integer No
ATTACK_TYPE_SPELLS integer No
AttackTypeDebugStr string Yes
BAmr_Attribute real Yes
BAmr_Boolean boolean Yes
BAmr_Config_ABSORBTION real No
BAmr_Config_ATT_BONUS real Yes
BAmr_Config_BASE_HP real No
BAmr_Config_BUFF buffcode No
BAmr_Config_FLAVOR integer No
BAmr_Config_FLAVOR_PATH string Yes
BAmr_Config_LVL_HP_BONUS real Yes
BAmr_Config_PERIODIC real No
BAmr_Config_RESIST_PHYSICAL real No
BAmr_Config_RESIST_SPELL real No
BAmr_Config_SEG_VALUE real Yes
BAmr_Config_SEGMENT_SPAWNED integer No
BAmr_Config_SPEF effect No
BAmr_Config_SPEF_PATH string Yes
BAmr_Config_SPEF_VALUE real Yes
BAmr_Config_SPELL_ID abilcode No
BAmr_Current_Rot_Speed real Yes
BAmr_DMG_Event real No
BAmr_Enchanted_Unit unit Yes
BAmr_Health real Yes
BAmr_Index integer No
BAmr_Loop integer No
BAmr_Loop_Segment integer No
BAmr_Max real Yes
BAmr_Point location Yes
BAmr_Real real Yes
BAmr_Seg_CValue integer No
BAmr_Seg_CValue_DeIndex integer No
BAmr_Segment_Missile effect Yes
BAmr_Segment_Missile_State string Yes
BAmr_Spef_Current_Height real Yes
BAmr_Total real Yes
BAmr_Unit unit Yes
CONVERTED_ATTACK_TYPE attacktype Yes
CONVERTED_DAMAGE_TYPE damagetype Yes
DAMAGE_TYPE_ACID integer No
DAMAGE_TYPE_COLD integer No
DAMAGE_TYPE_DEATH integer No
DAMAGE_TYPE_DEFENSIVE integer No
DAMAGE_TYPE_DEMOLITION integer No
DAMAGE_TYPE_DISEASE integer No
DAMAGE_TYPE_DIVINE integer No
DAMAGE_TYPE_ENHANCED integer No
DAMAGE_TYPE_FIRE integer No
DAMAGE_TYPE_FORCE integer No
DAMAGE_TYPE_LIGHTNING integer No
DAMAGE_TYPE_MAGIC integer No
DAMAGE_TYPE_MIND integer No
DAMAGE_TYPE_NORMAL integer No
DAMAGE_TYPE_PLANT integer No
DAMAGE_TYPE_POISON integer No
DAMAGE_TYPE_SHADOW_STRIKE integer No
DAMAGE_TYPE_SLOW_POISON integer No
DAMAGE_TYPE_SONIC integer No
DAMAGE_TYPE_SPIRIT_LINK integer No
DAMAGE_TYPE_UNIVERSAL integer No
DAMAGE_TYPE_UNKNOWN integer No
DamageEvent real No
DamageEventAmount real No
DamageEventAOE integer No
DamageEventAOEGroup group No
DamageEventArmorPierced real No
DamageEventArmorT integer No
DamageEventAttackT integer No
DamageEventDamageT integer No
DamageEventDefenseT integer No
DamageEventLevel integer No
DamageEventOverride boolean No
DamageEventPrevAmt real No
DamageEventSource unit No
DamageEventTarget unit No
DamageEventTrigger trigger No
DamageEventType integer No
DamageEventWeaponT integer No
DamageModifierEvent real No
DamageScalingUser real No
DamageScalingWC3 real No
DamageTypeBlocked integer No
DamageTypeCode integer No
DamageTypeCriticalStrike integer No
DamageTypeDebugStr string Yes
DamageTypeExplosive integer No
DamageTypeHeal integer No
DamageTypePure integer No
DamageTypePureExplosive integer No
DamageTypeReduced integer No
DamageTypeReduced_Copy integer No
DEFENSE_TYPE_DIVINE integer No
DEFENSE_TYPE_FORTIFIED integer No
DEFENSE_TYPE_HEAVY integer No
DEFENSE_TYPE_HERO integer No
DEFENSE_TYPE_LIGHT integer No
DEFENSE_TYPE_MEDIUM integer No
DEFENSE_TYPE_NORMAL integer No
DEFENSE_TYPE_UNARMORED integer No
DefenseTypeDebugStr string Yes
DmgEvQueued boolean No
EnhancedDamageTarget unit No
IsDamageCode boolean No
IsDamageMelee boolean No
IsDamageRanged boolean No
IsDamageSpell boolean No
LethalDamageEvent real No
LethalDamageHP real No
NextDamageType integer No
TPoint location Yes
WEAPON_TYPE_AM_CHOP integer No
WEAPON_TYPE_CH_SLICE integer No
WEAPON_TYPE_CL_SLICE integer No
WEAPON_TYPE_CM_SLICE integer No
WEAPON_TYPE_MH_BASH integer No
WEAPON_TYPE_MH_CHOP integer No
WEAPON_TYPE_MH_SLICE integer No
WEAPON_TYPE_MH_STAB integer No
WEAPON_TYPE_ML_CHOP integer No
WEAPON_TYPE_ML_SLICE integer No
WEAPON_TYPE_MM_BASH integer No
WEAPON_TYPE_MM_CHOP integer No
WEAPON_TYPE_MM_SLICE integer No
WEAPON_TYPE_MM_STAB integer No
WEAPON_TYPE_NONE integer No
WEAPON_TYPE_RH_BASH integer No
WEAPON_TYPE_WH_BASH integer No
WEAPON_TYPE_WH_SLICE integer No
WEAPON_TYPE_WL_BASH integer No
WEAPON_TYPE_WL_SLICE integer No
WEAPON_TYPE_WL_STAB integer No
WEAPON_TYPE_WM_BASH integer No
WEAPON_TYPE_WM_SLICE integer No
WEAPON_TYPE_WM_STAB integer No
WeaponTypeDebugStr string Yes
ZZZ_NtRq_Spite boolean No
ZZZ_NtRq_Split boolean No
ZZZ_NtRq_Zombie boolean No
Damage Engine Config
  Events
    Map initialization
  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
    -------- - --------
    -------- Added 25 July 2017 to allow detection of things like Bash or Pulverize or AOE spread --------
    -------- - --------
    Set VariableSet DamageEventAOE = 1
    Set VariableSet DamageEventLevel = 1
    -------- - --------
    -------- In-game World Editor doesn't allow Attack Type and Damage Type comparisons. Therefore I need to code them as integers into GUI --------
    -------- - --------
    Set VariableSet ATTACK_TYPE_SPELLS = 0
    Set VariableSet ATTACK_TYPE_NORMAL = 1
    Set VariableSet ATTACK_TYPE_PIERCE = 2
    Set VariableSet ATTACK_TYPE_SIEGE = 3
    Set VariableSet ATTACK_TYPE_MAGIC = 4
    Set VariableSet ATTACK_TYPE_CHAOS = 5
    Set VariableSet ATTACK_TYPE_HERO = 6
    -------- - --------
    Set VariableSet DAMAGE_TYPE_UNKNOWN = 0
    Set VariableSet DAMAGE_TYPE_NORMAL = 4
    Set VariableSet DAMAGE_TYPE_ENHANCED = 5
    Set VariableSet DAMAGE_TYPE_FIRE = 8
    Set VariableSet DAMAGE_TYPE_COLD = 9
    Set VariableSet DAMAGE_TYPE_LIGHTNING = 10
    Set VariableSet DAMAGE_TYPE_POISON = 11
    Set VariableSet DAMAGE_TYPE_DISEASE = 12
    Set VariableSet DAMAGE_TYPE_DIVINE = 13
    Set VariableSet DAMAGE_TYPE_MAGIC = 14
    Set VariableSet DAMAGE_TYPE_SONIC = 15
    Set VariableSet DAMAGE_TYPE_ACID = 16
    Set VariableSet DAMAGE_TYPE_FORCE = 17
    Set VariableSet DAMAGE_TYPE_DEATH = 18
    Set VariableSet DAMAGE_TYPE_MIND = 19
    Set VariableSet DAMAGE_TYPE_PLANT = 20
    Set VariableSet DAMAGE_TYPE_DEFENSIVE = 21
    Set VariableSet DAMAGE_TYPE_DEMOLITION = 22
    Set VariableSet DAMAGE_TYPE_SLOW_POISON = 23
    Set VariableSet DAMAGE_TYPE_SPIRIT_LINK = 24
    Set VariableSet DAMAGE_TYPE_SHADOW_STRIKE = 25
    Set VariableSet DAMAGE_TYPE_UNIVERSAL = 26
    -------- - --------
    -------- The below variables don't affect damage amount, but do affect the sound played --------
    -------- They also give important information about the type of attack used. --------
    -------- They can differentiate between ranged and melee for units who are both --------
    -------- - --------
    Set VariableSet WEAPON_TYPE_NONE = 0
    -------- Metal Light/Medium/Heavy --------
    Set VariableSet WEAPON_TYPE_ML_CHOP = 1
    Set VariableSet WEAPON_TYPE_MM_CHOP = 2
    Set VariableSet WEAPON_TYPE_MH_CHOP = 3
    Set VariableSet WEAPON_TYPE_ML_SLICE = 4
    Set VariableSet WEAPON_TYPE_MM_SLICE = 5
    Set VariableSet WEAPON_TYPE_MH_SLICE = 6
    Set VariableSet WEAPON_TYPE_MM_BASH = 7
    Set VariableSet WEAPON_TYPE_MH_BASH = 8
    Set VariableSet WEAPON_TYPE_MM_STAB = 9
    Set VariableSet WEAPON_TYPE_MH_STAB = 10
    -------- Wood Light/Medium/Heavy --------
    Set VariableSet WEAPON_TYPE_WL_SLICE = 11
    Set VariableSet WEAPON_TYPE_WM_SLICE = 12
    Set VariableSet WEAPON_TYPE_WH_SLICE = 13
    Set VariableSet WEAPON_TYPE_WL_BASH = 14
    Set VariableSet WEAPON_TYPE_WM_BASH = 15
    Set VariableSet WEAPON_TYPE_WH_BASH = 16
    Set VariableSet WEAPON_TYPE_WL_STAB = 17
    Set VariableSet WEAPON_TYPE_WM_STAB = 18
    -------- Claw Light/Medium/Heavy --------
    Set VariableSet WEAPON_TYPE_CL_SLICE = 19
    Set VariableSet WEAPON_TYPE_CM_SLICE = 20
    Set VariableSet WEAPON_TYPE_CH_SLICE = 21
    -------- Axe Medium --------
    Set VariableSet WEAPON_TYPE_AM_CHOP = 22
    -------- Rock Heavy --------
    Set VariableSet WEAPON_TYPE_RH_BASH = 23
    -------- - --------
    -------- Since GUI still doesn't provide Defense Type and Armor Types, I needed to include the below --------
    -------- - --------
    Set VariableSet ARMOR_TYPE_NONE = 0
    Set VariableSet ARMOR_TYPE_FLESH = 1
    Set VariableSet ARMOR_TYPE_METAL = 2
    Set VariableSet ARMOR_TYPE_WOOD = 3
    Set VariableSet ARMOR_TYPE_ETHEREAL = 4
    Set VariableSet ARMOR_TYPE_STONE = 5
    -------- - --------
    Set VariableSet DEFENSE_TYPE_LIGHT = 0
    Set VariableSet DEFENSE_TYPE_MEDIUM = 1
    Set VariableSet DEFENSE_TYPE_HEAVY = 2
    Set VariableSet DEFENSE_TYPE_FORTIFIED = 3
    Set VariableSet DEFENSE_TYPE_NORMAL = 4
    Set VariableSet DEFENSE_TYPE_HERO = 5
    Set VariableSet DEFENSE_TYPE_DIVINE = 6
    Set VariableSet DEFENSE_TYPE_UNARMORED = 7
    -------- - --------
    Custom script: call DamageEngine_DebugStr()
//===========================================================================
//  
//  Damage Engine 5.4.2.3 - update requires copying of the JASS script
//  
//===========================================================================
library DamageEngine initializer Init
   
globals
    private timer   alarm       = CreateTimer()
    private boolean alarmSet    = false
   
    //Values to track the original pre-spirit Link/defensive damage values
    private boolean canKick         = true
    private boolean totem           = false
    private real lastAmount         = 0.00
    private real lastPrevAmt        = 0.00
    private integer lastType        = 0  
    private boolean lastCode        = false
    private real lastPierced        = 0.00
    private integer armorType       = 0
    private integer lastArmor       = 0
    private integer lastPrevArmor   = 0
    private integer defenseType     = 0
    private integer lastDefense     = 0
    private integer lastPrevDefense = 0
   
    //Stuff to track recursive UnitDamageTarget calls.
    private boolean eventsRun       = false
    private boolean kicking         = false
    private integer damageStack     = 0
    private unit array sourceStack
    private unit array targetStack
    private real array amountStack
    private attacktype array attackTStack
    private damagetype array damageTStack
    private weapontype array weaponTStack
    private integer array userTrigStack
    private integer array typeStack
   
    //Added in 5.4 to silently eliminate infinite recursion.
    private integer userTrigs = 9
    private integer eventTrig = 0
    private integer array nextTrig
    private trigger array userTrig
    private boolean array trigFrozen
       
    //Added/re-tooled in 5.4.1 to allow forced recursion (for advanced users only).
    private constant integer    LIMBO           = 16    //Recursion will never go deeper than LIMBO.
    private integer array       levelsDeep              //How deep the user recursion currently is.
    public boolean              inception       = false //You must set DamageEngine_inception = true before dealing damage to utlize this.
                                                        //When true, it allows your trigger to potentially go recursive up to LIMBO.
    private boolean             dreaming        = false
    private boolean array       inceptionTrig           //Added in 5.4.2 to simplify the inception variable for very complex DamageEvent trigger.
    private integer             sleepLevel      = 0
    private group               proclusGlobal   = CreateGroup() //track sources of recursion
    private group               fischerMorrow   = CreateGroup() //track targets of recursion
   
    //Improves readability in the code to have these as named constants.
    private constant integer    MOD_EVENT       = 1
    private constant integer    SHIELD_EVENT    = 4
    private constant integer    DAMAGE_EVENT    = 5
    private constant integer    ZERO_EVENT      = 6
    private constant integer    AFTER_EVENT     = 7
    private constant integer    LETHAL_EVENT    = 8
    private constant integer    AOE_EVENT       = 9
   
    //private string crashStr = ""
endglobals
   
//GUI Vars:
/*
    Retained from 3.8 and prior:
    ----------------------------
    unit            udg_DamageEventSource
    unit            udg_DamageEventTarget
    unit            udg_EnhancedDamageTarget
    group           udg_DamageEventAOEGroup
    integer         udg_DamageEventAOE
    integer         udg_DamageEventLevel
    real            udg_DamageModifierEvent
    real            udg_DamageEvent
    real            udg_AfterDamageEvent
    real            udg_DamageEventAmount
    real            udg_DamageEventPrevAmt
    real            udg_AOEDamageEvent
    boolean         udg_DamageEventOverride
    boolean         udg_NextDamageType
    boolean         udg_DamageEventType
    boolean         udg_IsDamageSpell
   
    //Added in 5.0:
    boolean          udg_IsDamageMelee    
    boolean          udg_IsDamageRanged    
    unit             udg_AOEDamageSource  
    real             udg_LethalDamageEvent
    real             udg_LethalDamageHP    
    real             udg_DamageScalingWC3
    integer          udg_DamageEventAttackT
    integer          udg_DamageEventDamageT
    integer          udg_DamageEventWeaponT
   
    //Added in 5.1:
    boolean          udg_IsDamageCode    
   
    //Added in 5.2:
    integer          udg_DamageEventArmorT  
    integer          udg_DamageEventDefenseT
   
    //Addded in 5.3:
    real             DamageEventArmorPierced
    real             udg_DamageScalingUser  
   
    //Added in 5.4.2 to allow GUI users to re-issue the exact same attack and damage type at the attacker.
    attacktype array udg_CONVERTED_ATTACK_TYPE
    damagetype array udg_CONVERTED_DAMAGE_TYPE
*/

   
    private function RunTrigs takes integer i returns nothing
        local integer cat = i
        if dreaming then
            //call BJDebugMsg("Tried to run triggers while triggers were already running.")
            return
        endif
        set dreaming = true
        //call BJDebugMsg("Start of event running")
        loop
            set i = nextTrig[i]
            exitwhen i == 0
            exitwhen cat == MOD_EVENT and (udg_DamageEventOverride or udg_DamageEventType*udg_DamageEventType == 4)
            exitwhen cat == SHIELD_EVENT and udg_DamageEventAmount <= 0.00
            exitwhen cat == LETHAL_EVENT and udg_LethalDamageHP > 0.405
            //set crashStr = "Bout to inspect " + I2S(i)
            if not trigFrozen[i] and IsTriggerEnabled(userTrig[i]) then
                set eventTrig = i
                //set crashStr = "Bout to evaluate " + I2S(i)
                if TriggerEvaluate(userTrig[i]) then
                    //set crashStr = "Bout to execute " + I2S(i)
                    call TriggerExecute(userTrig[i])
                endif
                //set crashStr = "Ran " + I2S(i)
                //call BJDebugMsg("Ran " + I2S(i))
                //if not (udg_DamageEventPrevAmt == 0.00 or udg_DamageScalingWC3 == 0.00 or udg_DamageEventAmount == 0.00) then
                //    if cat == MOD_EVENT then
                //        set udg_DamageScalingUser = udg_DamageEventAmount/udg_DamageEventPrevAmt
                //    elseif cat == SHIELD_EVENT then
                //        set udg_DamageScalingUser = udg_DamageEventAmount/udg_DamageEventPrevAmt/udg_DamageScalingWC3
                //    endif
                //elseif udg_DamageEventPrevAmt == 0.00 then
                //    call BJDebugMsg("Prev amount 0.00 and User Amount " + R2S(udg_DamageEventAmount))
                //elseif udg_DamageEventAmount == 0.00 then
                //    call BJDebugMsg("User amount 0.00 and Prev Amount " + R2S(udg_DamageEventPrevAmt))
                //elseif udg_DamageScalingWC3 == 0.00 then
                //    call BJDebugMsg("WC3 amount somehow 0.00")
                //endif
                //set crashStr = "Filtered " + I2S(i)
            //elseif i > 9 then
            //    if trigFrozen[i] then
            //        call BJDebugMsg("User Trigger is frozen")
            //    else
            //        call BJDebugMsg("User Trigger is off")
            //    endif
            endif
        endloop
        //call BJDebugMsg("End of event running")
        set dreaming = false
    endfunction
   
    private function OnAOEEnd takes nothing returns nothing
        if udg_DamageEventAOE > 1 then
            call RunTrigs(AOE_EVENT)
            set udg_DamageEventAOE      = 1
        endif
        set udg_DamageEventLevel        = 1
        set udg_EnhancedDamageTarget    = null
        set udg_AOEDamageSource         = null
        call GroupClear(udg_DamageEventAOEGroup)
    endfunction
   
    private function AfterDamage takes nothing returns nothing
        if udg_DamageEventPrevAmt != 0.00 and udg_DamageEventDamageT != udg_DAMAGE_TYPE_UNKNOWN then
            call RunTrigs(AFTER_EVENT)
        endif
    endfunction
   
    private function Finish takes nothing returns nothing
        local integer i = 0
        local integer exit
        if eventsRun then
            //call BJDebugMsg("events ran")
            set eventsRun = false
            call AfterDamage()
        endif
        if canKick and not kicking then
            //call BJDebugMsg("can kick")
            if damageStack > 0 then
                set kicking = true
                //call BJDebugMsg("Clearing queued damage instances: " + I2S(damageStack))
                loop
                    set exit = damageStack
                    set sleepLevel = sleepLevel + 1
                    loop
                        set udg_NextDamageType = typeStack[i]
                        //call BJDebugMsg("Stacking on " + R2S(amountStack[i]))
                        call UnitDamageTarget(sourceStack[i], targetStack[i], amountStack[i], true, false, attackTStack[i], damageTStack[i], weaponTStack[i])
                        call AfterDamage()
                        set i = i + 1 //Need to loop bottom to top to make sure damage order is preserved.
                        exitwhen i == exit
                    endloop
                    //call BJDebugMsg("Exit at: " + I2S(i))
                    exitwhen i == damageStack
                endloop
                //call BJDebugMsg("Terminate at at: " + I2S(i))
                set sleepLevel = 0
                loop
                    set i = i - 1
                    set trigFrozen[userTrigStack[i]] = false //Only re-enable recursive triggers AFTER all damage is dealt.
                    set levelsDeep[userTrigStack[i]] = 0 //Reset this stuff if the user tried some nonsense
                    exitwhen i == 0
                endloop
                //call BJDebugMsg("Cleared queued damage instances: " + I2S(damageStack))
                set damageStack = 0 //Can only be set after all the damage has successfully ended.
                set kicking = false
            endif
            call GroupClear(proclusGlobal)
            call GroupClear(fischerMorrow)
        //elseif kicking then
        //    call BJDebugMsg("Somehow still kicking")
        //else
        //    call BJDebugMsg("Cannot kick")
        endif
    endfunction
   
    private function ResetArmor takes nothing returns nothing
        if udg_DamageEventArmorPierced != 0.00 then
            call BlzSetUnitArmor(udg_DamageEventTarget, BlzGetUnitArmor(udg_DamageEventTarget) + udg_DamageEventArmorPierced)
        endif
        if armorType != udg_DamageEventArmorT then
            call BlzSetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_ARMOR_TYPE, armorType) //revert changes made to the damage instance
        endif
        if defenseType != udg_DamageEventDefenseT then
            call BlzSetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_DEFENSE_TYPE, defenseType)
        endif
    endfunction
   
    private function FailsafeClear takes nothing returns nothing
        //call BJDebugMsg("Damage from " + GetUnitName(udg_DamageEventSource) + " to " + GetUnitName(udg_DamageEventTarget) + " has been messing up Damage Engine.")
        //call BJDebugMsg(R2S(udg_DamageEventAmount) + " " + " " + R2S(udg_DamageEventPrevAmt) + " " + udg_AttackTypeDebugStr[udg_DamageEventAttackT] + " " + udg_DamageTypeDebugStr[udg_DamageEventDamageT])
        call ResetArmor()
        set canKick = true
        set totem = false
        set udg_DamageEventAmount = 0.00
        set udg_DamageScalingWC3  = 0.00
        if udg_DamageEventDamageT != udg_DAMAGE_TYPE_UNKNOWN then
            call RunTrigs(DAMAGE_EVENT) //Run the normal on-damage event based on this failure.
            set eventsRun = true //Run the normal after-damage event based on this failure.
        endif
        call Finish()
    endfunction
   
    private function WakeUp takes nothing returns nothing
        set alarmSet    = false //The timer has expired. Flag off to allow it to be restarted when needed.
        //if dreaming then
        //    set dreaming= false
        //    call BJDebugMsg("Timer set dreaming to False")
        //    call BJDebugMsg(crashStr)
        //endif
        if totem then
            //Something went wrong somewhere; the WarCraft 3 engine didn't run the DAMAGED event despite running the DAMAGING event.
            call FailsafeClear()
        else
            if not canKick and damageStack > 0 then
                //call BJDebugMsg("Damage Engine recursion deployment was failing with application of: " + R2S(udg_DamageEventAmount))
                set canKick = true
            endif
            call Finish() //Wrap up any outstanding damage instance
        endif
        call OnAOEEnd() //Reset things so they don't perpetuate for AoE/Level target detection
        set udg_DamageEventPrevAmt = 0.00 //Added in 5.4.2.1 to try to squash the Cold Arrows glitch (failed to do it)
    endfunction
   
    private function CalibrateMR takes nothing returns nothing
        set udg_IsDamageMelee           = false
        set udg_IsDamageRanged          = false
        set udg_IsDamageSpell           = udg_DamageEventAttackT == 0 //In Patch 1.31, one can just check the attack type to find out if it's a spell.
        if udg_DamageEventDamageT == udg_DAMAGE_TYPE_NORMAL and not udg_IsDamageSpell then //This damage type is the only one that can get reduced by armor.
            set udg_IsDamageMelee       = IsUnitType(udg_DamageEventSource, UNIT_TYPE_MELEE_ATTACKER)
            set udg_IsDamageRanged      = IsUnitType(udg_DamageEventSource, UNIT_TYPE_RANGED_ATTACKER)
            if udg_IsDamageMelee and udg_IsDamageRanged then
                set udg_IsDamageMelee   = udg_DamageEventWeaponT > 0// Melee units play a sound when damaging
                set udg_IsDamageRanged  = not udg_IsDamageMelee     // In the case where a unit is both ranged and melee, the ranged attack plays no sound.
            endif                                                   // The Huntress has a melee sound for her ranged projectile, however it is only an issue
        endif                                                       //if she also had a melee attack, because by default she is only UNIT_TYPE_RANGED_ATTACKER.
    endfunction
   
    private function OnPreDamage takes nothing returns boolean
        local unit src      = GetEventDamageSource()
        local unit tgt      = GetTriggerUnit()
        local real amt      = GetEventDamage()
        local attacktype at = BlzGetEventAttackType()
        local damagetype dt = BlzGetEventDamageType()
        local weapontype wt = BlzGetEventWeaponType()
       
        //call BJDebugMsg("First damage event running")
       
        if dreaming then
            //call BJDebugMsg("Dreaming")
            if amt != 0.00 then
                //Store recursive damage into a queue from index "damageStack" (0-15)
                //This damage will be fired after the current damage instance has wrapped up its events.
                //This damage can only be caused by triggers.
                set amountStack[damageStack]   = amt
                set sourceStack[damageStack]   = src
                set targetStack[damageStack]   = tgt
                set attackTStack[damageStack]  = at
                set damageTStack[damageStack]  = dt
                set weaponTStack[damageStack]  = wt
                set userTrigStack[damageStack] = eventTrig
                if udg_NextDamageType == 0 then
                    set typeStack[damageStack] = udg_DamageTypeCode
                else
                    set typeStack[damageStack] = udg_NextDamageType
                endif
                //Next block added in 5.4.1 to allow *some* control over whether recursion should kick
                //in. Also it's important to track whether the source and target were both involved at
                //some earlier point, so this is a more accurate and lenient method than before.
                set inception = inception or inceptionTrig[eventTrig]
                call GroupAddUnit(proclusGlobal, udg_DamageEventSource)
                call GroupAddUnit(fischerMorrow, udg_DamageEventTarget)
                if kicking and IsUnitInGroup(src, proclusGlobal) and IsUnitInGroup(tgt, fischerMorrow) then
                    if inception and not trigFrozen[eventTrig] then
                        set inceptionTrig[eventTrig] = true
                        if levelsDeep[eventTrig] < sleepLevel then
                            set levelsDeep[eventTrig] = levelsDeep[eventTrig] + 1
                            if levelsDeep[eventTrig] >= LIMBO then
                                set trigFrozen[eventTrig] = true
                            endif
                        endif
                    else
                        set trigFrozen[eventTrig] = true
                    endif
                endif
                set damageStack = damageStack + 1
                //call BJDebugMsg("damageStack: " + I2S(damageStack) + " levelsDeep: " + I2S(levelsDeep[eventTrig]) + " sleepLevel: " + I2S(sleepLevel))
                call BlzSetEventDamage(0.00) //queue the damage instance instead of letting it run recursively
            endif
        else
            if not kicking then
                //Added 25 July 2017 to detect AOE damage or multiple single-target damage
                if alarmSet then
                    if totem then
                        if dt != DAMAGE_TYPE_SPIRIT_LINK and dt != DAMAGE_TYPE_DEFENSIVE and dt != DAMAGE_TYPE_PLANT then
                            //if 'totem' is still set and it's not due to spirit link distribution or defense retaliation,
                            //the next function must be called as a debug. This reverts an issue I created in patch 5.1.3.
                            call FailsafeClear()
                        else
                            set totem           = false
                            set lastAmount      = udg_DamageEventAmount
                            set lastPrevAmt     = udg_DamageEventPrevAmt    //Store the actual pre-armor value.
                            set lastType        = udg_DamageEventType       //also store the damage type.
                            set lastCode        = udg_IsDamageCode          //store this as well.
                            set lastArmor       = udg_DamageEventArmorT
                            set lastPrevArmor   = armorType
                            set lastDefense     = udg_DamageEventDefenseT
                            set lastPrevDefense = defenseType
                            set lastPierced     = udg_DamageEventArmorPierced
                            set canKick         = false
                        endif
                    else
                        call Finish()
                    endif
                    if src != udg_AOEDamageSource then //Source has damaged more than once
                        call OnAOEEnd() //New damage source - unflag everything
                        set udg_AOEDamageSource = src
                    elseif tgt == udg_EnhancedDamageTarget then
                        set udg_DamageEventLevel= udg_DamageEventLevel + 1  //The number of times the same unit was hit.
                    elseif not IsUnitInGroup(tgt, udg_DamageEventAOEGroup) then
                        set udg_DamageEventAOE  = udg_DamageEventAOE + 1    //Multiple targets hit by this source - flag as AOE
                    endif
                else
                    call TimerStart(alarm, 0.00, false, function WakeUp)
                    set alarmSet                = true
                    set udg_AOEDamageSource     = src
                    set udg_EnhancedDamageTarget= tgt
                endif
                call GroupAddUnit(udg_DamageEventAOEGroup, tgt)
            endif
            set udg_DamageEventType             = udg_NextDamageType
            set udg_IsDamageCode                = udg_NextDamageType != 0
            set udg_DamageEventOverride         = dt == null //Got rid of NextDamageOverride in 5.1 for simplicity
            set udg_DamageEventPrevAmt          = amt
            set udg_DamageEventSource           = src
            set udg_DamageEventTarget           = tgt
            set udg_DamageEventAmount           = amt
            set udg_DamageEventAttackT          = GetHandleId(at)
            set udg_DamageEventDamageT          = GetHandleId(dt)
            set udg_DamageEventWeaponT          = GetHandleId(wt)
           
            call CalibrateMR() //Set Melee and Ranged settings.
           
            set udg_DamageEventArmorT           = BlzGetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_ARMOR_TYPE) //Introduced in Damage Engine 5.2.0.0
            set udg_DamageEventDefenseT         = BlzGetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_DEFENSE_TYPE)
            set armorType                       = udg_DamageEventArmorT
            set defenseType                     = udg_DamageEventDefenseT
            set udg_DamageEventArmorPierced     = 0.00
            set udg_DamageScalingUser           = 1.00
            set udg_DamageScalingWC3            = 1.00
           
            if amt != 0.00 then
                if not udg_DamageEventOverride then
                    call RunTrigs(MOD_EVENT)
               
                    //All events have run and the pre-damage amount is finalized.
                    call BlzSetEventAttackType(ConvertAttackType(udg_DamageEventAttackT))
                    call BlzSetEventDamageType(ConvertDamageType(udg_DamageEventDamageT))
                    call BlzSetEventWeaponType(ConvertWeaponType(udg_DamageEventWeaponT))
                    if udg_DamageEventArmorPierced != 0.00 then
                        call BlzSetUnitArmor(udg_DamageEventTarget, BlzGetUnitArmor(udg_DamageEventTarget) - udg_DamageEventArmorPierced)
                    endif
                    if armorType != udg_DamageEventArmorT then
                        call BlzSetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_ARMOR_TYPE, udg_DamageEventArmorT) //Introduced in Damage Engine 5.2.0.0
                    endif
                    if defenseType != udg_DamageEventDefenseT then
                        call BlzSetUnitIntegerField(udg_DamageEventTarget, UNIT_IF_DEFENSE_TYPE, udg_DamageEventDefenseT) //Introduced in Damage Engine 5.2.0.0
                    endif
                    call BlzSetEventDamage(udg_DamageEventAmount)
                endif
                //call BJDebugMsg("Ready to deal " + R2S(udg_DamageEventAmount))
                set totem = true
            else
                call RunTrigs(ZERO_EVENT)
                set canKick = true
                call Finish()
            endif
        endif
        set src = null
        set tgt = null
        set inception = false
        set udg_NextDamageType = 0
        return false
    endfunction
   
    //The traditional on-damage response, where armor reduction has already been factored in.
    private function OnDamage takes nothing returns boolean
        local real r = GetEventDamage()
        //call BJDebugMsg("Second damage event running")
        if dreaming or udg_DamageEventPrevAmt == 0.00 then
            //if dreaming then
            //    call BJDebugMsg("Dreaming")
            //else
            //    call BJDebugMsg("Prev amount is zero")
            //endif
            return false
        endif
        if totem then
            set totem = false   //This should be the case in almost all circumstances
        else
            call AfterDamage() //Wrap up the outstanding damage instance
            set canKick                     = true
            //Unfortunately, Spirit Link and Thorns Aura/Spiked Carapace fire the DAMAGED event out of sequence with the DAMAGING event,
            //so I have to re-generate a buncha stuff here.
            set udg_DamageEventSource       = GetEventDamageSource()
            set udg_DamageEventTarget       = GetTriggerUnit()
            set udg_DamageEventAmount       = lastAmount
            set udg_DamageEventPrevAmt      = lastPrevAmt
            set udg_DamageEventAttackT      = GetHandleId(BlzGetEventAttackType())
            set udg_DamageEventDamageT      = GetHandleId(BlzGetEventDamageType())
            set udg_DamageEventWeaponT      = GetHandleId(BlzGetEventWeaponType())
            set udg_DamageEventType         = lastType
            set udg_IsDamageCode            = lastCode
            set udg_DamageEventArmorT       = lastArmor
            set udg_DamageEventDefenseT     = lastDefense
            set udg_DamageEventArmorPierced = lastPierced
            set armorType                   = lastPrevArmor
            set defenseType                 = lastPrevDefense
            call CalibrateMR() //Apply melee/ranged settings once again.
        endif
        call ResetArmor()
        if udg_DamageEventAmount != 0.00 and r != 0.00 then
            set udg_DamageScalingWC3 = r / udg_DamageEventAmount
        elseif udg_DamageEventAmount > 0.00 then
            set udg_DamageScalingWC3 = 0.00
        else
            set udg_DamageScalingWC3 = 1.00
            set udg_DamageScalingUser = udg_DamageEventAmount / udg_DamageEventPrevAmt
        endif
        set udg_DamageEventAmount = udg_DamageEventAmount*udg_DamageScalingWC3
       
        if udg_DamageEventAmount > 0.00 then
            //This event is used for custom shields which have a limited hit point value
            //The shield here kicks in after armor, so it acts like extra hit points.
            call RunTrigs(SHIELD_EVENT)
            set udg_LethalDamageHP = GetWidgetLife(udg_DamageEventTarget) - udg_DamageEventAmount
            if udg_LethalDamageHP <= 0.405 then
                call RunTrigs(LETHAL_EVENT) //Added 10 May 2019 to detect and potentially prevent lethal damage. Instead of
                //modifying the damage, you need to modify LethalDamageHP instead (the final HP of the unit).
               
                set udg_DamageEventAmount = GetWidgetLife(udg_DamageEventTarget) - udg_LethalDamageHP
                if udg_DamageEventType < 0 and udg_LethalDamageHP <= 0.405 then
                    call SetUnitExploded(udg_DamageEventTarget, true)   //Explosive damage types should blow up the target.
                endif
            endif
            set udg_DamageScalingUser = udg_DamageEventAmount/udg_DamageEventPrevAmt/udg_DamageScalingWC3
        endif
        call BlzSetEventDamage(udg_DamageEventAmount)   //Apply the final damage amount.
        if udg_DamageEventDamageT != udg_DAMAGE_TYPE_UNKNOWN then
            call RunTrigs(DAMAGE_EVENT)
        endif
        set eventsRun = true
        if udg_DamageEventAmount == 0.00 then
            call Finish()
        endif
        return false
    endfunction
   
    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger trig = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DAMAGED) //Thanks to this I no longer have to create an event for every unit in the map.
        call TriggerAddCondition(trig, Filter(function OnDamage))

        set trig = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DAMAGING) //The new 1.31 event which fires before damage.
        call TriggerAddCondition(trig, Filter(function OnPreDamage))
        set trig = null
    endfunction
   
    public function DebugStr takes nothing returns nothing
        local integer i = 0
        loop
            set udg_CONVERTED_ATTACK_TYPE[i] = ConvertAttackType(i)
            exitwhen i == 6
            set i = i + 1
        endloop
        set i = 0
        loop
            set udg_CONVERTED_DAMAGE_TYPE[i] = ConvertDamageType(i)
            exitwhen i == 26
            set i = i + 1
        endloop
        set udg_AttackTypeDebugStr[0] = "SPELLS"    //ATTACK_TYPE_NORMAL in JASS
        set udg_AttackTypeDebugStr[1] = "NORMAL"    //ATTACK_TYPE_MELEE in JASS
        set udg_AttackTypeDebugStr[2] = "PIERCE"
        set udg_AttackTypeDebugStr[3] = "SIEGE"
        set udg_AttackTypeDebugStr[4] = "MAGIC"
        set udg_AttackTypeDebugStr[5] = "CHAOS"
        set udg_AttackTypeDebugStr[6] = "HERO"
       
        set udg_DamageTypeDebugStr[0]  = "UNKNOWN"
        set udg_DamageTypeDebugStr[4]  = "NORMAL"
        set udg_DamageTypeDebugStr[5]  = "ENHANCED"
        set udg_DamageTypeDebugStr[8]  = "FIRE"
        set udg_DamageTypeDebugStr[9]  = "COLD"
        set udg_DamageTypeDebugStr[10] = "LIGHTNING"
        set udg_DamageTypeDebugStr[11] = "POISON"
        set udg_DamageTypeDebugStr[12] = "DISEASE"
        set udg_DamageTypeDebugStr[13] = "DIVINE"
        set udg_DamageTypeDebugStr[14] = "MAGIC"
        set udg_DamageTypeDebugStr[15] = "SONIC"
        set udg_DamageTypeDebugStr[16] = "ACID"
        set udg_DamageTypeDebugStr[17] = "FORCE"
        set udg_DamageTypeDebugStr[18] = "DEATH"
        set udg_DamageTypeDebugStr[19] = "MIND"
        set udg_DamageTypeDebugStr[20] = "PLANT"
        set udg_DamageTypeDebugStr[21] = "DEFENSIVE"
        set udg_DamageTypeDebugStr[22] = "DEMOLITION"
        set udg_DamageTypeDebugStr[23] = "SLOW_POISON"
        set udg_DamageTypeDebugStr[24] = "SPIRIT_LINK"
        set udg_DamageTypeDebugStr[25] = "SHADOW_STRIKE"
        set udg_DamageTypeDebugStr[26] = "UNIVERSAL"

        set udg_WeaponTypeDebugStr[0]  = "NONE"     //WEAPON_TYPE_WHOKNOWS in JASS
        set udg_WeaponTypeDebugStr[1]  = "METAL_LIGHT_CHOP"
        set udg_WeaponTypeDebugStr[2]  = "METAL_MEDIUM_CHOP"
        set udg_WeaponTypeDebugStr[3]  = "METAL_HEAVY_CHOP"
        set udg_WeaponTypeDebugStr[4]  = "METAL_LIGHT_SLICE"
        set udg_WeaponTypeDebugStr[5]  = "METAL_MEDIUM_SLICE"
        set udg_WeaponTypeDebugStr[6]  = "METAL_HEAVY_SLICE"
        set udg_WeaponTypeDebugStr[7]  = "METAL_MEDIUM_BASH"
        set udg_WeaponTypeDebugStr[8]  = "METAL_HEAVY_BASH"
        set udg_WeaponTypeDebugStr[9]  = "METAL_MEDIUM_STAB"
        set udg_WeaponTypeDebugStr[10] = "METAL_HEAVY_STAB"
        set udg_WeaponTypeDebugStr[11] = "WOOD_LIGHT_SLICE"
        set udg_WeaponTypeDebugStr[12] = "WOOD_MEDIUM_SLICE"
        set udg_WeaponTypeDebugStr[13] = "WOOD_HEAVY_SLICE"
        set udg_WeaponTypeDebugStr[14] = "WOOD_LIGHT_BASH"
        set udg_WeaponTypeDebugStr[15] = "WOOD_MEDIUM_BASH"
        set udg_WeaponTypeDebugStr[16] = "WOOD_HEAVY_BASH"
        set udg_WeaponTypeDebugStr[17] = "WOOD_LIGHT_STAB"
        set udg_WeaponTypeDebugStr[18] = "WOOD_MEDIUM_STAB"
        set udg_WeaponTypeDebugStr[19] = "CLAW_LIGHT_SLICE"
        set udg_WeaponTypeDebugStr[20] = "CLAW_MEDIUM_SLICE"
        set udg_WeaponTypeDebugStr[21] = "CLAW_HEAVY_SLICE"
        set udg_WeaponTypeDebugStr[22] = "AXE_MEDIUM_CHOP"
        set udg_WeaponTypeDebugStr[23] = "ROCK_HEAVY_BASH"

        set udg_DefenseTypeDebugStr[0] = "LIGHT"
        set udg_DefenseTypeDebugStr[1] = "MEDIUM"
        set udg_DefenseTypeDebugStr[2] = "HEAVY"
        set udg_DefenseTypeDebugStr[3] = "FORTIFIED"
        set udg_DefenseTypeDebugStr[4] = "NORMAL"   //Typically deals flat damage to all armor types
        set udg_DefenseTypeDebugStr[5] = "HERO"
        set udg_DefenseTypeDebugStr[6] = "DIVINE"
        set udg_DefenseTypeDebugStr[7] = "UNARMORED"
       
        set udg_ArmorTypeDebugStr[0] = "NONE"       //ARMOR_TYPE_WHOKNOWS in JASS, added in 1.31
        set udg_ArmorTypeDebugStr[1] = "FLESH"
        set udg_ArmorTypeDebugStr[2] = "METAL"
        set udg_ArmorTypeDebugStr[3] = "WOOD"
        set udg_ArmorTypeDebugStr[4] = "ETHEREAL"
        set udg_ArmorTypeDebugStr[5] = "STONE"
    endfunction
   
    //This function exists mainly to make it easier to switch from another DDS, like PDD.
    function UnitDamageTargetEx takes unit src, unit tgt, real amt, boolean a, boolean r, attacktype at, damagetype dt, weapontype wt returns boolean
        if udg_NextDamageType == 0 then
           set udg_NextDamageType = udg_DamageTypeCode
        endif
        call UnitDamageTarget(src, tgt, amt, a, r, at, dt, wt)
        return dreaming
    endfunction
   
    public function SetupEvent takes trigger whichTrig, string var, integer index returns nothing
        local integer max = 1
        local integer off = 0
        local integer exit = 0
        local integer i
        if var == "udg_DamageModifierEvent" then //MOD_EVENT 1-4 -> Events 1-4
            if index < 3 then
                set exit = index + 1
            endif
            if nextTrig[1] == 0 then
                set nextTrig[1] = 2
                set nextTrig[2] = 3
                set trigFrozen[2] = true
                set trigFrozen[3] = true
            endif
            set max = 4
        elseif var == "udg_DamageEvent" then //DAMAGE_EVENT 1,2 -> Events 5,6
            set max = 2
            set off = 4
        elseif var == "udg_AfterDamageEvent" then //AFTER_EVENT -> Event 7
            set off = 6
        elseif var == "udg_LethalDamageEvent" then //LETHAL_EVENT -> Event 8
            set off = 7
        elseif var == "udg_AOEDamageEvent" then //AOE_EVENT -> Event 9
            set off = 8
        else
            return
        endif
        set i = IMaxBJ(IMinBJ(index, max), 1) + off
        //call BJDebugMsg("Root index: " + I2S(i))
        loop
            set index = i
            set i = nextTrig[i]
            exitwhen i == exit
        endloop
        set userTrigs = userTrigs + 1   //User list runs from index 10 and up
        set nextTrig[index] = userTrigs
        set nextTrig[userTrigs] = exit
        set userTrig[userTrigs] = whichTrig
        //call BJDebugMsg("Registered " + I2S(userTrigs) + " to " + I2S(index))
    endfunction
   
    private function PreSetup takes trigger whichTrig, string var, limitop op, real value returns nothing
        call SetupEvent(whichTrig, var, R2I(value))
    endfunction
   
    hook TriggerRegisterVariableEvent PreSetup
   
endlibrary

                                                         :+++++++`                                                          
                                               ..........ymmmmmmm-...............                                            
                                              .NNNNNNNNNN:```````mNNNNNNNNNNNNNNh                                            
                                    +dddddddddh----------`       .--------------/ddddddd+                                    
                          oooooooooooooooooooo+                                 .oooooooooooooooooooo:                      
                       .--hddddddddd/                                                   /ddddddddddddo--`                    
                       sNN``````````                                                     ````````````+NN.                    
                       sMM`                                                                          +MM.                    
                       -++ss/                                                                      sso++`                    
                          NMy  -:-                                                         -:-    `MMs                      
                          NMy  hMm``                                                     ``mMh    `MMs                      
                          NMy  hMMmm+                                                   +mmMMh    `MMs                      
                          NMy  hMMMM+                                                   +MMMMh    `MMs                      
                          NMy  hMMMMy//                                               //yMMMMh    `MMs                      
                          NMy  hMMMMMMM`                                             `MMMMMMMh    `MMs                      
                          NMy  hMMMMMMM`                                             `MMMMMMMh    `MMs                      
                          NMy  hMMMMMMM`                                             `MMMMMMMh    `MMs                      
                          NMy  hMMMMMMM+/:                                           `MMMMMMMh  -//yy/                      
                          NMy  ymmMMMMMMMy          .......................`         `MMMMMMMh  yMN                          
                          NMy  ``-MMMMMMMy          mNNNNNNNNNNNNNNNNNNNNNNo         `MMMMMMMh  yMN                          
                          -:+hh- .MMMMMMMNhhhhhhhhhhMMMMMMMMMMMMMMMMMMMMMMMmhhhhhhhhhdMMMMMMMh  yMN                          
                            /MM: .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMys+  yMN                          
                            /MM: .ddNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNdd.    yMN                          
                            /MM:  ``sMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMs``     yMN                          
                            /MM:    .----oMMMMMMMs----+MMMMMMMMMMMMMMM+----sMMMMMMMMMN--.       yMN                          
                            .oooo+       .oooosMMo    .oomMMMMMMMMMmoo.    oMMsooooooo       .ooooo                          
                               hMm            .MMs--     hMMMMMMMMMh     --sMM.              :MM/                            
                               hNd``          .NNNMM.``  hMMMMMMMMMh  ``.MMNNN.            ``:NN/                            
                               .-:dd/          --yMMmds  hMMMMMMMMMh  sdmMMy--             hdy--`                            
                                 .MM+            -++++ossmMMMMMMMMMmssmMN++-               mMh                              
                                 .MM+                 :MMMMMMMMMMMMMMMmhh               .::yhs                              
                                 .NNo``               :MMMMMMMMMMMMMMM:               ``oNN.                                
                                  ..omm`              :MMMMMMMMMMMMMMM:              `mmo..                                  
                                    sMM`              .//dMMMMMMMMMMMM:              `MMs                                    
                                    /hh/:-               hMMhhhhhMMMMM:            -:/hh/                                    
                                       mmy..             hMN     NMMMM:          ..ymm                                      
                                       `./mm-            hMN     NMMMM:         -mm/.`                                      
                                         .//sys          hMN     NMd//`         :MM/                                        
                                            hMm          hMN/////NMh          //+yy-                                        
                                            ymd.....     ymNMMMMMNmy       `..dmy                                            
                                            ``.NNNNN`    ``.MMMMM.``       +NN.``                                            
                                               :::::hho     :::::     ohhhho::                                              
                                                    oso++++/       .++ossss:                                                
                                                      :mmmmd......./mm:                                                      
                                                           `NNNNNNNy                                                        
                                                            -------.                                                        
                                                                                                                             
               `-------`    `----.  `--  `--`  -----        --`    `-------`  .---------`    `-----  `-------`              
               /MMMNMMM+  ``/NNMMm  sMM``/MM: .MMMNN`     `.MMo``  :MMMNMMMo  mMMMMMMMMMs   `:NNMMN  +MMMNMMM/              
               /MM/.:MM+  dms..dMm  sMMmmmMM: .MMs..     smmMMNmm` :MM+.-MMo  mMMMMMMMMMs  hmy..hMN  +MM:./MM/              
               /MMysyMM+  NMy  hMm  sMMMMMMM: .MMdss`    hMN++hMM` :MMhssMMo  mMMMMMMMMMs  mMh  yMN  +MMysyMM/              
               /MMdhdMM+  NMy  hMm  sMMMMMMM: .MMmhh`    hMN::yMM` :MMmhdMMo  mMNhhNMMMMs  mMh  yMN  +MMdhdMM/              
               /MM- -MM+  NMy  dMm  sMMMMMMM: .MMo       hMMMMMMM` :MM: `MMo  mMh  yMMMMs  mMd  yMN  +MM. -MM/              
               /MMNNNMM+  NMMNNMMm  sMM.`/MM: .MMNNN`    hMN``sMM` :MM: `MMo  mMh  yMMMMs  mMMNNMMN  +MM. -MM/              
               .///////.  ////////  -//  .//` `/////     ://  -//` .//.  //-  //:  :////-  ////////  .//` `//.              
                                                                                                                             
                                                                                                                                   
                                                                                                                             
                                                                                                                           
Import Bone Armor in your map!

Step 1 - Allow creation of unknown variables - (Understand that this is absolutely nessesary)
1A - Under Preferences, make sure you have "Automatically create unknown variables while pasting trigger data" checked

Step 2 - Install Bribe's Damage Engine into your map:
2A - Copy Pasta Bribe'
s Damage Engine Folder into your trigger editor

Step 3 - Install Bone Armor
4A Copy Pasta the Bone Armor folder into your trigger editor
4B Copy the Bone Armor Ability from Object Editor, and set it to the variable BAmr_SPELL
4C Copy the Bone Armor Buff from Object Editor, and set it to the variable BArmr_BUFF
BAmr Config
  Events
    Map initialization
  Conditions
  Actions
    -------- This value represents how often the BAmr Peridic will run. --------
    Set VariableSet BAmr_Config_PERIODIC = 0.03
    Trigger - Add to BAmr_Periodic <gen> the event (Every BAmr_Config_PERIODIC seconds of game time)
    -------- --------
    -------- This value indicates what spell is being used by the caster --------
    Set VariableSet BAmr_Config_SPELL_ID = Bone Armor BAmr
    -------- --------
    -------- This value indicates which buff will be detected when the enchanted unit is struck, and which buff the enchanted unit needs to keep the effect going. --------
    Set VariableSet BAmr_Config_BUFF = Inner Fire BAmr
    -------- --------
    -------- Spell stat values --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
      Then - Actions
        -------- Stacking --------
        -------- Set to true to allow for "Stacking" of shield values when cast on the same unit consecutively --------
        Set VariableSet BAmr_Boolean[0] = True
        -------- --------
        -------- This indicates the base value for the shield --------
        Set VariableSet BAmr_Config_BASE_HP = 100.00
        -------- This indicates the base value for the shield --------
        -------- --------
        -------- This value will determine the increase in shield health if the hero invests skill points into the Ability --------
        Set VariableSet BAmr_Config_LVL_HP_BONUS[1] = 200.00
        Set VariableSet BAmr_Config_LVL_HP_BONUS[2] = 400.00
        Set VariableSet BAmr_Config_LVL_HP_BONUS[3] = 600.00
        -------- This value will determine the increase in shield health if the hero invests skill points into the Ability --------
        -------- --------
        -------- This value decides what percentage of the caster's Strength will be used to boost Bone Armor's Health (Default: 0.00) --------
        Set VariableSet BAmr_Config_ATT_BONUS[1] = 0.00
        -------- This value decides what percentage of the caster's Agility will be used to boost Bone Armor's Health (Default: 0.00) --------
        Set VariableSet BAmr_Config_ATT_BONUS[2] = 0.00
        -------- This value decides what percentage of the caster's Intelligence will be used to boost Bone Armor's Health (Default: 0.00) --------
        Set VariableSet BAmr_Config_ATT_BONUS[3] = 0.00
        -------- --------
        -------- This value denotes of what percentage of the damage will be taken by the shield. Default:1.00 (100%) --------
        -------- Example: 0.5 means only 50% of incoming damage will be taken by the shield and will be dealt to the unit --------
        Set VariableSet BAmr_Config_ABSORBTION = 1.00
        -------- --------
        -------- These two values determine what percentage of physical or Spell damage it will resist. Default: 1.00 (100%) --------
        -------- Not to be confused with the previous value --------
        -------- Example: Spell Resist at 2.00 means that spell damage will deal 200% more damage --------
        -------- Setting either of these values to 0.00 will ignore that type of damage --------
        Set VariableSet BAmr_Config_RESIST_SPELL = 1.00
        Set VariableSet BAmr_Config_RESIST_PHYSICAL = 1.00
        -------- --------
      Else - Actions
    -------- Spell stat values --------
    -------- --------
    -------- This value determines the "Flavour" of the Shield, the number corresponds with the options below, match it to get the intended effect --------
    Set VariableSet BAmr_Config_FLAVOR = 23
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
      Then - Actions
        -------- Flavors --------
        -------- --------
        -------- 23 --------
        -------- Lime / Necro --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Config_FLAVOR Equal to 23
          Then - Actions
            Set VariableSet BAmr_Config_FLAVOR_PATH[0] = Abilities\Weapons\NecromancerMissile\NecromancerMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[1] = Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[2] = Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[3] = BoneArmorCasterTC.mdx
          Else - Actions
        -------- 23 --------
        -------- --------
        -------- 1 --------
        -------- Red / Fire --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Config_FLAVOR Equal to 1
          Then - Actions
            Set VariableSet BAmr_Config_FLAVOR_PATH[0] = Abilities\Weapons\FireBallMissile\FireBallMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[1] = Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[2] = Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[3] = BoneArmorCasterTC.mdx
          Else - Actions
        -------- 1 --------
        -------- --------
        -------- 2 --------
        -------- Blue / Frost --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Config_FLAVOR Equal to 2
          Then - Actions
            Set VariableSet BAmr_Config_FLAVOR_PATH[0] = Abilities\Spells\Other\FrostBolt\FrostBoltMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[1] = Abilities\Spells\Undead\FrostNova\FrostNovaTarget.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[2] = Abilities\Spells\Undead\FrostNova\FrostNovaTarget.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[3] = BoneArmorCasterTC.mdx
          Else - Actions
        -------- 2 --------
        -------- --------
        -------- 3 --------
        -------- Teal / Ocean --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Config_FLAVOR Equal to 3
          Then - Actions
            Set VariableSet BAmr_Config_FLAVOR_PATH[0] = Abilities\Weapons\SeaElementalMissile\SeaElementalMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[1] = Abilities\Spells\Other\CrushingWave\CrushingWaveDamage.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[2] = Abilities\Spells\Other\CrushingWave\CrushingWaveDamage.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[3] = BoneArmorCasterTC.mdx
          Else - Actions
        -------- 3 --------
        -------- --------
        -------- 4 --------
        -------- Purple / Ooze? --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Config_FLAVOR Equal to 4
          Then - Actions
            Set VariableSet BAmr_Config_FLAVOR_PATH[0] = Abilities\Weapons\SludgeMissile\SludgeMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[1] = Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[2] = Abilities\Spells\Items\AIil\AIilTarget.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[3] = BoneArmorCasterTC.mdx
          Else - Actions
        -------- 4 --------
        -------- --------
        -------- 5 --------
        -------- Yellow / Holy --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Config_FLAVOR Equal to 5
          Then - Actions
            Set VariableSet BAmr_Config_FLAVOR_PATH[0] = Abilities\Weapons\FaerieDragonMissile\FaerieDragonMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[1] = Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[2] = Abilities\Spells\Other\HealingSpray\HealBottleMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[3] = BoneArmorCasterTC.mdx
          Else - Actions
        -------- 5 --------
        -------- --------
        -------- 6 --------
        -------- Orange / Drunk --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Config_FLAVOR Equal to 6
          Then - Actions
            Set VariableSet BAmr_Config_FLAVOR_PATH[0] = Abilities\Spells\Other\StrongDrink\BrewmasterMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[1] = Abilities\Spells\Orc\SpiritLink\SpiritLinkZapTarget.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[2] = Abilities\Spells\Human\Feedback\SpellBreakerAttack.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[3] = BoneArmorCasterTC.mdx
          Else - Actions
        -------- 6 --------
        -------- --------
        -------- 7 --------
        -------- Green / Nature --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Config_FLAVOR Equal to 7
          Then - Actions
            Set VariableSet BAmr_Config_FLAVOR_PATH[0] = Abilities\Weapons\KeeperGroveMissile\KeeperGroveMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[1] = Objects\Spawnmodels\NightElf\EntBirthTarget\EntBirthTarget.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[2] = Objects\Spawnmodels\NightElf\EntBirthTarget\EntBirthTarget.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[3] = BoneArmorCasterTC.mdx
          Else - Actions
        -------- 7 --------
        -------- --------
        -------- 8 --------
        -------- Pink / Darkness --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Config_FLAVOR Equal to 8
          Then - Actions
            Set VariableSet BAmr_Config_FLAVOR_PATH[0] = Abilities\Weapons\VoidWalkerMissile\VoidWalkerMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[1] = Abilities\Spells\Undead\OrbOfDeath\AnnihilationMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[2] = Abilities\Spells\Undead\OrbOfDeath\AnnihilationMissile.mdl
            Set VariableSet BAmr_Config_FLAVOR_PATH[3] = BoneArmorCasterTC.mdx
          Else - Actions
        -------- 8 --------
        -------- --------
        -------- Flavors --------
      Else - Actions
    -------- This value determines the "Flavour" of the Shield, the number corresponds with the options below, match it to get the intended effect --------
    -------- --------
    -------- --------
    -------- Special effects & related values --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
      Then - Actions
        -------- --------
        -------- This path denotes what form the orbiting segments will take. --------
        Set VariableSet BAmr_Config_SPEF_PATH[0] = BAmr_Config_FLAVOR_PATH[0]
        -------- This path denotes what form the orbiting segments will take. --------
        -------- --------
        -------- This value indicates what effect will occur when the segments are first spawned --------
        -------- see the "Flavor Section" to customize numerous effect loadouts --------
        Set VariableSet BAmr_Config_SPEF_PATH[1] = BAmr_Config_FLAVOR_PATH[1]
        -------- This value indicates what effect will occur when the segments are first spawned --------
        -------- --------
        -------- This value indicates what effect will occur when the segments are destroyed --------
        -------- see the "Flavor Section" to customize numerous effect loadouts --------
        Set VariableSet BAmr_Config_SPEF_PATH[2] = BAmr_Config_FLAVOR_PATH[2]
        -------- This value indicates what effect will occur when the segments are destroyed --------
        -------- --------
        -------- This value indicates what effect will occur when the enchanted unit is struck --------
        -------- see the "Flavor Section" to customize numerous effect loadouts --------
        Set VariableSet BAmr_Config_SPEF_PATH[3] = BAmr_Config_FLAVOR_PATH[3]
        -------- This value indicates what effect will occur when the enchanted unit is struck --------
        -------- --------
        -------- Values contained within directly influence the "shield flare" effect governed by BAmr_EFFECTPATH[3] --------
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
          Then - Actions
            -------- --------
            -------- This Value determines whether or not you want the "Shield Flare Effect" to match the player's colour or to a specific colour --------
            Set VariableSet BAmr_Boolean[1] = False
            -------- --------
            -------- Offset will determine how far away the Special effect will be created from the enchanted target --------
            -------- PLAYER COLOUR --------
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                BAmr_Boolean[1] Equal to False
              Then - Actions
                Set VariableSet BAmr_Config_SPEF_VALUE[0] = (Real(BAmr_Config_FLAVOR))
              Else - Actions
            -------- --------
            -------- Offset will determine how far away the Special effect will be created from the enchanted target --------
            -------- OFFSET --------
            Set VariableSet BAmr_Config_SPEF_VALUE[1] = 85.00
            -------- Offset will determine how far away the Special effect will be created from the enchanted target --------
            -------- --------
            -------- Height will determine at what height the Special effect will be created, starting from the enchanted target's current height & Z Height. --------
            -------- HEIGHT --------
            Set VariableSet BAmr_Config_SPEF_VALUE[2] = 65.00
            -------- Height will determine at what height the Special effect will be created, starting from the enchanted target's current height --------
            -------- --------
            -------- Scale will determine the percentage of scale the Special effect will have --------
            -------- SCALE --------
            Set VariableSet BAmr_Config_SPEF_VALUE[3] = 0.90
            -------- Scale will determine the percentage of scale the Special effect will have --------
            -------- --------
            -------- Timescale will determine the speed of the special effect's animation --------
            -------- TIMESCALE --------
            Set VariableSet BAmr_Config_SPEF_VALUE[4] = 7.50
            -------- Timescale will determine the speed of the special effect's animation --------
            -------- --------
            -------- RGB value from 0 - 255 will determine what colors will be present in the special effect (note this requires a lot of experimentation) --------
            -------- from 1 - 3 is RED, GREEN, BLUE --------
            Set VariableSet BAmr_Config_SPEF_VALUE[5] = 255.00
            Set VariableSet BAmr_Config_SPEF_VALUE[6] = 255.00
            Set VariableSet BAmr_Config_SPEF_VALUE[7] = 255.00
            -------- from 1 - 3 is RED, GREEN, BLUE --------
            -------- RGB value from 0 - 255 will determine what colors will be present in the special effect (note this requires a lot of experimentation) --------
            -------- --------
            -------- YPR will determine in order of apperance, Yaw, Pitch, & Roll. --------
            -------- Thanks to Hermit, the model provided already has an orienation to 90 degrees we need not add it, but I will leave these all the same for interesting effects! --------
            -------- The Values are calculated as (( X * 3.14 ) / 180 ), 1.57 = 90 degrees, 3.14 = 180 degrees, etc --------
            -------- To flip normally horizontal models like the default spirit touch, all values below must be set to 1.57 or ((90 x 3.14 /) 180) --------
            -------- from 8 - 10 is YAW, PITCH, ROLL --------
            -------- --------
            Set VariableSet BAmr_Config_SPEF_VALUE[8] = 0.00
            -------- YAW --------
            -------- --------
            Set VariableSet BAmr_Config_SPEF_VALUE[9] = 0.00
            -------- PITCH --------
            -------- --------
            Set VariableSet BAmr_Config_SPEF_VALUE[10] = 0.00
            -------- ROLL --------
            -------- --------
            -------- YPR will determine in order of apperance, Yaw, Pitch, & Roll. --------
            -------- --------
            -------- This Value checks whether or not the Shield flare intensity will match the shield's current health --------
            Set VariableSet BAmr_Boolean[2] = False
            -------- If Above Boolean is true, this handles the minimum the shield will fade to. --------
            -------- --------
            Set VariableSet BAmr_Config_SPEF_VALUE[12] = 25.00
            -------- --------
          Else - Actions
        -------- Values contained within directly influence the "shield flare" effect governed by BAmr_EFFECTPATH[3] --------
        -------- --------
      Else - Actions
    -------- Special effects & related values --------
    -------- --------
    -------- Segement Configuration --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
      Then - Actions
        -------- --------
        -------- This value indicates how "segments" will orbit around the enchanted Target. --------
        Set VariableSet BAmr_Config_SEGMENT_SPAWNED = 3
        -------- --------
        -------- This value indicates how far away the "segments" orbit away from the enchanted Target. --------
        -------- SEGMENT ORBIT OFFSET --------
        Set VariableSet BAmr_Config_SEG_VALUE[1] = 60.00
        -------- This value indicates how far away the segments spawn from the their target --------
        -------- SEGMENT SPAWN OFFSET --------
        Set VariableSet BAmr_Config_SEG_VALUE[2] = 120.00
        -------- --------
        -------- This value indicates at what height the segment will be at in addition the the unit's flying height --------
        -------- SEGMENT HEIGHT --------
        Set VariableSet BAmr_Config_SEG_VALUE[3] = 65.00
        -------- --------
        -------- This value indicates how far apart the segements will spawn from, this is default to a 360 --------
        -------- SEGMENT RADIUS TOTAL (I.e. don't change unless you are sure) --------
        Set VariableSet BAmr_Config_SEG_VALUE[4] = 360.00
        -------- --------
        -------- This value indicates how fast the "segments" orbit around the enchanted Target. --------
        -------- SEGMENT ORBIT SPEED --------
        Set VariableSet BAmr_Config_SEG_VALUE[5] = 3.00
        -------- --------
        -------- This value indicates how fast the "segments" intially move towards the enchanted Target. --------
        -------- SEGMENT MISSILE SPEED --------
        Set VariableSet BAmr_Config_SEG_VALUE[6] = 18.00
        -------- --------
        -------- This value Indicates the size of the individual segments --------
        -------- SEGMENT SIZE --------
        Set VariableSet BAmr_Config_SEG_VALUE[7] = 1.00
        -------- --------
        -------- Sets the segments lowest size from damage, the boolean below needs to be set to true for this to take any affect --------
        -------- the value below is how small the segment will shrink to as to avoid making it dissapear all together before the segment threshold damage is reached. --------
        -------- SEGMENT "SHRINK" EFFECT MINIMUM --------
        Set VariableSet BAmr_Config_SEG_VALUE[8] = 0.05
        -------- --------
        Set VariableSet BAmr_Boolean[3] = False
        -------- The value above directly is dependent on the boolean above being set to true --------
        -------- --------
        -------- the value below is how small the segment will shrink to as to avoid making it dissapear all together before the segment threshold damage is reached. --------
        Set VariableSet BAmr_Config_SEG_VALUE[9] = 5.00
        -------- SEGMENT "DIM" EFFECT MINIMUM --------
        -------- --------
        Set VariableSet BAmr_Boolean[4] = True
        -------- If Above Boolean is true, then segments will dim based on how much damage they have taken --------
        -------- --------
        -------- This value corresponds to the segment's "Alpha" i,e. sorta like transparency, do experiment as ribbons and particles will not be affected on the missile... --------
        -------- SEGMENT ALPHA (TEXTURE TRANSPARENCY) --------
        Set VariableSet BAmr_Config_SEG_VALUE[10] = 255.00
        -------- --------
        -------- RGB value from 0 - 255 will determine what colors will be present in the special effect (note this requires a lot of experimentation) --------
        -------- from 11 -13 is RED, GREEN, BLUE --------
        Set VariableSet BAmr_Config_SEG_VALUE[11] = 255.00
        Set VariableSet BAmr_Config_SEG_VALUE[12] = 255.00
        Set VariableSet BAmr_Config_SEG_VALUE[13] = 255.00
        -------- from 1 - 3 is RED, GREEN, BLUE --------
        -------- RGB value from 0 - 255 will determine what colors will be present in the special effect (note this requires a lot of experimentation) --------
        -------- --------
        -------- YPR will determine in order of apperance, Yaw, Pitch, & Roll WHEN ORBITING --------
        -------- The Values are calculated as (( X * 3.14 ) / 180 ), 1.57 = 90 degrees, 3.14 = 180 degrees, etc --------
        -------- from 14, 15, & 16 is YAW, PITCH, ROLL --------
        -------- --------
        Set VariableSet BAmr_Config_SEG_VALUE[14] = 1.57
        -------- YAW --------
        -------- --------
        Set VariableSet BAmr_Config_SEG_VALUE[15] = 0.00
        -------- PITCH --------
        -------- --------
        Set VariableSet BAmr_Config_SEG_VALUE[16] = 0.00
        -------- ROLL --------
        -------- --------
        -------- YPR will determine in order of apperance, Yaw, Pitch, & Roll. --------
        -------- --------
        -------- YPR will determine in order of apperance, Yaw, Pitch, & Roll ON INITIAL CAST AND CLOSING DISTANCE --------
        -------- The Values are calculated as (( X * 3.14 ) / 180 ), 1.57 = 90 degrees, 3.14 = 180 degrees, etc --------
        -------- from 17, 18, & 19 is YAW, PITCH, ROLL --------
        -------- --------
        Set VariableSet BAmr_Config_SEG_VALUE[17] = 0.00
        -------- YAW --------
        -------- --------
        Set VariableSet BAmr_Config_SEG_VALUE[18] = 0.00
        -------- PITCH --------
        -------- --------
        Set VariableSet BAmr_Config_SEG_VALUE[19] = 0.00
        -------- ROLL --------
        -------- --------
      Else - Actions
    -------- Segement orbit values --------
    -------- --------
    -------- Preload --------
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
      Then - Actions
        Set VariableSet BAmr_Point[1] = (Center of (Playable map area))
        Unit - Create 1.Albatross for Neutral Passive at BAmr_Point[1] facing Default building facing degrees
        Set VariableSet BAmr_Unit[0] = (Last created unit)
        Unit - Add BAmr_Config_SPELL_ID to BAmr_Unit[0]
        Unit - Add a 0.03 second Generic expiration timer to BAmr_Unit[0]
        Custom script: call RemoveLocation(udg_BAmr_Point[1])
      Else - Actions
    -------- Preload --------
BAmr Cast
  Events
    Unit - A unit Starts the effect of an ability
  Conditions
    (Ability being cast) Equal to BAmr_Config_SPELL_ID
  Actions
    -------- ===================================================================================================================================== --------
    -------- --------
    -------- Get our bearings --------
    Set VariableSet BAmr_Unit[1] = (Triggering unit)
    Set VariableSet BAmr_Unit[2] = (Target unit of ability being cast)
    Set VariableSet BAmr_Point[1] = (Position of BAmr_Unit[1])
    Set VariableSet BAmr_Point[2] = (Position of BAmr_Unit[2])
    -------- Get our bearings --------
    -------- --------
    -------- Prepare value of shield --------
    Set VariableSet BAmr_Attribute[1] = ((Real((Strength of BAmr_Unit[1] (Include bonuses)))) x BAmr_Config_ATT_BONUS[1])
    Set VariableSet BAmr_Attribute[2] = ((Real((Agility of BAmr_Unit[1] (Include bonuses)))) x BAmr_Config_ATT_BONUS[2])
    Set VariableSet BAmr_Attribute[3] = ((Real((Intelligence of BAmr_Unit[1] (Include bonuses)))) x BAmr_Config_ATT_BONUS[3])
    Set VariableSet BAmr_Real[0] = ((BAmr_Config_BASE_HP + BAmr_Config_LVL_HP_BONUS[(Level of BAmr_Config_SPELL_ID for BAmr_Unit[1])]) + (BAmr_Attribute[1] + (BAmr_Attribute[2] + BAmr_Attribute[3])))
    -------- Prepare value of shield --------
    -------- --------
    -------- Check if unit is already enchanted --------
    For each (Integer BAmr_Loop) from 1 to BAmr_Index, do (Actions)
      Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Enchanted_Unit[BAmr_Loop] Equal to BAmr_Unit[2]
          Then - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                BAmr_Boolean[0] Equal to False
              Then - Actions
                Set VariableSet BAmr_Health[BAmr_Loop] = BAmr_Real[0]
              Else - Actions
                Set VariableSet BAmr_Health[BAmr_Loop] = (BAmr_Health[BAmr_Loop] + BAmr_Real[0])
            Set VariableSet BAmr_Max[BAmr_Loop] = BAmr_Health[BAmr_Loop]
            Set VariableSet BAmr_Total[BAmr_Loop] = 0.00
            For each (Integer BAmr_Loop_Segment) from 1 to BAmr_Config_SEGMENT_SPAWNED, do (Actions)
              Loop - Actions
                Set VariableSet BAmr_Seg_CValue = ((BAmr_Config_SEGMENT_SPAWNED x BAmr_Loop) + (BAmr_Loop_Segment - 1))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    BAmr_Segment_Missile_State[BAmr_Seg_CValue] Not equal to Alive
                  Then - Actions
                    Set VariableSet BAmr_Point[3] = (BAmr_Point[1] offset by BAmr_Config_SEG_VALUE[2] towards ((BAmr_Config_SEG_VALUE[4] / (Real(BAmr_Config_SEGMENT_SPAWNED))) x (Real(BAmr_Loop_Segment))) degrees.)
                    Special Effect - Create a special effect at BAmr_Point[3] using BAmr_Config_SPEF_PATH[0]
                    Set VariableSet BAmr_Segment_Missile[BAmr_Seg_CValue] = (Last created special effect)
                    Custom script: set udg_BAmr_Spef_Current_Height[udg_BAmr_Seg_CValue] = GetLocationZ(udg_BAmr_Point[3])
                    Special Effect - Set Position - Z of BAmr_Segment_Missile[BAmr_Seg_CValue] to ((BAmr_Spef_Current_Height[BAmr_Seg_CValue] + BAmr_Config_SEG_VALUE[3]) + (Current flying height of BAmr_Enchanted_Unit[BAmr_Loop]))
                    Special Effect - Set Scale of BAmr_Segment_Missile[BAmr_Seg_CValue] to BAmr_Config_SEG_VALUE[7]
                    Special Effect - Set Color of BAmr_Segment_Missile[BAmr_Seg_CValue] to r: (Integer(BAmr_Config_SEG_VALUE[11])), g: (Integer(BAmr_Config_SEG_VALUE[12])), b: (Integer(BAmr_Config_SEG_VALUE[13]))
                    Set VariableSet BAmr_Segment_Missile_State[BAmr_Seg_CValue] = Alive
                  Else - Actions
                    Set VariableSet BAmr_Point[3] = (Point((Position - X of BAmr_Segment_Missile[BAmr_Seg_CValue].), (Position - Y of BAmr_Segment_Missile[BAmr_Seg_CValue].)))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    BAmr_Boolean[3] Equal to True
                  Then - Actions
                    Special Effect - Set Scale of BAmr_Segment_Missile[BAmr_Seg_CValue] to BAmr_Config_SEG_VALUE[7]
                  Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    BAmr_Boolean[4] Equal to True
                  Then - Actions
                    Special Effect - Set Alpha of BAmr_Segment_Missile[BAmr_Seg_CValue] to (Integer(BAmr_Config_SEG_VALUE[10]))
                  Else - Actions
                Special Effect - Create a special effect at BAmr_Point[3] using BAmr_Config_SPEF_PATH[1]
                Special Effect - Destroy (Last created special effect)
                Custom script: call RemoveLocation(udg_BAmr_Point[3])
            Custom script: call RemoveLocation(udg_BAmr_Point[1])
            Custom script: call RemoveLocation(udg_BAmr_Point[2])
            Skip remaining actions
          Else - Actions
    -------- Check if unit is already enchanted --------
    -------- --------
    -------- Insert the values & unit directly into the index --------
    -------- Insert the values & unit directly into the index --------
    -------- Insert the values & unit directly into the index --------
    -------- Insert the values & unit directly into the index --------
    Set VariableSet BAmr_Index = (BAmr_Index + 1)
    Set VariableSet BAmr_Health[BAmr_Index] = BAmr_Real[0]
    Set VariableSet BAmr_Max[BAmr_Index] = BAmr_Health[BAmr_Index]
    Set VariableSet BAmr_Total[BAmr_Index] = 0.00
    Set VariableSet BAmr_Enchanted_Unit[BAmr_Index] = BAmr_Unit[2]
    For each (Integer BAmr_Loop_Segment) from 1 to BAmr_Config_SEGMENT_SPAWNED, do (Actions)
      Loop - Actions
        Set VariableSet BAmr_Seg_CValue = ((BAmr_Config_SEGMENT_SPAWNED x BAmr_Index) + (BAmr_Loop_Segment - 1))
        Set VariableSet BAmr_Point[3] = (BAmr_Point[1] offset by BAmr_Config_SEG_VALUE[2] towards ((BAmr_Config_SEG_VALUE[4] / (Real(BAmr_Config_SEGMENT_SPAWNED))) x (Real(BAmr_Loop_Segment))) degrees.)
        Special Effect - Create a special effect at BAmr_Point[3] using BAmr_Config_SPEF_PATH[0]
        Set VariableSet BAmr_Segment_Missile[BAmr_Seg_CValue] = (Last created special effect)
        Custom script: set udg_BAmr_Spef_Current_Height[udg_BAmr_Seg_CValue] = GetLocationZ(udg_BAmr_Point[3])
        Special Effect - Set Position - Z of BAmr_Segment_Missile[BAmr_Seg_CValue] to ((BAmr_Spef_Current_Height[BAmr_Seg_CValue] + BAmr_Config_SEG_VALUE[3]) + (Current flying height of BAmr_Enchanted_Unit[BAmr_Index]))
        Special Effect - Set Scale of BAmr_Segment_Missile[BAmr_Seg_CValue] to BAmr_Config_SEG_VALUE[7]
        Special Effect - Set Color of BAmr_Segment_Missile[BAmr_Seg_CValue] to r: (Integer(BAmr_Config_SEG_VALUE[11])), g: (Integer(BAmr_Config_SEG_VALUE[12])), b: (Integer(BAmr_Config_SEG_VALUE[13]))
        Set VariableSet BAmr_Segment_Missile_State[BAmr_Seg_CValue] = Alive
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Boolean[3] Equal to True
          Then - Actions
            Special Effect - Set Scale of BAmr_Segment_Missile[BAmr_Seg_CValue] to BAmr_Config_SEG_VALUE[7]
          Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Boolean[4] Equal to True
          Then - Actions
            Special Effect - Set Alpha of BAmr_Segment_Missile[BAmr_Seg_CValue] to (Integer(BAmr_Config_SEG_VALUE[10]))
          Else - Actions
        Special Effect - Create a special effect at BAmr_Point[3] using BAmr_Config_SPEF_PATH[1]
        Special Effect - Destroy (Last created special effect)
        Custom script: call RemoveLocation(udg_BAmr_Point[3])
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        BAmr_Index Equal to 1
      Then - Actions
        Trigger - Turn on BAmr_Periodic <gen>
        Trigger - Turn on BAmr_Block <gen>
      Else - Actions
    -------- Insert the values & unit directly into the index --------
    -------- --------
    -------- --------
    -------- What are leaks? --------
    -------- https://www.hiveworkshop.com/threads/things-that-leak.35124/ --------
    -------- --------
    -------- No longer referencing the location, clean them up! --------
    Custom script: call RemoveLocation(udg_BAmr_Point[1])
    Custom script: call RemoveLocation(udg_BAmr_Point[2])
    -------- No longer referencing the location, clean them up! --------
    -------- --------
    -------- ===================================================================================================================================== --------
(250 - ((300 / 3 ) x (LOOP - 1))
BAmr Block
  Events
    Game - DamageModifierEvent becomes Equal to 4.00
  Conditions
    (DamageEventTarget has buff BAmr_Config_BUFF) Equal to True
  Actions
    For each (Integer BAmr_Loop) from 1 to BAmr_Index, do (Actions)
      Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            DamageEventTarget Equal to BAmr_Enchanted_Unit[BAmr_Loop]
          Then - Actions
            Set VariableSet BAmr_DMG_Event = BAmr_Health[BAmr_Loop]
            -------- --------
            -------- Damage "Flare" effect --------
            Set VariableSet BAmr_Point[1] = (Position of DamageEventTarget)
            Set VariableSet BAmr_Point[2] = (Position of DamageEventSource)
            Custom script: set udg_BAmr_Spef_Current_Height[udg_BAmr_Loop] = GetLocationZ(udg_BAmr_Point[1])
            Special Effect - Create a special effect at (BAmr_Point[1] offset by BAmr_Config_SPEF_VALUE[1] towards (Angle from BAmr_Point[1] to BAmr_Point[2]) degrees.) using BAmr_Config_SPEF_PATH[3]
            Set VariableSet BAmr_Config_SPEF = (Last created special effect)
            Special Effect - Set Position - Z of BAmr_Config_SPEF to ((BAmr_Spef_Current_Height[BAmr_Loop] + BAmr_Config_SPEF_VALUE[2]) + (Current flying height of DamageEventTarget))
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                BAmr_Boolean[1] Equal to True
              Then - Actions
                Special Effect - Set Color of BAmr_Config_SPEF to color of (Owner of DamageEventTarget)
              Else - Actions
                Special Effect - Set Color of BAmr_Config_SPEF to color of (Player((Integer(BAmr_Config_SPEF_VALUE[0]))))
            Special Effect - Set Color of BAmr_Config_SPEF to r: (Integer(BAmr_Config_SPEF_VALUE[5])), g: (Integer(BAmr_Config_SPEF_VALUE[6])), b: (Integer(BAmr_Config_SPEF_VALUE[7]))
            Special Effect - Set Scale of BAmr_Config_SPEF to BAmr_Config_SPEF_VALUE[3]
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                BAmr_Boolean[2] Equal to True
              Then - Actions
                Set VariableSet BAmr_Real[1] = (BAmr_Health[BAmr_Loop] / (BAmr_Max[BAmr_Loop] / 255.00))
                If (BAmr_Real[1] Less than BAmr_Config_SPEF_VALUE[11]) then do (Set VariableSet BAmr_Real[1] = BAmr_Config_SPEF_VALUE[11]) else do (Do nothing)
                Special Effect - Set Alpha of BAmr_Config_SPEF to (Integer(BAmr_Real[1]))
              Else - Actions
            Special Effect - Set Time Scale of BAmr_Config_SPEF to BAmr_Config_SPEF_VALUE[4]
            Special Effect - Set Orientation of BAmr_Config_SPEF to yaw: (BAmr_Config_SPEF_VALUE[8] + (Radians((Angle from BAmr_Point[1] to BAmr_Point[2])))), pitch: BAmr_Config_SPEF_VALUE[9], roll: BAmr_Config_SPEF_VALUE[10]
            Special Effect - Destroy BAmr_Config_SPEF
            Custom script: call RemoveLocation(udg_BAmr_Point[1])
            Custom script: call RemoveLocation(udg_BAmr_Point[2])
            -------- --------
            -------- This sets the damage of spells and physical attacks, it will ignore rates below zero allowing you to set strictly spell shields or physical sheilds! --------
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                IsDamageSpell Equal to True
              Then - Actions
                If (BAmr_Config_RESIST_SPELL Equal to 0.00) then do (Skip remaining actions) else do (Set VariableSet DamageEventAmount = (DamageEventAmount x BAmr_Config_RESIST_SPELL))
              Else - Actions
                If (BAmr_Config_RESIST_PHYSICAL Equal to 0.00) then do (Skip remaining actions) else do (Set VariableSet DamageEventAmount = (DamageEventAmount x BAmr_Config_RESIST_PHYSICAL))
            -------- --------
            -------- This sets the damage to the percentage that the spell will absorb --------
            Set VariableSet DamageEventAmount = (DamageEventAmount x BAmr_Config_ABSORBTION)
            -------- --------
            Set VariableSet BAmr_Total[BAmr_Loop] = (BAmr_Total[BAmr_Loop] + DamageEventAmount)
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                DamageEventAmount Less than (BAmr_DMG_Event - 0.01)
              Then - Actions
                Set VariableSet BAmr_DMG_Event = (BAmr_DMG_Event - DamageEventAmount)
                Set VariableSet DamageEventAmount = (DamageEventAmount - (DamageEventAmount x BAmr_Config_ABSORBTION))
                If (DamageEventAmount Less than 0.00) then do (Set VariableSet DamageEventAmount = 0.00) else do (Do nothing)
                Set VariableSet BAmr_Health[BAmr_Loop] = BAmr_DMG_Event
              Else - Actions
                Unit - Remove BAmr_Config_BUFF buff from DamageEventTarget
                Set VariableSet DamageEventAmount = (DamageEventAmount - BAmr_DMG_Event)
                Set VariableSet BAmr_Health[BAmr_Loop] = 0.00
            For each (Integer BAmr_Loop_Segment) from 1 to BAmr_Config_SEGMENT_SPAWNED, do (Actions)
              Loop - Actions
                Set VariableSet BAmr_Seg_CValue = ((BAmr_Config_SEGMENT_SPAWNED x BAmr_Loop) + (BAmr_Loop_Segment - 1))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    BAmr_Total[BAmr_Loop] Greater than (BAmr_Max[BAmr_Loop] - ((BAmr_Max[BAmr_Loop] / (Real(BAmr_Config_SEGMENT_SPAWNED))) x (Real((BAmr_Loop_Segment - 1)))))
                  Then - Actions
                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      If - Conditions
                        BAmr_Segment_Missile_State[BAmr_Seg_CValue] Equal to Alive
                      Then - Actions
                        Set VariableSet BAmr_Point[3] = (Point((Position - X of BAmr_Segment_Missile[BAmr_Seg_CValue].), (Position - Y of BAmr_Segment_Missile[BAmr_Seg_CValue].)))
                        Set VariableSet BAmr_Segment_Missile_State[BAmr_Seg_CValue] = Dead
                        Special Effect - Destroy BAmr_Segment_Missile[BAmr_Seg_CValue]
                        Special Effect - Create a special effect at BAmr_Point[3] using BAmr_Config_SPEF_PATH[2]
                        Special Effect - Destroy (Last created special effect)
                        Custom script: call RemoveLocation(udg_BAmr_Point[3])
                      Else - Actions
                  Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    (BAmr_Health[BAmr_Loop] - ((BAmr_Max[BAmr_Loop] / (Real(BAmr_Config_SEGMENT_SPAWNED))) x (Real((BAmr_Loop_Segment - 1))))) Less than or equal to (BAmr_Max[BAmr_Loop] / (Real(BAmr_Config_SEGMENT_SPAWNED)))
                    BAmr_Segment_Missile_State[BAmr_Seg_CValue] Equal to Alive
                    Or - Any (Conditions) are true
                      Conditions
                        BAmr_Boolean[3] Equal to True
                        BAmr_Boolean[4] Equal to True
                  Then - Actions
                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      If - Conditions
                        BAmr_Boolean[3] Equal to True
                      Then - Actions
                        Set VariableSet BAmr_Real[2] = ((BAmr_Health[BAmr_Loop] - ((BAmr_Max[BAmr_Loop] / (Real(BAmr_Config_SEGMENT_SPAWNED))) x (Real((BAmr_Loop_Segment - 1))))) / ((BAmr_Max[BAmr_Loop] / (Real(BAmr_Config_SEGMENT_SPAWNED))) / BAmr_Config_SEG_VALUE[7]))
                        If (BAmr_Real[2] Less than BAmr_Config_SEG_VALUE[8]) then do (Set VariableSet BAmr_Real[2] = BAmr_Config_SEG_VALUE[8]) else do (Do nothing)
                        Special Effect - Set Scale of BAmr_Segment_Missile[BAmr_Seg_CValue] to BAmr_Real[2]
                      Else - Actions
                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      If - Conditions
                        BAmr_Boolean[4] Equal to True
                      Then - Actions
                        Set VariableSet BAmr_Real[3] = ((BAmr_Health[BAmr_Loop] - ((BAmr_Max[BAmr_Loop] / (Real(BAmr_Config_SEGMENT_SPAWNED))) x (Real((BAmr_Loop_Segment - 1))))) / ((BAmr_Max[BAmr_Loop] / (Real(BAmr_Config_SEGMENT_SPAWNED))) / BAmr_Config_SEG_VALUE[10]))
                        If (BAmr_Real[3] Less than BAmr_Config_SEG_VALUE[9]) then do (Set VariableSet BAmr_Real[3] = BAmr_Config_SEG_VALUE[9]) else do (Do nothing)
                        Special Effect - Set Alpha of BAmr_Segment_Missile[BAmr_Seg_CValue] to (Integer(BAmr_Real[3]))
                      Else - Actions
                  Else - Actions
          Else - Actions
BAmr Periodic
  Events
  Conditions
  Actions
    For each (Integer BAmr_Loop) from 1 to BAmr_Index, do (Actions)
      Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            (BAmr_Enchanted_Unit[BAmr_Loop] has buff BAmr_Config_BUFF) Equal to False
          Then - Actions
            Set VariableSet BAmr_Health[BAmr_Loop] = 0.00
            For each (Integer BAmr_Loop_Segment) from 1 to BAmr_Config_SEGMENT_SPAWNED, do (Actions)
              Loop - Actions
                Set VariableSet BAmr_Seg_CValue = ((BAmr_Config_SEGMENT_SPAWNED x BAmr_Loop) + (BAmr_Loop_Segment - 1))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    BAmr_Segment_Missile_State[BAmr_Seg_CValue] Equal to Alive
                  Then - Actions
                    Set VariableSet BAmr_Point[3] = (Point((Position - X of BAmr_Segment_Missile[BAmr_Seg_CValue].), (Position - Y of BAmr_Segment_Missile[BAmr_Seg_CValue].)))
                    Set VariableSet BAmr_Segment_Missile_State[BAmr_Seg_CValue] = Dead
                    Special Effect - Destroy BAmr_Segment_Missile[BAmr_Seg_CValue]
                    Special Effect - Create a special effect at BAmr_Point[3] using BAmr_Config_SPEF_PATH[2]
                    Special Effect - Destroy (Last created special effect)
                    Custom script: call RemoveLocation(udg_BAmr_Point[3])
                  Else - Actions
                Set VariableSet BAmr_Seg_CValue_DeIndex = ((BAmr_Config_SEGMENT_SPAWNED x BAmr_Index) + (BAmr_Loop_Segment - 1))
                Set VariableSet BAmr_Segment_Missile[BAmr_Seg_CValue] = BAmr_Segment_Missile[BAmr_Seg_CValue_DeIndex]
                Set VariableSet BAmr_Segment_Missile_State[BAmr_Seg_CValue] = BAmr_Segment_Missile_State[BAmr_Seg_CValue_DeIndex]
            Set VariableSet BAmr_Enchanted_Unit[BAmr_Loop] = BAmr_Enchanted_Unit[BAmr_Index]
            Set VariableSet BAmr_Health[BAmr_Loop] = BAmr_Health[BAmr_Index]
            Set VariableSet BAmr_Max[BAmr_Loop] = BAmr_Max[BAmr_Index]
            Set VariableSet BAmr_Spef_Current_Height[BAmr_Loop] = BAmr_Spef_Current_Height[BAmr_Index]
            Set VariableSet BAmr_Total[BAmr_Loop] = BAmr_Total[BAmr_Index]
            Set VariableSet BAmr_Index = (BAmr_Index - 1)
            Set VariableSet BAmr_Loop = (BAmr_Loop - 1)
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                BAmr_Index Equal to 0
              Then - Actions
                Trigger - Turn off BAmr_Periodic <gen>
                Trigger - Turn off BAmr_Block <gen>
              Else - Actions
            -------- --------
          Else - Actions
            Set VariableSet BAmr_Point[1] = (Position of BAmr_Enchanted_Unit[BAmr_Loop])
            Set VariableSet BAmr_Current_Rot_Speed[BAmr_Loop] = (BAmr_Current_Rot_Speed[BAmr_Loop] + BAmr_Config_SEG_VALUE[5])
            For each (Integer BAmr_Loop_Segment) from 1 to BAmr_Config_SEGMENT_SPAWNED, do (Actions)
              Loop - Actions
                Set VariableSet BAmr_Seg_CValue = ((BAmr_Config_SEGMENT_SPAWNED x BAmr_Loop) + (BAmr_Loop_Segment - 1))
                Set VariableSet BAmr_Point[3] = (Point((Position - X of BAmr_Segment_Missile[BAmr_Seg_CValue].), (Position - Y of BAmr_Segment_Missile[BAmr_Seg_CValue].)))
                Custom script: set udg_BAmr_Spef_Current_Height[udg_BAmr_Seg_CValue] = GetLocationZ(udg_BAmr_Point[1])
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    (Distance between BAmr_Point[1] and BAmr_Point[3]) Less than (BAmr_Config_SEG_VALUE[1] + 15.00)
                  Then - Actions
                    -------- ORBITING --------
                    Set VariableSet BAmr_Point[2] = (BAmr_Point[1] offset by BAmr_Config_SEG_VALUE[1] towards (((360.00 / (Real(BAmr_Config_SEGMENT_SPAWNED))) x (Real(BAmr_Loop_Segment))) + BAmr_Current_Rot_Speed[BAmr_Loop]) degrees.)
                    Special Effect - Set Position of BAmr_Segment_Missile[BAmr_Seg_CValue] to x: (X of BAmr_Point[2]), y: (Y of BAmr_Point[2]), z: ((BAmr_Spef_Current_Height[BAmr_Seg_CValue] + BAmr_Config_SEG_VALUE[3]) + (Current flying height of BAmr_Enchanted_Unit[BAmr_Loop]))
                    Special Effect - Set Orientation of BAmr_Segment_Missile[BAmr_Seg_CValue] to yaw: (BAmr_Config_SEG_VALUE[14] + (Radians((Angle from BAmr_Point[1] to BAmr_Point[2])))), pitch: BAmr_Config_SEG_VALUE[15], roll: BAmr_Config_SEG_VALUE[16]
                  Else - Actions
                    -------- TRAVELING --------
                    Set VariableSet BAmr_Point[2] = (BAmr_Point[3] offset by BAmr_Config_SEG_VALUE[6] towards (Angle from BAmr_Point[3] to BAmr_Point[1]) degrees.)
                    Special Effect - Set Position of BAmr_Segment_Missile[BAmr_Seg_CValue] to x: (X of BAmr_Point[2]), y: (Y of BAmr_Point[2]), z: ((BAmr_Spef_Current_Height[BAmr_Seg_CValue] + BAmr_Config_SEG_VALUE[3]) + (Current flying height of BAmr_Enchanted_Unit[BAmr_Loop]))
                    Special Effect - Set Orientation of BAmr_Segment_Missile[BAmr_Seg_CValue] to yaw: (BAmr_Config_SEG_VALUE[17] + (Radians((Angle from BAmr_Point[3] to BAmr_Point[2])))), pitch: BAmr_Config_SEG_VALUE[18], roll: BAmr_Config_SEG_VALUE[19]
                -------- --------
                Custom script: call RemoveLocation(udg_BAmr_Point[2])
                Custom script: call RemoveLocation(udg_BAmr_Point[3])
            Custom script: call RemoveLocation(udg_BAmr_Point[1])
Select a unit and hit escape:
"Footman has 150 / 300 Shield Remaining."
Check Shield Value
  Events
    Player - Player 1 (Red) skips a cinematic sequence
  Conditions
  Actions
    Custom script: set bj_wantDestroyGroup = true
    Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      Loop - Actions
        For each (Integer BAmr_Loop) from 1 to BAmr_Index, do (Actions)
          Loop - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Picked unit) Equal to BAmr_Enchanted_Unit[BAmr_Loop]
                ((Picked unit) is selected by Player 1 (Red).) Equal to True
                ((Picked unit) has buff BAmr_Config_BUFF) Equal to True
              Then - Actions
                Game - Display to (All players) the text: ((Name of (Picked unit)) + ( has + (((String((Abs((Integer(BAmr_Health[BAmr_Loop])))))) + ( / + ((String((Abs((Integer(BAmr_Max[BAmr_Loop])))))) + Shield Remaining.))) + )))
              Else - Actions
Bones"Command" Example - "BonesSTACK"

Stack = Toggle Stack boolean
Skins = Toggle Player color based shied flare
Dim = Toggled dimming based on shield health for shield flare
Shrink = Toggled Shrinking of segments based on health of shield max spread through the individual segments (i.e. default 300 / 3 segments = 100 hp each segment, meaning at 50hp the segment will be shrunk down by 50% of their scale.)
Fade = Same as shrink however via the segment's "Alpha" appearing more faded based on health
SEM = Simple Effect mode, Lose orbiting segments and revert to simpler times~ (WARNING, DO NOT HAVE ANY INSTANCES OF DEFAULT BONE ARMOR WHEN USING THIS IT WILL BECOME BUGGY AND OR FUNKY)


Commands
  Events
    Player - Player 1 (Red) types a chat message containing Bones (stringnoformat) as A substring
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Substring((Entered chat string), 6, 10)) Equal to stack
        Or - Any (Conditions) are true
          Conditions
            (Substring((Entered chat string), 6, 10)) Equal to Stack
            (Substring((Entered chat string), 6, 10)) Equal to stack
            (Substring((Entered chat string), 6, 10)) Equal to STACK
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Boolean[0] Equal to True
          Then - Actions
            Set VariableSet BAmr_Boolean[0] = False
          Else - Actions
            Set VariableSet BAmr_Boolean[0] = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        Or - Any (Conditions) are true
          Conditions
            (Substring((Entered chat string), 6, 10)) Equal to Skins
            (Substring((Entered chat string), 6, 10)) Equal to skins
            (Substring((Entered chat string), 6, 10)) Equal to SKINS
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Boolean[1] Equal to True
          Then - Actions
            Set VariableSet BAmr_Boolean[1] = False
          Else - Actions
            Set VariableSet BAmr_Boolean[1] = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        Or - Any (Conditions) are true
          Conditions
            (Substring((Entered chat string), 6, 8)) Equal to Dim
            (Substring((Entered chat string), 6, 8)) Equal to dim
            (Substring((Entered chat string), 6, 8)) Equal to DIM
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Boolean[2] Equal to True
          Then - Actions
            Set VariableSet BAmr_Boolean[2] = False
          Else - Actions
            Set VariableSet BAmr_Boolean[2] = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        Or - Any (Conditions) are true
          Conditions
            (Substring((Entered chat string), 6, 11)) Equal to Shrink
            (Substring((Entered chat string), 6, 11)) Equal to shrink
            (Substring((Entered chat string), 6, 11)) Equal to SHRINK
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Boolean[3] Equal to True
          Then - Actions
            Set VariableSet BAmr_Boolean[3] = False
          Else - Actions
            Set VariableSet BAmr_Boolean[3] = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        Or - Any (Conditions) are true
          Conditions
            (Substring((Entered chat string), 6, 9)) Equal to Fade
            (Substring((Entered chat string), 6, 9)) Equal to fade
            (Substring((Entered chat string), 6, 9)) Equal to FADE
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            BAmr_Boolean[4] Equal to True
          Then - Actions
            Set VariableSet BAmr_Boolean[4] = False
          Else - Actions
            Set VariableSet BAmr_Boolean[4] = True
      Else - Actions
Selection
  Events
    Map initialization
  Conditions
  Actions
    Selection - Select Necromancer 0027 <gen> for Player 1 (Red)
    Hero - Create Dusty Tome Titled "Up-shins" and give it to Necromancer 0027 <gen>
    Hero - Create Staff of Negation and give it to Necromancer 0027 <gen>
    Visibility - Disable fog of war
    Visibility - Disable black mask
Options
  Events
    Unit - A unit Starts the effect of an ability
  Conditions
  Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Momento Mori
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            ZZZ_NtRq_Zombie Equal to True
          Then - Actions
            Set VariableSet ZZZ_NtRq_Zombie = False
            Trigger - Turn off DOTD_Loop <gen>
          Else - Actions
            Set VariableSet ZZZ_NtRq_Zombie = True
            Sound - Play NecromancerPissed3 <gen> at 100% volume, located at (Target of current camera view) with Z offset 0
            Trigger - Run DOTD_Loop <gen> (checking conditions)
            Trigger - Turn on DOTD_Loop <gen>
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Spite
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            ZZZ_NtRq_Spite Equal to True
          Then - Actions
            Set VariableSet ZZZ_NtRq_Spite = False
          Else - Actions
            Sound - Play GoblinSapperPissed6 <gen> at 100% volume, located at (Target of current camera view) with Z offset 0
            Set VariableSet ZZZ_NtRq_Spite = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Split
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            ZZZ_NtRq_Split Equal to True
          Then - Actions
            Set VariableSet ZZZ_NtRq_Split = False
          Else - Actions
            Sound - Play GyrocopterPissed6 <gen> at 100% volume, located at (Target of current camera view) with Z offset 0
            Set VariableSet ZZZ_NtRq_Split = True
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Ability being cast) Equal to Spirit shot
      Then - Actions
        Set VariableSet BAmr_Point[8] = (Target point of ability being cast)
        Unit - Create 1.Ghost for Neutral Passive at BAmr_Point[8] facing Default building facing degrees
        Unit - Add Invulnerable (Neutral) to (Last created unit)
        Unit - Set Name of (Last created unit) to Rebecca
        Animation - Change (Last created unit)'s size to (55.00%, 55.00%, 55.00%) of its original size
        Item - Create Medallion of Courage at (BAmr_Point[8] offset by 50.00 towards 180.00 degrees.)
        Special Effect - Create a special effect at BAmr_Point[8] using Abilities\Spells\Undead\RaiseSkeletonWarrior\RaiseSkeleton.mdl
        Special Effect - Destroy (Last created special effect)
        Custom script: call RemoveLocation(udg_BAmr_Point[8])
      Else - Actions
Death
  Events
    Unit - A unit Dies
  Conditions
  Actions
    Set VariableSet BAmr_Point[7] = (Position of (Dying unit))
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Random integer number between 1 and 80) Equal to 1
        (Owner of (Dying unit)) Equal to Neutral Hostile
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            (Random integer number between 1 and 10) Equal to 1
          Then - Actions
            Item - Create Rune of Greater Healing at BAmr_Point[6]
          Else - Actions
            Item - Create Rune of Lesser Healing at BAmr_Point[6]
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        ((Dying unit) is Summoned) Equal to False
        ZZZ_NtRq_Zombie Equal to True
      Then - Actions
        Unit - Create 1.Zombie for Player 4 (Purple) at BAmr_Point[7] facing Default building facing degrees
        Unit - Add classification of Summoned to (Last created unit)
        Unit - Order (Last created unit) to Attack-Move To.(Center of Region_002 <gen>)
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        ZZZ_NtRq_Spite Equal to True
        (Owner of (Dying unit)) Not equal to Player 2 (Blue)
        (Owner of (Dying unit)) Not equal to Player 1 (Red)
      Then - Actions
        Custom script: set bj_wantDestroyGroup = true
        Unit Group - Pick every unit in (Units within 250.00 of BAmr_Point[7].) and do (Actions)
          Loop - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                ((Picked unit) is alive) Equal to True
              Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    ((Picked unit) is Summoned) Equal to True
                  Then - Actions
                    Unit - Cause (Killing unit) to damage (Picked unit), dealing 100.00 damage of attack type Pierce and damage type Normal
                  Else - Actions
                    Unit - Cause (Killing unit) to damage (Picked unit), dealing 25.00 damage of attack type Spells and damage type Normal
                Special Effect - Create a special effect attached to the chest (attachpoint) of (Picked unit) using Abilities\Spells\Items\AIfb\AIfbSpecialArt.mdl
                Special Effect - Destroy (Last created special effect)
              Else - Actions
        Special Effect - Create a special effect at BAmr_Point[7] using Objects\Spawnmodels\Human\HumanLargeDeathExplode\HumanLargeDeathExplode.mdl
        Special Effect - Destroy (Last created special effect)
        Special Effect - Create a special effect at BAmr_Point[7] using Abilities\Weapons\Mortar\MortarMissile.mdl
        Special Effect - Destroy (Last created special effect)
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        ZZZ_NtRq_Split Equal to True
        (Owner of (Dying unit)) Not equal to Neutral Hostile
        (Owner of (Dying unit)) Not equal to Player 5 (Yellow)
        (Owner of (Dying unit)) Not equal to Player 2 (Blue)
        (Owner of (Dying unit)) Not equal to Player 1 (Red)
        ((Dying unit) is Summoned) Equal to False
        ((Dying unit) is A structure) Equal to False
      Then - Actions
        For each (Integer A) from 1 to 2, do (Actions)
          Loop - Actions
            Unit - Create 1.(Unit-type of (Dying unit)) for Player 4 (Purple) at BAmr_Point[7] facing Default building facing degrees
            Unit - Set Max HP of (Last created unit) to ((Max HP of (Triggering unit)) / 4)
            Unit - Add classification of Summoned to (Last created unit)
            Animation - Change (Last created unit)'s size to (65.00%, 65.00%, 65.00%) of its original size
            Special Effect - Create a special effect at BAmr_Point[6] using Abilities\Spells\Items\AIil\AIilTarget.mdl
            Special Effect - Destroy (Last created special effect)
      Else - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Unit-type of (Dying unit)) Equal to PARTUMGENERO
      Then - Actions
        Unit - Create 1.Universal Missile Dummy Unit 1 ( NOT REQUIRED) for Neutral Passive at BAmr_Point[7] facing Default building facing degrees
        Unit - Order (Last created unit) to Undead Destroyer - Devour Magic.(Center of Region_003 <gen>)
        Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      Else - Actions
    Custom script: call RemoveLocation(udg_BAmr_Point[7])
View
  Events
    Unit - A unit enters Region_004 <gen>
  Conditions
    (Owner of (Triggering unit)) Equal to Player 1 (Red)
  Actions
    Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across View_1 <gen>
    Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across View_2 <gen>
    Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across View_3 <gen>
    Trigger - Turn off (This trigger)
DOTD Loop
  Events
    Time - Every 45.00 seconds of game time
  Conditions
  Actions
    Set VariableSet BAmr_Point[4] = (Random point in Region_000 <gen>)
    Set VariableSet BAmr_Point[5] = (Random point in Region_001 <gen>)
    For each (Integer A) from 1 to (Random integer number between 4 and 6), do (Actions)
      Loop - Actions
        Unit - Create 1.Zombie for Player 4 (Purple) at BAmr_Point[(Random integer number between 4 and 6)] facing Default building facing degrees
        Unit - Order (Last created unit) to Attack-Move To.(Center of Region_002 <gen>)
    For each (Integer A) from 1 to (Random integer number between 4 and 5), do (Actions)
      Loop - Actions
        Unit - Create 1.Ghoul for Player 4 (Purple) at BAmr_Point[(Random integer number between 4 and 5)] facing Default building facing degrees
        Unit - Order (Last created unit) to Attack-Move To.(Center of Region_002 <gen>)
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      If - Conditions
        (Random integer number between 1 and 10) Less than or equal to 5
      Then - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          If - Conditions
            (Random integer number between 1 and 4) Equal to 1
          Then - Actions
            Sound - Play AbominationPissed1 <gen> at 100% volume, located at (Player 1 (Red) start location) with Z offset 0
          Else - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              If - Conditions
                (Random integer number between 1 and 3) Equal to 1
              Then - Actions
                Sound - Play AbominationPissed4 <gen> at 100% volume, located at (Player 1 (Red) start location) with Z offset 0
              Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  If - Conditions
                    (Random integer number between 1 and 2) Equal to 1
                  Then - Actions
                    Sound - Play AbominationWarcry1 <gen> at 100% volume, located at (Player 1 (Red) start location) with Z offset 0
                  Else - Actions
                    Sound - Play AbominationYes3 <gen> at 100% volume, located at (Player 1 (Red) start location) with Z offset 0
        Unit - Create 1.Abomination for Player 4 (Purple) at BAmr_Point[(Random integer number between 4 and 5)] facing Default building facing degrees
        Unit - Order (Last created unit) to Attack-Move To.(Center of Region_002 <gen>)
      Else - Actions
    Custom script: call RemoveLocation(udg_BAmr_Point[4])
    Custom script: call RemoveLocation(udg_BAmr_Point[5])
    Custom script: call RemoveLocation(udg_BAmr_Point[6])