Code: Select all
function bool SetEndCams(string Reason) {
local pawn P, BestPawn; // *BestPawn* can also be a Bot; shared parent of (Bot, TournamentPlayer) is *Pawn*
local Actor EndViewTarget;
local bool bGoodEnd, bShutDownMusic;
local Actor A;
bGoodEnd = True;
bShutDownMusic = false;
// find individual winner
for (P = Level.PawnList; P != None; P = P.nextPawn)
{
// remove velocity and freeze player:
P.Velocity = vect(0,0,0);
P.Acceleration = vect(0,0,0);
P.SetPhysics(PHYS_None);
P.SetLocation(P.Location);
if (P.bIsPlayer && ((BestPawn == None) || (class'SharedCode'.static.RankComparePawns(P, BestPawn) > 0 )))
BestPawn = P;
}
if (Reason == "No Hunters")
{
bGoodEnd = False;
GameEndedMessage = "Hunting party eliminated!";
}
if ((RemainingTime == 0) && (TimeLimit >= 1))
{
bGoodEnd = False;
GameReplicationInfo.GameEndedComments = TimeOutMessage;
}
else
GameReplicationInfo.GameEndedComments = GameEndedMessage;
EndTime = Level.TimeSeconds + 3.0;
if (EndCam != None)
{
EndViewTarget = EndCam;
bEndCamDancers = false;
}
else
{
EndViewTarget = BestPawn;
// Shut down music if dancers are shown:
bShutDownMusic = bShutDownMusic || (bEndCamDancers && GameReplicationInfoSB(GameReplicationInfo).MonsterCount <= 0);
}
for (P = Level.PawnList; P != None; P = P.nextPawn )
{
if (PlayerPawn(P) != None )
{
if ( ! bTutorialGame)
PlayWinMessage(PlayerPawn(P), bGoodEnd);
if (P == EndViewTarget)
PlayerPawn(P).ViewTarget = None;
else
PlayerPawn(P).ViewTarget = EndViewTarget;
PlayerPawn(P).bBehindView = bEndCamBehindView;
PlayerPawn(P).bFixedCamera = bEndCamFixedCamera;
if (bShutDownMusic)
PlayerPawn(P).ClientSetMusic(Music'null48.null48', 0, 255, MTRAN_Fade);
//P.ClientGameEnded(); // Pawn.ClientGameEnded sends itself to state 'GameEnded'
}
P.GotoState('GameEnded');
}
if (bEndCamDancers && (DancersClass != "") && GameReplicationInfoSB(GameReplicationInfo).MonsterCount <= 0)
if (spawn(Class<Actor>(DynamicLoadObject(DancersClass, class'Class')), , , BestPawn.Location) == None)
Warn("function SetEndCams: could not spawn SBDancers-class '" $ DancersClass $ "'");
// clean up the end game screen, removes leftover monsters
foreach AllActors(class'Actor', A)
if (ThingFactory(A) != None && A.IsInState('Spawning'))
A.GotoState('Finished');
else if (ScriptedPawn(A) != None)
A.Destroy();
CalcEndStats();
logger(LOG_Debug, "SetEndCams", "leaving function");
return true;
}