Here's my code..
Code:
function Trig_Spell_Mirror_Conditions takes nothing returns boolean
return GetUnitAbilityLevelSwapped('A007', GetSpellTargetUnit()) > 0
endfunction
function Trig_Spell_Mirror_Actions takes nothing returns nothing
local unit Target = GetSpellTargetUnit()
local unit Caster = GetSpellAbilityUnit()
local unit Dummy = GetLastCreatedUnit()
local integer ID = GetSpellAbilityId()
if GetRandomInt(1, 100) <= ( 10 * GetUnitAbilityLevelSwapped('A007', Target) ) then
call UnitAddAbilityBJ( 'A008', Target )
call CreateNUnitsAtLoc( 1, 'hpb1', GetOwningPlayer(Target), GetUnitLoc(Target), bj_UNIT_FACING )//make dummyunit
set Dummy = GetLastCreatedUnit()
call UnitAddAbilityBJ(ID, Dummy )
call SetUnitAbilityLevelSwapped( ID, Dummy, GetUnitAbilityLevelSwapped(ID, Caster) )
call IssueTargetOrderById(Dummy, ID, Caster)
call UnitApplyTimedLifeBJ( 2.00, 'BTLF', Dummy )
call DisplayTextToForce( GetPlayersAll(), I2S(ID) )
call DisplayTextToForce( GetPlayersAll(), GetUnitName(GetLastCreatedUnit()) )
endif
endfunction
//===========================================================================
function InitTrig_Spell_Mirror takes nothing returns nothing
set gg_trg_Spell_Mirror = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spell_Mirror, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Spell_Mirror, Condition( function Trig_Spell_Mirror_Conditions ) )
call TriggerAddAction( gg_trg_Spell_Mirror, function Trig_Spell_Mirror_Actions )
endfunction