Spell Force Lightning

duyen

New Member
Reaction score
214
Creates a lightning effect from the hero to a unit, then branches out to other units dealing damage.

GUI\JASS? GUI
Leakless? Yes
MUI? No :(
Import difficulty: VERY Low

This spell is EXTREMELY easy to change the following things:

Number of targets,
Lightning Type,
Levels of ability ( I only did one),
Lightning AoE
Unit # Struck


Code:
Force Lightning
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Force Lightning 
    Actions
        Set CasterPoint = (Position of (Triggering unit))
        Set TargetPoint = (Position of (Target unit of ability being cast))
        Set BranchAoE = 350.00
        Set BranchCount = 5
        For each (Integer A) from 1 to BranchCount, do (Actions)
            Loop - Actions
                Set BranchGroup = (Units within BranchAoE of TargetPoint matching ((((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True) and (((Matching unit) is alive) Equal to True)))
                Set BranchUnit = (Random unit from BranchGroup)
                Set BranchPoint = (Position of BranchUnit)
                Lightning - Create a Chain Lightning - Primary lightning effect from source TargetPoint to target BranchPoint
                Set Lightning[(Integer A)] = (Last created lightning effect)
                Unit - Cause (Triggering unit) to damage BranchUnit, dealing ((Real((Level of Force Lightning  for (Triggering unit)))) x 75.00) damage of attack type Spells and damage type Normal
                Custom script:   call DestroyGroup (udg_BranchGroup)
                Custom script:   call RemoveLocation (udg_BranchPoint)
        Wait 0.50 seconds
        For each (Integer A) from 1 to BranchCount, do (Custom script:   call DestroyLightning (udg_Lightning [bj_forLoopAIndex]))
        Custom script:   call RemoveLocation (udg_CasterPoint)
        Custom script:   call RemoveLocation (udg_TargetPoint)

forcelightningpicho8.png


+Rep if you like/use my spell please :D

UPDATED SPELL
 

Attachments

  • Force Lightning.w3x
    15 KB · Views: 636

elmstfreddie

The Finglonger
Reaction score
203
You can't bump dat soon!

Edit > nvm removed that looked at screeny nvm nvm


Okay yea I like this, and surprisingly it is MUI I think. It wouldn't be MUI if you added in a wait.
 

duyen

New Member
Reaction score
214
LOL, your right didn't have to add .50 second wait

EDIT: Nvm lightning effects don't show up if I didn't add a wait.

Is there a "Wait Command" in JASS that goes below .27 seconds?
 

elmstfreddie

The Finglonger
Reaction score
203
Uhh...
When you convert a GUI wait to a JASS wait they are the same thing (TriggerSleepAction(real)) but, I don't see what you mean by "below 0.27'. When I GUIed I used 0.01 waits all the time without fault...

Why the wait though it won't be MUI if you add a wait.

Oh, and, you might wanna add in the sound, because currently it's soundless?
 

duyen

New Member
Reaction score
214
Uhh...
When you convert a GUI wait to a JASS wait they are the same thing (TriggerSleepAction(real)) but, I don't see what you mean by "below 0.27'. When I GUIed I used 0.01 waits all the time without fault...

Why the wait though it won't be MUI if you add a wait.

Oh, and, you might wanna add in the sound, because currently it's soundless?

The GUI wait, when you set it below .27 it only waits .27 seconds no matter what it's set to, ask any admin. :cool:
Since it's based off Chain Lightning, it makes a sound.

Download before you judge :p
 

elmstfreddie

The Finglonger
Reaction score
203
If you add a wait however there will only be 1 sound, not multiple sounds (which it should since it branches)...
I know any mod/admin/etc say that about waits but I seriously have never had problems with 0.01 waits...
 

Tinki3

Special Member
Reaction score
418
The leaks, and the infamous code:

Unit Group - Pick every unit in (Random 1 units from (Units within 200.00 of TargetPoint))
-> Random 1 units from (<unit group>), leaks. Alternatively, and efficiently, you can set the unit group into a variable, without the 'random units' part, and use a unit variable to isolate the random unit from the group variable. You should also filter units that aren't dead, and that are enemies of the triggering unit (caster).

For ex:
Code:
Set BranchGroup = (Units within <BranchAoE> of TargetPoint matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)))
Set BranchUnit = (Random unit from BranchGroup)
[COLOR="Green"]//Do further actions below[/COLOR]

Set FL_Group = (Last created unit group)
Unit Group - Remove TargetUnit from FL_Group
-> Setting FL_Group won't save you from the leakage here. And you needed to place the custom script line that destroys the group inside the loop - actions. I'm quite sure that the "Pick every unit in (Random 1 units from.." leaks as soon as it's executed anyway. Fully remove the 'Set FL_Group" line.

"TargetUnit" is never set inside the trigger. Remove it, and the "Unit Group - Remove TargetUnit" line itself.

Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 100.00)

-> Setting the life of units doesn't give the caster of any spell credit for killing those affected units (ie, bounty, and possibly exp.). Use, "Unit - Damage Target", instead, as it does give credit for those such things, and also make the damage levelable.

For ex:
Code:
Unit - Cause (Triggering unit) to damage <BranchUnit>, dealing ((Real((Level of Force Lightning  for (Triggering unit)))) x 75.00) damage of attack type Spells and damage type Normal

Custom script: call DestroyLightning (udg_Lightning [1])
-> Lightning [2], [3], [4], and maybe even [5]. Yup, there is a "better" way to make the destroyal of the lighting easier. Simply set an integer variable to the amount of lightning branches, use that instead of the '3' that you have as the 'For each (Integer A) from 1 to..", at the moment, and use another loop to destroy all the lighting effects.

For ex:
Code:
Set BranchCount = 5
For each (Integer A) from 1 to BranchCount, do (Actions)
...
For each (Integer A) from 1 to BranchCount, do (Custom script:   call DestroyLightning (udg_Lightning [bj_forLoopAIndex]))
Simple, isn't it?
It'll destroy every lighting stored in the arrayed-variable via the loop, and if you wanted to edit the amount of lighting branches produced, all you have to do is change the "BranchCount" variable to the desired value. Then the loop takes care of all the leaks by using the BranchCount variable as a reference.


The Optimized Trigger:

I've created another few variables that make general editing a bit easier.
Leaks are all fixed.

Code:
Force Lightning Fixed
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Force Lightning 
    Actions
        Set CasterPoint = (Position of (Triggering unit))
        Set TargetPoint = (Position of (Target unit of ability being cast))
        Set BranchAoE = 500.00
        Set BranchCount = 5
        For each (Integer A) from 1 to BranchCount, do (Actions)
            Loop - Actions
                Set BranchGroup = (Units within BranchAoE of TargetPoint matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)))
                Set BranchUnit = (Random unit from BranchGroup)
                Set BranchPoint = (Position of BranchUnit)
                Lightning - Create a Chain Lightning - Primary lightning effect from source TargetPoint to target BranchPoint
                Set Lightning[(Integer A)] = (Last created lightning effect)
                Unit - Cause (Triggering unit) to damage BranchUnit, dealing ((Real((Level of Force Lightning  for (Triggering unit)))) x 75.00) damage of attack type Spells and damage type Normal
                Custom script:   call DestroyGroup (udg_BranchGroup)
                Custom script:   call RemoveLocation (udg_BranchPoint)
        Wait 0.60 seconds
        For each (Integer A) from 1 to BranchCount, do (Custom script:   call DestroyLightning (udg_Lightning [bj_forLoopAIndex]))
        Custom script:   call RemoveLocation (udg_CasterPoint)
        Custom script:   call RemoveLocation (udg_TargetPoint)
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
if i am not mistaken....u didnt remove BranchUnit from BranchGroup after damaging it...maybe this will cause double shock or even triple shock to the same unit...
 

Tinki3

Special Member
Reaction score
418
Good fixing.
One last thing though:

Set BranchGroup = (Units within BranchAoE of TargetPoint matching ((((Matching unit) belongs to an enemy of Player 1 (Red)) Equal to True) and (((Matching unit) is alive) Equal to True)))
-> What if Player 2 (Blue) were to use the spell? This is inaccurate as is. Change underlined-text to: (Owner of (Triggering unit))). That'll take care of any player that wants to use the spell.

You also need to include a player-unit restoration trigger, and a hero revival trigger in your test map.
Or you could always import everything into the STMT (see my sig below).
 

duyen

New Member
Reaction score
214
if i am not mistaken....u didnt remove BranchUnit from BranchGroup after damaging it...maybe this will cause double shock or even triple shock to the same unit...

How do you know that wasn't intended.
 

ironfist19

New Member
Reaction score
3
Uhmm, nice job. +rep Can i have a request?
Can you do this? Ex. Hero casts chain lightning then the forked lightning that strikes the other can knockback?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top