| 01-04-2003, 06:35 PM | #1 |
Guest | I have the following trigger, it's suppose to end a game when one team has no more units. But the game doesn't end. Basically, I check the food used from each player on the team, add them to together. If the value is 0, I give that team a defeat. Code:
function Trig_Game_End_Conditions takes nothing returns boolean
if ( not ( ( GetPlayerState(Player(0), PLAYER_STATE_RESOURCE_FOOD_USED) + ( GetPlayerState(Player(5), PLAYER_STATE_RESOURCE_FOOD_USED) + GetPlayerState(Player(7), PLAYER_STATE_RESOURCE_FOOD_USED) ) ) == 0 ) ) then
return false
endif
if ( not ( ( GetPlayerState(Player(1), PLAYER_STATE_RESOURCE_FOOD_USED) + ( GetPlayerState(Player(2), PLAYER_STATE_RESOURCE_FOOD_USED) + GetPlayerState(Player(9), PLAYER_STATE_RESOURCE_FOOD_USED) ) ) == 0 ) ) then
return false
endif
return true
endfunction
function Trig_Game_End_Func004002001 takes nothing returns boolean
return ( GetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_FOOD_USED) == 0 )
endfunction
function Trig_Game_End_Func004002 takes nothing returns nothing
if ( Trig_Game_End_Func004002001() ) then
call CustomDefeatBJ( GetEnumPlayer(), "TRIGSTR_161" )
else
call CustomVictoryBJ( GetEnumPlayer(), true, true )
endif
endfunction
function Trig_Game_End_Func005002001 takes nothing returns boolean
return ( GetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_FOOD_USED) == 0 )
endfunction
function Trig_Game_End_Func005002 takes nothing returns nothing
if ( Trig_Game_End_Func005002001() ) then
call CustomDefeatBJ( GetEnumPlayer(), "TRIGSTR_162" )
else
call CustomVictoryBJ( GetEnumPlayer(), true, true )
endif
endfunction
function Trig_Game_End_Actions takes nothing returns nothing
call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_160" )
call ForForce( udg_Force[1], function Trig_Game_End_Func004002 )
call ForForce( udg_Force[2], function Trig_Game_End_Func005002 )
endfunction
//===========================================================================
function InitTrig_Game_End takes nothing returns nothing
set gg_trg_Game_End = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Game_End, Player(0), EVENT_PLAYER_UNIT_DEATH )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Game_End, Player(5), EVENT_PLAYER_UNIT_DEATH )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Game_End, Player(7), EVENT_PLAYER_UNIT_DEATH )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Game_End, Player(1), EVENT_PLAYER_UNIT_DEATH )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Game_End, Player(2), EVENT_PLAYER_UNIT_DEATH )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_Game_End, Player(9), EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Game_End, Condition( function Trig_Game_End_Conditions ) )
call TriggerAddAction( gg_trg_Game_End, function Trig_Game_End_Actions )
endfunctionPlease help! |
| 01-04-2003, 07:05 PM | #2 |
try the other 2 food things - food cap and food max. cap might be it. Perhaps you should make the trigegr periodic, and see if that works. [edit] nevermind, your problem is that the conditions contradict each other. conditions are AND joined - this trigegr only fires when both team's food used is 0 ;) |
