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

Destroy lightning without error

Status
Not open for further replies.
The title explains pretty much everything. I have this simple loop and don't know how to remove the lightning without a crash:

  • Untitled Trigger 002
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Temp_Int) from 1 to 24, do (Actions)
        • Loop - Actions
          • Set pStaticT[Temp_Int] = (Position of uStaticT[Temp_Int])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between pStaticDestenation[Temp_Int] and pStaticT[Temp_Int]) Less than 100.00
            • Then - Actions
              • Lightning - Destroy StaticLightning[Temp_Int]
              • Set uStaticC[Temp_Int] = No unit
              • Set uStaticT[Temp_Int] = No unit
              • Set rStaticDamage[Temp_Int] = 0.00
            • Else - Actions
              • Set rStaticDamage[Temp_Int] = (rStaticDamage[Temp_Int] x 1.03)
              • Set StaticAngle = (Angle from pStaticT[Temp_Int] to pStaticDestenation[Temp_Int])
              • Set pStaticT[Temp_Int] = (pStaticT[Temp_Int] offset by rStaticDamage[Temp_Int] towards StaticAngle degrees)
              • Unit - Move uStaticT[Temp_Int] instantly to pStaticT[Temp_Int]
              • Unit - Cause uStaticC[Temp_Int] to damage uStaticT[Temp_Int], dealing (rStaticDamage[Temp_Int] / 3.00) damage of attack type Spells and damage type Normal
              • Lightning - Move StaticLightning[Temp_Int] to source pStaticT[Temp_Int] and target pStaticDestenation[Temp_Int]
Please help
 
Moving a lightning object that has been destroyed will create a fatal error.

Before you do the "Else" actions, you should first check if uStaticC[Temp_Int] is equal to No unit. This would mean that the lightning is destroyed. If it is not equal to No unit, then you can go on and do the actions.

That should fix the error.
  • Untitled Trigger 002
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Temp_Int) from 1 to 24, do (Actions)
        • Loop - Actions
          • Set pStaticT[Temp_Int] = (Position of uStaticT[Temp_Int])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between pStaticDestenation[Temp_Int] and pStaticT[Temp_Int]) Less than 100.00
            • Then - Actions
              • Lightning - Destroy StaticLightning[Temp_Int]
              • Set uStaticC[Temp_Int] = No unit
              • Set uStaticT[Temp_Int] = No unit
              • Set rStaticDamage[Temp_Int] = 0.00
            • Else - Actions
              • If (uStaticC[Temp_Int] Equal to No unit) then do (Skip remaining actions) else do (Do nothing)
              • Set rStaticDamage[Temp_Int] = (rStaticDamage[Temp_Int] x 1.03)
              • Set StaticAngle = (Angle from pStaticT[Temp_Int] to pStaticDestenation[Temp_Int])
              • Set pStaticT[Temp_Int] = (pStaticT[Temp_Int] offset by rStaticDamage[Temp_Int] towards StaticAngle degrees)
              • Unit - Move uStaticT[Temp_Int] instantly to pStaticT[Temp_Int]
              • Unit - Cause uStaticC[Temp_Int] to damage uStaticT[Temp_Int], dealing (rStaticDamage[Temp_Int] / 3.00) damage of attack type Spells and damage type Normal
              • Lightning - Move StaticLightning[Temp_Int] to source pStaticT[Temp_Int] and target pStaticDestenation[Temp_Int]
I might do it like that above^.
 
Thanks it works now :)
I think posting the other trigger that is related to this might help, try posting the triggers that create the lightning.
I already knew the problem; I was moving a none resisting lightning in the loop but thanks for your effort.

+rep to PurgeandFire

EDIT: ugh a nother error. D: there are 2 casters in the opisite corners and an enemy in the center. cast the ability on the enemy with 1 hero and wait for it to reach is destenation. After that you cast the same ability with the other hero and BANG you got yourself a FATAL ERROR! please help

EDIT: FOUND IT! I removed the 'move lightning' and found that when I cast it the second time, the lightning is trmoved instantly. But why? the target isin't dead! So basicly it moved a none existing lightning on the 2nd cast.
  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Static pull
    • Actions
      • If (iStaticIndex Greater than 23) then do (Set iStaticIndex = 1) else do (Set iStaticIndex = (iStaticIndex + 1))
      • Set uStaticC[iStaticIndex] = (Casting unit)
      • Set uStaticT[iStaticIndex] = (Target unit of ability being cast)
      • Set pStaticDestenation[iStaticIndex] = (Position of uStaticC[iStaticIndex])
      • Lightning - Create a Forked Lightning lightning effect from source (Position of uStaticT[iStaticIndex]) to target (Position of uStaticC[iStaticIndex])
      • Set StaticLightning[iStaticIndex] = (Last created lightning effect)
      • Set rStaticDamage[iStaticIndex] = 0.50
      • -------- Caster, target, destenation, Damage and lightning is saved --------
  • Untitled Trigger 002
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Temp_Int) from 1 to 24, do (Actions)
        • Loop - Actions
          • Set pStaticT[Temp_Int] = (Position of uStaticT[Temp_Int])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Distance between pStaticT[Temp_Int] and pStaticDestenation[Temp_Int]) Less than 150.00) or ((uStaticT[Temp_Int] is dead) Equal to True)
            • Then - Actions
              • Lightning - Destroy StaticLightning[Temp_Int]
              • Set uStaticC[Temp_Int] = No unit
              • Set uStaticT[Temp_Int] = No unit
              • Set rStaticDamage[Temp_Int] = 0.00
            • Else - Actions
              • If (uStaticT[Temp_Int] Equal to No unit) then do (Skip remaining actions) else do (Do nothing)
              • Set rStaticDamage[Temp_Int] = (rStaticDamage[Temp_Int] x 1.02)
              • If (rStaticDamage[Temp_Int] Less than 45.00) then do (Set rStaticDamage[Temp_Int] = (rStaticDamage[Temp_Int] x 1.03)) else do (Do nothing)
              • Set StaticAngle = (Angle from pStaticT[Temp_Int] to pStaticDestenation[Temp_Int])
              • Set pStaticT[Temp_Int] = (pStaticT[Temp_Int] offset by rStaticDamage[Temp_Int] towards StaticAngle degrees)
              • Unit - Move uStaticT[Temp_Int] instantly to pStaticT[Temp_Int]
              • Unit - Cause uStaticC[Temp_Int] to damage uStaticT[Temp_Int], dealing (rStaticDamage[Temp_Int] / 3.00) damage of attack type Spells and damage type Normal
              • Lightning - Move StaticLightning[Temp_Int] to source pStaticT[Temp_Int] and target pStaticDestenation[Temp_Int]
 

Attachments

  • lightning.w3x
    14.4 KB · Views: 82
Last edited:
Status
Not open for further replies.
Top