• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Defining a cone area.

Status
Not open for further replies.
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...
 
Level 11
Joined
Oct 11, 2012
Messages
711
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...

Actually I need some explanation about this thread, I don't get it, my math sucks.... :/
http://www.hiveworkshop.com/forums/triggers-scripts-269/pick-units-cone-shape-212855/
 
Level 11
Joined
Oct 11, 2012
Messages
711
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
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
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
 
Level 11
Joined
Oct 11, 2012
Messages
711
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
Joined
Jun 9, 2011
Messages
13,219
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
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
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 !
 
Level 11
Joined
Oct 11, 2012
Messages
711
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
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • 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.
 
Level 11
Joined
Oct 11, 2012
Messages
711
  • 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.

Thanks Maker. +Rep
 
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
untitled-png.388883
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
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:
Status
Not open for further replies.
Top