• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] trigger not firing

Status
Not open for further replies.
umm can anyone tell me y this isnt firing it was working b4 but im not sure y it stopped working i dont think i edited anything on it in a while thx

here is the trigger tht starts the random events number 3 is the trigger in question
JASS:
function Trig_Timer_Expires_Actions takes nothing returns nothing
    local integer r 
    local integer LoopR = 1
    local real x
    local real y
    local integer L = 0
    set r = GetRandomInt(3, 3)
    set udg_Income_Boolean_Player[0] = false
    set udg_Income_Boolean_Player[1] = false
        call PolledWait( 0.05 )
        call PauseTimer( udg_Random_Events_Timer )
        call TimerDialogDisplayBJ( false, udg_Random_Events_Timer_Window )
        call PauseAllUnitsBJ( true )
    if ( r == 1 ) then
        //checkers
        set x = GetRectCenterX(gg_rct_Checkers_B4)
        set y = GetRectCenterY(gg_rct_Checkers_B4)
    elseif ( r == 2 ) then
        // checkers 
        set x = GetRectCenterX(gg_rct_Checkers_B4)
        set y = GetRectCenterY(gg_rct_Checkers_B4)
    elseif ( r == 3 ) then
        // plus sign random 
        set x = GetRectCenterX(gg_rct_Plus_Sign_Center)
        set y = GetRectCenterY(gg_rct_Plus_Sign_Center)
        set udg_Random_Plus_Sign_Counter = 0
        call SetUnitX( Selected_Hero_Player[0], x )
        call SetUnitY( Selected_Hero_Player[0], y )
        call SetUnitX( Selected_Hero_Player[1], x )
        call SetUnitY( Selected_Hero_Player[1], y )
        call PauseUnitBJ( false, Selected_Hero_Player[0] )
        call PauseUnitBJ( false, Selected_Hero_Player[1] )
        loop
            exitwhen LoopR > 24
            call PauseUnit( LightningUnit[LoopR], false )
            set LoopR = LoopR + 1
        endloop
        call PolledWait( 0.50 )
        call EnableTrigger( trg_Plus_Sign_Random[1] )
        call EnableTrigger( trg_Plus_Sign_Random_Kill[1] )
        call EnableTrigger( trg_Plus_Sign_Random_Kill[2] )
        call EnableTrigger( trg_Plus_Sign_Random_Kill[3] )
    elseif ( r == 4 ) then
        set x = GetRectCenterX(gg_rct_Life_or_Death_Random)
        set y = GetRectCenterY(gg_rct_Life_or_Death_Random)
        call SetUnitState( Life_or_Death_Units[9], UNIT_STATE_LIFE, 100.00 )
        call SetUnitState( Life_or_Death_Units[10], UNIT_STATE_LIFE, 100.00 )
        loop
            exitwhen LoopR > 10
            call PauseUnit( Life_or_Death_Units[LoopR], false )
            set LoopR = LoopR + 1
        endloop
        call EnableTrigger( trg_Life_or_Death_Changing )
        call EnableTrigger( trg_Life_or_Death_Checking )
    elseif ( r == 5 ) then
        set x = GetRectCenterX(gg_rct_Portal_Jumping_Spawn_Point)
        set y = GetRectCenterY(gg_rct_Portal_Jumping_Spawn_Point)
        call PauseUnit( gg_unit_h00C_0110, false )
        call TriggerExecute( trg_Portal_Jumping )
    endif

    loop
        exitwhen L > 5
        call PanCameraToTimedForPlayer( Player(L), x, y, 0.00 )
        set L = L + 1
    endloop
    
    call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_ZOFFSET, 1500.00, 0 )
    call SetCameraFieldForPlayer( Player(1), CAMERA_FIELD_ZOFFSET, 1500.00, 0 )
endfunction

//===========================================================================
function InitTrig_Timer_Expires takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerExpireEventBJ( t, udg_Random_Events_Timer )
    call TriggerAddAction( t, function Trig_Timer_Expires_Actions )
    set t = null
endfunction
this one moves the units on the map
JASS:
globals 
    integer Random_Plus_Sign_Counter = 0 // used in Plus Sign Random (1,2,3) Triggers 
    boolean array Lightning_Boolean
    trigger array trg_Plus_Sign_Random
    trigger array trg_Plus_Sign_Random_Kill
endglobals

function Trig_Plus_Sign_Random_1_Actions takes nothing returns nothing
    local rect randomloc1 = (gg_rct_Random_1_for_cross_random)
    local rect randomloc2 = (gg_rct_Random_2_for_cross_random)
    local real cross_center_y = GetRandomReal(GetRectMinY(randomloc1), GetRectMaxY(randomloc1)) // use for center
    local real cross_center_x = GetRandomReal(GetRectMinX(randomloc2), GetRectMaxX(randomloc2)) // use for center
    local real array cross1_rx
    local real array cross1_ry
    local lightning array LightningEffect
    set cross1_rx[0] = GetRandomReal(GetRectMinX(randomloc1), GetRectMaxX(randomloc1)) //used for gg_rct_Random_1a_for_cross_random
    set cross1_ry[0] = GetRandomReal(GetRectMinY(randomloc2), GetRectMaxY(randomloc2)) //used for gg_rct_Random_1a_for_cross_random
    call MoveRectTo( gg_rct_Random_1a_for_cross_random, cross1_rx[0], cross_center_y )
    call MoveRectTo( gg_rct_Random_1a_for_cross_random, cross_center_x, cross1_ry[0] )
    //  
    // offset units facing 0 degrees
    //  
    set cross1_rx[1] = cross1_rx[0] + 987.50 // east x value
    set cross1_rx[2] = cross1_rx[0] + 493.75 // east x value
    //  
    // offset units facing 180 degrees
    //  
    set cross1_rx[3] = cross1_rx[0] - 987.50 // west x value
    set cross1_rx[4] = cross1_rx[0] - 493.75 // west x value 
    //  
    // offset units facing 90 degrees
    //  
    set cross1_ry[1] = cross1_ry[0] + 987.50 // north y value
    set cross1_ry[2] = cross1_ry[0] + 493.75 // north y value
    //  
    // offset units facing 270 degrees
    //  
    set cross1_ry[3] = cross1_ry[0] - 987.50 // south y value
    set cross1_ry[4] = cross1_ry[0] - 493.75 // south y value
    //  
    // units at center
    //  
    // Making Units move to the random point selected w offseting specified above
    //  
    // unit offset moving units = 180 degrees
    //  
    call SetUnitPosition( LightningUnit[1], cross1_rx[3], cross_center_y )
    call IssuePointOrder( LightningUnit[1], "patrol", cross1_rx[4], cross_center_y )
    //  
    call SetUnitPosition( LightningUnit[2], cross1_rx[4], cross_center_y )
    call IssuePointOrder( LightningUnit[2], "patrol", cross1_rx[0], cross_center_y )
    //  
    // unit offset moving units = 0 degrees
    //  
    call SetUnitPosition( LightningUnit[3], cross1_rx[1], cross_center_y )
    call IssuePointOrder( LightningUnit[3], "patrol", cross1_rx[2], cross_center_y )
    //  
    call SetUnitPosition( LightningUnit[4], cross1_rx[2], cross_center_y )
    call IssuePointOrder( LightningUnit[4], "patrol", cross1_rx[0], cross_center_y )
    //  
    // unit offset moving units = 270 degrees
    //  
    call SetUnitPosition( LightningUnit[5], cross_center_x, cross1_ry[3] )
    call IssuePointOrder( LightningUnit[5], "patrol", cross_center_x, cross1_ry[4] )
    //  
    call SetUnitPosition( LightningUnit[6], cross_center_x, cross1_ry[4] )
    call IssuePointOrder( LightningUnit[6], "patrol", cross_center_x, cross1_ry[0] )
    //  
    // unit offset moving units = 90 degrees
    //  
    call SetUnitPosition( LightningUnit[7], cross_center_x, cross1_ry[1] )
    call IssuePointOrder( LightningUnit[7], "patrol", cross_center_x, cross1_ry[2] )
    //  
    call SetUnitPosition( LightningUnit[8], cross_center_x, cross1_ry[2] )
    call IssuePointOrder( LightningUnit[8], "patrol", cross_center_x, cross1_ry[0] )
    //  
    // starting lightning effects
    //  
    set LightningEffect[0] = AddLightning( "CLPB", true, cross1_rx[1], cross_center_y, cross1_rx[3], cross_center_y )
    set LightningEffect[1] = AddLightning( "CLPB", true, cross_center_x, cross1_ry[1], cross_center_x, cross1_ry[3] )
    call PolledWait( 3.00 )
    set Lightning_Boolean[1] = true
    call DestroyLightning( LightningEffect[0] )
    call DestroyLightning( LightningEffect[1] )
    set LightningEffect[0] = AddLightning("AFOD", true, cross1_rx[1], cross_center_y, cross1_rx[3], cross_center_y )
    set LightningEffect[1] = AddLightning("AFOD", true, cross_center_x, cross1_ry[1], cross_center_x, cross1_ry[3] )
    call PolledWait( 2.50 )
    set Lightning_Boolean[1] = false
    call DestroyLightning( LightningEffect[0] )
    call DestroyLightning( LightningEffect[1] )
    set Random_Plus_Sign_Counter = Random_Plus_Sign_Counter + 1
    if ( Random_Plus_Sign_Counter == 5 ) then
        call EnableTrigger( trg_Plus_Sign_Random[2] )
    elseif ( Random_Plus_Sign_Counter == 10 ) then
        call EnableTrigger( trg_Plus_Sign_Random[3] )
    endif
endfunction

//===========================================================================
function InitTrig_Plus_Sign_Random_1 takes nothing returns nothing
    set trg_Plus_Sign_Random[1] = CreateTrigger()
    call DisableTrigger( trg_Plus_Sign_Random[1] )
    call TriggerRegisterTimerEvent( trg_Plus_Sign_Random[1], 6.00, true )
    call TriggerAddAction( trg_Plus_Sign_Random[1], function Trig_Plus_Sign_Random_1_Actions )
endfunction
this one is supposed to kill the units but it doesnt work anymore ?
JASS:
function Trig_Plus_Sign_Random_Kill_Trigger_1_Actions takes nothing returns nothing
    local real x
    local real y
    local integer Loop1 = 1
    local integer triggerplayer
    call DisplayTextToForce( GetPlayersAll(), " fires" )
    if ( (GetTriggerPlayer() == Player(0)) or (GetTriggerPlayer() == Player(1)) ) and (Lightning_Boolean[1] == true)  then
        set triggerplayer = GetPlayerId( GetTriggerPlayer())
        if ( triggerplayer == 0 ) then
            call DisplayTextToForce( GetPlayersAll(), "Player 2 Has Won The Minigame" )
        elseif ( triggerplayer == 1 ) then
            call DisplayTextToForce( GetPlayersAll(), "Player 1 Has Won The Minigame" )
        endif
        call DisableTrigger( trg_Plus_Sign_Random_Kill_Trigger[1] )
        call DisableTrigger( trg_Plus_Sign_Random_Kill_Trigger[2] )
        call DisableTrigger( trg_Plus_Sign_Random_Kill_Trigger[3] )
        call DisableTrigger( trg_Plus_Sign_Random[1] )
        call DisableTrigger( trg_Plus_Sign_Random[2] )
        call DisableTrigger( trg_Plus_Sign_Random[3] )
        call PolledWait( 7.00 )
        loop
            exitwhen Loop1 > 24
            call SetUnitPosition( LightningUnit[Loop1], LightningUnit_X[Loop1], LightningUnit_Y[Loop1] )
            set Loop1 = Loop1 + 1
        endloop
        set Lightning_Boolean[1] = false
        set Lightning_Boolean[2] = false
        set Lightning_Boolean[3] = false
        call ResumeTimer( udg_Random_Events_Timer )
        call TimerDialogDisplay( udg_Random_Events_Timer_Window, true )
    endif
endfunction

//===========================================================================
function InitTrig_Plus_Sign_Random_Kill_Trigger_1 takes nothing returns nothing
    set trg_Plus_Sign_Random_Kill_Trigger[1] = CreateTrigger(  )
    call TriggerRegisterUnitInRange( trg_Plus_Sign_Random_Kill_Trigger[1], LightningUnit[1], 125.00, null )
    call TriggerRegisterUnitInRange( trg_Plus_Sign_Random_Kill_Trigger[1], LightningUnit[2], 125.00, null )
    call TriggerRegisterUnitInRange( trg_Plus_Sign_Random_Kill_Trigger[1], LightningUnit[3], 125.00, null )
    call TriggerRegisterUnitInRange( trg_Plus_Sign_Random_Kill_Trigger[1], LightningUnit[4], 125.00, null )
    call TriggerRegisterUnitInRange( trg_Plus_Sign_Random_Kill_Trigger[1], LightningUnit[5], 125.00, null )
    call TriggerRegisterUnitInRange( trg_Plus_Sign_Random_Kill_Trigger[1], LightningUnit[6], 125.00, null )
    call TriggerRegisterUnitInRange( trg_Plus_Sign_Random_Kill_Trigger[1], LightningUnit[7], 125.00, null )
    call TriggerRegisterUnitInRange( trg_Plus_Sign_Random_Kill_Trigger[1], LightningUnit[8], 125.00, null )
    call TriggerAddAction( trg_Plus_Sign_Random_Kill_Trigger[1], function Trig_Plus_Sign_Random_Kill_Trigger_1_Actions )
endfunction
 
Last edited:
Level 6
Joined
Nov 24, 2012
Messages
218
ya everything is the right way i think i dont get any syntax errors and the trigger name is a trigger array variable

If it is a variable, shouldn't
JASS:
set trg_Plus_Sign_Random_Kill_Trigger[1] = CreateTrigger()
be something like
JASS:
set udg_Plus_Sign_Random_Kill_Trigger[1] = CreateTrigger()
???
Unless you have this somewhere else, but you didn't post:
JASS:
globals
    trigger trg_UrTriggers = udg_UrTriggers
endglobals
 
Level 6
Joined
Nov 24, 2012
Messages
218
If it's not variable editor, then where is this variable,
trg_Plus_Sign_Random_Kill_Trigger, created?
There has to be somewhere, a globals or locals block where it's created???
Well, since you're not getting syntax error, I would assume so.

Is there something disallowing you from doing this?
JASS:
function InitTrig_Plus_Sign_Random_Kill_Trigger_1 takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterUnitInRange(t, LightningUnit[1], 125.00, null)...etc
    call TriggerAddAction(t, function Trig_Plus_Sign...Actions)
    set t = null
endfunction
 
Level 6
Joined
Nov 24, 2012
Messages
218
Okay, look here. Took me 10 seconds after I opened map. Lmao.
The trigger name of the suspected culprit is : Plus_Sign_Random_Kill_Trigger_1
You initialised it as: function InitTrig_Plus_Sign_Random_Kill_1 takes nothing returns nothing <-- Where is "_Trigger_"?
Edit: Weird thing is, the version you posted for us to inspect is correct... how did this happen?
Edit2: Screenied the test, it works, since it fired. http://i48.tinypic.com/ob05za.png You gave us the correct code T_T
 
Level 6
Joined
Nov 24, 2012
Messages
218
Yeah I know, all I tested for is if that trigger runs.
Result: It runs.

Why it's not working:
Something is bugging up InRange events.
I made a periodic cinematic ping on all LightningUnit[LoopA], and it works perfectly.
They are getting indexed correctly...

Edit: I can only imagine TriggerRegisterUnitInRangeSimple only allows for preset units.
 
Level 6
Joined
Nov 24, 2012
Messages
218
Temporary Fix:
Delete all events and add events through another trigger function:
JASS:
    call TriggerRegisterUnitInRangeSimple( trg_Plus_Sign_Random_Kill[1], 125, LightningUnit[1])
    call TriggerRegisterUnitInRangeSimple( trg_Plus_Sign_Random_Kill[1], 125, LightningUnit[2])
    //etc
Also, it's spamming fires because they are running into range of each other.
 
Level 6
Joined
Nov 24, 2012
Messages
218
Did tht work when u tried adding them from another trigger ? If it does thx if not ill try it tomorrow lol thx for ur help

Make a trigger [TempFix]
JASS:
function TempFix_Actions takes nothing returns nothing
    local integer i = 0
    loop
        call TriggerRegisterUnitInRangeSimple(trg_Plus_Sign_Random_Kill[1], 125, LightningUnit[i])
        exitwhen i > 8
        set i = i + 1
    endloop
    call DisplayTextToForce(GetPlayersAll(), "Events Added" )
endfunction
//===========================================================================
function InitTrig_TempFix takes nothing returns nothing
    local trigger t = CreateTrigger( )
    call TriggerRegisterTimerEventSingle(t , 3)
    call TriggerAddAction(t , function TempFix_Actions)
    set t = null
endfunction
Also remove events from the other trigger. Yeah it worked while testing. Spammed fires a lot though since they are colliding with each other.
I hope this is fixed, it appears that way at the moment. The mini-game never ends though, and the player doesn't die for colliding, just says "Fires".
Anyways, no problem for helping, I actually hardly knew any jass before starting to help you here. I learned a lot too.
Look like a very interesting TD/mini-game map btw =P.

EDIT: Steps to fixing the trigger.
1 - InitTrig function must match trigger name (just take the word Trigger out of the trigger [Plus Sign Random Kill Trigger 1], leave code as is)
2 - Paste in TempFix (trigger must be named TempFix) , I tried otherwise and it won't work ??? You may have thought otherwise since changing trigger name automatically changes InitTrig code inside.
 
Last edited:
Ok lol ill have to try it after work thx a lot lol and glad u think it looks interesting its my first map haha also plan on making it 4 players but I just started w 2 lol gonna add on the other 2 in a while I guess I'll also switch it over to vjass and hop I don't run into the same problem but ur fix should work great thx lol ill have to fix the dying and tht soon also thx tho hopefull ill be able to try it after work lol thx a lot for the time u spent on it and I'm new to jass also lol learning vjass tho since its a lot better if u ever need help on something just ask hopefully ill be able to return the help lol
 
Last edited:
You misunderstood me and the problem is just what I said.

The parameters of jass functions are used as "value" and not as "variable". For instance, this initialization is wrong :

JASS:
globals
    unit TheUnit = null
    trigger TheTrig = null
endglobals

function InitTrig takes nothing returns nothing
    set TheTrig=CreateTrigger()
    call TriggerRegisterUnitInRangeSimple(TheTrig, 125, TheUnit)
    set TheUnit=CreateUnit(Player(0), 'hfoo', 0, 0, 0)
endfunction

It won't work because the unit registered for the event is "null", and not any unit the variable may be after the initialization. That's why you have to set the variable before you add the events.

EDIT : Yeah, HesitationSnow's solution works, but it's smarter to add the events in the same trigger you set the units.
 
Level 6
Joined
Nov 24, 2012
Messages
218
He set the units in this gigantic globals block in an init trigger. Would it be hiding too much if added the events in this?
Its in separate trigger folders and seems like it can be easily lost or forgotten about.
But I do see what u mean, it would be better to addevent in an init function rather than making 2 more functions, that and I see now tempfix only needs 1 function if ran on init.
Well , i did call it tempfix because i had a feeling there were probably better ways,here they are.
 
yes but u missed what i said earlier tirlititi the units arent null because they r set in an earlier run trigger the trigger in question is only run after the units r set

and ya im splitting up the unit spawn trigger to the other triggers i didnt know u could have multiple globals blocks till after i made tht and i just didnt get around to it yet
 
Last edited:
Status
Not open for further replies.
Top