• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[Trigger] Units within Cone Area

Status
Not open for further replies.
Level 7
Joined
Nov 4, 2006
Messages
153
Hey, I need help with finding units in a cone shaped area. Like,umm, yeah. The picture below shows a black dot as the casting unit. Blue is the affected area, red are just enemy units. Thanks.

edit: Previous question was answered but, here's another one. How do I make units move faster towards the caster the closer they are. And make them move towards the center of the cone too? Thanks.
 

Attachments

  • DevourInhale.jpg
    DevourInhale.jpg
    10 KB · Views: 130
Last edited:
Level 16
Joined
Mar 3, 2006
Messages
1,564
  • Unit Group - Pick every unit in (Units within 512.00 of point matching (((Angle from point to (Position of (Matching unit))) Greater than or equal to 30.00) and ((Angle from point to (Position of (Matching unit))) Greater than or equal to -30.00))) and do (Actions)
    • Loop - Actions
      • -------- YOUR ACTIONS HERE --------
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
Well yah, but it's hard to understand and it leaks...
I know it leaks as you once told me that points are evil :wink: but I just gave him the idea to make what he want; he could care for leaks later.

<< ADDED >>

To Element of water:

Is this right ?

JASS:
globals
    group ConeGr = CreateGroup()
    location Centre
    boolexpr InCone
endglobals
 
function ConeDetect takes nothing returns nothing
    call GroupEnumUnitsInRange(ConeGr,GetLocationX(Centre),GetLocationY(Centre),512,InCone)
endfunction
 
function FilterUnit takes nothing returns boolean
    return bj_RADTODEG * Atan2(GetUnitY(GetFilterUnit()) - GetLocationY(Centre), GetUnitX(GetFilterUnit()) - GetLocationX(Centre)) <= 30 and bj_RADTODEG * Atan2(GetUnitY(GetFilterUnit()) - GetLocationY(Centre), GetUnitX(GetFilterUnit()) - GetLocationX(Centre)) >= -30
endfunction
 
function f takes nothing returns nothing
    local trigger t = CreateTrigger()
    // Other trigger stuff like add condition and action and event registration
    set InCone = Filter(function FilterUnit)
endfunction
 
Last edited:
Level 11
Joined
Apr 6, 2008
Messages
760
man i cry when i see locations in jass QQ

Ah thanks. I thought that angle thing wouldn't work but eh...it does. I have another question though: How do I make units move faster towards the caster the closer they are. And make them move towards the center of the cone too? Thanks.

  • Unit - Move 'Unit' instantly to ((Position of ('Unit')) offset by 'real' towards (Angle from (Position of ('Unit')) to ('Location') degrees)
Leak the shit thou, leaving some work too you :p
 
Level 9
Joined
Nov 28, 2008
Messages
704
I don't feel like spending the time, but basically your getting all the units in a radius, then getting the angle between the middle of the angle the cone's middle is in, and comparing all the units in the group's angles with the start of the cone to the angle of the cone. If the difference is greater then a half of the radius you want, then you don't count it as part of the group.

Basically, you had the right idea, then you started using locations, making me want to cry. t.t.

Try this anyways.

JASS:
library Cone initializer Init_Cone
    globals
        private real MaxAngle
        private real MinAngle
        private real X
        private real Y
        private boolexpr ConeFilter
    endglobals
    
    private function FilterCone takes nothing returns boolean
        local real UnitAngle = Atan2(GetUnitY(GetFilterUnit()) - Y, GetUnitX(GetFilterUnit()) - X)
        return (UnitAngle < MaxAngle) and (UnitAngle > MinAngle)
    endfunction
    
    function GetCone takes real ConeX, real ConeY, real ConeRadius, real ConeAngle, real ConeSize returns group
        local group Group = CreateGroup()
        set X = ConeX
        set Y = ConeY
        set ConeRadius = ConeRadius / 2
        set MaxAngle = ConeAngle + ConeRadius
        set MinAngle = ConeAngle - ConeRadius
        call GroupEnumUnitsInRange(Group, X, Y, ConeSize, ConeFilter)
        return Group
    endfunction
    
    function Init_Cone takes nothing returns nothing
        set ConeFilter = Filter(function FilterCone)
    endfunction
endlibrary

I haven't tested it, but it compiles fine. If anyone finds an error, do shout out. Everything is in radians. What you pass should be in radians, anyways.
 
Last edited:
Status
Not open for further replies.
Top