• 🏆 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] Help Fix Loop Trigger

Status
Not open for further replies.
Level 6
Joined
Jan 2, 2015
Messages
171
  • Chain Rocket Cast
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Chain Rocket
    • Actions
      • Set gunner = (Casting unit)
      • Unit - Create 1 Dumy Chain for (Owner of (Casting unit)) at (Position of (Casting unit)) facing (Facing of (Casting unit)) degrees
      • Unit - Set level of Chain Rocket Dummy for (Last created unit) to (Level of Chain Rocket dummy 3 for gunner)
      • Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb (Target unit of ability being cast)
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • For each (Integer chainsegment) from 0 to 0, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dumy Chain 2 for (Owner of (Casting unit)) at (Position of (Casting unit)) facing (Facing of (Casting unit)) degrees
          • Unit - Set level of Chain Rocket Dummy 2 for (Last created unit) to (Level of Chain Rocket dummy 3 for gunner)
          • Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb (Target unit of ability being cast)
          • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
my spell sometime work so well firing 3 times but sometimes it only fires 2 times bcuz dummy from loop dont fire it. how to make the dummy from loop keep firing whenever i use the spell?
i set my hero chain rocket casting time to 1 sec, chain rocket dummy casting time 0,33 and chain rocket dummy 2 to 0,33. Everything are in good setup except the loop.

my spell based on this skill on video
 
Level 6
Joined
Jan 2, 2015
Messages
171
What's the point of the For loop if youre only going from 0 -> 0?

When you say "to keep firing whenever I use spell," do you mean the spell breaks whenever you cast another instance?

i thought loop 0 -> 0 means it will trigger the action once and i want the dummy from loop to use the spell only once whenever i cast my Chain Rocket but the problem is sometimes dummy from loop didnt use the spell
 
Level 39
Joined
Feb 27, 2007
Messages
5,013
The problem is that all of your code runs at once without any waits or sleeps in the middle of it. So there are two dummy units each casting the spell once, but they're doing it at the same time so it only looks like 1 is. The problem is that usually doing something like
  • Wait 0.33 game-time seconds
is a really bad idea because waits suck in WC3 (the targeted unit might die in the middle, variables could be modified, etc.). In your case that might actually solve your problem though: (also fix the loop from 0 to 0)
  • Chain Rocket Cast
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Chain Rocket
    • Actions
      • Set gunner = (Casting unit)
      • Unit - Create 1 Dumy Chain for (Owner of (Casting unit)) at (Position of (Casting unit)) facing (Facing of (Casting unit)) degrees
      • Unit - Set level of Chain Rocket Dummy for (Last created unit) to (Level of Chain Rocket dummy 3 for gunner)
      • Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb (Target unit of ability being cast)
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • For each (Integer chainsegment) from 0 to 2, do (Actions)
        • Loop - Actions
          • Wait 0.33 seconds of game-time
          • Unit - Create 1 Dumy Chain 2 for (Owner of (Casting unit)) at (Position of (Casting unit)) facing (Facing of (Casting unit)) degrees
          • Unit - Set level of Chain Rocket Dummy 2 for (Last created unit) to (Level of Chain Rocket dummy 3 for gunner)
          • Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb (Target unit of ability being cast)
          • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
Or you could make a second dummy unit with a 0.66s cast time and have them each cast the ability simultaneously but they will come out staggered because one has a longer cast time. These are all generally pretty ugly solutions, though.
 
Status
Not open for further replies.
Top