@b0ne123: Go
If you change the buff effect from final to initial, then it will break the chain if the unit dies, that's why it's set as final to ensure the chain doesn't break, if you want it to happen instantly, then just set the duration to something like 0.001.
No there has to be at least two targets, unless you remove the values in Search - Exclude. If you remove that it would probably do all the damage to one target, if there is only one.
I've seen a lot of ways to make chain lightning, one which consists of creating a lot of bounce effects per number of chains to archive, but imo this is a terrible way of doing this, since you most likely will end up with a lot of effects in your data editor and things can get really complicated if you want some long chains, so i decided to try it out in my own way, using recursive effects with a stop validator which doesn't take up a lot of space in your data editor. This way you can also easily and dynamically change the length of your chain if you later on decided that you should be able to make your chain longer by levelling your chain lightning ability. One thing however which this is not so good for (or at least i haven't found an easy way of doing it) is if you want your bounces to do different things like different damage on impact, or if you want your chain to end with some other effect like a blast effect or something like that.
I will try in this picture to explain the way it works:
The reason for the Chain Lightning Count buff is a trick to keep a count on how many bounces your chain have, each time the Chain Lightning (Set) effect gets called the behavior Chain Lightning Count stacks up by one. This also means that you will have to remove the buffs each time you cast it, or else you will only be able to cast it once, furthermore it also means your ability should have a cooldown which is greater than the time it takes to iterate through the chain, or else you would be able to make the chain go on infinitely (since no stop criteria would exist, since it would have been removed). I guess this also means that the caster has to be kept alive while iterating through the chain, but i haven't seen any example of this, so i am not sure, maybe some of you can clarify this.
The way it is constructed is by using the TSRandom sorter, which means it doesn’t necessarily skip targets it has already visited, but it will try its best not to, that way the chain wil not beak at the fourth bounce although it was six long because it has no other targets to visit, an example of this is included in the linked video down at the bottom (look at the first time the ability is used, where it circles around three targets until it has reached its length.
Well enough chit-chat, let’s get to the point!
I assume you have already created a unit and ability to be the starting point of the spell and set the range and whatnot, if not, create an ability of the type Effect - Target and tie it to your unit with a button, you could probably also tie it to a weapon if you prefer, or if you are completely lost, just read the first part of the Extra section down at the buttom.
First, go to the Effects tab, and create these effects (we will come back to them later on, right now we just need to create them to be able to point to them):
Ok, now we have created what we need for the first part, time to put it together
While at the Behaviors tab, do this for Chain Lightning (Buff):
Set Behavior - Alignment to Negative
Set Effect - Effect - Final to Chain Lightning (Search)
Set Duration to 0.2
Now go back to the Effects tab
Do the following for Chain Lightning (Apply Behavior):
Set Behavior - Behavior to Chain Lightning (Buff)
Do the following for Chain Lightning (Damage):
Set Combat - Amount to 10 (doesn’t really matter much, but don’t set it too high while testing)
Set Effect - Death to Electrocute
Under Target - Marker, set Count to 1, and set id in Match Flags to Enabled
Do the following for Chain Lightning (Search):
Under Search - Areas, add a new entity in Areas, and set Arc to 360, Effect to Chain Lightning (Set), Maximum Count to 1, and Radius to 10 (you can use something lower, but for testing purposes just keep it high)
Under Search - Exclude, add Source and Target to Exclude
Under Search - Search Filters, set Buried, Cloaked, Dead, Hidden, Invulnerable, Item, self, Structure, Resource (Harvestable), Resource(Raw) to Excluded, and set Visible to Required, also uncheck Ally and Player.
Under Target - Target Sorts, add TSRandom to Sorts, and set Request Count to 0
Do the following for Chain Lightning (Set):
Under Effect - Effects, add Chain Lightning (Apply Behavior) and Chain Lightning (Damage), in that order (or else your chain´s animations will look a bit weird if the target unit dies from the strike)
Now go to your ability you use to call the effect from:
Set Effect - Effect to Chain Lightning (Set)
Alright, that was first step, time to test it. If you have done it right, what you should be able to see if you cast it on a unit, is that specific unit taking damage, passing it on to the next unit, which takes damage, which passes it on to the next infinitely. Because we are using markers when a unit takes damage (or gets the behavior applied to it), the search function in Chain Lightning (Search) will try the best it can to not hit a unit which has been hit already, but it is not guaranteed, which means the chain doesn't break just because it cannot find a target, but tries the best it can to even out the chain.
Now, time for step two.
Go to the Models tab, and make this Model:
Name: Chain Lightning Beam
ID: ChainLightningBeam
Model Type: Generic
Based On: PersistentSpellFX
Set Model to Assets\Effects\Protoss\ArchonBeam\ArchonBeam.m3 (or whatever you like)
Go to the Actors tab, and create these Actors:
Name: Chain Lightning Suffix: (Beam)
ID: ChainLightningBeam
Actor Type: Beam (Simple)
Based On: Beam Simple Animation Style One Shot
Set Art - Model to Chain Lightning Beam
Name: Chain Lightning Suffix: (Action)
ID: ChainLightningAction
Actor Type: Action
Based On: GenericAttack
Set Beam to ChainLightningBeam (Choose it under the radio button Actor)
Under Event - Events, Add a new Event with Msg Type Effect, Source Name Chain Lightning (Damage) and Sub Name Start. Then select the node which points to your newly created event (it’s most likely called ActionImpact), and set its Msg Type to Create.
If you test the map now, you should be able to see the actual chain lightning in effect and see it bounce between all the targets in a random pattern. Only thing left now, is to make a counter which will count the number of bounces the chain has made, which is a little tricky, and i will be very happy if you can tell me a better way of doing it, since there is certain complications to the way i do it. Anyway here goes:
Go to the Behaviors tab, and create a new Behavior:
Set Validator - Behavior to Chain Lightning Count (Buff)
Set Validator - Compare to Less Then
Set Validator - Value to 10 (or how long you want your chain)
Set Validator - Unit to Caster
Now go back to the Effects tab, and choose Chain Lightning (Set):
Add Chain Lightning Count (Behavior Count) to Effect - Validators
If you test it now, your chain will only be 10 long, but you will be unable to cast your chain lightning twice, since the counter hasn’t been reset, which is what is next in line:
Assuming you are still in the Effects tab, create these two Effects:
Under Effect - Effects add Chain Lightning Reset Count (Remove Behavior) and then Chain Lightning (Set) in that order
Now go back to your ability from which you call the Chain Lightning (Set) from, and change it so it calls Chain Lightning Start (Set) instead, don’t forget to set some kind of cooldown on your ability.
Extra
I will here list some of the small details which you would probably need to do anyway.
First up, for those of you who don’t know how to set up the ability your unit should cast, read on.
I will be using the unit Archon.
Start by going to the Abilities tab, and create a new Ability:
Under Cost - Cost, add a new Cost, and set Time Use to 10
Set Effect - Effect to Chain Lightning Start (Set)
Set Stats - Cast Start Finish to 1
Set Stats - Range to 10
Now we just need to link the ability to the units list of abilities and add a button to the command card which calls the ability. Let's start by making our own button:
Go to the Buttons tab, and add a new Button:
Name: Chain Lightning
ID: ChainLightning
Now fill in the tooltip and set a hotkey and icon
Next, go to the Units tab, and select Archon:
Under Ability - Abilities, add the ability Chain Lightning
Under Ability - Command Card, press a square where you want your button to be located, and press the add icon. Choose your newly created button, and set Command Type to Ability Command, and then set Ability to Chain Lightning, leave Ability Command empty.
That was it, now what i like to do is make the unit animate, so it displays the cast animation while using the ability:
Now go to the Actors tab, and select Archon:
Under Event - Events, add a new Event with Msg Type Ability, Source Name (Any) and Sub Name Source Channel Start. set the node to Animation Play, and set Properties to Attack
@b0ne123: Go If you change the buff effect from final to initial, then it will break the chain if the unit dies, that's why it's set as final to ensure the chain doesn't break, if you want it to happen instantly, then just set the duration to something like 0.001.
Also, you need to put the validator on the Set.
@b0ne123: Go
No there has to be at least two targets, unless you remove the values in Search - Exclude. If you remove that it would probably do all the damage to one target, if there is only one.
Hello there.
I've seen a lot of ways to make chain lightning, one which consists of creating a lot of bounce effects per number of chains to archive, but imo this is a terrible way of doing this, since you most likely will end up with a lot of effects in your data editor and things can get really complicated if you want some long chains, so i decided to try it out in my own way, using recursive effects with a stop validator which doesn't take up a lot of space in your data editor. This way you can also easily and dynamically change the length of your chain if you later on decided that you should be able to make your chain longer by levelling your chain lightning ability. One thing however which this is not so good for (or at least i haven't found an easy way of doing it) is if you want your bounces to do different things like different damage on impact, or if you want your chain to end with some other effect like a blast effect or something like that.
I will try in this picture to explain the way it works:
The reason for the Chain Lightning Count buff is a trick to keep a count on how many bounces your chain have, each time the Chain Lightning (Set) effect gets called the behavior Chain Lightning Count stacks up by one. This also means that you will have to remove the buffs each time you cast it, or else you will only be able to cast it once, furthermore it also means your ability should have a cooldown which is greater than the time it takes to iterate through the chain, or else you would be able to make the chain go on infinitely (since no stop criteria would exist, since it would have been removed). I guess this also means that the caster has to be kept alive while iterating through the chain, but i haven't seen any example of this, so i am not sure, maybe some of you can clarify this. The way it is constructed is by using the TSRandom sorter, which means it doesn’t necessarily skip targets it has already visited, but it will try its best not to, that way the chain wil not beak at the fourth bounce although it was six long because it has no other targets to visit, an example of this is included in the linked video down at the bottom (look at the first time the ability is used, where it circles around three targets until it has reached its length.
Well enough chit-chat, let’s get to the point!
I assume you have already created a unit and ability to be the starting point of the spell and set the range and whatnot, if not, create an ability of the type Effect - Target and tie it to your unit with a button, you could probably also tie it to a weapon if you prefer, or if you are completely lost, just read the first part of the Extra section down at the buttom.
First, go to the Effects tab, and create these effects (we will come back to them later on, right now we just need to create them to be able to point to them):
Then go to the Behavior tab:
Ok, now we have created what we need for the first part, time to put it together
While at the Behaviors tab, do this for Chain Lightning (Buff):
Now go back to the Effects tab
Do the following for Chain Lightning (Apply Behavior):
Do the following for Chain Lightning (Damage):
Do the following for Chain Lightning (Search):
Do the following for Chain Lightning (Set):
Now go to your ability you use to call the effect from:
Alright, that was first step, time to test it. If you have done it right, what you should be able to see if you cast it on a unit, is that specific unit taking damage, passing it on to the next unit, which takes damage, which passes it on to the next infinitely. Because we are using markers when a unit takes damage (or gets the behavior applied to it), the search function in Chain Lightning (Search) will try the best it can to not hit a unit which has been hit already, but it is not guaranteed, which means the chain doesn't break just because it cannot find a target, but tries the best it can to even out the chain.
Now, time for step two.
Go to the Models tab, and make this Model:
Go to the Actors tab, and create these Actors:
If you test the map now, you should be able to see the actual chain lightning in effect and see it bounce between all the targets in a random pattern. Only thing left now, is to make a counter which will count the number of bounces the chain has made, which is a little tricky, and i will be very happy if you can tell me a better way of doing it, since there is certain complications to the way i do it. Anyway here goes:
Go to the Behaviors tab, and create a new Behavior:
Next go to Effects, and create this Effect:
Now choose Chain Lightning (Set):
Now go to Validators, and create a new Validator:
Now go back to the Effects tab, and choose Chain Lightning (Set):
If you test it now, your chain will only be 10 long, but you will be unable to cast your chain lightning twice, since the counter hasn’t been reset, which is what is next in line:
Assuming you are still in the Effects tab, create these two Effects:
Now go back to your ability from which you call the Chain Lightning (Set) from, and change it so it calls Chain Lightning Start (Set) instead, don’t forget to set some kind of cooldown on your ability.
Extra
I will here list some of the small details which you would probably need to do anyway.
First up, for those of you who don’t know how to set up the ability your unit should cast, read on.
I will be using the unit Archon.
Start by going to the Abilities tab, and create a new Ability:
Now we just need to link the ability to the units list of abilities and add a button to the command card which calls the ability. Let's start by making our own button:
Go to the Buttons tab, and add a new Button:
Now fill in the tooltip and set a hotkey and icon
Next, go to the Units tab, and select Archon:
That was it, now what i like to do is make the unit animate, so it displays the cast animation while using the ability:
Now go to the Actors tab, and select Archon:
And that’s it, enjoy!