- Joined
- Jun 14, 2007
- Messages
- 56
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.
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?
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?