//=============================================================================
// CounterZone.
// Put this zone info in a zone where you need to trigger something based on the number of players in that zone.
// Most immediate use would be a cage-match trap, where when enough players enter the zone, a triggered mover
// door shuts to trap the players in until someone dies. N men enter, N-1 men leave!
// Set the CounterZone properties to the number which triggers, and the event to trigger.
//=============================================================================
class CounterZone expands ZoneInfo;
var () int Threshold; // when number of players reaches this, trigger stuff
var() name ZoneCounterEvent; // fire this event when threshold is reached
// When an actor enters this zone.
event ActorEntered( actor Other )
{
local actor A;
Super.ActorEntered (Other); // do the parent behavior, which ticks the counter
if( Pawn(Other)!=None && Pawn(Other).bIsPlayer )if (ZonePlayerCount == Threshold && ZoneCounterEvent!='' )
{//log ("threshold reached");
foreach AllActors( class 'Actor', A, ZoneCounterEvent )A.Trigger( Self, Pawn(Other) );
}
}
// When an actor leaves this zone.
event ActorLeaving( actor Other )
{
local actor A;
Super.ActorLeaving (Other);
if( Pawn(Other)!=None && Pawn(Other).bIsPlayer )if (ZonePlayerCount == (Threshold-1) && ZoneCounterEvent!='' )
{//log ("below threshold");
foreach AllActors( class 'Actor', A, ZoneCounterEvent )A.UnTrigger( Self, Pawn(Other) );
}
}