Refreshing lightning effects

Tawnttoo

New Member
Reaction score
36
I'm trying to create a channeled spell which requires creating a lightning effect from point a to b. I can't understand why it works properly only on first cast (when 2 simultaneous instances are active).
 

Attachments

  • Power Surge.w3x
    39.8 KB · Views: 91

Accname

2D-Graphics enthusiast
Reaction score
1,464
it would be better to post the triggers here directly i guess. i for example do not have access to the world editor right now and maybe others havent as well.
triggering problems like the ones you mentioned are most of the time found by attentively looking at the code.
 

Tawnttoo

New Member
Reaction score
36
As you wish. I have looked into the code, tried to modify it but to no avail.

Trigger:
  • Power Surge Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Surge_Group and do (Actions)
        • Loop - Actions
          • -------- Reducing duration so that spell isn't infinite. --------
          • Hashtable - Save ((Load (Key duration) of (Key (Picked unit)) from Surge_Hash) - 0.05) as (Key duration) of (Key (Picked unit)) in Surge_Hash
          • -------- Removing the beam(s) here so they last 0.05 seconds per loop. So they display properly, that is. --------
          • Custom script: call DestroyLightning( LoadLightningHandleBJ(StringHashBJ("low"), GetHandleIdBJ(GetEnumUnit()), udg_Surge_Hash) )
          • Custom script: call DestroyLightning( LoadLightningHandleBJ(StringHashBJ("med"), GetHandleIdBJ(GetEnumUnit()), udg_Surge_Hash) )
          • Custom script: call DestroyLightning( LoadLightningHandleBJ(StringHashBJ("high"), GetHandleIdBJ(GetEnumUnit()), udg_Surge_Hash) )
          • -------- Refreshing the location of the target. --------
          • Hashtable - Save Handle Of(Position of (Load (Key target) of (Key (Picked unit)) in Surge_Hash)) as (Key targetloc) of (Key (Picked unit)) in Surge_Hash
          • -------- Then checking that spell channeling can still continue, and making everything happen if it can. --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load (Key duration) of (Key (Picked unit)) from Surge_Hash) Greater than 0.00
              • ((Picked unit) is alive) Equal to True
              • ((Load (Key target) of (Key (Picked unit)) in Surge_Hash) is alive) Equal to True
              • (Distance between (Load (Key casterloc) of (Key (Picked unit)) in Surge_Hash) and (Load (Key targetloc) of (Key (Picked unit)) in Surge_Hash)) Less than (Load (Key radius) of (Key (Picked unit)) from Surge_Hash)
            • Then - Actions
              • -------- Stage 1 of channeled beam --------
              • -------- IF NEEDED, MODIFY THE LIGHTNING EFFECT HERE! --------
              • Lightning - Create a Chain Lightning - Secondary lightning effect from source (Load (Key casterloc) of (Key (Picked unit)) in Surge_Hash) to target (Load (Key targetloc) of (Key (Picked unit)) in Surge_Hash)
              • Hashtable - Save Handle Of(Last created lightning effect) as (Key low) of (Key (Picked unit)) in Surge_Hash
              • Hashtable - Save (Load (Key damage low) of (Key (Picked unit)) from Surge_Hash) as (Key damage) of (Key (Picked unit)) in Surge_Hash
              • -------- Stage 2 of channeled beam --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Key duration) of (Key (Picked unit)) from Surge_Hash) Less than ((Surge_Duration / 3.00) x 2.00)
                • Then - Actions
                  • -------- IF NEEDED, MODIFY THE LIGHTNING EFFECT HERE! --------
                  • Lightning - Create a Chain Lightning - Primary lightning effect from source (Load (Key casterloc) of (Key (Picked unit)) in Surge_Hash) to target (Load (Key targetloc) of (Key (Picked unit)) in Surge_Hash)
                  • Hashtable - Save Handle Of(Last created lightning effect) as (Key med) of (Key (Picked unit)) in Surge_Hash
                  • Hashtable - Save (Load (Key damage med) of (Key (Picked unit)) from Surge_Hash) as (Key damage) of (Key (Picked unit)) in Surge_Hash
                  • -------- Stage 3 of channeled beam --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load (Key duration) of (Key (Picked unit)) from Surge_Hash) Less than (Surge_Duration / 3.00)
                    • Then - Actions
                      • -------- IF NEEDED, MODIFY THE LIGHTNING EFFECT HERE! --------
                      • Lightning - Create a Forked Lightning lightning effect from source (Load (Key casterloc) of (Key (Picked unit)) in Surge_Hash) to target (Load (Key targetloc) of (Key (Picked unit)) in Surge_Hash)
                      • Hashtable - Save Handle Of(Last created lightning effect) as (Key high) of (Key (Picked unit)) in Surge_Hash
                      • Hashtable - Save (Load (Key damage high) of (Key (Picked unit)) from Surge_Hash) as (Key damage) of (Key (Picked unit)) in Surge_Hash
                    • Else - Actions
                • Else - Actions
              • -------- Actually damaging the target --------
              • Unit - Cause (Picked unit) to damage (Load (Key target) of (Key (Picked unit)) in Surge_Hash), dealing (Load (Key damage) of (Key (Picked unit)) from Surge_Hash) damage of attack type Spells and damage type Normal
              • -------- Optional, additional eye-candy. --------
              • Special Effect - Create a special effect attached to the origin of (Picked unit) using Surge_Effect
              • Special Effect - Destroy (Last created special effect)
              • Special Effect - Create a special effect attached to the origin of (Load (Key target) of (Key (Picked unit)) in Surge_Hash) using Surge_Effect
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • -------- When channeling cannot continue, it won't. Clearing data from cast. --------
              • Unit - Order (Picked unit) to Stop
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Surge_Hash
              • Unit Group - Remove (Picked unit) from Surge_Group


In greater detail, it works perfectly when used once at a time. While used multiple times simultaneously, it works properly once. After that, the lightning effects are created at the caster which casted previously.
 

DioD

New Member
Reaction score
57
if you save instance to unit it will work only once per unit.

you must save instance to lightning itself or virtual object.
 

baassee

Member
Reaction score
5
Basic you save the instance of "GetHandleId(handle)". Don't know the exact term in GUI, don't have so much experience of hashtables in GUI.
 

Tawnttoo

New Member
Reaction score
36
Am I not doing it already?

Trigger:
  • Hashtable - Save Handle Of(Last created lightning effect) as (Key high) of (Key (Picked unit)) in Surge_Hash


Should I replace (Key (Picked unit)) with, say, the target point of the spell instead?
 

baassee

Member
Reaction score
5
No it shouldn't although the key picked unit will make it only one instance per unit. I haven't done this in GUI. I can recommend you to start with JASS or indexing :D
 

Tawnttoo

New Member
Reaction score
36
How does it only make "1 instance per unit" if the spell works correctly when running only once, and the first stage works for as many as needed?

Please, make the effort and try it in the map. It's a bit complicated to explain.
 

baassee

Member
Reaction score
5
Still they can fire it twice without breaking it. Only cooldown will make it possible.
 

Tawnttoo

New Member
Reaction score
36
Can they? There's a trigger in the map which stops the loop if the casters stops channeling. Plus, that's not my problem anyways. It is that the first stage (the first lightning effect) works as it should on as many simultaneous casters as needed. The second and third stages (read: lightning effects) do not work as intended (except for the first time casting multiple instances simultaneously). How would I go about fixing it? Have you really even checked the map in the first post?
 

baassee

Member
Reaction score
5
Yes I have and now when I open it again I got it. It leaks alot as you never set any locations, you just stores the position which also creates a leak. Forgot about the last trigger totally btw.

Trigger:
  • Hashtable - Save Handle Of(Position of (Triggering unit)) as (Key casterloc) of (Key (Triggering unit)) in Surge_Hash
    • Hashtable - Save Handle Of(Position of (Target unit of ability being cast)) as (Key targetloc) of (Key (Triggering unit)) in Surge_Hash


And

Trigger:
  • Hashtable - Save Handle Of(Position of (Load (Key target) of (Key (Picked unit)) in Surge_Hash)) as (Key targetloc) of (Key (Picked unit)) in Surge_Hash


Also this is very inefficient as it destroys and creates new lightning effect every 0.05. Maybe you should try to use "Move Lightning"?

You maybe should use booleans instead of calculating each stage? So when the duration is set you check an if "your calc" + "your boolean == false" and if so you set the boolean to true.
 

Tawnttoo

New Member
Reaction score
36
I tried and failed. I use booleans to check whether they are created or not. For some reason the booleans are never set to true
 

Tawnttoo

New Member
Reaction score
36
bump

EDIT: Dag nabbit, I set them to another hashtable I didn't use in the map -- now it works like a charm. I don't know, maybe destroying the effects all the time made it off-sync or something. Thanks, baassee, and +rep for your efforts.

EDIT 2: Can't give rep again, but you have my thanks :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top