The trigger:
Event
-A unit is attacked
Conditions
-Level of (spell name) for attacking unit is greater than 0 and attacked unit is magic immune equal to false
Events
-Cause attacking unit to damage attacked unit, dealing (damage) damage of attack type chaos and damage type unknown
(Pretty simple ^^)
The problem is the chaos damage is dealt before the attacked unit receives basic damage.
Is there a way to make the trigger work when a unit receives damage?|||Add some on hit ability to the hero and use 'a unit starts the effect of an ability'.
EDIT: Unless the damage is constant in which case that's actually exactly what you're asking and I haven't helped in the least. The Orb of Slow item ability is great for implementing on-hit abilities.
If you don't want to do that, you can use the following trigger:
Code:
function Trig_On_Hit_Conditions takes nothing returns boolean
if ( not ( GetUnitAbilityLevel(GetAttacker(), 'ANab') > 0 ) ) then
return false
endif
if ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_MAGIC_IMMUNE) ) then
return false
endif
return true
endfunction
function Trig_TOnHit_Conditions takes nothing returns boolean
return ( GetEventDamageSource() == LoadUnitHandle( udg_htGlobal, GetHandleId(GetTriggeringTrigger()), 0 ) )
endfunction
function Trig_TOnHit_Actions takes nothing returns nothing
call UnitDamageTarget( GetEventDamageSource(), GetTriggerUnit(), AMOUNT_GOES_HERE, true, false, ATTACK_TYPE_CHAOS, WEAPON_TYPE_WHOKNOWS )
call RemoveSavedHandle( udg_htGlobal, GetHandleId(GetTriggeringTrigger()), 0 )
call DestroyTrigger( GetTriggeringTrigger() )
endfunction
function Trig_On_Hit_Actions takes nothing returns nothing
local trigger t = CreateTrigger()
call SaveUnitHandle( udg_htGlobal, GetHandleId(t), 0, GetAttacker() )
call TriggerRegisterUnitEvent( t, GetTriggerUnit(), EVENT_UNIT_DAMAGED )
call TriggerAddCondition( t, Condition(function Trig_TOnHit_Conditions) )
call TriggerAddAction( t, function Trig_TOnHit_Actions )
set u = null
call TriggerSleepAction( 2.00 )
call DestroyTrigger(t)
set t = null
endfunction
//===========================================================================
function InitTrig_On_Hit takes nothing returns nothing
set gg_trg_On_Hit = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_On_Hit, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_On_Hit, Condition( function Trig_On_Hit_Conditions ) )
call TriggerAddAction( gg_trg_On_Hit, function Trig_On_Hit_Actions )
endfunction
I don't use EVENT_UNIT_DAMAGED much but that SHOULD work. Be sure to replace AMOUNT_GOES_HERE with the amount you want.
EDIT2: Forgot to mention, if you want to use that trigger, create a global hashtable variable called htGlobal.
No comments:
Post a Comment