1. 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
  2. The 15th Mini-Mapping Contest came to an end. The Secrets of Warcraft 3 are soon to be revealed! Come and vote in the public poll for your favorite maps.
    Dismiss Notice
  3. The 12th incarnation of the Music Contest is LIVE! The theme is Synthwave. Knight Rider needs a song to listen to on his journey. You should definitely have some fun with this theme!
    Dismiss Notice
  4. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] Trigger fixing

Discussion in 'Triggers & Scripts' started by TheBigMetalHandInTheSky, Feb 19, 2017.

  1. TheBigMetalHandInTheSky

    TheBigMetalHandInTheSky

    Joined:
    Jan 14, 2017
    Messages:
    74
    Resources:
    0
    Resources:
    0
    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
     
  2. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,573
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    healunit and sourceofhaunt needs to be edited. You cannot store them like that in the init trigger.

    Same goes for:
    ((Target unit of ability being cast) is Undead) Equal to True
     
  3. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,285
    Resources:
    0
    Resources:
    0
    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.
     
  4. TheBigMetalHandInTheSky

    TheBigMetalHandInTheSky

    Joined:
    Jan 14, 2017
    Messages:
    74
    Resources:
    0
    Resources:
    0
    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?
     
  5. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,285
    Resources:
    0
    Resources:
    0
    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 --------
     
  6. TheBigMetalHandInTheSky

    TheBigMetalHandInTheSky

    Joined:
    Jan 14, 2017
    Messages:
    74
    Resources:
    0
    Resources:
    0
    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:
     
  7. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,285
    Resources:
    0
    Resources:
    0
    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.
     

    Attached Files:

  8. TheBigMetalHandInTheSky

    TheBigMetalHandInTheSky

    Joined:
    Jan 14, 2017
    Messages:
    74
    Resources:
    0
    Resources:
    0
    Ok, thank you! I'm sure I will understand how to work it better now!