| 10-18-2009, 12:54 PM | #1 | ||
Hey guys!! I made a small function which requires a few parameters and then returnes the first unit which is nearest to a line which is constructed by the given parameters!! I made some Debug Msgs, to find the error but now im at a point where i dont know how to go on! Bevor i post the function: I know its still pretty unfinished and if you use it from a point to a direction where no unit is it will end in an loop that never stops. atm that doesnt matter for me! I used a spell to cast it on a other unit to make sure that the function will always find a target!! The problem is, it never finds a target also if i cast it on the caster itself!! I never get an INRANGE or NEAREST Debug message and i dont know what to do now :( First my testcode:
Is it possible that the angle isnt calculated correctly? I sometimes had propblems on getting the angle between points with some special spell events so here is the event: EVENT_PLAYER_UNIT_SPELL_CHANNEL The Dummy spell base is banish! (from the bloodmage). Here is the function code:
Would be great if somen could help me im not that trigger pro (and as you can see im also not that english pro :(, so sorry!) Thanks!! |
| 10-18-2009, 01:20 PM | #2 |
you shouldn't use roots and use ForGroup to loop through groups JASS:
loop
exitwhen FirstOfGroup(g) != null
set u = FirstOfGroup(g)
if(getDistanceBetweenUnitAndPoint(u, x, y) < 10 * aoerad) then
...
endif
call GroupRemoveUnit(g, u)
set u = null
endloop
try JASS:
loop
set u = FirstOfGroup(g)
exitwhen u== null
if(getDistanceBetweenUnitAndPoint(u, x, y) < 10 * aoerad) then
...
endif
call GroupRemoveUnit(g, u)
endloop
and everything should work that's one of the reasons why you should use ForGroup() |
| 10-18-2009, 01:41 PM | #3 |
seems it works now thank you |
