• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] How to use local arrays in JASS correctly?

Status
Not open for further replies.
Level 3
Joined
Dec 7, 2012
Messages
52
Hi!
I need to create 5 special effects in different points on the unit, each effect to store in local variable (array) and then destroy all effects in my local array at the one time.
Should be something like that:
----------------------------------
local unit uCaster = GetSpellAbilityUnit()
local effect array eFrost
set eFrost[1]=AddSpecialEffectTarget("Abilities\\Weapons\\ZigguratFrostMissile\\ZigguratFrostMissile.mdl", uCaster, "hand left")
set eFrost[2]=AddSpecialEffectTarget("Abilities\\Weapons\\ZigguratFrostMissile\\ZigguratFrostMissile.mdl", uCaster, "hand right")

set eFrost[3]=AddSpecialEffectTarget("Abilities\\Weapons\\ZigguratFrostMissile\\ZigguratFrostMissile.mdl", uCaster, "head")
set eFrost[4]=AddSpecialEffectTarget("Abilities\\Weapons\\ZigguratFrostMissile\\ZigguratFrostMissile.mdl", uCaster, "origin")
set eFrost[5]=AddSpecialEffectTarget("Abilities\\Weapons\\ZigguratFrostMissile\\ZigguratFrostMissile.mdl", uCaster, "weapon")
call TriggerSleepAction(0.50)
call DestroyEffect(eFrost)

----------------------------------
But... i do something wrong!... How i can do this in JASS correctly?
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
If you're creating and destroying them at the same time, you can just do something like this:

JASS:
function CreateEffects takes nothing returns nothing
    local integer i = 0

    loop
        exitwhen i > 4
        call DestroyEffect(AddSpecialEffectTarget(string modelName, widget targetWidget, string attachPointName)
        set i = i + 1
    endloop

endfunction
 
Status
Not open for further replies.
Top