Warcraft III resources & community, 2003–2006 · archived

My special effects wont DIE!

3 posts
#1

My special effects wont DIE!

I have completed my second spell, but it wont kill the special effects. It justs leaves them there... Even though i have a destroying function.

Why dont they die???

One function that doesnt remove sfx (Its not the variable passing)

function SkyFinishPortion takes nothing returns nothing
local effect Morbid82 = GetHandleEffect(GetExpiredTimer(), "FrozenSfx2150")
local unit FOG = GetHandleUnit(GetExpiredTimer(), "FOGCurrent2150")
call SetUnitMoveSpeed(FOG, (GetUnitDefaultMoveSpeed(FOG)))
call DestroyEffect(Morbid82)
set FOG = null
set Morbid82 = null
endfunction



function EarthPortion takes real painful, real range, integer maxama, location targpos, unit casterunit returns nothing
local location array TargetPoint
local effect array DestroEff
local integer lvl = GetHandleInt(GetTriggeringTrigger(), "levelism")
local real TargposX = GetLocationX(targpos)
local real TargposY = GetLocationY(targpos)
local real RanX = 0.00
local real RanY = 0.00
local real Twait = 0.00
local real Mawait = (0.80 / I2R(lvl))
local real Miwait = (0.20 / I2R(lvl))
local integer CountA = 0
local unit FOG
local group TotalTargs
local location BlackLoc
local player owner = GetOwningPlayer(casterunit)
set TotalTargs = GetUnitsInRangeOfLocAll(range, targpos)
loop
 exitwhen(CountA == maxama)
 set RanX = (GetRandomReal((range / 10), (range)))
 set RanY = (GetRandomReal((range / 10), (range)))
 set TargetPoint[CountA] = Location((RanX + TargposX), (RanY + TargposY))
 call AddSpecialEffectLoc("Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathTargetArt.mdl", TargetPoint[CountA])
 set DestroEff[CountA] = GetLastCreatedEffectBJ()
 set TotalTargs = GetUnitsInRangeOfLocAll(range, TargetPoint[CountA])
 set FOG = FirstOfGroup(TotalTargs)
  if(IsUnitAliveBJ(FOG) == true) then
   if(IsUnitEnemy(FOG, owner) == true) then
   call UnitDamageTargetBJ(casterunit, FOG, painful, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL)
   endif
  endif
set Twait = (GetRandomReal(Miwait, Mawait))
call TriggerSleepAction(Twait)
call DestroyEffectBJ(DestroEff[CountA])
set DestroEff[CountA] = null
set CountA = (CountA + 1)
endloop
endfunction


Its so weird... they just stay as if nothing was happening... And i dont get why, its not a variable problem...??? Jass is weird O_o
#2
The function GetLastCreatedEffectBJ only works if you created the effect usinga BJ function. That is, AddSpecialEffectBJ or AddSpecialEffectTargetBJ.
But I don't recommend using those function. I'd rather save the effect directly in a local:

// This is where you create the effect
 set TargetPoint[CountA] = Location((RanX + TargposX), (RanY + TargposY)) 
 call AddSpecialEffectLoc("Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathTargetArt.mdl", TargetPoint[CountA])
set DestroEff[CountA] = GetLastCreatedEffectBJ() 

// Instead: do this:
set DestroEff[CountA] = AddSpecialEffect("Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathTargetArt.mdl", (RanX + TargposX), (RanY + TargposY))

Note that I also replaced AddSpecialEffectLoc with AddSpecialEffect. It would still work using locations, but it is better to use the coordinates when possible.
#3
Dam, you know what you're doing! I didint realize i could call something from a set-var outside of initializing the locals, thats very useful to know! Thank you again ^,^.