• 🏆 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!

what's wrong with special effect behaviour

Status
Not open for further replies.
Level 3
Joined
Mar 10, 2018
Messages
32
I expect 10 green special effects of the same size.

(lua code)
JASS:
function spell()
    local trig = CreateTrigger()
    TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    TriggerAddAction(trig, function()
        if GetSpellAbilityId() ~= FourCC('A000') then return end

        local u = GetTriggerUnit()

        local sfs = {}
        for j=1,10,1 do
            print('iteration', j)

            sfs[j] = AddSpecialEffectTarget('Abilities\\Spells\\Orc\\SpiritLink\\SpiritLinkTarget.mdl', u, 'origin')
            --sfs[j] = AddSpecialEffect('Abilities\\Spells\\Orc\\SpiritLink\\SpiritLinkTarget.mdl', GetUnitX(u), GetUnitY(u))
           
            BlzSetSpecialEffectScale(sfs[j], 2)
            BlzSetSpecialEffectColor(sfs[j], 0, 255, 0)
        PolledWait(0.1)
       
        end
       
       
    end)
end

What I get is that they vary in scaling (despite that I set scaling to 2).
Also divine shield grew bigger for some reason.
upload_2020-11-28_14-39-7.png


The commented line works fine but it's not attached to the unit. How do I make this work?
(p.s. how do I highlight lua code, not vjass)
 

Attachments

  • testm.w3m
    16.9 KB · Views: 12
Level 18
Joined
Jan 1, 2018
Messages
728
The commented line works fine but it's not attached to the unit. How do I make this work?
Most special effect natives don't work if the effect attached to a unit, so you have to create effect at a location and periodically update its position to keep it 'attached' to the unit.

(p.s. how do I highlight lua code, not vjass)
[code=lua]
 
Level 3
Joined
Mar 10, 2018
Messages
32
Most special effect natives don't work if the effect attached to a unit, so you have to create effect at a location and periodically update its position to keep it 'attached' to the unit.


[code=lua]

Thanks! That will work for me.

I have another question. I used to use dummy units that served as special effects and once you RemoveUnit() it disappears instantly. However if I do similarly but with DestroyEffect(), the model won't disappear immediately, but only after it finished playing its animation till the end. Is it possible to interrupt animation and destroy effect immediately or I have to go back to dummy units?
 
Status
Not open for further replies.
Top