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. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    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 Running two times

Discussion in 'Triggers & Scripts' started by Saishy, Jan 29, 2009.

  1. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    I think this trigger is running two times or at least, when I use the spell on terrain, appear two units and double inferno spell.

    Code (vJASS):
    scope Ginto initializer InitTrig_Ginto

    globals
        private player tplayer
    endglobals

    function Trig_Ginto_Conditions takes nothing returns boolean
        return (GetSpellAbilityId() == 'A03T')
    endfunction

    private function IsEnemy takes nothing returns boolean
        return ( (IsUnitEnemy(GetFilterUnit(), tplayer)) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.449 )
    endfunction

    function Trig_Ginto_Actions takes nothing returns nothing
        local unit tempunit
        local unit cage
        local unit caster
        local group tgroup = CreateGroup()
        local real tpx
        local real tpy
        local real tr
        local real tx
        local real ty
        local location tloc
       
        set tplayer = GetOwningPlayer(GetTriggerUnit())
           
        if ( IsUnitAliveBJ(GetSpellTargetUnit()) and IsUnitEnemy(GetSpellTargetUnit(), tplayer) ) then
            set tpx = GetUnitX(GetSpellTargetUnit())
            set tpy = GetUnitY(GetSpellTargetUnit())
            set tempunit = GetSpellTargetUnit()
            set cage = CreateUnit(tplayer, 'h00Y', tpx, tpy, 90.00)
            set caster = CreateUnit(tplayer, 'h00B', tpx, tpy, 90.00)
            call UnitApplyTimedLife(cage, 'BTLF', 1.00)
            call UnitApplyTimedLife(caster, 'BTLF', 1.00)
            call SetUnitAbilityLevel(caster, 'A03U', 1)
            call IssueTargetOrder(caster, "firebolt", tempunit)
            call SetUnitVertexColorBJ( tempunit, 100, 100, 100, 100.00 )
            call SetUnitVertexColorBJ( cage, 40, 40, 100, 10.00 )
            call PolledWait2(1.00)
            call SetUnitVertexColorBJ( tempunit, 100, 100, 100, 0.00 )
        else    
            set tloc = GetSpellTargetLoc()
            set tpx = GetLocationX(tloc)
            set tpy = GetLocationY(tloc)
            call RemoveLocation(tloc)
           
            if (GetSpellTargetUnit() != GetTriggerUnit()) then
                set caster = CreateUnit(tplayer, 'h00E', tpx, tpy, 90.00)
                call IssuePointOrder(caster, "dreadlordinferno", tpx, tpy)
                call UnitApplyTimedLife(caster, 'BTLF', 1.00)
                set cage = CreateUnit(tplayer, 'h010', tpx, tpy, GetRandomReal(0,360))
                call SetUnitVertexColorBJ( cage, 5, 5, 90, 60.00 )
                call UnitApplyTimedLife(cage, 'BTLF', 1.00)
            else
                call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl", tpx, tpy))
                call GroupEnumUnitsInRange(tgroup, tpx, tpy, 350, Condition(function IsEnemy))
                set caster = GetTriggerUnit()
               
                loop
                    set tempunit = FirstOfGroup(tgroup)
                    exitwhen tempunit == null
                    set tx = GetUnitX(tempunit)
                    set ty = GetUnitY(tempunit)
                    set tr = bj_RADTODEG * Atan2(ty - tpy, tx - tpx)
                    call KnockbackTarget(caster, tempunit, tr, 200, 10, false,  false, false)
                    call GroupRemoveUnit(tgroup, tempunit)
                endloop
               
                call DestroyGroup(tgroup)
            endif
        endif
       
        set tempunit = null
        set cage = null
        set caster = null
    endfunction

    //===========================================================================
    function InitTrig_Ginto takes nothing returns nothing
        set gg_trg_Ginto = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Ginto, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( gg_trg_Ginto, Condition( function Trig_Ginto_Conditions ) )
        call TriggerAddAction( gg_trg_Ginto, function Trig_Ginto_Actions )
    endfunction

    endscope
     
  2. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,149
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    Uh... if the thing is for whenever something casts a spell and your newly spawned units are casting spells....

    and your else statements and what not.

    I haven't looked at it thoroughly hard, but that's what I see thus far ^^
     
  3. Saishy

    Saishy

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

    Sorry, can't understand :(
     
  4. HINDYhat

    HINDYhat

    Joined:
    Apr 22, 2007
    Messages:
    1,594
    Resources:
    3
    Maps:
    2
    Spells:
    1
    Resources:
    3
    Maybe because you're using a scope initializer and the traditional method for initializing trigger (InitTrig_<yourTriggerName>)? Not sure, though.
     
  5. Saishy

    Saishy

    Joined:
    Mar 23, 2008
    Messages:
    947
    Resources:
    0
    Resources:
    0
    :grin:

    I came to post that I found that xD

    *blush*