• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Army of the Dead

Status
Not open for further replies.
Level 9
Joined
Dec 16, 2017
Messages
367
Hello guys, recently i've made this spell, i am struggling to make something over it, i want for each cast of the loop, to make a lightning from the caster to the point where the unit is created to, but seems like i don't find it how to xD.
How shall i trigger it correctly?

  • Army of the Dead Cast
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Army of the Dead (Death Knight UNHOLY)
    • Actions
      • Set AOTD_Index = (AOTD_Index + 1)
      • Set AOTD_Caster[AOTD_Index] = (Triggering unit)
      • Set AOTD_Player[AOTD_Index] = (Owner of AOTD_Caster[AOTD_Index])
      • Set AOTD_Duration[AOTD_Index] = 16
      • Player - Set the current research level of Ghoul Stats to (Level of (Ability being cast) for AOTD_Caster[AOTD_Index]) for AOTD_Player[AOTD_Index]
      • Player - Set the current research level of Ghoul Stats2 to (Level of (Ability being cast) for AOTD_Caster[AOTD_Index]) for AOTD_Player[AOTD_Index]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AOTD_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Army of the Dead Loop <gen>
          • Trigger - Turn on Army of the Dead Stop <gen>
        • Else - Actions
  • Army of the Dead Loop
    • Events
      • Time - Every 0.33 seconds of game time
    • Conditions
    • Actions
      • For each (Integer AOTD_Loop) from 1 to AOTD_Index, do (Actions)
        • Loop - Actions
          • Set AOTD_Duration[AOTD_Loop] = (AOTD_Duration[AOTD_Loop] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AOTD_Duration[AOTD_Loop] Greater than or equal to 0
              • (AOTD_Caster[AOTD_Loop] is alive) Equal to True
              • (Current order of AOTD_Caster[AOTD_Loop]) Equal to (Order(channel))
            • Then - Actions
              • Set AOTD_Position[AOTD_Loop] = (Position of AOTD_Caster[AOTD_Loop])
              • Set AOTD_SummonPoint[AOTD_Loop] = (AOTD_Position[AOTD_Loop] offset by (Random real number between 100.00 and 300.00) towards (Random real number between 0.00 and 360.00) degrees)
              • Unit - Create 1 Ghoul (Death Knight UNHOLY) for AOTD_Player[AOTD_Loop] at AOTD_SummonPoint[AOTD_Loop] facing 0.00 degrees
              • Special Effect - Create a special effect attached to the origin of (Last created unit) using Blood Massacre Black.mdx
              • Special Effect - Destroy (Last created special effect)
              • Unit - Add a 35.00 second Generic expiration timer to (Last created unit)
              • Lightning - Create a Spirit Link lightning effect from source AOTD_Position[AOTD_Loop] to target AOTD_SummonPoint[AOTD_Loop]
              • Lightning - Destroy (Last created lightning effect)
              • Custom script: call RemoveLocation(udg_AOTD_Position[udg_AOTD_Loop])
              • Custom script: call RemoveLocation(udg_AOTD_SummonPoint[udg_AOTD_Loop])
            • Else - Actions
              • Set AOTD_Caster[AOTD_Loop] = AOTD_Caster[AOTD_Index]
              • Set AOTD_Player[AOTD_Loop] = AOTD_Player[AOTD_Index]
              • Set AOTD_Duration[AOTD_Loop] = AOTD_Duration[AOTD_Index]
              • Set AOTD_Index = (AOTD_Index - 1)
              • Set AOTD_Loop = (AOTD_Loop - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AOTD_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                  • Trigger - Turn off Army of the Dead Stop <gen>
                • Else - Actions
  • Army of the Dead Stop
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • For each (Integer AOTD_Loop) from 1 to AOTD_Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AOTD_Caster[AOTD_Loop] Equal to (Triggering unit)
            • Then - Actions
              • Set AOTD_Caster[AOTD_Loop] = No unit
            • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,677
I'm pretty sure you can delete the Army of the Dead Stop trigger. It looks entirely unnecessary.

Anyway, you're destroying the Lightning right after you create it which is why you can't see it.

Solution:
Create 2 new Variables, Delayed_Lightning (lightning) and Delayed_Duration (real). Then create a new trigger like this:
  • Delayed Lightning
    • Events
    • Conditions
    • Actions
      • Custom script: local lightning udg_Delayed_Lightning = GetLastCreatedLightningBJ()
      • Wait Delayed_Duration seconds
      • Lightning - Destroy Delayed_Lightning
      • Custom script: set udg_Delayed_Lightning = null

Now whenever you want to create lightning that will last a duration you do this:
  • Actions
  • Lightning - Create a Spirit Link lightning effect from source X to target Y
  • Set Variable Delayed_Duration = 1.00
  • Trigger - Run Delayed Lightning (ignoring conditions)

Edit:
Also, AOTD_Position and AOTD_SummonPoint don't need to be Arrays.
 
Last edited:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,677
Yes, their only purpose is to avoid memory leaks. It's not like you need to track these positions between triggers or at some later period in time.

And if you wanted to use 1 less variable you could use a single Point array:
  • Set Variable AOTD_Point[0] = Position A
  • Set Variable AOTD_Point[1] = Position B
 
Last edited:
Level 6
Joined
Dec 29, 2019
Messages
82
I'm pretty sure you can delete the Army of the Dead Stop trigger. It looks entirely unnecessary.

Anyway, you're destroying the Lightning right after you create it which is why you can't see it.

Solution:
Create 2 new Variables, Delayed_Lightning (lightning) and Delayed_Duration (real). Create a new trigger like this:
  • Delayed Lightning
    • Events
    • Conditions
    • Actions
      • Custom script: local lightning udg_Delayed_Lightning = GetLastCreatedLightningBJ()
      • Wait Delayed_Duration seconds
      • Lightning - Destroy Delayed_Lightning
      • Custom script: set udg_Delayed_Lightning = null

Now whenever you want to create lightning that will last a duration you do this:
  • Actions
  • Lightning - Create a Spirit Link lightning effect from source X to target Y
  • Set Variable Delayed_Duration = 1.00
  • Trigger - Run Delayed Lightning (ignoring conditions)

Edit:
Also, AOTD_Position and AOTD_SummonPoint don't need to be Arrays.
Are you sure that using Wait action is safe approach here ?
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,677
Are you sure that using Wait action is safe approach here ?
Yep, because I'm "shadowing" the global variable Delayed_Lightning -> local udg_

This causes it to act like a local variable which means that it's value will not change during the Wait.
I suppose you could even ditch Delayed_Lightning and just use a standard local variable instead... Something like this:
  • Actions
  • Custom script: local lightning lg = GetLastCreatedLightningBJ()
  • Wait Delayed_Duration seconds
  • Custom script: call DestroyLightning(lg)
  • Custom script: set lg = null

Also, when you Run a trigger it acts differently. The ran trigger's Waits won't interfere/delay the Actions of your original trigger.
 
Last edited:
Level 6
Joined
Dec 29, 2019
Messages
82
Yep, because I'm "shadowing" the global variable Delayed_Lightning -> local udg_

This causes it to act like a local variable which means that it's value will not change during the Wait.
I suppose you could even ditch Delayed_Lightning and just use a standard local variable instead... Something like this:
  • Actions
  • Custom script: local lightning lg = GetLastCreatedLightningBJ()
  • Wait Delayed_Duration seconds
  • Custom script: call DestroyLightning(lg)
  • Custom script: set lg = null

Also, when you Run a trigger it acts differently. The ran trigger's Waits won't interfere/delay the Actions of your original trigger.
Oh i got confused by variable name... my bad.
 
Status
Not open for further replies.
Top