• 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.

Pick Units In Half Circle

Status
Not open for further replies.
Level 37
Joined
Aug 14, 2006
Messages
7,614
Hey there.

I have little problem I don't know how to solve it. I have a minor boss, who will throw some stones(Hurl Boulder ability) to player's units that are in his front. I know how to pick all units around a unit, but I don't know how to pick units that are in boss' front. I have attached a picture if you didn't get what's my problem.

Orange = The Boss
Red = The half circle where the dummy units should throw the stones(Hurl Boulders).
Green = Where the boss currently looks.

I have also attached the map where this problem is. Could someone help me and do this type of trigger? I will give you some rep + credits.
 

Attachments

  • BOSS.JPG
    BOSS.JPG
    11.8 KB · Views: 99
  • POSSU EVENT.w3x
    22.7 KB · Views: 57
I guess its something like this.

Can't test right now.

JASS:
library HalfEnumGroup

    private function interface enumInterface takes unit u returns boolean
    
    globals
        private real enumFacing = 0.
        private enumInterface enumFilter = null
    endglobals
    
    private function getCorrectFacing takes real f returns real
        loop
            exitwhen f > 0 and f < 360
            
            if f < 0 then
                set f = f +360
            elseif f > 360
                set f = f -360
            endif
        endloop
        
        return f
    endmethod
    
    private function halfEnumFilter takes nothing returns boolean
        local unit u = GetEnumUnit()
        local real f = getCorrectFacing(GetUnitFacing(u))
        
        return (f <= enumFacing +90 or f >= enumFacing -90) and enumFilter.evaluate(u)
    endfunction
    
    function enumUnitsInHalfRange takes group whichGroup, real x, real y, real r, real f, enumInterface filter returns nothing
        local integer i = 0
        local unit u = 0
        local boolexpr b = Condition(function halfEnumFilter)
        
        set enumFacing = getCorrectFacing(f)
        set enumFilter = filter
        call GroupEnumUnitsInRange(whichGroup, x, y, r, b)
        
        set b = null
    endfunction
endlibrary

JASS:
scope Test initializer init
    private function enumTest takes unit u returns boolean
        return true
    endfunction

    private function init takes nothing returns nothing
        local group g = CreateGroup()
        call enumUnitsInHalfRange(g, 0., 0., 256., 90, enumTest)
    endfunction
endscope
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Here's the thing in GUI:

  • DW
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to ...
    • Actions
      • Set Temp_Unit_1 = (Triggering unit)
      • Set Temp_Loc_1 = (Position of Temp_Unit_1)
      • Set Temp_Real_1 = (Facing of Temp_Unit_1)
      • Set Temp_Real_2 = 800.00
      • ...
      • Set Temp_Group = (Units within Temp_Real_2 of Temp_Loc_1 matching ((Owner of (Matching unit)) Not equal to (Owner of (Temp_Unit_1)...)))
      • Unit Group - Pick every unit in Temp_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Loc_2 = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Cos((Temp_Real_1 - (Angle from Temp_Loc_1 to Temp_Loc_2)))) Greater than (Cos(90.00))
            • Then - Actions
              • *Unit is in front of the caster*
 
Level 37
Joined
Aug 14, 2006
Messages
7,614
Test map works, but the "Possu Event" map doesn't work properly. It lags when he throws and I guess it throws to few units many stones(should be one stone / unit). Also in the project player won't have that many unit, instead something like 1-5 units max. so you can reduce the amount of p1 units if necessary.

Can you fix this problem, please?
 
Status
Not open for further replies.
Top