globals
integer MirrorSkill = 'A000' // Skill Activator
integer MirrorBuff = 'B000' // Buff
integer DummyID = 'h000' // Dummy Unit
endglobals
function Trig_Mirror_System_Conditions takes nothing returns boolean
return GetUnitAbilityLevel(GetSpellTargetUnit(), MirrorBuff) > 0
endfunction
function Trig_Mirror_System_Actions takes nothing returns nothing
local unit MirroredTarget = GetSpellTargetUnit()
local unit MirrorCaster = GetSpellAbilityUnit()
local unit = MirrorDummy
local real XOC = GetUnitX(MirroredTarget)
local real YOC = GetUnitY(MirroredTarget)
local integer chance = 50 // Chance to reflect skill back
local integer SpelledMirror
local string order = OrderId2StringBJ(GetUnitCurrentOrder(MirrorCaster))
if (GetRandomInt(1,100) <= chance ) then
set SpelledMirror= GetSpellAbilityId()
set MirrorDummy = CreateUnit(GetOwningPlayer(MirroredTarget),DummyID,XOC,YOC,0.)
call UnitAddAbility(MirrorDummy,SpelledMirror)
call IssueTargetOrder(MirrorDummy,order,MirrorCaster)
call UnitApplyTimedLife(MirrorDummy,'BTLF',1.0)
else
endif
endfunction
//===========================================================================
function InitTrig_Mirror_System takes nothing returns nothing
set gg_trg_Mirror_System = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Mirror_System, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Mirror_System, Condition( function Trig_Mirror_System_Conditions ) )
call TriggerAddAction( gg_trg_Mirror_System, function Trig_Mirror_System_Actions )
endfunction