 Joined
 Oct 11, 2012
 Messages
 711
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.
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
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...
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...
AngleBetweenPoints I think will be what you'll use
or wait... Atan2(x2x1,y2y1)
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...
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
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
local real angle = Atan2(tyy, txx)
local real point_x = 100*Cos(angle)
local real point_y = 100*Sin(angle)
Thank you for the example, +Repah 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
Actually my code did not work properly.... :/ I made something like this:Why don't you post your code too Gesh.
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(tyy,txx)
To get a point from a offset of 100 for example :
JASS:local real angle = Atan2(tyy, txx) 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 !

 Untitled Trigger 007
 Events
 Player  Player 1 (Red) skips a cinematic sequence
 Conditions
 Actions
 Set u1 = Paladin 0003 <gen>
 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.
That necro though@Maker, thank you! I'm still not quite sure why my way didn't work but yours did!
I believe they're talking about a cone like thisJust to be clear, are all of you reffering a cone or a circular sector? because they are not the same.