|
Jass代码如下:
[jass]
function Trig_devour_Timer takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit unit1 = I2U(GetStoredInteger(udg_gc, I2S(H2I(t)), "unit1"))
local unit unit2 = I2U(GetStoredInteger(udg_gc, I2S(H2I(t)), "unit2"))
if IsUnitLoaded(unit2) then
call UnitDamageTarget(unit1, unit2, 5, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
else
call PauseTimer(t)
call DestroyTimer(t)
call FlushStoredMission(udg_gc, I2S(H2I(t)))
call UnitRemoveAbility(unit2, 'B000')
endif
set unit1 = null
set unit2 = null
set t = null
endfunction
function Trig_devour_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function Trig_devour_Actions takes nothing returns nothing
local unit unit1 = GetTriggerUnit()
local unit unit2 = GetSpellTargetUnit()
local timer t = CreateTimer()
call UnitAddAbilityBJ( 'A001', unit2 )
call SetPlayerAbilityAvailableBJ( true, 'A001', GetOwningPlayer(unit2) )
call UnitAddItemByIdSwapped( 'I000', unit2 )
call SetPlayerAbilityAvailableBJ( false, 'A001', GetOwningPlayer(unit2) )
call StoreInteger(udg_gc, I2S(H2I(t)), "unit1", H2I(unit1))
call StoreInteger(udg_gc, I2S(H2I(t)), "unit2", H2I(unit2))
call TimerStart(t, 1, true, function Trig_devour_Timer)
set unit1 = null
set unit2 = null
set t = null
endfunction
//===========================================================================
function InitTrig_devour takes nothing returns nothing
set gg_trg_devour = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_devour, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_devour, Condition( function Trig_devour_Conditions ) )
call TriggerAddAction( gg_trg_devour, function Trig_devour_Actions )
endfunction
[/jass] |
|