[JASS] How to find units between points?

El-Sevio

New Member
Reaction score
0
Trying to code a manual swing sword. Point targeted.

What i do is:
-I use (GroupEnumUnitsInRangeOfLoc) to Group the units within 50 range of a polar projected point towards the cast location.
-I loop this so the location groups units at small sections at a time, with projected point getting further from caster each loop. stops when distance = 200
-then i execute functions for the units in that group (loop FirstOfGroup etc) so that all units in the group are hit



It works on occasion, but it isnt very effective, usually misses grouping the units it should have hit.


















For those who want to see the code.

Code:
Function ExecuteSwingSword takes nothing returns nothing
local unit c = GetTriggerUnit()
local real a = AngleBetweenPoints(GetUnitLoc(c),  GetSpellTargetLoc())
local real distance = 0
local group g = CreateGroup()
local location loc
local unit f
local location p = GetUnitLoc(c)
call TriggerSleepAction(0.1) // animation hits after 0.1 seconds
loop
exitwhen distance >= 200
set distance = distance + 20
set loc = PolarProjectionBJ(p, distance, a)
call GroupEnumUnitsInRangeOfLoc(g, loc, 100, null)
endloop
loop
set f = FirstOfGroup(g)
exitwhen f == null
call GroupRemoveUnit(g, f)
<<damage / knockback functions>>
endloop
endfunction

trying to get an accurate projection of a forwards blade swing, and make sure units that should be hit (even right next to the blademaster, but not behind) are getting hit!

It just seems to be missing, and doesnt really hit in the immediate. is there a more effective way of doing this?
 

Builder Bob

Live free or don't
Reaction score
249
If you just want to filter out the units behind the caster you could enumerate all units in 200 range of the caster, and filter out all units that have an angle difference from the caster's facing greater than X.

I can provide code for angle difference if needed.
 

cleeezzz

The Undead Ranger.
Reaction score
268
it shouldn't miss.. are you sure its missing? 100 range is small

>is there a more effective way of doing this?
not that i know of, thats the way ive seen people pick units in a line.
 

El-Sevio

New Member
Reaction score
0
i see what you're saying. thing is he thrusts the sword forwards, a semi circle isnt quite the projection im after. but thanks tho :)

also trying to do the same with an instant gun shot with much higher range
 

El-Sevio

New Member
Reaction score
0
cool il have a read

haha sweet as bro. yeah my ones kind of working atm just misses ocassionaly. thanks ill check
 

El-Sevio

New Member
Reaction score
0
must be something wrong with my trigger then. i found a system someones made tho so ill check thatt outtt cheers cleeezo
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top