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

[JASS] Trigger only work first time

Status
Not open for further replies.
Level 12
Joined
Mar 23, 2008
Messages
942
Hi, I'm getting a strange issue with a trigger, it only work correctly the first time my unit cast the spell.

The spell should create 1 illusion for every level of the spell, it works the first time, many illusion are spawned, but them only one start to spawn every time I cast the spell.

JASS:
function Trig_Kage_Bushin_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A045' )
endfunction

function Trig_Kage_Bushin_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local integer ti = GetUnitAbilityLevel(caster, 'A045')
    local real x = GetUnitX(caster)
    local real y = GetUnitY(caster)
    local unit u
    
    set u = CreateUnit( GetOwningPlayer(caster), 'h00E', x, y, 0.00 )
    call UnitAddAbility( u, 'A044' )
    
    loop
        exitwhen 1 > ti
        call IssueTargetOrderById(u, 852274, caster)
        set ti = ti - 1
    endloop
    
    call UnitApplyTimedLife( u, 'BTLF', 1.00 )
    set caster = null
    set u = null
    call RemoveLocation(udg_temppoint)
endfunction

//===========================================================================
function InitTrig_Kage_Bushin takes nothing returns nothing
    set gg_trg_Kage_Bushin = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Kage_Bushin, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Kage_Bushin, Condition( function Trig_Kage_Bushin_Conditions ) )
    call TriggerAddAction( gg_trg_Kage_Bushin, function Trig_Kage_Bushin_Actions )
endfunction

Thanks in advance
 
Level 6
Joined
Jun 20, 2005
Messages
108
You're not creating the units inside the loop (as ppl arealdy pointed out), but you're also not setting the timed life inside the loop. That's how I think you want your spell (only the loop part):

JASS:
loop
    exitwhen 1 > ti
    set u = CreateUnit( GetOwningPlayer(caster), 'h00E', x, y, 0.00 )
    call UnitAddAbility( u, 'A044' )
    call IssueTargetOrderById(u, 852274, caster)
    call UnitApplyTimedLife( u, 'BTLF', 1.00 )
    set ti = ti - 1
endloop
 
Level 12
Joined
Mar 23, 2008
Messages
942
Because you're not creating the unit inside the loop. Can griffen's answer be any more obvious?

If you want to recycle dummies you must change casting time and animation time to 0

You may wanna change the phrase "I'm right you're wrong"...

Saishy said:
Because I have other spells that use the same dummy caster to cast it many times and never got problems :(

As you see, my dummy caster can cast many spells in short periods of time, the spell don't have either mana cost or casting time or even animation delay, also my unit don't have animation time, model or others things.
I also have another spell that fires 20 shock waves at the same time, and works.

That spell works if my unit spawn and DON'T move, It will always work, but as soon as I move it will stop working and only spawn 1 illusion, also at some specific points and facing angles the spell will work again.

That is why I'm interested, its not my first spell to do that, I had a bloodlust (just 1 cast) that didn't worked if my unit was facing west...

And please, do not awnser someone making it feel like a idiot.

@mecatronic the expiration timer outside the loop is just a safe, to not kill the dummy before it do everything.
 
Level 7
Joined
Jul 20, 2008
Messages
377
No, it shouldn't be working as is. In fact, I'm surprised it even works the first time. You're giving orders to an unit inside of a loop. There's not enough time for the dummy to finish casting the first time to cast the second time, and so on forth.

It makes sense that it only casts once subsequently, but what makes no sense to me is that it does it multiple times the first time.

You need to allow a delay for the dummy to cast again and again. Alternatively, you could make each level of the spell spawn a different number of illusions (in the ability editor) and then set the ability level of that dummy spell to the level of the main caster's spell.

Or yet again alternatively, create multiple dummies and have each of them cast it once.
 
Level 12
Joined
Mar 23, 2008
Messages
942
No, it shouldn't be working as is. In fact, I'm surprised it even works the first time. You're giving orders to an unit inside of a loop. There's not enough time for the dummy to finish casting the first time to cast the second time, and so on forth.

It makes sense that it only casts once subsequently, but what makes no sense to me is that it does it multiple times the first time.

You need to allow a delay for the dummy to cast again and again. Alternatively, you could make each level of the spell spawn a different number of illusions (in the ability editor) and then set the ability level of that dummy spell to the level of the main caster's spell.

Or yet again alternatively, create multiple dummies and have each of them cast it once.
Lol. Thanks for explaining.
There isn't a field to change the illusions spawned, so I will stick with the multiple dummies.

+rep to all and thanks ^^
 
Level 12
Joined
Mar 23, 2008
Messages
942
Why? Once again, I'm right, am I not? I you want to recycle dummies and use the same dummy to cast spells instantly, you have to make sure your spell is insta-cast, like I said.
No it isn't, it casting many times in a row because god wanna ¬¬
Please read the whole post lol, you are still missing something...


Thanks everyone! The spell is working fine. ^^
 
Status
Not open for further replies.
Top