HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

AddSpecialEffect and GetLasCreatedEffectBJ

08-21-2007, 07:19 PM#1
Castlemaster
I'm still trying to learn all the JASS commands. I've made a loop that will create a circle of a special effect.

Collapse JASS:
function Trig_Ring_of_Blood_Begin_Actions takes nothing returns nothing
    local real centerX = udg_RingofBloodCenterX
    local real centerY = udg_RingofBloodCenterY
    local integer i = 0
    local real angle
    local real newlength
    if udg_RingofBloodTempCount > 20 then
        call DisableTrigger(GetTriggeringTrigger())
    endif
    loop
        exitwhen i > 36
        set angle = (i*10)
        set newlength = (udg_RingofBloodTempCount*25)
// focus on this part, the rest works fine
        call DestroyEffect(udg_RingofBloodSE[i])
        call AddSpecialEffect( "Abilities\\Spells\\Orc\\TrollBerserk\\HeadhunterWEAPONSLeft.mdl", NewPositionX(newlength, angle, centerX), NewPositionY(newlength, angle, centerY))
        set udg_RingofBloodSE[i] = GetLastCreatedEffectBJ()
        set i = i +1
    endloop
    set udg_RingofBloodTempCount = udg_RingofBloodTempCount+1
endfunction

This is in a periodic event trigger. Everything works fine, except the DestroyEffect() command won't destroy. I'm sure its because GetLastCreatedEffectBJ() doesn't store the special effect from AddSpecialEffect().

I intentionally put the destroy effect before the creation because when the trigger ends, I want the special effects to remain.

Thanks ahead of time.
08-21-2007, 07:22 PM#2
botanic
Um you have to destroy it after you use it... you cant do it before... Set a timer if you want the effect to stay
08-21-2007, 07:24 PM#3
TaintedReality
GetLastCreatedEffectBJ() only returns the last created effect if you used a BJ function to create the effect. Look at the BJ SFX creating function:

Collapse JASS:
function AddSpecialEffectLocBJ takes location where, string modelName returns effect
    set bj_lastCreatedEffect = AddSpecialEffectLoc(modelName, where)
    return bj_lastCreatedEffect
endfunction

And at GetLastCreatedEffectBJ():

Collapse JASS:
function GetLastCreatedEffectBJ takes nothing returns effect
    return bj_lastCreatedEffect
endfunction

You should just directly store the effect to your variable when you create it, rather than using GetLastCreatedEffectBJ(). Like this:

Collapse JASS:
set udg_RingofBloodSE[i] = AddSpecialEffect( "Abilities\\Spells\\Orc\\TrollBerserk\\HeadhunterWEAPONSLeft.mdl", NewPositionX(newlength, angle, centerX), NewPositionY(newlength, angle, centerY))

Botanic, he's destroying the effect from the previous time the trigger ran, then creating a new one.
08-21-2007, 07:26 PM#4
cohadar
Collapse JASS:
native AddSpecialEffect takes string modelName, real x, real y returns effect

Noticed that returns part?

Collapse JASS:
        set udg_RingofBloodSE[i] =  AddSpecialEffect( "Abilities\\Spells\\Orc\\TrollBerserk\\HeadhunterWEAPONSLeft.mdl", NewPositionX(newlength, angle, centerX), NewPositionY(newlength, angle, centerY))

EDIT:

heh, speed is everything :D
08-21-2007, 07:34 PM#5
botanic
yes but there will be one left over at the end is what i ment :/ he needs to add a line to remove the final effect as well
08-21-2007, 09:36 PM#6
Castlemaster
@tainted: Thanks. I'm still trying to learn those lesser things about JASS.

@botanic
Quote:
I intentionally put the destroy effect before the creation because when the trigger ends, I want the special effects to remain.

This is just one part of a spell. I don't need to destroy the effects on the last run.
08-21-2007, 10:41 PM#7
botanic
ah ok just making shure I am not super JASS man so i help with what i can :P