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

[Trigger] what's wrong with this TRIGGER

Status
Not open for further replies.
Level 13
Joined
Jan 30, 2012
Messages
1,298
what's wrong with this TRIGGER?
  • Shoot
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shoot
    • Actions
      • Set Max_Index = (Max_Index + 1)
      • Set ShootCaster[Max_Index] = (Triggering unit)
      • Set Point[1] = (Position of ShootCaster[Max_Index])
      • Set Point[2] = (Target point of ability being cast)
      • Unit - Create 1 BulletDummy for (Owner of ShootCaster[Max_Index]) at Point[1] facing (Angle from Point[1] to Point[2]) degrees
      • Set ShootDummy[Max_Index] = (Last created unit)
      • Unit - Add a 0.60 second Generic expiration timer to ShootDummy[Max_Index]
      • Animation - Play ShootDummy[Max_Index]'s birth animation
      • Custom script: call RemoveLocation(udg_Point[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 Shoot Loop <gen>
        • Else - Actions
  • Shoot Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Current_Index) from 1 to Max_Index, do (Actions)
        • Loop - Actions
          • Set Point[3] = (Position of ShootDummy[Current_Index])
          • Set ShootAngle[Current_Index] = (Angle from Point[3] to Point[2])
          • Set Point[4] = (Point[3] offset by 50.00 towards (Angle from Point[3] to Point[2]) degrees)
          • Unit - Move ShootDummy[Current_Index] instantly to Point[4]
          • Set ShootGroup[Current_Index] = (Units within 200.00 of Point[3] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of ShootCaster[Current_Index])) Equal to True)))
          • Unit Group - Pick every unit in ShootGroup[Current_Index] and do (Actions)
            • Loop - Actions
              • Unit - Kill ShootDummy[Current_Index]
              • Unit - Cause ShootCaster[Current_Index] to damage (Picked unit), dealing 25.00 damage of attack type Hero and damage type Normal
          • Custom script: call DestroyGroup(udg_ShootGroup[udg_Current_Index])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (ShootDummy[Current_Index] is dead) Equal to True
            • Then - Actions
              • Set ShootAngle[Current_Index] = ShootAngle[Max_Index]
              • Set ShootAngle[Max_Index] = 0.00
              • Set ShootDistance = 0.00
              • Set ShootCaster[Current_Index] = ShootCaster[Max_Index]
              • Set ShootCaster[Max_Index] = No unit
              • Set ShootDummy[Current_Index] = ShootDummy[Max_Index]
              • Set ShootDummy[Max_Index] = No unit
              • Set Current_Index = (Current_Index - 1)
              • Set Max_Index = (Max_Index - 1)
            • Else - Actions
          • Custom script: call RemoveLocation(udg_Point[1])
          • Custom script: call RemoveLocation(udg_Point[2])
          • Custom script: call RemoveLocation(udg_Point[3])
      • 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 (This trigger)
        • Else - Actions
when unit cast shoot the dummy move into center of the map
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
Seems the problem lies in your point set up.

In your second trigger you use points 2, 3 and 4, but through custom script you remove points 1, 2 and 3; you also destroy point 2 which is set up in your first trigger, which is the bug.
You also don't use ShootDistance and ShootAngle.
You don't need unit group array, since you don't store units in it for later use.

I suggest you store ShootAngle in your first trigger as angle between Point 1 and 2, in your second trigger create point 1 at position of dummy and create point 2 as point with polar offset towards ShootAngle[current index] (what I mean is that the angle does not change since the time the dummy has been created - so store the angle when the dummy is created... don't store the angle anew every 0,03 second)
 
Status
Not open for further replies.
Top