my trigger gives fatal error why?

Evan1993

Ultra Cool Member
Reaction score
30
This gives me a fatal error, and I can't figure out why.

Code:
function IsBad takes nothing returns boolean
    return ( IsPlayerEnemy(GetFilterPlayer(), ConvertedPlayer(udg_Numb[1])) == true )
endfunction
function Attack takes nothing returns nothing
    call IssuePointOrderLocBJ( GetEnumUnit(), "attack", udg_Point )
    call DisplayTextToForce( GetPlayersAll(), ":O" )
endfunction
function Noworkers takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) != 'uaco' )
endfunction
function Trig_LaunchAttacks_Actions takes nothing returns nothing
    local location array l
    local integer i = GetRandomInt(1, 5)
    local integer start = 1
    local integer end = 12 
    local boolean stop
    local integer count = 0
    call DisplayTextToForce( GetPlayersAll(), ":O" )
    set l[1] = GetPlayerStartLocationLoc(Player(0))
    set l[2] = GetPlayerStartLocationLoc(Player(3))
    set l[3] = GetPlayerStartLocationLoc(Player(6))
    set l[4] = GetPlayerStartLocationLoc(Player(9))
    set l[5] = GetRectCenter(gg_rct_Region_001)
    loop
        exitwhen start > end
        set udg_Spawns[start] = GetUnitsOfPlayerMatching(ConvertedPlayer(start), Condition(function Noworkers))
        loop
            set udg_Numb[1] = start
            call DisplayTextToForce( GetPlayersAll(), I2S(CountUnitsInGroup(GetUnitsInRangeOfLocMatching(655.0, l[i], Condition(function IsBad)))))
            if CountUnitsInGroup(GetUnitsInRangeOfLocMatching(655.0, l[i], Condition(function IsBad))) == 0 then
                set i = GetRandomInt(1, 5)
                set stop = false
                call DisplayTextToForce( GetPlayersAll(), I2S(udg_Numb[1]))
            else
                call DisplayTextToForce( GetPlayersAll(), "Yes!" )
                set stop = true
            endif
            exitwhen stop == true
            set start = start + 1
        endloop
        set udg_Point = l[i]
        call ForGroupBJ( udg_Spawns[start], function Attack )
        call DisplayTextToForce( GetPlayersAll(), ":O" )
    endloop
endfunction

//===========================================================================
function InitTrig_LaunchAttacks takes nothing returns nothing
    set gg_trg_LaunchAttacks = CreateTrigger(  )
    call TriggerAddAction( gg_trg_LaunchAttacks, function Trig_LaunchAttacks_Actions )
endfunction
 

Sim

Forum Administrator
Staff member
Reaction score
534
set stop = true


In my opinion it never gets to be true, thus leading to an infinite loop. Recheck your if then else conditions.
 

Evan1993

Ultra Cool Member
Reaction score
30
No because when its like this it doesn't crash, it just never sends them no matter what.

Code:
function IsBad takes nothing returns boolean
    return ( IsPlayerEnemy(GetFilterPlayer(), ConvertedPlayer(udg_Numb[1])) == true )
endfunction
function Attack takes nothing returns nothing
    call IssuePointOrderLocBJ( GetEnumUnit(), "attack", udg_Point )
    call DisplayTextToForce( GetPlayersAll(), ":O" )
endfunction
function Noworkers takes nothing returns boolean
    return ( GetUnitTypeId(GetFilterUnit()) != 'uaco' )
endfunction										
function Trig_LaunchAttacks_Actions takes nothing returns nothing
    local location array l
    local integer i = GetRandomInt(1, 5)
    local integer start = 1
    local integer end = 12 
    local boolean stop
    local integer count = 0
    set l[1] = GetPlayerStartLocationLoc(Player(0))
    set l[2] = GetPlayerStartLocationLoc(Player(3))
    set l[3] = GetPlayerStartLocationLoc(Player(6))
    set l[4] = GetPlayerStartLocationLoc(Player(9))
    set l[5] = GetRectCenter(gg_rct_Region_001)
    loop
        exitwhen start > end
        set start = start + 1
        set udg_Spawns[start] = GetUnitsOfPlayerMatching(ConvertedPlayer(start), Condition(function Noworkers))
        loop
            set udg_Numb[1] = start
             call DisplayTextToForce( GetPlayersAll(), I2S(CountUnitsInGroup(GetUnitsInRangeOfLocMatching(655.0, l[i], Condition(function IsBad)))))
            if CountUnitsInGroup(GetUnitsInRangeOfLocMatching(655.0, l[i], Condition(function IsBad))) == 0 then
                set i = GetRandomInt(1, 5)
                set stop = false
                call DisplayTextToForce( GetPlayersAll(), I2S(udg_Numb[1]))
            else
                call DisplayTextToForce( GetPlayersAll(), "Yes!" )
                set stop = true
            endif
            exitwhen stop == true
        endloop
        set udg_Point = l[i]
        call ForGroupBJ( udg_Spawns[start], function Attack )
        call DisplayTextToForce( GetPlayersAll(), ":O" )
    endloop
endfunction

//===========================================================================
function InitTrig_LaunchAttacks takes nothing returns nothing
    set gg_trg_LaunchAttacks = CreateTrigger(  )
    call TriggerAddAction( gg_trg_LaunchAttacks, function Trig_LaunchAttacks_Actions )
endfunction
 

Sim

Forum Administrator
Staff member
Reaction score
534
It's exactly what I'm saying.

You need to change "set start = start + 1"'s spot in your loop in order for it not to crash. That means somewhere in the trigger it never reaches "set start = start + 1"

Since the "stop loop" depends on the start variable...

There's a problem in the loop (We can deduce) :p

Where exactly? That would be to see.
 

Duwenbasden

Ver 6 CREATE energy AS SELECT * FROM u.energy
Reaction score
165
if there is no enemy in the location all the time, this WILL cause an infinite loop.
 

Evan1993

Ultra Cool Member
Reaction score
30
I added a wait, and made SURE that there was units there and still it never attacked. I could tell by my debug messages that it never stoped looking for a place with units to attack.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top