Spell Chain Lightning

Flare

Stops copies me!
Reaction score
662
A fully triggered chain lightning spell (absolutely everything that I can think of is customizable :D)

Huge thanks to Vypur85 for helping me to fix the spell :) (he saved this spell from the scrap-heap :p)

Technical Details:
LIST OF CONFIGURABLE PROPERTIES: (this is all I can think of at the moment)
Amount of bounces
Time between bounces
AoE for potential bounce targets
Repeat/Don't repeat same unit
Damage
Damage reduction per bounce
Lightning duration
Lightning fade speed
Lightning's colour
Alternating lightning/special effects
Different (damage) effect on each bounce (e.g. mana burn, then life drain, then shackles ETC)
If you can link me to a Chain Lightning spell that's equally/more customizable than this, I'll give you a cookie!

GUI/JASS? GUI

MUI/MPI: MUI, 1000 cast instances and 1000 lightning instances (lightning lasts for 0.6 seconds, so try and get 1000 instances in that time...)

Leaks: I don't think so

Laggy: Unless lightning effects can screw you over, no.

How to import:
-Copy the custom Chain Lightning base skill into your map
-In File -> Preferences, make sure that 'Automatically create unknown variables when pasting trigger data' is checked.

-Copy the 'Lightning cast' and 'Lightning bounce and decay' into your map
*If using the alternating lightning version, copy the Set lightningtype and Set sfxstring actions into your Map Initialization trigger, so you have a default value for your varying lightning effects and corresponding zap effects.

-Add the ability to your hero

-Test it out and hope it works

-Give me credit and cookies!

SCREENSHOT (it's difficult to get a picture of this)

CODE: (have fun reading through all this :p)
Code:
Lightning cast
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Chain Lightning 
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                customvalue1 Less than 1000
            Then - Actions
                Set customvalue1 = (customvalue1 + 1)
            Else - Actions
                Set customvalue1 = 1
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                customvalue2 Less than 1000
            Then - Actions
                Set customvalue2 = (customvalue2 + 1)
            Else - Actions
                Set customvalue2 = 1
        Set caster[customvalue1] = (Triggering unit)
        Set oldtarget[customvalue1] = (Triggering unit)
        Set target[customvalue1] = (Target unit of ability being cast)
        Set currentbounce[customvalue1] = 0
        Set maxbounce[customvalue1] = 10
        Set damage[customvalue1] = 100.00
        Set lightningunita[customvalue2] = (Triggering unit)
        Set lightningunitb[customvalue2] = (Target unit of ability being cast)
        Set temppoint = (Center of (Playable map area))
        Set lightningmaxdur[customvalue2] = 0.60
        Set lightningfade[customvalue2] = 1.00
        Set lightningcurrentdur[customvalue2] = 0.00
        Set pointa = (Position of caster[customvalue1])
        Set pointb = (Position of target[customvalue1])
        Set timebetweenbounce[customvalue1] = (0.75 - (0.15 x (Real((Level of Chain Lightning  for caster[customvalue1])))))
        Set bouncearea[tempinteger1] = (200.00 x (Real((Level of Chain Lightning  for caster[customvalue1]))))
        Unit Group - Add target[customvalue1] to previoustargets[customvalue1]
        Lightning - Create a Chain Lightning - Primary lightning effect from source pointa to target pointb
        Set lightning[customvalue2] = (Last created lightning effect)
        Custom script:   call RemoveLocation (udg_pointa)
        Custom script:   call RemoveLocation (udg_pointb)
        Unit - Create 1 Dummy Unit for (Owner of caster[customvalue1]) at temppoint facing Default building facing degrees
        Unit - Set the custom value of (Last created unit) to customvalue1
        Unit Group - Add (Last created unit) to dummygroup
        Unit - Create 1 Dummy Unit for (Owner of caster[customvalue1]) at temppoint facing Default building facing degrees
        Unit - Set the custom value of (Last created unit) to customvalue2
        Unit Group - Add (Last created unit) to lightninggroup2
        Custom script:   call RemoveLocation (udg_temppoint)
        Unit - Cause caster[customvalue1] to damage target[customvalue1], dealing damage[customvalue1] damage of attack type Spells and damage type Normal



--------------------------------------------------------------


Lightning bounce and decay
    Events
        Time - Every 0.05 seconds of game time
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Number of units in dummygroup) Greater than 0
                (Number of units in lightninggroup2) Greater than 0
    Actions
        Unit Group - Pick every unit in dummygroup and do (Actions)
            Loop - Actions
                Set tempinteger1 = (Custom value of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        currentbounce[tempinteger1] Less than maxbounce[tempinteger1]
                    Then - Actions
                        Set bouncetime[tempinteger1] = (bouncetime[tempinteger1] + 0.05)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                bouncetime[tempinteger1] Greater than or equal to timebetweenbounce[tempinteger1]
                            Then - Actions
                                Set bouncetime[tempinteger1] = 0.00
                                Set oldtarget[tempinteger1] = target[tempinteger1]
                                Set temppoint = (Position of oldtarget[tempinteger1])
                                Set nearbytargets = (Units within 600.00 of temppoint matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is alive) Equal to True)) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True)))
                                Custom script:   call RemoveLocation (udg_temppoint)
                                Unit Group - Remove all units of previoustargets[tempinteger1] from nearbytargets
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Number of units in nearbytargets) Greater than 0
                                    Then - Actions
                                        Set currentbounce[tempinteger1] = (currentbounce[tempinteger1] + 1)
                                        Set damagedecay[tempinteger1] = (damage[tempinteger1] x 0.10)
                                        Set damage[tempinteger1] = (damage[tempinteger1] - damagedecay[tempinteger1])
                                        Set target[tempinteger1] = (Random unit from nearbytargets)
                                        Set temppoint = (Center of (Playable map area))
                                        Unit Group - Add target[tempinteger1] to previoustargets[tempinteger1]
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                customvalue2 Less than 1000
                                            Then - Actions
                                                Set customvalue2 = (customvalue2 + 1)
                                            Else - Actions
                                                Set customvalue2 = 1
                                        Unit - Cause caster[customvalue1] to damage target[customvalue1], dealing damage[customvalue1] damage of attack type Spells and damage type Normal
                                        -------- NONE OF THIS IS WORKING --------
                                        Unit - Create 1 Dummy Unit for (Owner of caster[tempinteger1]) at temppoint facing Default building facing degrees
                                        Set TEMPUNIT = (Last created unit)
                                        Unit - Set the custom value of TEMPUNIT to customvalue2
                                        Unit Group - Add TEMPUNIT to lightninggroup2
                                        -------- ANYTHING BETWEEN THESE COMMENTS = BROKEN --------
                                        Set lightningunita[customvalue2] = oldtarget[tempinteger1]
                                        Set lightningunitb[customvalue2] = target[tempinteger1]
                                        Set pointa = (Position of lightningunita[customvalue2])
                                        Set pointb = (Position of lightningunitb[customvalue2])
                                        Lightning - Create a Chain Lightning - Primary lightning effect from source pointa to target pointb
                                        Set lightning[customvalue2] = (Last created lightning effect)
                                        -------- THIS ALLOWS YOU TO ALTER THE MAX DURATION OF THE LIGHTNING. --------
                                        Set lightningmaxdur[customvalue2] = 0.60
                                        -------- THIS ALLOWS YOU TO ALTER THE FADING RATE OF LIGHTNING --------
                                        Set lightningfade[customvalue2] = 1.00
                                        Set lightningcurrentdur[customvalue2] = 0.00
                                        Custom script:   call RemoveLocation (udg_pointa)
                                        Custom script:   call RemoveLocation (udg_pointb)
                                        Custom script:   call RemoveLocation (udg_temppoint)
                                    Else - Actions
                                        Set currentbounce[tempinteger1] = 0
                                        Unit Group - Remove all units of previoustargets[tempinteger1] from previoustargets[tempinteger1]
                                        Unit Group - Remove all units of previoustargets[tempinteger1] from previoustargets[tempinteger1]
                                        Unit - Remove (Picked unit) from the game
                            Else - Actions
                    Else - Actions
                        Set currentbounce[tempinteger1] = 0
                        Unit Group - Remove all units of previoustargets[tempinteger1] from previoustargets[tempinteger1]
                        Unit Group - Remove all units of previoustargets[tempinteger1] from previoustargets[tempinteger1]
                        Unit - Remove (Picked unit) from the game
        Unit Group - Pick every unit in lightninggroup2 and do (Actions)
            Loop - Actions
                Set tempinteger2 = (Custom value of (Picked unit))
                Set pointa = (Position of lightningunita[tempinteger2])
                Set pointb = (Position of lightningunitb[tempinteger2])
                Lightning - Move lightning[tempinteger2] to source pointa and target pointb
                Set lightningcurrentdur[tempinteger2] = (lightningcurrentdur[tempinteger2] + 0.05)
                Set lightningfade[tempinteger2] = (lightningfade[tempinteger2] - 0.08)
                Lightning - Change color of (Last created lightning effect) to (1.00 1.00 1.00) with lightningfade[tempinteger2] alpha
                Custom script:   call RemoveLocation (udg_pointa)
                Custom script:   call RemoveLocation (udg_pointb)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        lightningcurrentdur[tempinteger2] Equal to lightningmaxdur[tempinteger2]
                    Then - Actions
                        Lightning - Destroy lightning[tempinteger2]
                        Set lightningcurrentdur[tempinteger2] = 0.00
                        Set lightningfade[tempinteger2] = 1.00
                        Unit - Remove (Picked unit) from the game
                    Else - Actions

If you find any bugs with the spell, let me know

If you use this spell, give me credits (and to vypur85, if he wants credit, for helping me to get the spell to work)


Thanks to Draphoelix for (accidently?) inspiring me to make this :)

Some info about customizing the second one (that uses alternate lightning, special effect on target and bounce on closest target)
Code:
If you are using the second version (for closest target bounce, and zappy effects), but want to keep the lightning effect consistent, do the following:

-Go to the Map Init trigger, and find the Set lightningtype and Set sfxstring actions. Set the value for both arrays to the same lightning type, and the same SFX string i.e.

Set lightningtype[0] = Chain Lightning - Primary
Set lightningtype[1] = Chain Lightning - Primary

Set sfxstring[0] = (your special effect's model path)
Set sfxstring[1] = (same model path as sfxstring[0])

It'll save the trouble of trying to dig through the main spell code and alter the lightning stuff from there, since editting 4 lines that are side-by-side is much easier than searching through triggers for 4 lines of code that are scattered.

UPDATES:
Code:
Update 1: Added the lightning effect when a unit is hit
Update 2: Added a second demo map. This demo map uses alternating lightning/special effects, and it bounces to the nearest target when bouncing.
 

Attachments

  • Chain Lightning SFX added.w3x
    24.9 KB · Views: 271
  • Chain Lightning alternate.w3x
    25.3 KB · Views: 251

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Is this the chain lightning you started to work on months ago? :D

It looks nice in game, I like how the lightnings fade out. Though I can hardly see why you want to spend so much time editing this when you can use the regular one.

Edit: IMO you should attach some lightning effect to the chest of each unit hit so that it looks like they are getting shocked by it too.

Edit 2: You also forgot to remove your "THIS IS BROKEN..." comments inside your trigger.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
I wonder why can't I view your screenshot.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Sounds like a plan. Anyway this can also be used if you want to make a chain lightning that can bounce at the same target multiple times, and also for bouncing a lot of times. so I guess this really is useful.
 

vypur85

Hibernate
Reaction score
803
>If you use this spell, give me credits (and to vypur85, if he wants credit, for helping me to get the spell to work)

Lol... Not necessary.

Damn it, I've just created a chain lightning spell for my map too = =. Just 2 days ago (but MPI). What a coincidence.

Though I can hardly see why you want to spend so much time editing this when you can use the regular one.
I believe it's more flexible as you can easily create another dummy to stun, slow or whatever you want to the picked unit. So it can become a chain stun lightning or slow chain lightning or mana burn chain lightning. :)
 

Flare

Stops copies me!
Reaction score
662
@Larcenist: yes, its the chain lightning spell i was working on months ago, and i think it would be a shame to abandon the spell. and as vypur said, its much more flexible. daelin's Chain spell tutorial may be easier for making chain lightning, but it doesnt have the customizability that this has (from what i remember, his demo spell hit everyone simultaneously, but im not sure)

Oops about forgetting to remove those comments ^^

@Gals: screeny fixed, I used the wrong URL given by imageshack

@ziggy: exactly ^^

@vypur: exactly again :p

@larcenist again: currently, its set up to not repeat a target, which keeps it similar to chain lightning and the ability to increase the bounce count above that of normal chain lightning spell is another great bonus :)
 

Slapshot136

Divide et impera
Reaction score
471
ty, ive also been trying 2 do something like this, but i dont think there is a bounce limit on the normal chain lightning (except that you cant recast while it is still bouncing)
 

darkRae

Ueki Fan (Ueki is watching you)
Reaction score
173
Note in the Configurable Properties :

>Time between bounces
>Delay between each bounce

Aren't they the same?
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
ty, ive also been trying 2 do something like this, but i dont think there is a bounce limit on the normal chain lightning (except that you cant recast while it is still bouncing)

If you push your normal Chain Lightning to the limit, it will probably result in a crash.
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
I think Chain Lightning will bounce from a unit to another nearest unit, not random. Healing Wave will bounce randomly
 

Flare

Stops copies me!
Reaction score
662
I think Chain Lightning will bounce from a unit to another nearest unit, not random. Healing Wave will bounce randomly

It bounces to the nearest unit?!?! Ah f*** that, that's just too much trouble to go to just to make it a perfect replica ^^

If this poll gets set up, and enough people vote Yes, I will alter the trigger so it bounces to nearest unit rather than a random unit.


UPDATE: Added a new demo map, read the updates section in main post for more info.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Okay I'mma use this one. I take back any negative comments ever said about this. Though I'll probably make it so that it can bounce on the same unit multiple times.

Still can't +rep you so credits will have to do for now.
 

Flare

Stops copies me!
Reaction score
662
Beware: The second map will require a nice bit of altering to get it to bounce on same target. If you remove the (Remove Units from Unit Group) bit, it'll continuously bounce on the same target since that unit will always be closest (distance-wise) to himself :S

Just so you know, and don't screw up and come running back to me saying "OMG UR SPELL BROKED" or something equally stupid ^^

Oh, silly me. You could just add an extra condition to the UG, saying that matching unit =/= oldtarget[tempinteger1] (and remove the Remove Units from Unit Group action as well). It -SHOULD- work the way you want then, not 100% sure though
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Oh wells I like the first one more, since it's a little bit more random. Also I think I can pull of a simple thing as making it not bounce on the same unit all the time.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
IMO this one has got everything it needs, and it's like really really easy to customize too.
 
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