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

Special Effects at two locations

Status
Not open for further replies.
Code:
HpRecall
    Events
        Unit - A unit Is attacked
    Conditions
    Actions
        Set RecalledUnit = (Attacked unit)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (RecalledUnit has buff Recall ) Equal to True
                (Life of RecalledUnit) Less than or equal to (((Max life of RecalledUnit) / 100.00) x 10.00)
            Then - Actions
                Special Effect - Create a special effect attached to the overhead of RecalledUnit using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
                Unit Group - Pick every unit in (Units owned by (Owner of RecalledUnit) of type Salvation Spire) and do (Actions)
                    Loop - Actions
                        Set TempLoc50 = (Position of (Picked unit))
                        Unit - Move RecalledUnit instantly to TempLoc50
                        Unit - Set mana of RecalledUnit to 0.00
                        Special Effect - Create a special effect attached to the overhead of RecalledUnit using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
            Else - Actions
        Set RecalledUnit = No unit
        Custom script:   call RemoveLocation (udg_TempLoc50)



This works perfectly except both the special effects play at the same time. The first is meant to play at the units position when it is attacked, and the second at its new location.

Keep in mind this must be MUI so no wait functions.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
You should really use "
  • " tags to encapsulate GUI code.
  • What you should be doing with this is:
  • [trigger]HpRecall
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacked unit) has buff Recall ) Equal to True
          • (Life of (Attacked unit)) Less than or equal to (((Max life of (Attacked unit)) / 100.00) x 10.00)
    • Actions
      • Set RecalledUnit = (Attacked unit)
      • Set TempLoc50 = (Position of (RecalledUnit))
      • Special Effect - Create a special effect at (TempLoc50) using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_TempLoc50)
      • Unit Group - Pick every unit in (Units owned by (Owner of RecalledUnit) of type Salvation Spire) and do (Actions)
        • Loop - Actions
          • Set TempLoc50 = (Position of (Picked unit))
          • Unit - Move RecalledUnit instantly to TempLoc50
          • Unit - Set mana of RecalledUnit to 0.00
          • Special Effect - Create a special effect at (TempLoc50) using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call RemoveLocation (udg_TempLoc50)
I moved your conditions on the if-statement to the conditions field in the trigger, keeps it more organized and easier to read. This is how you should be organizing your spell-code.

In addition to that I moved your custom script into the unit-group loop so that the location is removed after it is needed, rather than creating 5 and then removing the last 1 (if 5 locations were necessary). You also do not need to null global variables so I removed your line that sets RecalledUnit to "No unit".

At the beginning of the actions I added a line that sets location "TempLoc50" to the location of the caster so that it can be referenced/removed after the special effect is created/destroyed. Notice the special effect now plays at a point rather than attached to a unit. I've made similar changes to the second special effect that you create, within the unit-group loop. Oh and I fixed up your memory leaks involving special effects. Both of the effects that you use in this trigger work when destroyed immediately so they will still work properly.

Try testing out what I have shown you here and see if that doesn't help.
 
  • Like
Reactions: Kam
Code:
HpRecall
    Events
        Unit - A unit Is attacked
    Conditions
    Actions
        Set RecalledUnit = (Attacked unit)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (RecalledUnit has buff Recall ) Equal to True
                (Life of RecalledUnit) Less than or equal to (((Max life of RecalledUnit) / 100.00) x 10.00)
            Then - Actions
                Special Effect - Create a special effect attached to the overhead of RecalledUnit using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
                Unit Group - Pick every unit in (Units owned by (Owner of RecalledUnit) of type Salvation Spire) and do (Actions)
                    Loop - Actions
                        Set TempLoc50 = (Position of (Picked unit))
                        Unit - Move RecalledUnit instantly to TempLoc50
                        Unit - Set mana of RecalledUnit to 0.00
                        Special Effect - Create a special effect attached to the overhead of RecalledUnit using Abilities\Spells\Human\Resurrect\ResurrectTarget.mdl
            Else - Actions
        Set RecalledUnit = No unit
        Custom script:   call RemoveLocation (udg_TempLoc50)



This works perfectly except both the special effects play at the same time. The first is meant to play at the units position when it is attacked, and the second at its new location.

Keep in mind this must be MUI so no wait functions.

use Berbanog's trigger... your problem is that you attached the effect to the unit itself and not on its position...
 
Status
Not open for further replies.
Top