• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Mind Control

Status
Not open for further replies.
Level 25
Joined
Sep 26, 2009
Messages
2,373
Hello, I created a trigger for Mind Controling, based on "Unholy Frenzy" (here renamed to curse). The problem is that sometimes it works, sometimes it works not.

Here's the trigger
  • Mind Control
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Curse
    • Actions
      • Set CurseCaster = (Casting unit)
      • Wait 0.20 seconds
      • Set CurseTarget = (Target unit of ability being cast)
      • Wait 0.50 seconds
      • Set CurseOwner = (Owner of CurseTarget)
      • Wait 12.50 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (CurseTarget has buff Curse ) Equal to True
        • Then - Actions
          • Special Effect - Create a special effect attached to the overhead of CurseTarget using Abilities\Spells\Other\Charm\CharmTarget.mdl
          • Unit - Change ownership of CurseTarget to (Owner of CurseCaster) and Change color
          • Unit - Add classification of Undead to CurseTarget
          • Unit - Add Eat Soul to CurseCaster
          • Wait 10.00 seconds
          • Unit - Change ownership of CurseTarget to CurseOwner and Change color
          • Special Effect - Create a special effect attached to the overhead of CurseTarget using Abilities\Spells\Other\Charm\CharmTarget.mdl
          • Unit - Remove Eat Soul from CurseCaster
          • Unit - Remove classification of Undead from CurseTarget
          • Wait 1.00 seconds
        • Else - Actions
          • Do nothing
(note that the undead clasification is for Eat Soul spell that is in fact Death Pact)

Does anybody know how to make it work everytime it's used?
 
Level 25
Joined
Sep 26, 2009
Messages
2,373
Okey, so I read a little about hashtables, tried to use them but I still failed.


Since I don't know what is causing the trouble, I'll post here all the triggers related to the spell:
  • Curse Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set CurseHashTable = (Last created hashtable)
  • Curse
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Curse
    • Actions
      • Set CurseCaster = (Casting unit)
      • Wait 0.20 seconds
      • Set CurseTarget = (Target unit of ability being cast)
      • Set CurseOwner = (Owner of CurseTarget)
      • Hashtable - Save 14.00 as 0 of (Key (Target unit of ability being cast)) in CurseHashTable
      • Hashtable - Save 10.00 as 1 of (Key (Target unit of ability being cast)) in CurseHashTable
      • Unit Group - Add CurseTarget to CurseGroup
The following trigger should check if the unit has the "curse" buff and if yes, then it should change the unit's team (after 14 secs).
  • Curse Timer
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CurseGroup and do (Actions)
        • Loop - Actions
          • Set CurseTimer = (Load 0 of (Key (Picked unit)) from CurseHashTable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CurseTimer Greater than 0.00
            • Then - Actions
              • Hashtable - Save (CurseTimer - 1.00) as 0 of (Key (Picked unit)) in CurseHashTable
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CurseTarget has buff Curse ) Equal to True
                • Then - Actions
                  • Special Effect - Create a special effect attached to the overhead of CurseTarget using Abilities\Spells\Other\Charm\CharmTarget.mdl
                  • Unit - Change ownership of CurseTarget to (Owner of CurseCaster) and Change color
                  • Unit Group - Add CurseTarget to CurseEfxGroup
                  • Unit Group - Remove CurseTarget from CurseGroup
                • Else - Actions
                  • Unit Group - Remove CurseTarget from CurseGroup
This should change the unit's team back to it's previous owner (after additional 10 secs).
  • Curse End
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CurseEfxGroup and do (Actions)
        • Loop - Actions
          • Set CurseEfxTimer = (Load 1 of (Key (Picked unit)) from CurseHashTable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CurseEfxTimer Greater than 0.00
            • Then - Actions
              • Hashtable - Save (CurseEfxTimer - 1.00) as 1 of (Key (Picked unit)) in CurseHashTable
            • Else - Actions
              • Unit - Change ownership of CurseTarget to CurseOwner and Change color
              • Special Effect - Create a special effect attached to the overhead of CurseTarget using Abilities\Spells\Other\Charm\CharmTarget.mdl
              • Unit Group - Remove CurseTarget from CurseEfxGroup
Well, the problem here is, that the first time I completed this spell, it worked partially - it changed the unit's owner to the casters, but after 1 period (here 1 sec), it changed the unit to it's previous team.
I played with the trigger a little, tried to find out the error, but I probably created another error, because the trigger now does not even change the unit's owner.

Any thoughts?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Curse:

Remove wait
Remove "Set CurseOwner = (Owner of CurseTarget)"
Save handle of owner of casting unit for target unit of ability being cast as player index (integer) or player handle
Save handle of owner of target unit of ability being cast for target unit of ability being cast as player index (integer) or player handle

Curse timer:

Replace all <curse target> with <picked unit>

  • Unit - Change ownership of CurseTarget to (Owner of CurseCaster) and Change color
^Change to
  • Unit - Change ownership of CurseTarget to (load player handle that you saved in the first trigger) and Change color
Curse End:

Replace all <curse target> with <picked unit>
When chaging owner, load the player handle
Clear child hashtable at the end
 
Status
Not open for further replies.
Top