• 🏆 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] Make dummy cast "only" once or only counted peroid of time"

Status
Not open for further replies.
Level 2
Joined
Nov 28, 2015
Messages
8
Hi people! I've been trying to learn most of programming in the warcraft world editor, in two years of my progressive programming, I think I only gained about 10% of overall knowledge in warcraft scripting. I need your help with these and let me understand on how to fix this problem because I'm not really smart enough with this thing. Hope you can help me with this thing work.
Here is the trigger:
  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer TimeWalk_Int[2]) from 1 to TimeWalk_Int[1], do (Actions)
        • Loop - Actions
          • Set TimeWalk_Loc[2] = (Position of TimeWalk_Caster[TimeWalk_Int[2]])
          • Set TimeWalk_Loc[3] = (Target point of ability being cast)
          • Set TimeWalk_Loc[4] = (TimeWalk_Loc[2] offset by TimeWalk_Speed[TimeWalk_Int[2]] towards TimeWalk_Angle[TimeWalk_Int[2]] degrees)
          • Set TimeWalk_Distance[TimeWalk_Int[2]] = (TimeWalk_Distance[TimeWalk_Int[2]] - TimeWalk_Reached[TimeWalk_Int[2]])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TimeWalk_Distance[TimeWalk_Int[2]] Greater than 0.00
            • Then - Actions
              • Unit - Move TimeWalk_Caster[TimeWalk_Int[2]] instantly to TimeWalk_Loc[4]
            • Else - Actions
              • Unit - Create 1 Dummy for TimeWalk_Owner[TimeWalk_Int[2]] at TimeWalk_Loc[2] facing 0.00 degrees
              • Unit - Add Time Walk Slow Dummy to (Last created unit)
              • Unit - Add a 0.30 second Generic expiration timer to (Last created unit)
              • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
      • Custom script: call RemoveLocation (udg_TimeWalk_Loc[2])
      • Custom script: call RemoveLocation (udg_TimeWalk_Loc[3])
      • Custom script: call RemoveLocation (udg_TimeWalk_Loc[4])
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
You can use a counter variable that keeps track of when the dummy should cast. For example, if you wanted your dummy to cast Thunder Clap after 3 seconds:

  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Counter = (Counter + 0.03)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Counter Greater than or equal to 3.00
        • Then - Actions
          • Unit - Order Dummy to Human Mountain King - Thunder Clap
          • Trigger - Turn off Loop <gen>
        • Else - Actions

Or once every 3 seconds (you have to reset the counter to 0 so that it can count up to 3 again):

  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Counter = (Counter + 0.03)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Counter Greater than or equal to 3.00
        • Then - Actions
          • Set Counter = 0.00
          • Unit - Order Dummy to Human Mountain King - Thunder Clap
        • Else - Actions


If you aren't using time, then you can just use a simple boolean:
  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UseSpell Equal to True
        • Then - Actions
          • Set UseSpell = False
          • Unit - Order Dummy to Human Mountain King - Thunder Clap
        • Else - Actions
      • -------- other loop actions will continue to run --------
 
Level 2
Joined
Nov 28, 2015
Messages
8
I'm confused...? Just do it right after the "Move unit instantly to point" function.

I think it should be on the "else" so after certain actions have worked the dummy will immidiately appear and should cast spell right after. Still confused on how the dummy did not work at all. Any help?
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
I think it should be on the "else" so after certain actions have worked the dummy will immidiately appear and should cast spell right after. Still confused on how the dummy did not work at all. Any help?

You want your dummy to cast a spell after it has reached its desired location. If you were to put it in Else - Actions, the dummy will be constantly casting the spell and stop when your caster has reached its location.

I'm a little confused on you can't just make your dummy cast the spell the same time you move the caster?
 
Level 2
Joined
Nov 28, 2015
Messages
8
Really complicated for me, dude. Something's really wrong, it maybe indexing or something in the actions. Really dunno but I wanted to make my dummy spawn after the caster reached it's desired location after casting the Time Walk spell. Any help, please?
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Well if you're wondering why the dummy keeps casting the spell even after it has reached its destination, it's because you never turn the trigger off. It's a periodic loop... meaning that it will go on forever.

I can show you how to I would properly index + deindex variables for a spell, but I highly recommend reading this tutorial if you haven't already. If you have, read it again because Purge does an excellent job at explaining how everything works. Show me the other triggers involved with this spell so I can provide you a good base.

EDIT: Did it anyway because I was bored.

  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Time Walk
    • Actions
      • Set Max_Index = (Max_Index + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Max_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Loop <gen>
        • Else - Actions
          • -------- loop has already been turned on; do nothing --------
      • -------- --------
      • Set Caster[Max_Index] = (Triggering unit)
      • Set Owner[Max_Index] = (Triggering player)
      • Set DistanceTraveled[Max_Index] = 0.00
      • -------- --------
      • Set CurrentLoc = (Position of Caster[Max_Index])
      • Set TempLoc = (Target point of ability being cast)
      • Set Direction[Max_Index] = (Angle from CurrentLoc to TempLoc)
      • -------- --------
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Custom script: call RemoveLocation(udg_CurrentLoc)

  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Loop_Int) from 1 to Max_Index, do (Actions)
        • Loop - Actions
          • Set TempLoc = (Position of Caster[Loop_Int])
          • Set CurrentLoc = (TempLoc offset by TimeWalk_Speed towards Direction[Loop_Int] degrees)
          • Unit - Move Caster[Loop_Int] instantly to CurrentLoc
          • Set DistanceTraveled[Loop_Int] = (DistanceTraveled[Loop_Int] + TimeWalk_Speed)
          • -------- --------
          • -------- checking to see if the caster has reached the targeted location --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DistanceTraveled[Loop_Int] Greater than or equal to TimeWalk_Distance
            • Then - Actions
              • Unit - Create 1 Dummy for Owner[Loop_Int] at CurrentLoc facing Default building facing degrees
              • Set TempUnit = (Last created unit)
              • Unit - Add a 1.00 second Generic expiration timer to TempUnit
              • Unit - Order TempUnit to Human Mountain King - Thunder Clap
              • -------- --------
              • -------- deindex --------
              • Set Caster[Loop_Int] = Caster[Max_Index]
              • Set Owner[Loop_Int] = Owner[Max_Index]
              • Set DistanceTraveled[Loop_Int] = DistanceTraveled[Max_Index]
              • Set Direction[Loop_Int] = Direction[Max_Index]
              • Set Max_Index = (Max_Index - 1)
              • Set Loop_Int = (Loop_Int - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Max_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off Loop <gen>
                • Else - Actions
                  • -------- there are still other spell instances running; do not turn loop off --------
            • Else - Actions
          • Custom script: call RemoveLocation(udg_TempLoc)
          • Custom script: call RemoveLocation(udg_CurrentLoc)
 
Last edited:
Level 2
Joined
Nov 28, 2015
Messages
8
Thank you very much, Skyflash this helps me a lot. Keep helping people, I really need people like you to guide on my future college course, programming. Finally!
 
Status
Not open for further replies.
Top