- Joined
- Mar 3, 2012
- Messages
- 9
JASS:
function Trig_Replicate_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A051' or GetSpellAbilityId() == 'A052' or GetLearnedSkill() == 'A08H'
endfunction
function Trig_Replicate_Image takes nothing returns boolean
return GetUnitAbilityLevel(GetFilterUnit(),'B01C') > 0 and GetOwningPlayer(GetFilterUnit()) == GetOwningPlayer(GetTriggerUnit())
endfunction
function Trig_Replicate_Die takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local hashtable gc = udg_HashCache
local integer s = GetHandleId(t)
local unit u = LoadUnitHandle(gc,s,1)
call UnitRemoveAbility(u,'A052')
call UnitAddAbility(u,'A051')
call SetUnitAbilityLevel(u,'A051',LoadInteger(gc,s,10))
call UnitMakeAbilityPermanent(u,true,'A051')
call TriggerRemoveAction(t,LoadTriggerActionHandle(gc,s,2))
call KillTrigger(t)
set u = null
set t = null
set gc = null
endfunction
function Trig_Replicate takes nothing returns nothing
local unit u = GetTriggerUnit()
local trigger tr
local triggeraction ta
local hashtable gc = udg_HashCache
local integer s
local unit p
local group g
local boolexpr b
if GetSpellAbilityId() == 'A051' then
set tr = CreateTrigger()
set s = GetHandleId(tr)
set g = CreateGroup()
set b = Condition(function Trig_Replicate_Image)
call TriggerSleepAction(0)
call GroupEnumUnitsInRange(g,0,0,99999,b)
set p = FirstOfGroup(g)
call SaveUnitHandle(gc,GetHandleId(u),17,p)
call TriggerRegisterUnitEvent(tr,p,EVENT_UNIT_DEATH)
set ta = TriggerAddAction(tr,function Trig_Replicate_Die)
call SaveUnitHandle(gc,s,1,u)
call SaveInteger(gc,s,10,GetUnitAbilityLevel(u,'A051'))
call SaveTriggerActionHandle(gc,s,2,ta)
call UnitMakeAbilityPermanent(u,false,'A051')
call UnitRemoveAbility(u,'A051')
call UnitAddAbility(u,'A052')
call UnitMakeAbilityPermanent(u,true,'A052')
set tr = null
set ta = null
call DestroyGroup(g)
call DestroyBoolExpr(b)
set g = null
set b = null
set p = null
elseif GetSpellAbilityId() == 'A052' then
set p = LoadUnitHandle(gc,GetHandleId(u),17)
call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Naga\\NagaDeath\\NagaDeath.mdl",GetUnitX(u),GetUnitY(u)))
call DestroyEffect(AddSpecialEffect("Units\\Creeps\\SeaElemental\\SeaElemental.mdl",GetUnitX(u),GetUnitY(u)))
call SetUnitPosition(u,GetUnitX(p),GetUnitY(p))
call SetUnitAnimation(u,"birth")
call KillUnit(p)
call RemoveSavedInteger(gc,GetHandleId(u),StringHash("p"))
set p = null
elseif GetLearnedSkill() == 'A08H' then
if GetUnitAbilityLevel(u,'A051') == 0 then
call UnitAddAbility(u,'A051')
endif
call SetUnitAbilityLevel(u,'A051',GetUnitAbilityLevel(u,'A08H'))
endif
set gc = null
set u = null
endfunction
function InitTrig_Replicate takes nothing returns nothing
set gg_trg_Replicate = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Replicate,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterAnyUnitEventBJ(gg_trg_Replicate,EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(gg_trg_Replicate, Condition(function Trig_Replicate_Conditions))
call TriggerAddAction(gg_trg_Replicate, function Trig_Replicate)
endfunction
Please help me with.