• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Trigger] Unit (Projectile) Movement and a multi-phase spell check

Status
Not open for further replies.
Level 20
Joined
Apr 14, 2012
Messages
2,901
I currently don't have access to the trigger editor at the moment, so I had to write this on notepad.

The spell basically creates a projectile unit at the position of the caster, sends it to the target point (over time) then when the projectile reaches the target point, it stops, then commences to execute the second stage, which when done, will execute the third and last stage.

I'm not exactly sure about how to move the projectiles. From what I can remember, it requires a periodic event time loop thingy, which has 3 points needed: the caster's point, the target point, and an offset point; the projectile is moved to that unit point every x seconds (in this case it's every 0.5 seconds).

  • Variables
  • ER_MaxIndex = 0
  • ER_CurrentIndex = 0
  • ER_Abil - Earth's Rampage Ability
  • ER_Level[] - level of ER_Abil for ER_Caster[]
  • ER_Caster[] - Triggering Unit
  • ER_TargetPoint[] - Target Point of Ability Being Cast
  • ER_CasterPoint[] - Position of ER_Caster
  • ER_Projectile[] - Dummy Unit
  • ER_ProjectileModel - string model path
  • ER_ProjCounter[] - a counter for the projectile
  • ER_ProjLoc[] - the position of the projectile
  • ER_StageCounter[] - a counter for the spell's two phases after projectile reaches TP.
  • ER_CurrentPoint[] - TargetPoint offset by 5.00 towards (Angle from CasterPoint to TargetPoint) degrees.
  • Cast Trigger
    • Event - U starts the effect of an ability
    • Condition - Ability being cast equal to ER_Abil
    • Actions -
      • /-- setup the stuff --/
      • set ER_MaxIndex = ER_MaxIndex + 1
      • set ER_Caster[ER_MaxIndex] = Triggering Unit
      • set ER_Level[ER_MaxIndex] = level of ER_Abil for ER_Caster[ER_MaxIndex]
      • set ER_TargetPoint[ER_MaxIndex] = Target point of ER_Abil
      • set ER_CasterPoint[ER_MaxIndex] = Position of ER_Caster[ER_MaxIndex]
      • /-- I dont think the degree matters at this point --/
      • Create 1 DummyUnit at ER_CasterPoint[ER_MaxIndex] facing 200.00 degrees
      • set ER_Projectile[ER_MaxIndex] = last created unit
      • set ER_StageCounter[ER_MaxIndex] = 0
      • ER_ProjCounter[ER_MaxIndex] = 0
      • if MaxIndex == 1 then
        • Turn On Loop Trigger
  • Loop Trigger
    • Event - Every 0.03 seconds of game time
    • Condition -
    • Actions -
      • For each (ER_CurrentIndex) from 1 to ER_MaxIndex, do actions:
        • set ER_StageCounter[ER_CurrentIndex] ++ 1
        • /--Determine the stage number for the appropriate phase --
        • If - ER_StageCounter[ER_CurrentIndex] == 1
        • Then -
          • /-- Add one to the projectile counter --/
          • set ER_ProjCounter[ER_CurrentIndex] ++ 1
          • /-- Since it's going to move every .5 seconds, I check first if the projectile has reached the target point AND if the counter has reached that time--/
          • If ER_ProjCounter[ER_CurrentIndex] >= 16
          • Then -
            • If - Distance Between ER_TargetPoint[CurrentIndex] and ER_ProjLoc[ER_CurrentIndex] <= 0.00
            • Then -
              • /-- At this point, the counter should be around 16, and the distance must have been closed --/
              • /-- Increment the stage counter by 1 to move on to the next phase --/
              • set ER_StageCounter[ER_StageCounter[ER_CurrentIndex]] ++ 1
            • Else -
              • /-- This means that the distance hasn't been travelled yet --/
              • /-- So, we move the projectile unit a bit forward then reset the counter to 0 --/
              • set ER_CurrentPoint[ER_CurrentIndex] = ER_TargetPoint[ER_CurrentIndex] offset by 5.00 towards (Angle from ER_CasterPoint[ER_CurrentIndex] to ER_TargetPoint[ER_CurrentIndex] degrees)
              • Move ER_Projectile[CurrentIndex] to ER_CurrentPoint Instantly
              • set ER_ProjLoc[ER_CurrentIndex] = Position of ER_Projectile[ER_CurrentIndex]
              • set ER_ProjCounter[ER_CurrentIndex] == 0
          • Else
        • /--Check if the stage counter is equal to 2 --/
        • Elseif ER_StageCounter[ER_CurrentIndex] == 2
        • Then -
          • /--Stuff--/
          • set ER_StageCounter[ER_CurrentIndex] == 3
        • Elseif ER_StageCounter[ER_CurrentIndex] == 3
        • Then -
          • /--stuff--/
          • /--RECYCLE--/

From what I can see, it should be err, smooth? Like, at cast, the unit is created, in the loop, it checks first if the distance has been reached, if not, then it moves a bit, then when it has reached the point, it increments the stagecounter, so that in the next run at the loop, the next phase is executed, and so on.

But again, I could be committing some serious oversight here.
Help and insight is very much appreciated!

P.S. Idk how to check with the pathing yet, but I'm hoping to be able to cross that bridge when I get there.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Problem 1
You are increasing your StageCounter each frame.

This means
0.00 > StageCounter = 1
0.03 > StageCounter = 2
0.06 > StageCounter = 3
0.09 > StageCounter = 4

I believe this is not what you want it to be so it could pass the checks later?

Problem 2
You are moving the projectile the other way around.
Target >>> Caster instead of Caster >>> Target
  • set ER_CurrentPoint[ER_CurrentIndex] = ER_TargetPoint[ER_CurrentIndex] offset by 5.00 towards (Angle from ER_CasterPoint[ER_CurrentIndex] to ER_TargetPoint[ER_CurrentIndex] degrees)
It would be more like:
  • set TempPoint = ER_ProjPoint[ER_CurrentIndex] offset by 5.00 towards (Angle from ER_ProjPoint[ER_CurrentIndex] to ER_TargetPoint[ER_CurrentIndex] degrees)
  • Move to TempPoint
  • Clean TempPoint
  • Set ProjPoint = Position of Proj

I believe that pathing is like one line?
Terrain at ThisPoint is walkable equals to true


That is my input.

Hope this helps!
-Ned
 
Status
Not open for further replies.
Top