# Forked Lightning combined with Chain Lightning

Status
Not open for further replies.

#### Inaltu

Level 2
Im workin on a spell that looks like Forked Lightning at first but hten all of the sudden the lightnings go on to other units and dmg them too Basicly Ive made a Chain Ligtning spell that has the Forked Lightning lightning effect and made dummys that cast that spell 3-5 times on different units.

The tricky thing is , i want to make it look 100% credible so i have to make the dummys cast the spell on different units (so no double Chain Lightninging the same unit), and make sure the targets are in front of the direction the real caster is facing, and not behind. To do this i think i have to somehow check if the angle between the facing direction of the caster and the angle between the pos of the caster and pos of the target of the dummy is <=90 degrees. I know this sounds wiedr i probably didnt explain it well but i hope its understandable. The problem is lets say one of the angels is 350 and the other is 10 then 350-10=340 wich is far greater than 90, but actually the angle is only 20 degrees ...

Any ideeas on solving this problem ?

#### Captain Griffen

Level 14
JASS:
function Within90Degrees takes real a1, real a2 returns boolean //in DEGREES
return (a2 < a1 + 90 and a2 > a1 - 90) or (a1 < 90. and a2 < a1 + 450. and a2 > a1 + 270.) or (a1 > 360. and a2 < a1 - 270. and a2 > a1 - 450.)
endfunction

SHOULD work, I think, but I haven't tested it.

#### Inaltu

Level 2
thats exactly the problem i dont use jass -- didnt get to learn it yet, but i know some c++ and those knowledges make me presume it should be easy with jass --- but i was looking for a solution with triggers

So i make this more understandable i drew this. The red circle is the caster and the other 6 black ones are enemies. If you think about FL u know it would only cast on units I II and III, and not on IV V and VI. The angle wich has to be smaller than 90 degrees is the one between the red arrow wich is indicating the direction wich the caster is facing and the black line connecting the pos on the caster and the pos of unit III.

#### Attachments

• Angle.JPG
11.3 KB · Views: 226

#### Captain Griffen

Level 14
Learn JASS. Really, maths in GUI is EVIL.

#### Inaltu

Level 2
=)) dont worry i did fine - its like a challenge knowing u have to solve a problem like that . The thing was i needed a condition like this : d>=270 or (d <= 90 and d>=-90) or d<=-270 , where each d is angle between points minus caster facing angle. Hell of a condition but it works very cool

Level 19
vexorian has one

#### Xesirin

Level 4
Create a unit array for the spell and add units to it as they get hit. Delete the array when the spell has finished.

Personally I do everything in GUI myself, (except patching up leaks) so my opinion is that such a system oughtn't to be very difficult to implement.

Just one question though: do multiple units get this spell, or just one per game? That might be relevant. If it is multiple, you'll need to use Jass to do it.

#### PurplePoot

Level 40
If you don't particularly care about efficiency, since I suspect this is rather slow, there's a really clean (as in simple to input into GUI) way to check the angle between two angles:

Acos(cos(angle1-angle2)

Status
Not open for further replies.

Replies
5
Views
648
[Trigger] Forked spell
Replies
19
Views
958
Replies
7
Views
731
Replies
2
Views
975
Replies
6
Views
2K