JASS:
function Trig_Transfer_Energy_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A045' ) ) then
return false
endif
return true
endfunction
function MySpell_Stop_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A045' or GetTriggerUnit() == null
endfunction
function MySpell_Stop_Actions takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local unit dummy = GetHandleUnit(t,"dummy")
call SetUnitUserData( dummy, 1 )
set dummy = null
set t = null
endfunction
function Trig_Transfer_Energy_Actions takes nothing returns nothing
local real i = 0
local unit u = GetTriggerUnit()
local integer level = GetUnitAbilityLevel(u,'A045')
local trigger t = CreateTrigger()
local triggeraction ta = TriggerAddAction(t, function MySpell_Stop_Actions)
local triggercondition tc = TriggerAddCondition(t, Condition(function MySpell_Stop_Conditions))
local unit dummy = CreateUnit(Player(1),'n02E' ,GetUnitX(u) + Cos(bj_DEGTORAD * GetUnitFacing(u)) * 130, GetUnitY(u) + Sin(bj_DEGTORAD * GetUnitFacing(u)) * 130, GetUnitFacing(u))
call TriggerRegisterPlayerUnitEvent(t, GetOwningPlayer(u), EVENT_PLAYER_UNIT_SPELL_ENDCAST, null)
call SetHandleHandle(t,"dummy",dummy)
loop
exitwhen(GetBooleanOr(i==6.0,GetUnitUserData(dummy) == 1))
call TriggerSleepAction(0.5)
if(level > 1) then
call SetUnitScale(dummy,0.2 + i * I2R(level) * 0.1,0.2 + i * I2R(level) * 0.1,0.2 + i * I2R(level) * 0.1)
elseif (level == 1) then
call SetUnitScale(dummy,0.2 + i * I2R(level) * 0.15,0.2 + i * I2R(level) * 0.15,0.2 + i * I2R(level) * 0.15)
endif
set i=i+1.0
endloop
if(GetUnitUserData(dummy) != 1) then
call UnitRemoveAbility(u,'A045')
call UnitAddAbility(u,'A043')
call SetUnitAbilityLevel(u,'A043',level)
endif
call RemoveUnit(dummy)
set dummy = null
set u = null
call DestroyTrigger(t)
call TriggerRemoveAction(t,ta)
call TriggerRemoveCondition(t,tc)
endfunction
//===========================================================================
function InitTrig_Transfer_Energy takes nothing returns nothing
set gg_trg_Transfer_Energy = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg_trg_Transfer_Energy, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition( gg_trg_Transfer_Energy, Condition( function Trig_Transfer_Energy_Conditions ) )
call TriggerAddAction( gg_trg_Transfer_Energy, function Trig_Transfer_Energy_Actions )
endfunction
this code suppose to create something and if the caster moves delete it, everything works fine exept for the deleting the unit part.
if you find leaks please tell me about them also
Last edited: