- Joined
- Jun 14, 2007
- Messages
- 56
Hellooo thar!
In order to programme my own knockback system for missiles, I was wondering what the most effective way of detecting when a unit is hit with a missile?
For the missile I create it as a unit, and manually trigger its movement, using Jass.
Things that come to mind atm are either checking every x seconds if any missile unit is in range of an enemy, then creating the collision then.
Or having the collision actions in a trigger with no events, then a seperate trigger that takes every new unit added to the game (event - Unit enters playable map area), and then adds the event to the collision trigger "(A unit enters 50 range of (trig unit).
The first one seems inefficient and the second one doesnt work for different missile shapes and sizes without making a new trigger with 100 odd events for each missile.
This is the missile create code
In order to programme my own knockback system for missiles, I was wondering what the most effective way of detecting when a unit is hit with a missile?
For the missile I create it as a unit, and manually trigger its movement, using Jass.
Things that come to mind atm are either checking every x seconds if any missile unit is in range of an enemy, then creating the collision then.
Or having the collision actions in a trigger with no events, then a seperate trigger that takes every new unit added to the game (event - Unit enters playable map area), and then adds the event to the collision trigger "(A unit enters 50 range of (trig unit).
The first one seems inefficient and the second one doesnt work for different missile shapes and sizes without making a new trigger with 100 odd events for each missile.
This is the missile create code
JASS:
function Missile takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit missile = GetHandleUnit(t, "missile")
local real direction = GetHandleReal(t, "angle")
call SetUnitPositionLoc(missile, PolarProjectionBJ(GetUnitLoc(missile), 100.00, direction))
set t = null
set missile = null
endfunction
function ExecuteMissile takes nothing returns nothing
local unit c = GetTriggerUnit()
local real direction = AngleBetweenPoints(GetUnitLoc(c), GetSpellTargetLoc())
local timer t = CreateTimer()
local integer p = GetConvertedPlayerId(GetOwningPlayer(c))
local unit u
call TriggerSleepAction(0.25)
set u = CreateUnitAtLoc(GetOwningPlayer(c), 'h01L', GetUnitLoc(c), direction)
call SetHandleHandle(t, "missile", u)
call SetHandleReal(t, "angle", direction)
call TimerStart(t, 0.035, true, function Missile)
call TriggerSleepAction(0.5)
call FlushHandleLocals(t)
call DestroyTimer(t)
call RemoveUnit(u)
set c = null
set t = null
endfunction
Last edited by a moderator: