• 🏆 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!

[Solved] Trigger fixing

Status
Not open for further replies.
Level 4
Joined
Jan 14, 2017
Messages
75
Hi there,
I created a trigger for a spell called Haunt, where the caster casts a bolt of shadow at the target, dealing 20 damage every second for 10 seconds to the target, or 20 healing every second for 10 seconds it if it is an undead, and then the missile returns to the caster. I've done almost everything myself, but I am confused to how to make the missile return to the caster. I also realized that the damage/healing over time effect doesn't work. My base spell is Death Coil. So, where are the errors in the damage/healing over time triggers and how do I make the missile return to the caster? I apologize for this thread being two questions.

  • Haunt init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hashtableforhaunt = (Last created hashtable)
      • Set HealUnit = (Target unit of ability being cast)
      • Set Sourceofhaunt = (Triggering unit)


  • Haunt cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Haunt
    • Actions
      • Hashtable - Save 10.00 as 0 of 0 in (Last created hashtable)
      • Hashtable - Save 10.00 as 0 of 1 in (Last created hashtable)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (HealUnit is Undead) Equal to True
        • Then - Actions
          • Unit Group - Add HealUnit to HealUnitGroup
        • Else - Actions
          • Unit Group - Add HealUnit to Hauntdamagegroup

  • Haunt loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in HealUnitGroup and do (Actions)
        • Loop - Actions
          • Set Haunthealtime = (Load 0 of (Key (Picked unit)) from (Last created hashtable))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Target unit of ability being cast) is Undead) Equal to True
              • Haunthealtime Greater than 0.00
            • Then - Actions
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 20.00)
              • Hashtable - Save (Haunthealtime - 1.00) as 0 of (Key (Picked unit)) in hashtableforhaunt
            • Else - Actions
              • Unit Group - Remove HealUnit from HealUnitGroup
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in hashtableforhaunt
          • Unit Group - Pick every unit in Hauntdamagegroup and do (Actions)
            • Loop - Actions
              • Set Hauntdamagetime = (Load 1 of (Key (Picked unit)) from (Last created hashtable))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Hauntdamagetime Greater than 0.00
                • Then - Actions
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 20.00)
                  • Hashtable - Save (Hauntdamagetime - 1.00) as 0 of (Key (Picked unit)) in hashtableforhaunt
                • Else - Actions
                  • Unit Group - Remove (Picked unit) from Hauntdamagegroup
                  • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in hashtableforhaunt
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Haunt init:

Set HealUnit = Target unit of ability being cast
Set Sourceofhaunt = Triggring Unit

On Map init there is no Target unit of ability being cast or Triggring Unit

Haunt Cast:

I don't know what you are doing with the hashtable here. You need to save the duration to the unit: (0 of key(Target unit of ability being cast))
You only need one duration/group. You can decide in the loop whether you damage/heal.
Here you also need to store the caster, so you can make the missile return later.

Haunt Loop:

As I said only one group necessary, but trigger seems fine. When you remov the unit from the group/clear child hashtables you can also start the missile to return.
This can be easily done, because you have stored the caster earlier. For the missile you can use a missile based spell or a normal attack. Or you use the missile system again.
 
Level 4
Joined
Jan 14, 2017
Messages
75
I created this:

  • Haunt init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hashtableforhaunt = (Last created hashtable)

  • Haunt cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Haunt
    • Actions
      • Hashtable - Save 10.00 as 0 of 0 in (Last created hashtable)
      • Set Missile__Model = Abilities\Spells\Other\BlackArrow\BlackArrowMissile.mdl
      • Set HealUnit = (Target unit of ability being cast)
      • Set Sourceofhaunt = (Triggering unit)

  • Haunt loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in HealUnitGroup and do (Actions)
        • Loop - Actions
          • Set Haunthealtime = (Load 0 of (Key (Picked unit)) from (Last created hashtable))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Target unit of ability being cast) is Undead) Equal to True
              • Haunthealtime Greater than 0.00
            • Then - Actions
              • Special Effect - Create a special effect attached to the chest of HealUnit using Abilities\Spells\Other\BlackArrow\BlackArrowMissile.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 20.00)
              • Hashtable - Save (Haunthealtime - 1.00) as 0 of (Key (Picked unit)) in hashtableforhaunt
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (HealUnit is Undead) Equal to False
                • Then - Actions
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 20.00)
                  • Hashtable - Save (Haunthealtime - 1.00) as 0 of (Key (Picked unit)) in hashtableforhaunt
                • Else - Actions
            • Else - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in hashtableforhaunt
              • Unit Group - Remove HealUnit from HealUnitGroup
              • Unit - Create 1 Haunt Dummy for Player 1 (Red) at (Position of HealUnit) facing Default building facing degrees
              • Unit - Add Death Coil (for trigger) (Neutral Hostile) to (Last created unit)
              • Unit - Order (Last created unit) to Undead Death Knight - Death Coil (Triggering unit)
              • Unit - Add a 0.40 second Generic expiration timer to (Last created unit)

but still no damage/healing over time and no missile return. Any suggestions?
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
In the cast trigger you need in your hashtable: save 10 as 0 of key(target unit of ability being cast)
You do not need the variables HealUnit and Sourceofhaunt, since you save your data in a hashtable.

This is how the loop trigger should look like:
  • Haunt loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in HauntUnitGroup and do (Actions)
        • Loop - Actions
          • Set HauntTime = (Load 0 of (Key (Picked unit)) from HauntHashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HauntTime Greater than 0.00
            • Then - Actions
              • Special Effect - Create a special effect attached to the chest of (Picked unit) using ...
              • Special Effect - Destroy (Last created special effect)
              • Hashtable - Save (HauntTime - 1.00) as 0 of (Key (Picked unit)) in HauntHashtable
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is Undead) Equal to True
                • Then - Actions
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 20.00)
                • Else - Actions
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 20.00)
            • Else - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in HauntHashtable
              • Unit Group - Remove (Picked unit) from HauntUnitGroup
              • -------- Dummy is fine, but you need to target the caster. --------
              • -------- The caster is not triggering unit --------
              • -------- you need to store the caster in the hashtable as well --------
 
Level 4
Joined
Jan 14, 2017
Messages
75
If the caster isn't triggering unit, then is it casting unit?
Also, here's what I did:

  • Haunt init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hashtableforhaunt = (Last created hashtable)

  • Haunt cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Haunt
    • Actions
      • Hashtable - Save 10.00 as 0 of 0 in (Last created hashtable)
      • Set Missile__Model = Abilities\Spells\Other\BlackArrow\BlackArrowMissile.mdl
      • Hashtable - Save 10 as 0 of (Key (Target unit of ability being cast)) in (Last created hashtable)
      • Hashtable - Save 10 as 0 of (Key (Casting unit)) in (Last created hashtable)

  • Haunt loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in HauntGroup and do (Actions)
        • Loop - Actions
          • Set HauntTime = (Load 0 of (Key (Picked unit)) from hashtableforhaunt)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HauntTime Greater than 0.00
            • Then - Actions
              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Spells\Other\BlackArrow\BlackArrowMissile.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 20.00)
              • Hashtable - Save (HauntTime - 1.00) as 0 of (Key (Picked unit)) in hashtableforhaunt
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is Undead) Equal to True
                • Then - Actions
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + 20.00)
                • Else - Actions
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 20.00)
            • Else - Actions
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in hashtableforhaunt
              • Unit Group - Remove (Picked unit) from HauntGroup
              • Unit - Create 1 Haunt Dummy for Player 1 (Red) at (Position of (Picked unit)) facing Default building facing degrees
              • Unit - Add Death Coil (for trigger) (Neutral Hostile) to (Last created unit)
              • Unit - Order (Last created unit) to Undead Death Knight - Death Coil (Load 10 of (Key (Casting unit)) in (Last created hashtable))
              • Unit - Add a 0.40 second Generic expiration timer to (Last created unit)


P.S. Thank you very much for the help! I know it is tiresome, but it's essential to expanding my trigger knowledge. :grin:
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Functions like triggering unit/casting unit can only be used when the trigger has a fitting event. These functions are labeled as event response - casting unit. Event response means they need a fitting event. Most of the time there is a description, that tells you for which event this function works.
If you use and event like A unit starts the effet of an ability both triggering unit and casting unit are the caster. But this only works in this trigger (Haunt cast) and only before using a wait. This means, that if you want to use the caster after a wait or in a different trigger you need to save it to a variable or in a hashtable.
In triggers with an event like map initialization or every 1 seconds you cannot use triggering unit/casting unit/dying unit/...

I have created a map with all the working triggers for you to study. :)
I added a trigger that removes dead units from the group, so no coils fly from a corpse to the caster.
 

Attachments

  • Haunt.w3x
    18.9 KB · Views: 41
Status
Not open for further replies.
Top