• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Spell] Spell starts to not work randomly

Status
Not open for further replies.
Level 22
Joined
Feb 3, 2009
Messages
3,292
Hello, I made a mana shield type of spell triggered and for some reason at some random point it stops working for a certain hero.

Here are the triggers:

  • Energy Shield Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Energy Shield [Mage]
    • Actions
      • Unit - Add Dispersion to (Triggering unit)
  • Energy Shield Use
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Issued order) Equal to (Order(manashieldon))
              • (Level of Energy Shield [Mage] for (Triggering unit)) Greater than 0
        • Then - Actions
          • Unit Group - Add (Triggering unit) to ManaShieldGroup
          • Unit Group - Pick every unit in ManaShieldGroup and do (Actions)
            • Loop - Actions
              • Game - Display to (All players) for 15.00 seconds the text: (Name of (Picked unit))
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Issued order) Equal to (Order(manashieldoff))
                  • (Level of Energy Shield [Mage] for (Triggering unit)) Greater than 0
            • Then - Actions
              • Unit Group - Remove (Triggering unit) from ManaShieldGroup
              • Unit Group - Pick every unit in ManaShieldGroup and do (Actions)
                • Loop - Actions
                  • Game - Display to (All players) for 15.00 seconds the text: (Name of (Picked unit))
            • Else - Actions
  • Energy Shield
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget is in ManaShieldGroup) Equal to True
    • Actions
      • Game - Display to (All players) for 15.00 seconds the text: Condition Fired
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Mana of DamageEventTarget) Greater than or equal to DamageEventAmount
        • Then - Actions
          • Game - Display to (All players) for 15.00 seconds the text: Activated
          • Unit - Set life of DamageEventTarget to ((Life of DamageEventTarget) + DamageEventAmount)
          • Unit - Set mana of DamageEventTarget to ((Mana of DamageEventTarget) - (0.75 x DamageEventAmount))
          • Game - Display to (All players) for 15.00 seconds the text: (Name of DamageEventTarget)
          • Game - Display to (All players) for 15.00 seconds the text: (Name of DamageEventSource)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Dispersion[(Custom value of DamageEventTarget)] Equal to No unit
            • Then - Actions
              • Special Effect - Create a special effect attached to the origin of DamageEventSource using Abilities\Spells\Human\Feedback\ArcaneTowerAttack.mdl
              • Unit - Cause DamageEventTarget to damage DamageEventSource, dealing DamageEventAmount damage of attack type Chaos and damage type Normal
              • Game - Display to (All players) for 15.00 seconds the text: (String(DamageEventAmount))
            • Else - Actions
              • Special Effect - Create a special effect attached to the origin of Dispersion[(Custom value of (Triggering unit))] using Abilities\Spells\Human\Feedback\ArcaneTowerAttack.mdl
              • Unit - Cause DamageEventTarget to damage Dispersion[(Custom value of (Triggering unit))], dealing DamageEventAmount damage of attack type Chaos and damage type Normal
              • Game - Display to (All players) for 15.00 seconds the text: (String(DamageEventAmount))
        • Else - Actions
          • Unit - Order DamageEventTarget to Neutral Naga Sea Witch - Deactivate Mana Shield
Bellow is the damage engine I use in my map (in case it's needed to post:

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

I also figured out that it only stops working for that hero, in the replay I remove him from the game and make a new one, and it works again.
I also tried making a trigger to remove and add the ability, which didn't fix the problem.

I have updated the main post with the other relevant triggers.
 

Attachments

  • Titan_Land_Rise_of_Kingdoms v3.82.w3x
    7.8 MB · Views: 57
  • EnergyShield.w3g
    29 KB · Views: 40
Last edited:
Status
Not open for further replies.
Top