Weird bug in my spell

Status
Not open for further replies.
Hello Hive

I have a problem with one of my spells. It is a long range arrow kind of spell. It works like this:

When hero uses spell a dummy unit is summoned and attacks target of spell being cast. When target of spell being cast takes damage and the damage source is the dummy then the caster of the spell deals damage to the target of spell being cast, and another dummy is summoned and casts slow on target of spell being cast.

This all works just fine, but the problem I am having is with removing the dummy units. When I cast the spell on one unit, and then I cast the spell a second time on another unit it works fine. But when I cast the spell twice on the same unit the unit takes double damage and spawns two slow dummy units, one of which is not removed properly. Every time I cast the spell on the same unit the damage is doubled/tripled etc, and an additional dummy unit is left on the map.

Maybe any of you can take a look? Triggers below:




  • Holy Arrow
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Ability being cast) Equal to Holy Arrow LvL 1 ) or (((Ability being cast) Equal to Holy Arrow LvL 2 ) or (((Ability being cast) Equal to Holy Arrow LvL 3 ) or (((Ability being cast) Equal to Holy Arrow LvL 4 ) or ((Ability being cast) Equal to Holy Arrow LvL 5 ))))
    • Actions
      • Set HolyArrowTarget = (Target unit of ability being cast)
      • Trigger - Add to Holy Arrow Damage <gen> the event (Unit - HolyArrowTarget Takes damage)
      • If ((Hero is alive) Equal to False) then do (Skip remaining actions) else do (Do nothing)
      • Wait 0.01 seconds
      • If ((Hero is alive) Equal to False) then do (Skip remaining actions) else do (Do nothing)
      • Animation - Play Hero's attack animation
      • Unit - Pause Hero
      • Wait 0.10 seconds
      • If ((Hero is alive) Equal to False) then do (Skip remaining actions) else do (Do nothing)
      • Animation - Change Hero's animation speed to 50.00% of its original speed
      • Wait 0.10 seconds
      • If ((Hero is alive) Equal to False) then do (Skip remaining actions) else do (Do nothing)
      • Special Effect - Create a special effect attached to the chest of Hero using Abilities\Spells\Items\StaffOfSanctuary\Staff_Sanctuary_Target.mdl
      • Set HolyArrowEffect = (Last created special effect)
      • Animation - Change Hero's animation speed to 35.00% of its original speed
      • Wait 0.20 seconds
      • If ((Hero is alive) Equal to False) then do (Skip remaining actions) else do (Do nothing)
      • Special Effect - Create a special effect attached to the chest of Hero using AngelWingGigy.mdx
      • Unit - Create 1 Holy Arrow Dummy for Player 1 (Red) at (Position of Hero) facing Default building facing degrees
      • Set HolyArrowDummy = (Last created unit)
      • Unit - Order HolyArrowDummy to Attack HolyArrowTarget
      • Wait 2.00 seconds
      • If ((Hero is alive) Equal to False) then do (Skip remaining actions) else do (Do nothing)
      • Special Effect - Destroy HolyArrowEffect
      • Animation - Change Hero's animation speed to 100.00% of its original speed
      • Animation - Reset Hero's animation
      • Unit - Unpause Hero

  • Holy Arrow Damage
    • Events
    • Conditions
      • (Triggering unit) Equal to HolyArrowTarget
      • (Damage source) Equal to HolyArrowDummy
    • Actions
      • Unit - Remove HolyArrowDummy from the game
      • If ((Hero is alive) Equal to False) then do (Skip remaining actions) else do (Do nothing)
      • Unit - Create 1 Generic Dummy for (Owner of Hero) at (Position of HolyArrowTarget) facing Default building facing degrees
      • Set HolyArrowSlowDummy = (Last created unit)
      • Unit - Add Slow to (Last created unit)
      • Unit - Order (Last created unit) to Human Sorceress - Slow HolyArrowTarget
      • Special Effect - Create a special effect attached to the origin of HolyArrowTarget using Abilities\Spells\Orc\Disenchant\DisenchantSpecialArt.mdl
      • Special Effect - Create a special effect attached to the origin of HolyArrowTarget using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Holy Arrow LvL 1 for Hero) Equal to 1
        • Then - Actions
          • Unit - Cause Hero to damage HolyArrowTarget, dealing 200.00 damage of attack type Spells and damage type Magic
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Holy Arrow LvL 2 for Hero) Equal to 1
        • Then - Actions
          • Unit - Cause Hero to damage HolyArrowTarget, dealing 250.00 damage of attack type Spells and damage type Magic
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Holy Arrow LvL 3 for Hero) Equal to 1
        • Then - Actions
          • Unit - Cause Hero to damage HolyArrowTarget, dealing 300.00 damage of attack type Spells and damage type Magic
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Holy Arrow LvL 4 for Hero) Equal to 1
        • Then - Actions
          • Unit - Cause Hero to damage HolyArrowTarget, dealing 350.00 damage of attack type Spells and damage type Magic
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Holy Arrow LvL 5 for Hero) Equal to 1
        • Then - Actions
          • Unit - Cause Hero to damage HolyArrowTarget, dealing 400.00 damage of attack type Spells and damage type Magic
        • Else - Actions

  • Holy Arrow Target Dead
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to HolyArrowTarget
    • Actions
      • Unit - Remove HolyArrowDummy from the game

  • Holy Arrow Hero Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to Hero
    • Actions
      • Special Effect - Destroy HolyArrowEffect
      • Unit - Remove HolyArrowDummy from the game
      • Unit - Remove HolyArrowSlowDummy from the game
      • Animation - Change Hero's animation speed to 100.00% of its original speed
      • Animation - Reset Hero's animation
      • Unit - Unpause Hero

  • Remove Slow Dummy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Triggering unit) Equal to HolyArrowSlowDummy
    • Actions
      • Wait 0.50 seconds
      • Unit - Remove HolyArrowSlowDummy from the game

EDIT: I had to null the HolyArrowDummy var by setting it to no unit after dealing damage, now it works. Pretty weird as it can only be one value/unit per variable. Does anyone have a logic answer to this?
 
Last edited:
Level 11
Joined
Nov 23, 2013
Messages
665
Sadly I don't have too much time to help you, but here are some quick thoughts:
  • You use wait actions in your triggers. If this spell is cast within a short period (by the same unit, or by several different units), the spell will be broken. You might want to take a look at MUI spells tutorial: MUI Triggers with Waits
  • An easy and handy way to remove a unit from the game without using waits is to give the unit an expiration timer just after it was created:
    • Unit - Create 1 SpellDummy for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing (Random angle) degrees
    • Unit - Add a 1.5 second Generic expiration timer to (Last created unit)
Hope this helps a little :)
 
Sadly I don't have too much time to help you, but here are some quick thoughts:
  • You use wait actions in your triggers. If this spell is cast within a short period (by the same unit, or by several different units), the spell will be broken. You might want to take a look at MUI spells tutorial: MUI Triggers with Waits
  • An easy and handy way to remove a unit from the game without using waits is to give the unit an expiration timer just after it was created:
    • Unit - Create 1 SpellDummy for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing (Random angle) degrees
    • Unit - Add a 1.5 second Generic expiration timer to (Last created unit)
Hope this helps a little :)

Thanks, this is not the issue though as my map is a single player map :) My spell works fine now, after I added a trigger to null my dummy variables.
 
Status
Not open for further replies.
Top