HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Attack event help D:

01-16-2011, 03:37 AM#1
Nestharus
So, how would I go about catching all attacks by units?

EVENT_PLAYER_UNIT_ATTACKED only works if the attack has a target

EVENT_PLAYER_UNIT_ISSUED_ORDER and all of the variants work, but the orders are only issued one time. If the order is something like attack ground with a canon tower, you're screwed ; P.

Also, at EVENT_UNIT_DAMAGED, it's already too late as damage can't be linked to an attack at that point.

I've run out of ideas on how to accomplish this ; (.



I guess the only thing I can't capture is attacks from an attackground order

edit
IDEA!!

On attackground order, create a tiny invisible unit at the point and have the thing attack that instead. On create, link that unit to the attacker so that future orders can just move the unit. On deindex, recycle the invis unit.
01-18-2011, 04:32 AM#2
chobibo
Could you explain what you want to do? I don't get the problem, but if you want to detect when a unit is ordered to "attackground" and to link the attack to the attacker then you could use something like this:
Collapse test script:
function onAttackGround takes nothing returns nothing
    local integer orderId=GetIssuedOrderId()
    local unit attackingUnit=GetTriggerUnit()
    if orderId==OrderId("attackground") then
        call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Attack Ground order has been issued to a "+GetUnitName(attackingUnit))
    endif
    set attackingUnit=null
endfunction

//===========================================================================
function InitTrig_DetectAttackGround takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
    call TriggerAddAction( t, function onAttackGround )
endfunction