• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Projectile Collision - Best Way To Detect When A Missile Hits A Unit?

Status
Not open for further replies.
Level 3
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 :)
Code:
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
 
Level 5
Joined
May 23, 2008
Messages
148
It is not the most effective one.

Few days ago I made a beta of my system and it has only some glitches to be fixed.

Hint: it only uses unit is being attacked and unit is being issued an ... order events. No Unit takes damage or every 0.03 seconds. That's NOT effective.
 
I have a simple solution: add Mine detection(or what is the spell name(check the abilities from the goblin land mine)) to the dummy(i was just playing with this yesterday) It worked nice, i just need to polish it a bit more =)
Than edit the ability(the time before it "triggers" default is 10 i think)
Than when that unit(dummy/missile) dies damage the area or what you wish it to do.
Hope you know what i mean.
 
Level 3
Joined
Jun 14, 2007
Messages
56
Yesh i be with youu. I tried this out and there was some reason why it wasn't ideal. I think it was because I wanted a knockback function aswell which i now have.

Instead i just used GroupEnumUnitsInRange function, worked out quite well

EDIT:
"It is not the most effective one.

Few days ago I made a beta of my system and it has only some glitches to be fixed.

Hint: it only uses unit is being attacked and unit is being issued an ... order events. No Unit takes damage or every 0.03 seconds. That's NOT effective."










Yeah i figured out instead of checking every x seconds in a new trigger, I'd just check ever time i move the missile but thanks anyway!
 
Last edited by a moderator:
Status
Not open for further replies.
Top