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

Need help with a spell

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2014
Messages
152
I was planning on making a spell where the hero throws cannon balls to a targeted area and damages them per second. I tried using cluster rockets, but the cannon balls were too small, and I have to increase the caster's size for that to happen.

The problem is that the cannon balls arent moving the way they should move. I tried the dynamic indexing way, 'coz I thought it was somewhat what tI needed for the spell. So here's the code:

  • Genkotsu Ryuseigun
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Genkotsu Ryuseigun
    • Actions
      • Set GR_Caster = (Casting unit)
      • Set GR_Loc[0] = (Position of GR_Caster)
      • Set GR_Loc[1] = (Target point of ability being cast)
      • Set GR_Facing = (Angle from GR_Loc[0] to GR_Loc[1])
      • Animation - Change GR_Caster's animation speed to 200.00% of its original speed
      • Trigger - Turn on GR Loop <gen>


  • GR Loop
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Set GR_Index = (GR_Index + 1)
      • Animation - Play GR_Caster's attack animation
      • Unit - Create 1 Garp Cannon for (Owner of GR_Caster) at GR_Loc[0] facing GR_Facing degrees
      • Set GR_CDummy[GR_Index] = (Last created unit)
      • Unit - Add a 4.00 second Generic expiration timer to GR_CDummy[GR_Index]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GR_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on GR Move Loop <gen>
        • Else - Actions


  • GR Move Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer GR_Loop_Int) from 1 to GR_Index, do (Actions)
        • Loop - Actions
          • Set GR_Move[GR_Loop_Int] = (GR_Move[GR_Loop_Int] + 40.00)
          • Set GR_MoveLoc[GR_Loop_Int] = (GR_Loc[0] offset by GR_Move[GR_Loop_Int] towards GR_Facing degrees)
          • Unit - Move GR_CDummy[GR_Loop_Int] instantly to GR_MoveLoc[GR_Loop_Int], facing GR_Facing degrees
          • Set GR_Distance[GR_Loop_Int] = (Distance between GR_MoveLoc[GR_Loop_Int] and GR_Loc[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (GR_Distance[GR_Loop_Int] Less than or equal to 40.00) or (GR_Counter Equal to 20)
            • Then - Actions
              • Unit - Kill GR_CDummy[GR_Loop_Int]
              • Set GR_Distance[GR_Loop_Int] = 0.00
              • Set GR_Move[GR_Loop_Int] = 0.00
              • Set GR_CDummy[GR_Loop_Int] = GR_CDummy[GR_Index]
              • Set GR_Move[GR_Loop_Int] = GR_Move[GR_Index]
              • Set GR_MoveLoc[GR_Loop_Int] = GR_MoveLoc[GR_Index]
              • Set GR_Distance[GR_Loop_Int] = GR_Distance[GR_Index]
              • Set GR_Index = (GR_Index - 1)
              • Set GR_Loop_Int = (GR_Loop_Int - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • GR_Index Less than or equal to 0
                • Then - Actions
                  • Animation - Change GR_Caster's animation speed to 100.00% of its original speed
                  • Trigger - Turn off GR Loop <gen>
                  • Trigger - Turn off Seconds Counter <gen>
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
 
Level 18
Joined
May 11, 2012
Messages
2,103
I was planning on making a spell where the hero throws cannon balls to a targeted area and damages them per second. I tried using cluster rockets, but the cannon balls were too small, and I have to increase the caster's size for that to happen.

The problem is that the cannon balls arent moving the way they should move. I tried the dynamic indexing way, 'coz I thought it was somewhat what tI needed for the spell. So here's the code:

  • Genkotsu Ryuseigun
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Genkotsu Ryuseigun
    • Actions
      • Set GR_Caster = (Casting unit)
      • Set GR_Loc[0] = (Position of GR_Caster)
      • Set GR_Loc[1] = (Target point of ability being cast)
      • Set GR_Facing = (Angle from GR_Loc[0] to GR_Loc[1])
      • Animation - Change GR_Caster's animation speed to 200.00% of its original speed
      • Trigger - Turn on GR Loop <gen>


  • GR Loop
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Set GR_Index = (GR_Index + 1)
      • Animation - Play GR_Caster's attack animation
      • Unit - Create 1 Garp Cannon for (Owner of GR_Caster) at GR_Loc[0] facing GR_Facing degrees
      • Set GR_CDummy[GR_Index] = (Last created unit)
      • Unit - Add a 4.00 second Generic expiration timer to GR_CDummy[GR_Index]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GR_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on GR Move Loop <gen>
        • Else - Actions


  • GR Move Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer GR_Loop_Int) from 1 to GR_Index, do (Actions)
        • Loop - Actions
          • Set GR_Move[GR_Loop_Int] = (GR_Move[GR_Loop_Int] + 40.00)
          • Set GR_MoveLoc[GR_Loop_Int] = (GR_Loc[0] offset by GR_Move[GR_Loop_Int] towards GR_Facing degrees)
          • Unit - Move GR_CDummy[GR_Loop_Int] instantly to GR_MoveLoc[GR_Loop_Int], facing GR_Facing degrees
          • Set GR_Distance[GR_Loop_Int] = (Distance between GR_MoveLoc[GR_Loop_Int] and GR_Loc[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (GR_Distance[GR_Loop_Int] Less than or equal to 40.00) or (GR_Counter Equal to 20)
            • Then - Actions
              • Unit - Kill GR_CDummy[GR_Loop_Int]
              • Set GR_Distance[GR_Loop_Int] = 0.00
              • Set GR_Move[GR_Loop_Int] = 0.00
              • Set GR_CDummy[GR_Loop_Int] = GR_CDummy[GR_Index]
              • Set GR_Move[GR_Loop_Int] = GR_Move[GR_Index]
              • Set GR_MoveLoc[GR_Loop_Int] = GR_MoveLoc[GR_Index]
              • Set GR_Distance[GR_Loop_Int] = GR_Distance[GR_Index]
              • Set GR_Index = (GR_Index - 1)
              • Set GR_Loop_Int = (GR_Loop_Int - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • GR_Index Less than or equal to 0
                • Then - Actions
                  • Animation - Change GR_Caster's animation speed to 100.00% of its original speed
                  • Trigger - Turn off GR Loop <gen>
                  • Trigger - Turn off Seconds Counter <gen>
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions

Uuuuu, this is so wrongly made haha
Take a look at his tut on how to MUI (Index), and if you don't understand something, yell right here!

For this you need only Cast trigger and Loop trigger.
 
Level 5
Joined
Jan 23, 2014
Messages
152
I wasnt really aiming for MUI though, just needed the indexing method for the Cannon ball dummies since this spell will only be used by one hero in my map. So my mistake is in the de-indexing part right?
 

sentrywiz

S

sentrywiz

I have three points about the triggers:

1. There are leaks everywhere

2. Your second loop isn't necessary. Like @BloodDrunk said, you don't need more than the cast trigger and loop trigger since you can create the balls either in the cast trigger or in the loop trigger.

3. I think this is where your problem is

  • Set GR_MoveLoc[GR_Loop_Int] = (GR_Loc[0] offset by GR_Move[GR_Loop_Int] towards GR_Facing degrees)
    • Unit - Move GR_CDummy[GR_Loop_Int] instantly to GR_MoveLoc[GR_Loop_Int], facing GR_Facing degrees
Your GR_MoveLoc should be the current position of the cannonball, but you are always referencing it to your GR_Loc[0] which is the caster's position and the balls are always going back to it.

You should make a new var, like GR_CurrentMove which will say position of GR_CDummy[GR_Index] and then in GR_MoveLoc do GR_CurrentMove offset by X towards GR_Facing degrees.

Something like this:

  • Set GR_CurrentMove = (Position of GR_CDummy[GR_Loop_Int])
  • Set GR_MoveLoc[GR_Loop_Int] = (GR_CurrentMove offset by GR_Move[GR_Loop_Int] towards GR_Facing degrees)
  • Unit - Move GR_CDummy[GR_Loop_Int] instantly to GR_CurrentMove, facing GR_Facing degrees
Also don't forget to clean your leaks, since there are a lot of.
 
Level 5
Joined
Jan 23, 2014
Messages
152
Sorry for the late reply, I was trying to fix the trigger. I was gonna clean the leaks after I got it working. It's working now. But i just have one problem, whenever I cast the spell near the caster or on the caster's position, the trigger doesnt create the cannon balls. Here's the new trigger:
  • Genkotsu Ryuseigun
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Genkotsu Ryuseigun
    • Actions
      • Set GR_Caster = (Casting unit)
      • Set GR_Loc[0] = (Position of GR_Caster)
      • Set GR_Loc[1] = (Target point of ability being cast)
      • Set GR_Facing = (Angle from GR_Loc[0] to GR_Loc[1])
      • Unit - Pause GR_Caster
      • Animation - Play GR_Caster's spell animation
      • Trigger - Turn on GR Loop <gen>


  • GR Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set GR_Index = (GR_Index + 1)
      • Unit - Create 1 Garp Cannon for (Owner of GR_Caster) at GR_Loc[0] facing (GR_Facing + (Random real number between -3.00 and 3.00)) degrees
      • Game - Display to (All players) the text: Created Cannon Ball
      • Set GR_CDummy[GR_Index] = (Last created unit)
      • Unit - Add a 3.00 second Generic expiration timer to GR_CDummy[GR_Index]
      • Set GR_Counter = (GR_Counter + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GR_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on GR Move Loop <gen>
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GR_Counter Greater than or equal to 66
        • Then - Actions
          • Set GR_Counter = 0
          • Unit - Unpause GR_Caster
          • Game - Display to (All players) the text: GR Loop OFF!
          • Unit - Unpause GR_Caster
          • Animation - Play GR_Caster's stand ready animation
          • Trigger - Turn off (This trigger)
        • Else - Actions


  • GR Move Loop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • For each (Integer GR_Loop_Int) from 1 to GR_Index, do (Actions)
        • Loop - Actions
          • Set GR_Move[GR_Loop_Int] = (GR_Move[GR_Loop_Int] + 60.00)
          • Set GR_MoveLoc[GR_Loop_Int] = (GR_Loc[0] offset by GR_Move[GR_Loop_Int] towards (Facing of GR_CDummy[GR_Loop_Int]) degrees)
          • Unit - Move GR_CDummy[GR_Loop_Int] instantly to GR_MoveLoc[GR_Loop_Int], facing (Facing of GR_CDummy[GR_Loop_Int]) degrees
          • Set GR_Distance[GR_Loop_Int] = (Distance between GR_MoveLoc[GR_Loop_Int] and GR_Loc[1])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GR_Distance[GR_Loop_Int] Less than or equal to 80.00
            • Then - Actions
              • Unit - Kill GR_CDummy[GR_Loop_Int]
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 140.00 of GR_MoveLoc[GR_Loop_Int] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of GR_Caster)) Equal to True)))) and do (Actions)
                • Loop - Actions
                  • Unit - Cause GR_Caster to damage (Picked unit), dealing 100.00 damage of attack type Spells and damage type Force
              • Set GR_CDummy[GR_Loop_Int] = GR_CDummy[GR_Index]
              • Set GR_CDummy[GR_Index] = No unit
              • Set GR_Move[GR_Loop_Int] = GR_Move[GR_Index]
              • Set GR_Move[GR_Index] = 0.00
              • Set GR_MoveLoc[GR_Loop_Int] = GR_MoveLoc[GR_Index]
              • Set GR_Distance[GR_Loop_Int] = GR_Distance[GR_Index]
              • Set GR_Index = (GR_Index - 1)
              • Set GR_Loop_Int = (GR_Loop_Int - 1)
              • Custom script: call RemoveLocation (udg_GR_MoveLoc[udg_GR_Loop_Int])
              • Custom script: call RemoveLocation (udg_GR_MoveLoc[udg_GR_Index])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (GR_Index Equal to 0) or ((GR_Caster is dead) Equal to True)
                • Then - Actions
                  • Game - Display to (All players) the text: Index = 0
                  • Custom script: call RemoveLocation (udg_GR_Loc[0])
                  • Custom script: call RemoveLocation (udg_GR_Loc[1])
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
          • Custom script: call RemoveLocation (udg_GR_MoveLoc[udg_GR_Loop_Int])
 
Last edited:
Status
Not open for further replies.
Top