• 🏆 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] Missile Behavior Problem

Status
Not open for further replies.
Level 20
Joined
Apr 14, 2012
Messages
2,901
The problem isn't really with the projectile system I used (Kingz' Projectile System) but how it totally does not cooperate with my spell.

The spell:
The spell has two phases. First it creates a circle of sfx upon casting, literally 0.03 seconds after the cast. Then, after 2 seconds, it (supposedly should) creates missiles in a circle (the same circle as in the first phase) and then launches those towards a target unit.

The problem:

The first phase checks out. The second phase is what boggles my mind. The missiles are created, but they head towards the same corner of the map every time the spell is cast, and after a delay, one super dense missile falls out of the sky and that missile is what hits the target unit. Damage is delivered and it seems to follow the <time to reach> variable.

What I've tried:
I've tried applying the second phase of the spell to the original system map; it works there. I've also tried replacing the part of my spell which uses the projectile system with a completely simple one, which was to create a footman circle instead of the missiles: this also works normally.

Things only go awry when I use the projectile system. I am running out of troubleshooting ideas. Nay, I'm running out of spirit. I would really appreciate some help.


  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set FslashAbil = Fireslash
      • Set FslashTempInt = 0

  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to FslashAbil
        • Then - Actions
          • Set FslashMaxIndex = (FslashMaxIndex + 1)
          • Set FslashCaster[FslashMaxIndex] = (Triggering unit)
          • Set FslashCasterPoint[FslashMaxIndex] = (Position of FslashCaster[FslashMaxIndex])
          • Set FslashTarget[FslashMaxIndex] = (Target unit of ability being cast)
          • Set FslashTargetPoint[FslashMaxIndex] = (Position of FslashTarget[FslashMaxIndex])
          • Set FslashPlayer[FslashMaxIndex] = (Owner of FslashCaster[FslashMaxIndex])
          • Set FslashCounter[FslashMaxIndex] = 0
          • Set FslashTempInt = 0
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • FslashMaxIndex Equal to 1
            • Then - Actions
              • Trigger - Turn on Loop <gen>
            • Else - Actions
        • Else - Actions

  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer FslashCurrentIndex) from 1 to FslashMaxIndex, do (Actions)
        • Loop - Actions
          • Set FslashCounter[FslashCurrentIndex] = (FslashCounter[FslashCurrentIndex] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • FslashCounter[FslashCurrentIndex] Equal to 1
            • Then - Actions
              • -------- First, instantly create the circle of sfx --------
              • For each (Integer FslashTempInt) from 1 to 8, do (Actions)
                • Loop - Actions
                  • -------- This part works --------
                  • Set FslashTempPoint = (FslashCasterPoint[FslashCurrentIndex] offset by 400.00 towards ((Real(FslashTempInt)) x (360.00 / 8.00)) degrees)
                  • Special Effect - Create a special effect at FslashTempPoint using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Custom script: call RemoveLocation(udg_FslashTempPoint)
            • Else - Actions
              • -------- Next, when two seconds are up, create fireballs at those points and aim towards target --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • FslashCounter[FslashCurrentIndex] Equal to 66
                • Then - Actions
                  • -------- Creating the projectiles in the circle --------
                  • For each (Integer FslashTempInt) from 1 to 8, do (Actions)
                    • Loop - Actions
                      • -------- After the point has been determined, create a projectile and set it towards target --------
                      • -------- Start Projectile System --------
                      • Set MS_dmg_source = FslashCaster[FslashCurrentIndex]
                      • Set MS_owner = FslashPlayer[FslashCurrentIndex]
                      • Set MS_create_point = (FslashCasterPoint[FslashCurrentIndex] offset by 400.00 towards ((Real(FslashTempInt)) x (360.00 / 8.00)) degrees)
                      • Set MS_target_point = FslashTargetPoint[FslashCurrentIndex]
                      • Set MS_damage = 10.00
                      • Set MS_seconds_to_reach = 3.00
                      • Set MS_angle = (Angle from MS_create_point to MS_target_point)
                      • Set MS_distance = (Distance between MS_create_point and MS_target_point)
                      • Set MS_missile_gfx = Abilities\Weapons\FrostWyrmMissile\FrostWyrmMissile.mdl
                      • Set MS_impact_gfx = Abilities\Weapons\FrostWyrmMissile\FrostWyrmMissile.mdl
                      • Set MS_unit_hit_eff = Abilities\Weapons\FrostWyrmMissile\FrostWyrmMissile.mdl
                      • Set MS_arcs = True
                      • Set MS_arc_dist = 300.00
                      • Set MS_parabola = True
                      • Set MS_arc_type = FslashTempInt
                      • Set MS_parabola_height = 450.00
                      • Trigger - Run MS init <gen> (ignoring conditions)
                      • Custom script: call RemoveLocation(udg_MS_create_point)
                      • Custom script: call RemoveLocation(udg_MS_target_point)
                      • -------- End --------
                      • Custom script: call RemoveLocation(udg_FslashTempPoint)
                  • -------- Recycling --------
                  • Set FslashCounter[FslashCurrentIndex] = FslashCounter[FslashMaxIndex]
                  • Set FslashCaster[FslashCurrentIndex] = FslashCaster[FslashMaxIndex]
                  • Set FslashCasterPoint[FslashCurrentIndex] = FslashCasterPoint[FslashMaxIndex]
                  • Set FslashPlayer[FslashCurrentIndex] = FslashPlayer[FslashMaxIndex]
                  • Set FslashTarget[FslashCurrentIndex] = FslashTarget[FslashMaxIndex]
                  • Set FslashTargetPoint[FslashCurrentIndex] = FslashTargetPoint[FslashMaxIndex]
                  • Set FslashTargetPoint[FslashCurrentIndex] = FslashTargetPoint[FslashMaxIndex]
                  • Set FslashMaxIndex = (FslashMaxIndex - 1)
                  • Set FslashCurrentIndex = (FslashCurrentIndex - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • FslashMaxIndex Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
P.S. Sorry that the spell's name has nothing to do with the spell's mechanics. I realized too late.
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
So I just tried again with another projectile system, this time with BPower's. It was the same result, 7 ouf of 8 missiles went off wildly to the corner of the map, only one was able to reach the target unit.

I mean it works if all 8 missiles come from the position of the caster, but if they come from each of the 8 points on the circle, it all goes to sht.
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
TURNS OUT

If I do MS_target_point = (Position of Footman 0001<gen>), then the spell mysteriously works.

EDIT
I set the MS_target_point to (Position of FslashTarget[FslashCurrentIndex]) instead of FslashTargetPoint. That solved the problem. For some reason.

I would still like to find out why though. Oh well. Thanks for the help guys!
 
Level 7
Joined
Oct 19, 2015
Messages
286
  • Custom script: call RemoveLocation(udg_MS_target_point)
You destroy your target point after creating the first missile. You need to move this action outside the loop.
 
Level 7
Joined
Oct 19, 2015
Messages
286
Why a new point? You're setting it to your existing point:
  • Set MS_target_point = FslashTargetPoint[FslashCurrentIndex]
There's no new point being created here, both MS_target_point and FslashTargetPoint[FslashCurrentIndex] are referencing the same location.
 
Level 12
Joined
May 20, 2009
Messages
822
I think you have a few leaks. From my understanding, you're leaking your Caster and Target point in the Cast trigger. You change the variable references in Loop, but you don't destroy the points. Changing the reference doesn't destroy the point, I think.

  • -------- Recycling --------
  • Set FslashCounter[FslashCurrentIndex] = FslashCounter[FslashMaxIndex]
  • Set FslashCaster[FslashCurrentIndex] = FslashCaster[FslashMaxIndex]
  • Set FslashCasterPoint[FslashCurrentIndex] = FslashCasterPoint[FslashMaxIndex]
  • Set FslashPlayer[FslashCurrentIndex] = FslashPlayer[FslashMaxIndex]
  • Set FslashTarget[FslashCurrentIndex] = FslashTarget[FslashMaxIndex]
  • Set FslashTargetPoint[FslashCurrentIndex] = FslashTargetPoint[FslashMaxIndex]
  • Set FslashTargetPoint[FslashCurrentIndex] = FslashTargetPoint[FslashMaxIndex]
You Set FslashTargetPoint[FslashCurrentIndex] to FlashTargetPoint[FslashMaxIndex] twice.

  • Custom script: call RemoveLocation(udg_MS_create_point)
  • Custom script: call RemoveLocation(udg_MS_target_point)
Do you need to destroy these points? Is it not handled by the missile system? That may be what's actually causing the problem. I'm sure if you continue testing what you have right now, it'll still glitch out in some way because you're destroying the target_point there and not replacing it at all. udg_MS_target_point and FslashTargetPoint[FslashCurrentIndex] are referencing the same point, so if you destroy one of them then they are both nulled. (From my understanding, anyway) Besides, while you do need to destroy create_point (If it's not already handled by the Missile System), because you make 8 different points, you don't need to destroy target_point because it's referencing the same point every time. It's not creating a new point.
 
Level 20
Joined
Apr 14, 2012
Messages
2,901
I think you have a few leaks. From my understanding, you're leaking your Caster and Target point in the Cast trigger. You change the variable references in Loop, but you don't destroy the points. Changing the reference doesn't destroy the point, I think.

  • -------- Recycling --------
  • Set FslashCounter[FslashCurrentIndex] = FslashCounter[FslashMaxIndex]
  • Set FslashCaster[FslashCurrentIndex] = FslashCaster[FslashMaxIndex]
  • Set FslashCasterPoint[FslashCurrentIndex] = FslashCasterPoint[FslashMaxIndex]
  • Set FslashPlayer[FslashCurrentIndex] = FslashPlayer[FslashMaxIndex]
  • Set FslashTarget[FslashCurrentIndex] = FslashTarget[FslashMaxIndex]
  • Set FslashTargetPoint[FslashCurrentIndex] = FslashTargetPoint[FslashMaxIndex]
  • Set FslashTargetPoint[FslashCurrentIndex] = FslashTargetPoint[FslashMaxIndex]
You Set FslashTargetPoint[FslashCurrentIndex] to FlashTargetPoint[FslashMaxIndex] twice.
Oh yeah now that I look at it, I was so preoccupied with removing leaks for those in the loop I forgot to clear the caster and target locs lol
Especially that setting twice. Thanks for pointing that out.
  • Custom script: call RemoveLocation(udg_MS_create_point)
  • Custom script: call RemoveLocation(udg_MS_target_point)
Do you need to destroy these points? Is it not handled by the missile system? That may be what's actually causing the problem. I'm sure if you continue testing what you have right now, it'll still glitch out in some way because you're destroying the target_point there and not replacing it at all. udg_MS_target_point and FslashTargetPoint[FslashCurrentIndex] are referencing the same point, so if you destroy one of them then they are both nulled. (From my understanding, anyway) Besides, while you do need to destroy create_point (If it's not already handled by the Missile System), because you make 8 different points, you don't need to destroy target_point because it's referencing the same point every time. It's not creating a new point.

Idk the missile system said in the docu that each time I create a missile I should destroy MS_target_point and the MS_create_point. But I will continue testing.

But so far, the only fix I've had was to set MS_target_point to (Position of FslashTarget[FslashCurrentIndex]), and that let the missiles behave properly.
 
Level 7
Joined
Oct 19, 2015
Messages
286
But so far, the only fix I've had was to set MS_target_point to (Position of FslashTarget[FslashCurrentIndex])
Have you tried what I suggested? Just leave this line as it was:
  • Set MS_target_point = FslashTargetPoint[FslashCurrentIndex]
And move this line outside of the loop:
  • Custom script: call RemoveLocation(udg_MS_target_point)
 
Status
Not open for further replies.
Top