55 lines
1.5 KiB
Ucode
55 lines
1.5 KiB
Ucode
// ACTION_WaitForPlayer succeds only if MyPlayerController.Pawn is nearby
|
|
// ACTION_WaitForAnyPlayer succeeds if any players are nearby
|
|
|
|
class ACTION_WaitForAnyPlayer extends ACTION_WaitForPlayer;
|
|
|
|
var(Action) float CheckTime; // how often to look for a player?
|
|
|
|
var ScriptedController MyScriptedController;
|
|
|
|
function bool InitActionFor(ScriptedController C)
|
|
{
|
|
MyScriptedController = C;
|
|
if ( CheckIfNearPlayer(C) )
|
|
return false;
|
|
C.CurrentAction = self;
|
|
C.SetTimer(fmax(CheckTime, 0.1),true);
|
|
return true;
|
|
}
|
|
|
|
|
|
function bool WaitForPlayer()
|
|
{
|
|
if ( MyScriptedController != none )
|
|
CheckIfNearPlayer(MyScriptedController); // update MyScriptedController.MyPlayerController
|
|
return true;
|
|
}
|
|
|
|
function bool CheckIfNearPlayer(ScriptedController SC)
|
|
{
|
|
local Controller C;
|
|
local PlayerController PC, BACKUP_MyPlayerController;
|
|
|
|
if ( SC.MyPlayerController != none && SC.MyPlayerController.Pawn != none && SC.CheckIfNearPlayer(Distance) )
|
|
return true;
|
|
|
|
BACKUP_MyPlayerController = SC.MyPlayerController;
|
|
|
|
for ( C = SC.Level.ControllerList; C != none; C = C.nextController ) {
|
|
PC = PlayerController(C);
|
|
if ( PC != none && PC.Pawn != none ) {
|
|
SC.MyPlayerController = PC;
|
|
if ( SC.CheckIfNearPlayer(Distance) )
|
|
return true;
|
|
}
|
|
}
|
|
// restore original MyPlayerController, if no players are nearby - just in case
|
|
SC.MyPlayerController = BACKUP_MyPlayerController;
|
|
return false;
|
|
}
|
|
|
|
defaultproperties
|
|
{
|
|
CheckTime=1.000000
|
|
}
|