1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. The results are out! Check them out.
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Trigger only work first time

Discussion in 'Triggers & Scripts' started by Saishy, Feb 3, 2009.

  1. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    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.

    Code (vJASS):
    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
     
  2. Captain Griffen

    Captain Griffen

    Joined:
    Nov 20, 2005
    Messages:
    1,001
    Resources:
    3
    Maps:
    3
    Resources:
    3
    Put the create unit within the loop...
     
  3. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    I'm really interested why this is not working always.

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

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    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
     
  5. mecatronic

    mecatronic

    Joined:
    Jun 20, 2005
    Messages:
    112
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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):

    Code (vJASS):
    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
     
  6. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    You may wanna change the phrase "I'm right you're wrong"...

    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.
     
  7. Captain Griffen

    Captain Griffen

    Joined:
    Nov 20, 2005
    Messages:
    1,001
    Resources:
    3
    Maps:
    3
    Resources:
    3
    Alternatively, it may be possible to use just one dummy, just remove Amov, make sure the spell is instant cast, 0 spell cast animation time, no mana cost, etc..
     
  8. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    Amov?

    o.o?

    Thanks for the awnser.

    The spell actually should be working if casted many times :(
     
  9. Soga-

    Soga-

    Joined:
    Jul 20, 2008
    Messages:
    374
    Resources:
    0
    Resources:
    0
    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.
     
  10. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    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 ^^
     
  11. Captain Griffen

    Captain Griffen

    Joined:
    Nov 20, 2005
    Messages:
    1,001
    Resources:
    3
    Maps:
    3
    Resources:
    3
    O rly?

    It's possible to setup a dummy such that it can simultaneously cast multiple times.
     
  12. Soga-

    Soga-

    Joined:
    Jul 20, 2008
    Messages:
    374
    Resources:
    0
    Resources:
    0
    And a very crude way to do it.
     
  13. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    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 so it can actually be cast instantly rather than "just fast", like I said.
     
  14. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    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. ^^
     
  15. Captain Griffen

    Captain Griffen

    Joined:
    Nov 20, 2005
    Messages:
    1,001
    Resources:
    3
    Maps:
    3
    Resources:
    3
    Most efficient...
     
  16. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    Since you two don't stop saying short phrases, I'm curious now xD
     
  17. Captain Griffen

    Captain Griffen

    Joined:
    Nov 20, 2005
    Messages:
    1,001
    Resources:
    3
    Maps:
    3
    Resources:
    3
    One of us knows what we're talking about, one of us doesn't. Go figure.