# Need help in my spell

Discussion in 'World Editor Help Zone' started by makeranj, Nov 21, 2016.

1. ### makeranj

Joined:
Aug 29, 2016
Messages:
56
Resources:
0
Resources:
0
Hello, so i decided to create a spell like this, this is my first time making think kind of spell.

So the problem is, i can't remove a lightning effect.I used point with polar offset to create the lightning effect, is there any other way i can remove it?

My Spell
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Soul_Shock
Actions
Wait 0.01 seconds
Set Caster = (Triggering unit)
Set Cas_Loc = (Position of Caster)
Set Damage[1] = (20.00 x (Real((Level of Soul_Shock for Caster))))
Set Damage[2] = (30.00 x (Real((Level of Soul_Shock for Caster))))
Set Damage[3] = (40.00 x (Real((Level of Soul_Shock for Caster))))
Set DmgType = Normal
Set AttkType = Spells
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Set EffectRange[1] = (Cas_Loc offset by Radius[1] towards ((Real((Integer A))) x 40.00) degrees)
Set EffectRange[2] = (Cas_Loc offset by Radius[2] towards ((Real((Integer A))) x 40.00) degrees)
Set EffectRange[3] = (Cas_Loc offset by Radius[3] towards ((Real((Integer A))) x 40.00) degrees)
Unit - Pause Caster
Special Effect - Create a special effect attached to the overhead of Caster using Summon
Set SpecialEff = (Last created special effect)
Trigger - Turn on Dmg <gen>
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Soul_Shock for Caster) Equal to 1
Then - Actions
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Then - Actions
Unit - Create 1 Peasant for (Owner of Caster) at (Cas_Loc offset by Radius[1] towards ((Real((Integer A))) x 40.00) degrees) facing Default building facing degrees
Set Dummy = (Last created unit)
Animation - Play Dummy's birth animation
Unit - Add a 7.60 second Generic expiration timer to Dummy
Lightning - Create a Chain Lightning - Primary lightning effect from source Cas_Loc to target (Cas_Loc offset by Radius[1] towards ((Real((Integer A))) x 40.00) degrees)
Lightning - Change color of (Last created lightning effect) to (1.00 1.00 0.00) with 1.00 alpha
Set LightEffct = (Last created lightning effect)
Else - Actions
Wait 7.00 seconds
Trigger - Turn off Dmg <gen>
Unit - Unpause Caster
Special Effect - Destroy SpecialEff
Animation - Play Dummy's death animation
Special Effect - Destroy SpecialEff
Custom script: call RemoveLocation( udg_Cas_Loc )
Lightning - Destroy LightEffct
Else - Actions

Since i don't know how to add that trigger picture thing, im gonna add this sorry for that.

2. ### Chaosy

Joined:
Jun 9, 2011
Messages:
10,693
Resources:
18
Maps:
1
Spells:
11
Tutorials:
6
Resources:
18
Use [trigger]code here[/trigger]
How to easily post triggers

As for your problem, there is only one way to remove a lightning effect. (in GUI)
I don't really get what you want to know, doesn't it work?

3. ### makeranj

Joined:
Aug 29, 2016
Messages:
56
Resources:
0
Resources:
0
removing lightning effects doenst work
Lightning is not removed

4. ### Chaosy

Joined:
Jun 9, 2011
Messages:
10,693
Resources:
18
Maps:
1
Spells:
11
Tutorials:
6
Resources:
18
Does it work if you remove the wait?

5. ### makeranj

Joined:
Aug 29, 2016
Messages:
56
Resources:
0
Resources:
0
No, it doesn't remove the lightning and also the dummy
I've tried using Countdown timer, also doesnt work

I guess removing lightning that was created on point with polar offset is hard,,
BUT i'll do some experimenting to see if it will remove the lightning.Btw , I was also thinking of creating a dummy with Life Drain Ability and make it cast on Dummy(I would also change the lighting effect but the catch is I can't Change the color of the lighting ) but not considering the catch, is it ok to do?

6. ### BloodSoul

Joined:
May 10, 2009
Messages:
767
Resources:
2
Spells:
2
Resources:
2
It's a little bit difficult to know what's inside or outside those For each (Integer A) loops.

• For each (Integer A) from 1 to 10, do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Then - Actions
• Unit - Create 1 Peasant for (Owner of Caster) at (Cas_Loc offset by Radius[1] towards ((Real((Integer A))) x 40.00) degrees) facing Default building facing degrees
• Set Dummy = (Last created unit)
• Animation - Play Dummy's birth animation
• Unit - Add a 7.60 second Generic expiration timer to Dummy
• Lightning - Create a Chain Lightning - Primary lightning effect from source Cas_Loc to target (Cas_Loc offset by Radius[1] towards ((Real((Integer A))) x 40.00) degrees)
• Lightning - Change color of (Last created lightning effect) to (1.00 1.00 0.00) with 1.00 alpha
• Set LightEffct = (Last created lightning effect)
• Else - Actions
• Wait 7.00 seconds
• Trigger - Turn off Dmg <gen>
• Unit - Unpause Caster
• Special Effect - Destroy SpecialEff
• Animation - Play Dummy's death animation
• Special Effect - Destroy SpecialEff
• Custom script: call RemoveLocation( udg_Cas_Loc )
• Lightning - Destroy LightEffct

Well, the problem is that you're creating 10 lightning effects, but you're registering one of them (the last one). That's why you can't remove all of them. Your variable must be an array one. Then you do this

• Set LightEfct[Integer A] = (Last created lightning effect)

In the end, you'll have to do another loop removing those lightning effects. However, keep in mind that your spell is not MUI, so if two units cast the spell at the same time, the first one that cast it won't have their lightning effects removed.

7. ### makeranj

Joined:
Aug 29, 2016
Messages:
56
Resources:
0
Resources:
0
I did not really understood how to remove those lightnings in a loop, can you do a sample trigger?

8. ### makeranj

Joined:
Aug 29, 2016
Messages:
56
Resources:
0
Resources:
0
Here's what he does, it damages enemies inside, You can see the lightning effect there.

File size:
174.1 KB
Views:
18

### Spell Reviewer

Joined:
Jan 18, 2005
Messages:
25,804
Resources:
3
Maps:
1
Spells:
2
Resources:
3
For every lightning effect that is created the lightning effect needs to be destroyed. This means that a reference to each lightning created needs to be stored in a variable for its duration so it can be referenced and destroyed after the duration ends.

As BloodSoul has pointed out, you are probably storing a reference to just 1 of the 10 created lightning effects.

10. ### makeranj

Joined:
Aug 29, 2016
Messages:
56
Resources:
0
Resources:
0
Blood heres the map

File size:
19.6 KB
Views:
26

### Spell Reviewer

Joined:
Jan 18, 2005
Messages:
25,804
Resources:
3
Maps:
1
Spells:
2
Resources:
3
Here you go...

File size:
19.5 KB
Views:
18
12. ### BloodSoul

Joined:
May 10, 2009
Messages:
767
Resources:
2
Spells:
2
Resources:
2
I ended up remaking it entirely. However, Dr. Super Good did that change and fixed the problem related to those lightning effects not being destroyed.

Anyway, I'll post it, because it's now MUI.

File size:
27.4 KB
Views:
17
13. ### makeranj

Joined:
Aug 29, 2016
Messages:
56
Resources:
0
Resources:
0
Thank you guys for your efforts, btw im thinking of uploading the spell and I'm gonna give credits to you guys.

EDIT: i will upload the MUI one, but i will use the other one on my map(im still gonna make it tho) cause there wont be the same heroes or spells used.To be fair.

14. ### BloodSoul

Joined:
May 10, 2009
Messages:
767
Resources:
2
Spells:
2
Resources:
2
Well, I didn't expect that...

In that case, here's some more improvements that would be nice to have in your spell:
-Change the spell to channeling "mode", so it would be possible to stop a caster with stuns or something like that. Right now, your spell only pauses casters, and they only stop when they die or finish casting it.
-Allow users to modify the lightning height for both caster and special effect side. For that, you have to change this function

• Lightning - Create a SS_Lightning_Type lightning effect from source tpoint[0] to target tpoint[1]

to this:
Code (vJASS):
AddLightningEx takes string codeName, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns lightning

Last edited: Nov 22, 2016

Joined:
Aug 29, 2016
Messages:
56
Resources:
0
Resources:
0

16. ### BloodSoul

Joined:
May 10, 2009
Messages:
767
Resources:
2
Spells:
2
Resources:
2
Not exactly, that's just JASS. You can use it as a custom script in a GUI trigger. It would be something like this:

• Custom script: set udg_SS__lightning[udg_int[2]] = AddLightningEx(udg_SS_Lightning_Type, false, GetLocationX(udg_tpoint[0]), GetLocationY(udg_tpoint[0]), GetLocationZ(udg_tpoint[0])+VAR_CasterHeight, GetLocationX(udg_tpoint[1]), GetLocationY(udg_tpoint[1]), GetLocationZ(udg_tpoint[1])+VAR_TombHeight)

However, I'll tell you to not do this anymore, because if you write around 256 characters in a custom script, that will crash your editor.

17. ### makeranj

Joined:
Aug 29, 2016
Messages:
56
Resources:
0
Resources:
0
so i would change it to jass so editor won't crash?

18. ### BloodSoul

Joined:
May 10, 2009
Messages:
767
Resources:
2
Spells:
2
Resources:
2
It's possible to reduce the name of those variables in order to avoid exceeding the limit: ss__lightning can be renamed to: ss_l; SS_Lightning_Type -> SS_LT; VAR_CasterHeight (well, this was an example) -> SS_CHgt; VAR_TombHeight -> SS_THgt.

You could also use temporary short-named variables to store the values of GetLocationZ(udg_tpoint[x]) + Height, which defines one side of your lightning's height, and then use them in that function. However, that will just complicate things a little bit more.

As for JASS, you won't even need to worry about it, its limit is around 2100 characters.

Last edited: Nov 23, 2016