1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] TOTAL ERROR when casting a spell

Discussion in 'Triggers & Scripts' started by Krakenn99, Apr 14, 2018.

  1. Krakenn99

    Krakenn99

    Joined:
    Jun 26, 2014
    Messages:
    480
    Resources:
    1
    Maps:
    1
    Resources:
    1
    (I accidentally posted this on the Help Zone first, pls delete that thread)
    Usually I get the total error after 20th or 30th cast (if the number of casting is even the problem here)
    Spell desc.: Links the caster and the target, healing the target per second and draining the mana of the caster. Caster can link himself with multiple units.

    • Cell Link
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Cell Link
      • Actions
        • For each (Integer A) from 1 to SP_CL_mui, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Target unit of ability being cast) Equal to SP_CL_unit[(Integer A)]
              • Then - Actions
                • Player Group - Add (Owner of (Triggering unit)) to Player_Messages
                • Game - Display to Player_Messages for 5.00 seconds the text: |cffffcc00Unit is a...
                • Player Group - Remove (Owner of (Triggering unit)) from Player_Messages
                • Skip remaining actions
              • Else - Actions
        • Set SP_CL_index = (SP_CL_index + 1)
        • Set SP_CL_mui = (SP_CL_mui + 1)
        • Set SP_CL_caster[SP_CL_mui] = (Triggering unit)
        • Set SP_CL_unit[SP_CL_mui] = (Target unit of ability being cast)
        • Set SP_CL_data[SP_CL_mui] = ((Real((Level of Cell Link for (Triggering unit)))) x 1.00)
        • Set SP_CL_mana[SP_CL_mui] = ((Real((Level of Cell Link for (Triggering unit)))) x 0.10)
        • Set SP_CL_distance[SP_CL_mui] = (((Level of Cell Link for (Triggering unit)) x 75) + 675)
        • Set SP_CL_point1[SP_CL_mui] = (Position of (Triggering unit))
        • Set SP_CL_point2[SP_CL_mui] = (Position of (Target unit of ability being cast))
        • Lightning - Create a Healing Wave - Secondary lightning effect from source SP_CL_point1[SP_CL_mui] to target SP_CL_point2[SP_CL_mui]
        • Set SP_CL_link[SP_CL_mui] = (Last created lightning effect)
        • Trigger - Turn on Cell Link Loop <gen>

    • Cell Link Loop
      • Events
        • Time - Every 0.10 seconds of game time
      • Conditions
      • Actions
        • For each (Integer A) from 1 to SP_CL_mui, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((SP_CL_caster[(Integer A)] is alive) Equal to True) and ((SP_CL_unit[(Integer A)] is alive) Equal to True)
              • Then - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Distance between SP_CL_point1[(Integer A)] and SP_CL_point2[(Integer A)]) Less than or equal to (Real(SP_CL_distance[(Integer A)]))
                  • Then - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (Percentage mana of SP_CL_caster[(Integer A)]) Greater than 5.00
                      • Then - Actions
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • (Percentage life of SP_CL_unit[(Integer A)]) Less than 100.00
                          • Then - Actions
                            • Set SP_CL_point1[(Integer A)] = (Position of SP_CL_caster[(Integer A)])
                            • Set SP_CL_point2[(Integer A)] = (Position of SP_CL_unit[(Integer A)])
                            • Lightning - Move SP_CL_link[(Integer A)] to source SP_CL_point1[(Integer A)] and target SP_CL_point2[(Integer A)]
                            • Unit - Set mana of SP_CL_caster[(Integer A)] to ((Mana of SP_CL_caster[(Integer A)]) - SP_CL_mana[(Integer A)])
                            • Unit - Set life of SP_CL_unit[(Integer A)] to ((Life of SP_CL_unit[(Integer A)]) + SP_CL_data[(Integer A)])
                            • Custom script: call RemoveLocation(udg_SP_CL_point1[bj_forLoopAIndex])
                            • Custom script: call RemoveLocation(udg_SP_CL_point2[bj_forLoopAIndex])
                          • Else - Actions
                            • Lightning - Destroy SP_CL_link[(Integer A)]
                            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                              • If - Conditions
                                • SP_CL_unit[(Integer A)] Not equal to No unit
                              • Then - Actions
                                • Set SP_CL_caster[(Integer A)] = No unit
                                • Set SP_CL_unit[(Integer A)] = No unit
                                • Set SP_CL_index = (SP_CL_index - 1)
                                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                  • If - Conditions
                                    • SP_CL_index Less than or equal to 0
                                  • Then - Actions
                                    • Set SP_CL_index = 0
                                    • Set SP_CL_mui = 0
                                    • Trigger - Turn off (This trigger)
                                  • Else - Actions
                              • Else - Actions
                      • Else - Actions
                        • Lightning - Destroy SP_CL_link[(Integer A)]
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • SP_CL_unit[(Integer A)] Not equal to No unit
                          • Then - Actions
                            • Set SP_CL_caster[(Integer A)] = No unit
                            • Set SP_CL_unit[(Integer A)] = No unit
                            • Set SP_CL_index = (SP_CL_index - 1)
                            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                              • If - Conditions
                                • SP_CL_index Less than or equal to 0
                              • Then - Actions
                                • Set SP_CL_index = 0
                                • Set SP_CL_mui = 0
                                • Trigger - Turn off (This trigger)
                              • Else - Actions
                          • Else - Actions
                  • Else - Actions
                    • Lightning - Destroy SP_CL_link[(Integer A)]
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • SP_CL_unit[(Integer A)] Not equal to No unit
                      • Then - Actions
                        • Set SP_CL_caster[(Integer A)] = No unit
                        • Set SP_CL_unit[(Integer A)] = No unit
                        • Set SP_CL_index = (SP_CL_index - 1)
                        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • If - Conditions
                            • SP_CL_index Less than or equal to 0
                          • Then - Actions
                            • Set SP_CL_index = 0
                            • Set SP_CL_mui = 0
                            • Trigger - Turn off (This trigger)
                          • Else - Actions
                      • Else - Actions
              • Else - Actions
                • Lightning - Destroy SP_CL_link[(Integer A)]
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • SP_CL_unit[(Integer A)] Not equal to No unit
                  • Then - Actions
                    • Set SP_CL_caster[(Integer A)] = No unit
                    • Set SP_CL_unit[(Integer A)] = No unit
                    • Set SP_CL_index = (SP_CL_index - 1)
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • SP_CL_index Less than or equal to 0
                      • Then - Actions
                        • Set SP_CL_index = 0
                        • Set SP_CL_mui = 0
                        • Trigger - Turn off (This trigger)
                      • Else - Actions
                  • Else - Actions
     
  2. pOke

    pOke

    Joined:
    Mar 24, 2013
    Messages:
    1,102
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Error as in crash or what type of error?

    I have only glanced at the code, but I am assuming you're moving a destroyed lightning which causes a crash.

    Your code within the loop is also less than optimal.
     
  3. Krakenn99

    Krakenn99

    Joined:
    Jun 26, 2014
    Messages:
    480
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I tried moving the lightning destroy function to a better position, I hope it will fix it. I'll let you know if it continues to crash and I'll screenshot the error if it happens.
     
  4. Krakenn99

    Krakenn99

    Joined:
    Jun 26, 2014
    Messages:
    480
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Yeah I managed to fix it. Moving the destruction of the lightning effect when I check if unit = no unit works just fine. Ty for help :)