- Joined
- Jul 19, 2007
- Messages
- 824
I imported this spell from a spellpack and it seems to be workling like it should except one thing. The special effect unit isn't removed when the spell is over. How can I fix that?
JASS:
constant function TB_Damage_Base takes nothing returns real
return 75.0 //The base damage for the spell
endfunction
constant function TB_AoE takes nothing returns real
return 360.00 //The Area of Effect for the spell
endfunction
constant function TB_Text_Size takes nothing returns real
return 8.00 //The size of the floating text 'x'
endfunction
constant function TB_Text_Color_Red_Base takes nothing returns real
return 100.00 //The value of red to be used in the floationg text 'x'
endfunction
constant function TB_Text_Color_Green_Base takes nothing returns real
return 0.00 //The value of green to be used in the floationg text 'x'
endfunction
constant function TB_Text_Color_Blue_Base takes nothing returns real
return 0.00 //The value of blue to be used in the floationg text 'x'
endfunction
constant function TB_Text_Transparency takes nothing returns real
return 0.00 //The transparency of the floationg text 'x' (100% is invisible)
endfunction
constant function TB_Text_Velocity takes nothing returns real
return 92.5 //The speed in which the floationg text 'x' travels at
endfunction
constant function TB_Bomb_Duration_Base takes nothing returns integer
return 12 //The base value of waiting time before the boom
endfunction
constant function TB_SFX takes nothing returns string
return "war3mapImported\\void_Bomb_Portrait.mdx" //Created on the target unit's overhead.
endfunction
constant function TB_SFX_2 takes nothing returns string
return "war3mapImported\\Magical Explosion1.mdl" //Created on the target unit's origin.
endfunction
constant function TB_Ability_ID takes nothing returns integer
return 'A0L2' //Raw code of the ability "Timed Bomb"
endfunction
constant function TB_Animation_Dummy_ID_1 takes nothing returns integer
return 'u00T' //Raw code of the dummy unit "Timed Bomb Dummy Animation 1"
endfunction
constant function TB_Animation_Dummy_ID_2 takes nothing returns integer
return 'u00U' //Raw code of the dummy unit "Timed Bomb Dummy Animation 2"
endfunction
function Timed_Bomb_Filter takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405
endfunction
function Timed_Bomb_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local integer lvl = GetUnitAbilityLevel(u, TB_Ability_ID())
local real dmg = TB_Damage_Base() + lvl * 50.0
local integer Bomb_Duration = TB_Bomb_Duration_Base() - (lvl*2) //How much time to wait before the boom
local effect e = AddSpecialEffectTarget(TB_SFX(), t, "overhead")
local boolexpr b = Condition(function Timed_Bomb_Filter)
local group g = CreateGroup()
local boolean bo = true
local unit p
local texttag x
loop
exitwhen Bomb_Duration == 0
if GetWidgetLife(t) > 0.405 then //If unit t is not alive, then the loop/spell stops
set x = CreateTextTagUnitBJ(I2S(Bomb_Duration), t, 0, TB_Text_Size(), TB_Text_Color_Red_Base(), TB_Text_Color_Green_Base(), TB_Text_Color_Blue_Base(), TB_Text_Transparency())
call SetTextTagVelocityBJ(x, TB_Text_Velocity(), 90)
call SetTextTagPermanent(x, false)
call SetTextTagLifespan(x, 4.00)
call SetTextTagFadepoint(x, 2.25)
set Bomb_Duration = Bomb_Duration - 1
call TriggerSleepAction(1)
else
set Bomb_Duration = 0
call DestroyEffect(e)
set bo = false
endif
endloop
if bo == true then
call GroupEnumUnitsInRange(g, GetUnitX(t), GetUnitY(t), TB_AoE(), b)
loop
set p = FirstOfGroup(g)
exitwhen p == null
call GroupRemoveUnit(g, p)
call UnitDamageTarget(u, p, dmg, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
endloop
call CreateUnit(GetOwningPlayer(u), TB_Animation_Dummy_ID_1(), GetUnitX(t), GetUnitY(t), 0)
call UnitApplyTimedLife(GetLastCreatedUnit(), 'BTLF', 1.25)
call CreateUnit(GetOwningPlayer(u), TB_Animation_Dummy_ID_2(), GetUnitX(t), GetUnitY(t), 0)
call UnitApplyTimedLife(GetLastCreatedUnit(), 'BTLF', 1.25)
call DestroyEffect(AddSpecialEffectTarget(TB_SFX_2(), t, "origin"))
endif
call DestroyEffect(e)
call DestroyBoolExpr(b)
call DestroyGroup(g)
set u = null
set t = null
set e = null
set b = null
set g = null
set x = null
endfunction
function Timed_Bomb_Conditions takes nothing returns boolean
return GetSpellAbilityId() == TB_Ability_ID()
endfunction
function InitTrig_Timed_Bomb takes nothing returns nothing
set gg_trg_Timed_Bomb = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Timed_Bomb, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Timed_Bomb, Condition(function Timed_Bomb_Conditions))
call TriggerAddAction(gg_trg_Timed_Bomb, function Timed_Bomb_Actions)
call Preload(TB_SFX())
endfunction