# Defining a cone area.

#### Geshishouhu

Level 11
Hi all, I want to make a cone area spell, just like breath of fire, but I cannot define a cone area to damage the units inside it. Any help, thanks.

Level 36
You can make an increasingly large circle area...

like circle1 has radius of 100, then put circle2 in front of it and use radius of 200 for example and so on...

or there might be scripts for that already

#### Geshishouhu

Level 11
You can make an increasingly large circle area...

like circle1 has radius of 100, then put circle2 in front of it and use radius of 200 for example and so on...

or there might be scripts for that already

But thats a circle, right? I need a cone shape. :/

Level 36
You put it up in front of each other... the end result will be a cone... the sides might not be as straight as a normal cone viewed on 2D, unless you use too many circles though

unless you need the cone in 3D (meaning you include flying height in calculations)...

or you can use thin rects too...

Rects might yield more accurate results but circles will be easier to use since you will use the same definition no matter what direction the cone will go... while if you use rects, the angles will change how you make the rect... you might not even be able to make diagonal rects, in which case, you can only use rects to make the cones if you are facing 0,90,180,270 degrees...

#### Geshishouhu

Level 11

Level 36
that method is well, faster and better unless you don't understand how it goes...

basically you just have 1 circle, pick every unit around it, then check the angle between the tip and the unit, if it's within the angle of the cone, then the unit is inside the cone

IDK if I can explain it in a simpler manner...

#### Geshishouhu

Level 11
that method is well, faster and better unless you don't understand how it goes...

basically you just have 1 circle, pick every unit around it, then check the angle between the tip and the unit, if it's within the angle of the cone, then the unit is inside the cone

IDK if I can explain it in a simpler manner...

Thanks for still being here,
I get this part, just don't know how to get the angles in jass

Level 36
AngleBetweenPoints I think will be what you'll use

or wait... Atan2(x2-x1,y2-y1)

try Atan2(X of tip - X of unit, Y of tip - Y of unit)

then get absolute value... maybe using ((Value^2)^0.5)

then check the angle... I forgot if Atan2 returns degrees or radians

#### Geshishouhu

Level 11
AngleBetweenPoints I think will be what you'll use

or wait... Atan2(x2-x1,y2-y1)

I will try that again. +Rep

#### chobibo

Level 22

Level 36
take note though that this is for instant/static cones... if you need it dynamic (like increasing cone), then you will be doing it for a couple of times... starting from using a smaller radius, and increasing it... while keeping the tip position the same...

#### Geshishouhu

Level 11
take note though that this is for instant/static cones... if you need it dynamic (like increasing cone), then you will be doing it for a couple of times... starting from using a smaller radius, and increasing it... while keeping the tip position the same...

Ok, notes taken. Thanks.

Edit: failed actually, maybe I have done something wrong,..... :/

#### Chaosy

Tutorial Reviewer
Level 40
I dont think you can make it more simple than this
• Melee Initialization
• Events
• Map initialization
• Conditions
• Actions
• Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
• Set u = (Last created unit)
• Unit Group - Pick every unit in (Units within 250.00 of (Position of u)) and do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Angle from (Position of u) to (Position of (Picked unit))) Less than or equal to ((Facing of u) + 45.00)
• (Angle from (Position of u) to (Position of (Picked unit))) Greater than or equal to ((Facing of u) - 45.00)
• Then - Actions
• Game - Display to (All players) the text: a unit is detected ...
• Else - Actions

#### Geshishouhu

Level 11
I dont think you can make it more simple than this
• Melee Initialization
• Events
• Map initialization
• Conditions
• Actions
• Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
• Set u = (Last created unit)
• Unit Group - Pick every unit in (Units within 250.00 of (Position of u)) and do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Angle from (Position of u) to (Position of (Picked unit))) Less than or equal to ((Facing of u) + 45.00)
• (Angle from (Position of u) to (Position of (Picked unit))) Greater than or equal to ((Facing of u) - 45.00)
• Then - Actions
• Game - Display to (All players) the text: a unit is detected ...
• Else - Actions

Great! I really need an example. Can you post that map, please? Or can you convert it to text? I am not familiar with GUI, sorry

#### Chaosy

Tutorial Reviewer
Level 40
ah didnt know you were a jasser. I might rewrite that a little then. will update this post.
JASS:
``````function unitgroup takes nothing returns boolean
if AngleBetweenPoints(GetUnitLoc(udg_u), GetUnitLoc(GetEnumUnit())) <= ( GetUnitFacing(udg_u) + 45.00 )   then
if AngleBetweenPoints(GetUnitLoc(udg_u), GetUnitLoc(GetEnumUnit())) >= ( GetUnitFacing(udg_u) - 45.00 )  then
//detected
else
return false
endif
return false
endif
return true
endfunction

function Trig_Melee_Initialization_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
set udg_u = GetLastCreatedUnit()
call ForGroupBJ( GetUnitsInRangeOfLocAll(250.00, GetUnitLoc(udg_u)), function unitgroup )
endfunction``````

its far from good, but I removed most of the retarded GUIish jass. I am not a jasser myself I only know the basic rules so to speak

#### chobibo

Level 22
Why don't you post your code too Gesh.

#### Malhorne

Level 18
AngleBetweenPoint == Atan2(ty-y,tx-x)

To get a point from a offset of 100 for example :
JASS:
``````local real angle = Atan2(ty-y, tx-x)
local real point_x = 100*Cos(angle)
local real point_y = 100*Sin(angle)``````

Remember that mathematical functions take radians and return radians when it comes to angle !

#### Geshishouhu

Level 11
ah didnt know you were a jasser. I might rewrite that a little then. will update this post.
JASS:
``````function unitgroup takes nothing returns boolean
if AngleBetweenPoints(GetUnitLoc(udg_u), GetUnitLoc(GetEnumUnit())) <= ( GetUnitFacing(udg_u) + 45.00 )   then
if AngleBetweenPoints(GetUnitLoc(udg_u), GetUnitLoc(GetEnumUnit())) >= ( GetUnitFacing(udg_u) - 45.00 )  then
//detected
else
return false
endif
return false
endif
return true
endfunction

function Trig_Melee_Initialization_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
set udg_u = GetLastCreatedUnit()
call ForGroupBJ( GetUnitsInRangeOfLocAll(250.00, GetUnitLoc(udg_u)), function unitgroup )
endfunction``````

its far from good, but I removed most of the retarded GUIish jass. I am not a jasser myself I only know the basic rules so to speak
Thank you for the example, +Rep
Why don't you post your code too Gesh.
Actually my code did not work properly.... :/ I made something like this:
JASS:
``````function DBetweenP takes real x, real y, real x1, real y1 returns real
return SquareRoot(( x - x1 ) * ( x - x1 ) + ( y- y1 ) * ( y- y1 ))
endfunction

function AAngle takes real x1, real x2, real x3, real y1, real y2, real y3 returns real
return (DBetweenP(x1,y1,x2,y2)*DBetweenP(x1,y1,x2,y2)+DBetweenP(x1,y1,x3,y3)*DBetweenP(x1,y1,x3,y3)-DBetweenP(x2,y2,x3,y3)*DBetweenP(x2,y2,x3,y3))/(2*(DBetweenP(x1,y1,x2,y2)*DBetweenP(x1,y1,x2,y2)+DBetweenP(x1,y1,x3,y3)*DBetweenP(x1,y1,x3,y3)))
endfunction``````

AngleBetweenPoint == Atan2(ty-y,tx-x)

To get a point from a offset of 100 for example :
JASS:
``````local real angle = Atan2(ty-y, tx-x)
local real point_x = 100*Cos(angle)
local real point_y = 100*Sin(angle)``````

Remember that mathematical functions take radians and return radians when it comes to angle !

Thanks Malhorne. I tried to make a function myself so that I can get an angle if I know the coordinates of three points, but failed....xD

#### Maker

Level 37
 Untitled Trigger 007 Events Player - Player 1 (Red) skips a cinematic sequence Conditions Actions Set u1 = Paladin 0003 Set p1 = (Position of u1) Set plr = (Triggering player) Set r1 = (Facing of u1) Custom script: set bj_wantDestroyGroup = true Unit Group - Pick every unit in (Units within 1000.00 of p1) and do (Actions) Loop - Actions Set u2 = (Picked unit) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (u2 is alive) Equal to True (u2 belongs to an enemy of plr) Equal to True Then - Actions Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: picked alive Set p2 = (Position of u2) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Acos((Cos((r1 - (Angle from p1 to p2)))))) Less than 30.00 Then - Actions Special Effect - Create a special effect attached to the origin of u2 using Abilities\Weapons\DemolisherFireMissile\DemolisherFireMissile.mdl Special Effect - Destroy (Last created special effect) Else - Actions Custom script: call RemoveLocation(udg_p2) Else - Actions Custom script: call RemoveLocation(udg_p1)

The r1 can be angle from caster to target point of ability being cast. In jass I would ditch the Acos and modify the 30 to a desired value between -1 and 1.

#### Geshishouhu

Level 11
 Untitled Trigger 007 Events Player - Player 1 (Red) skips a cinematic sequence Conditions Actions Set u1 = Paladin 0003 Set p1 = (Position of u1) Set plr = (Triggering player) Set r1 = (Facing of u1) Custom script: set bj_wantDestroyGroup = true Unit Group - Pick every unit in (Units within 1000.00 of p1) and do (Actions) Loop - Actions Set u2 = (Picked unit) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (u2 is alive) Equal to True (u2 belongs to an enemy of plr) Equal to True Then - Actions Game - Display to Player Group - Player 1 (Red) for 5.00 seconds the text: picked alive Set p2 = (Position of u2) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Acos((Cos((r1 - (Angle from p1 to p2)))))) Less than 30.00 Then - Actions Special Effect - Create a special effect attached to the origin of u2 using Abilities\Weapons\DemolisherFireMissile\DemolisherFireMissile.mdl Special Effect - Destroy (Last created special effect) Else - Actions Custom script: call RemoveLocation(udg_p2) Else - Actions Custom script: call RemoveLocation(udg_p1)

The r1 can be angle from caster to target point of ability being cast. In jass I would ditch the Acos and modify the 30 to a desired value between -1 and 1.

Thanks Maker. +Rep

#### HerlySQR

Level 21
Just to be clear, are all of you reffering a cone or a circular sector? because they are not the same.

#### FeelsGoodMan

Level 40
Just to be clear, are all of you reffering a cone or a circular sector? because they are not the same.
I believe they're talking about a cone like this

Level 21
This is a cone

Circular sector

#### Chaosy

Tutorial Reviewer
Level 40
It is common gaming-speak to refer to a "cone attack" as what is described as a circular sector in the above image.

In WoW for example, there is a mage ability called Cone of Cold.

Although this might be because you kinda-sorta shoot a cone outward in front of you. Rotate a cone 90 degree and put the pointy bit by your chest and the cone will seem like a circular section from above.

Last edited:

Replies
11
Views
2K
Replies
17
Views
2K
Replies
6
Views
1K
Replies
5
Views
523
Replies
3
Views
209