Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

KFStoryGame.KF_StoryCheckPointVolume


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
/*
	--------------------------------------------------------------
	KF_StoryCheckPointVolume
	--------------------------------------------------------------

	Volume used to control spawning of players in story maps.

	When active, only those player starts inside the bounds of the volume are considered
	valid spawn points.  Can also be configured to force the respawn of dead (out of lives) players.

	Author :  Alex Quick

	--------------------------------------------------------------
*/


class KF_StoryCheckPointVolume extends  PhysicsVolume
	hidecategories(PhysicsVolume,Collision,Brush,Advanced,Force,Karma,Lighting,LightColor,Movement,Sound,Volume,Display,VolumeFog) ;


/* prints debug text */
var							bool						bDebugCheckpoint;

/* if true this checkpoint will begin play active */
var(StoryCheckPoint)		bool						bStartEnabled;

/* 	If true, touching (or triggering) this checkpoint will restart all dead players at one of the playerstarts inside the volume's bounds */
var(StoryCheckPoint)		bool						bRespawnPlayers;

/* If true, this scripted action will respawn bot players as well as humans . Only used if bRespawnPlayers is true*/
var(StoryCheckPoint)		bool						bIncludeBots;

/* true if CheckPointActivated() was called and this volume is the current spawn-checkpoint for players*/
var							bool						bIsActive;

/* if true, CheckPointActivated() will only be called when the entire team is inside the Volume */
var(StoryCheckPoint)		bool						bRequiresWholeTeam;

/* Only relevant if bRespawn players is true.  In addition to respawning dead players when Activated  this volume will also auto-respawn everyone when their whole team wipes out */
var(StoryCheckPoint)		bool						bRespawnOnWipe;

/* Event that triggers when a team that was wiped out is given a 'second chance' by this Volume. Only relevant if bRespawnOnWipe is true */
var(Events)					array<name>					SecondChanceEvents;

/* array of additional events this checkpoint can trigger for use in maps with complex trigger setups */
var(Events)					array<name>					ActivationEvents;

/* Delay before dead players are actually restarted after the Checkpoint activates */
var(StoryCheckPoint)		float						RespawnDelay;

/* %of Max Health a player spawns with when this checkpoint brings him back to life. */
var(StoryCheckPoint)		float						RespawnHealthModifier;

/* if true ,  'RespawnHealthModifier' becomes cumulative each time a player respawns at this checkpoint.  ie.  if a player dies twice with a value of 0.75,  his starting health would be 56*/
var(StoryCheckPoint)		bool						bCumulativeHealthModifier;

/* same as above, but used if the LD wants to reset only specific actors in the map */
var(Team_Restart)			array<actor>				CheckPointResetActors;

/* for cases where the LD wants to reset all actors in the map of a particular class *Except* some specific actors ..*/
var(Team_Restart)			array<actor>				ResetExcludeActors;


var                         name       					RestartFromObjective;

/* players who wipe out will respawn at this specific checkpoint, if assigned */
var(Team_Restart)			string						RestartFromCheckPoint;

/* Object reference to the CheckPoint who's name we specified above */
var							KF_StoryCheckPointVolume	ForcedRestartCheckPoint;

/* Removes all dropped / thrown weapon pickups from play when a team is restarted at this checkpoint */
var(Team_Restart)			bool						bRemoveDroppedWeapons;

/* true while the Respawn Timer is running but RespawnPlayers() has not yet been called */
var							bool						bPendingRespawn;

/* true while the team is wiped out completely and is waiting to be restarted from this checkpoint */
var							bool						bPendingFullRestart;

/* Spawned to control timing of Player respawns.  Necessary because volumes are Static & can't run their own timers */
var							RespawnTimer				RespawnDelayTimer;

/* Cached reference to the player who last activated this Checkpoint */
var							Controller					ActivatingPlayer;

/* Cached reference to the player who was last respawned by this Checkpoint */
var							Controller					LastRespawnedPlayer;

/* If true,  teleport stragglers to a playerstart inside this volume */
var(Stragglers)		        bool						bTeleportStragglers;

/* Max distance a player can be from this volume before being consider a straggler */
var(Stragglers)		       float						TeleportStragglerDist;

// if bTeleportStragglers, any living players not inside this volume will be teleported to a playerstart in the checkpoitn volume.
var(Stragglers)   const     Volume                      TeleportExclusionVolume;

/* 	If true this checkpoint can only be set as the active checkpoint in the map a single time
	Should probably be set true by default as most story maps will probably have a linear progression.
*/

var(StoryCheckPoint)		bool						bShowActivationMsg;

var(StoryCheckPoint)		bool						bSingleActivationOnly;

/* FriendlyName */
var(StoryCheckPoint)		string						CheckPointName;

/* Cached reference to Story gameinfo to cut down on typecasting */
var							KFStoryGameInfo				StoryGI;

/* used to save the current state of Dialogue at the time a checkpoint is activated so that it can be returned to later if a team restarts */
struct SDialogueState
{
	var 					KF_DialogueSpot				DialogueActor;
	var						int							SavedIndex;
	var						array<byte>  				DialogueTriggerStates;
};

var 						array<SDialogueState>		SavedDialogue;


enum ECheckPointTriggerType
{
	CTT_Touch,
	CTT_Trigger,
};

/* do we want this checkpoint to become active when remotely triggered, or on player touch ? */
var	(StoryCheckPoint)		ECheckPointTriggerType		CheckPointTriggerType;

var array<PlayerStart> PSList;

function Reset()
{
	LastRespawnedPlayer = none;
	ActivatingPlayer = none;
	bPendingRespawn = false;
	bIsActive = false;
}


simulated function PostBeginPlay()
{
	local 	NavigationPoint N;
	local 	PlayerStart PS;
	local	KF_DialogueSpot  DlgSpot;

	if( Level.NetMode==NM_Client )
		return;

	/* No KFO Gametype, no Initialization */
	StoryGI = KFStoryGameInfo(Level.Game);
	if(StoryGI == none)
	{
        return;
	}

	For( N=Level.NavigationPointList; N!=None; N=N.NextNavigationPoint )
	{
		PS = PlayerStart(N);
		if( PS!=None  )
		{
			if(Encompasses(PS) )
			{
				PSList[PSList.Length] = PS;
			}
		}
	}

	if(RestartFromCheckPoint != "" &&
	RestartFromCheckPoint != CheckPointName &&
	StoryGI != none )
	{
		ForcedRestartCheckPoint = StoryGI.FindCheckPointNamed(RestartFromCheckPoint);
	}

	// cache all the DialogueSpots in the map -  we'll need this to store the states for each one
	foreach DynamicActors(class 'KF_DialogueSpot', DlgSpot)
	{
		SavedDialogue.length = SavedDialogue.length + 1;
		SavedDialogue[SavedDialogue.length-1].DialogueActor = DlgSpot;
		SavedDialogue[SavedDialogue.length-1].DialogueTriggerStates.length = DlgSpot.Dialogues.length ;
	}
}


/* Wrapper for checking if this volume can grant second chances to teams that wipe out during story gameplay */
function bool		CanGrantSecondChances()
{
	local bool Result;

	if(ForcedRestartCheckPoint != none)
	{
		Result = true;//ForcedRestartCheckPoint.IsActiveRespawnPoint();
	}
	else
	{
		Result = IsActiveRespawnPoint();
	}


	if(!Result)
	{
		if(ForcedRestartCheckPoint != none)
		{
			log("Forced Restart CheckPoint : "@ForcedRestartCheckPoint.CheckPointName@" for - "@CheckPointName@" is unable to Respawn players at the moment. It is probably inactive . ");
		}
		else
		{
			log("CheckPoint : "@CheckPointName@"is unable to Respawn players at the moment. It is probably inactive . ");
		}
	}
	return Result ;
}

function bool IsActiveRespawnPoint()
{
	return bIsActive && bRespawnPlayers && bRespawnOnWipe /*&& !bPendingRespawn*/;
}

/* Respawns all dead players in the game when they wipe out -  Returns true if successful */

function	bool	GrantASecondChance(out KF_StoryCheckPointVolume RespawnPoint)
{
	if(CanGrantSecondChances())
	{
		RespawnPoint = self;

		if(ForcedRestartCheckPoint != none)
		{
			RespawnPoint = ForcedRestartCheckPoint ;
		}

		bPendingFullRestart = true;
		RespawnPoint.Reset() ;
		RespawnPoint.Instigator = Instigator;

		return true;
	}

	return false;
}


function UpdateSpawnAvailability()
{
	local NavigationPoint			N;
	local PlayerStart				PS;
	local bool 						bEnableMe;

	if( PSList.Length>0 )
	{
		For( N=Level.NavigationPointList; N!=None; N=N.NextNavigationPoint )
		{
			PS = PlayerStart(N);
			if(PS != none)
			{
//				log("Updating spawn availability for "@self@" - "@PS@".bEnabled = "@bEnableMe);
				bEnableMe = bIsActive && PStartBelongsToThisVolume(PS);
				PS.bEnabled = bEnableMe ;
			}
		}
	}
	else
	{
		log("Warning -  No Playerstarts associated with "@self@": Respawns will fail.");
	}
}


function		bool	PStartBelongsToThisVolume( PlayerStart TestSpot)
{
	local int i;

	for( i = 0 ; i < PSList.length; i ++)
	{
		if(PSList[i] == TestSpot)
		{
			return true;
		}
	}

	return Encompasses(TestSpot);
}

/* CTT_Touch*/

simulated event PawnEnteredVolume(Pawn Other)
{
	if(CheckPointTriggerType == CTT_Touch &&
	(Other.Controller != none && Other.Controller.bIsPlayer)	/*&&	 Other.IsPlayerPawn()*/)	// <- IsPlayerPawn() returns true in Monster.uc ...derp
	{
		CheckPointActivated(Other,false,bShowActivationMsg);
	}
}

/* CTT_Trigger*/

function Trigger( actor Other, pawn EventInstigator )
{
	if(CheckPointTriggerType == CTT_Trigger/* && EventInstigator != none &&
	EventInstigator.IsPlayerPawn()*/)
	{
		CheckPointActivated(EventInstigator,false,bShowActivationMsg);
	}
}

function ResetPlayerCheckPointStats()
{
	local Controller C;
	local KFPlayerController_Story	PC;

	For ( C= Level.ControllerList; C!=None; C=C.NextController )
	{
		PC = KFPlayerController_Story(C);
		if(PC != none)
		{
			PC.NumCheckPointRespawns = 0 ;
		}
	}
}


function int GetNumPlayersInVolume()
{
	local int Num;
	local Controller C;

	for ( C=Level.ControllerList; C!=None; C=C.NextController )
	{
		if(C.bIsPlayer && C.Pawn != none)
		{
			if(Encompasses(C.Pawn))
			{
				Num ++ ;
			}
		}
	}

//	log("NUM PLAYERS IN VOLUME : "@Num);

	return Num;
}

/* Tracks the current state of game Objectives & Dialogue at the time this checkpoint was activated */
function SaveStoryState()
{
	local int i,idx;
	local KF_DialogueSpot 	Dlg;
	local bool bJumpingForward;
	local int NextEventIdx;
	local name NextSortedObj;
	local Controller C;
	local KFPlayerController_Story SPC;


	if(bPendingFullRestart)
	{
		return;
	}

	/* If the LD hasn't provided a forced Objective to restart from, use whatever was current at the time of activation */
	if(RestartFromObjective == '' )
	{
		if(StoryGI.CurrentObjective != none && StoryGI.CurrentObjective.bCheckPointable)
		{
			RestartFromObjective = StoryGI.CurrentObjective.ObjectiveName;
		}
		else
		{
			/* if there's no current objective - the next objective is probably bManualActivate , so we're at a gap between obj's.
			 In this case we can just use the LastObjective and jump one forward.    */

            NextSortedObj = StoryGI.SortedObjectives[ Min( StoryGI.CurrentObjectiveIdx + 1 ,StoryGI.SortedObjectives.length - 1 )  ].ObjectiveName ;
            log(" No current Objective .. Checkpoint will restart from Next sorted objective : "@NextSortedObj,'Story_Debug');
			RestartFromObjective = NextSortedObj;
			bJumpingForward = true;
		}

        for(i = 0 ; i < StoryGI.AllObjectives.length ; i ++)
        {
            if(StoryGI.AllObjectives[i].ObjectiveName == RestartFromObjective)
            {
                StoryGI.AllObjectives[i].SetCheckPoint(self);
            }
            else
            {
                StoryGI.AllObjectives[i].ClearCheckPoint();
            }
        }
	}

	for( i = 0 ; i < SavedDialogue.length ; i ++)
	{
		Dlg = SavedDialogue[i].DialogueActor ;
		if(Dlg != none)
		{
			NextEventIdx = Dlg.GetNextDlgRequiredEventIdx(Dlg.CurrentMsgIdx) ;
			if(bJumpingForward && NextEventIdx > 0)
			{
				SavedDialogue[i].SavedIndex = NextEventIdx;
			}
			else
			{
				SavedDialogue[i].SavedIndex = Dlg.CurrentMsgIdx ;
			}

			if(Dlg.bDebugDialogue)
			{
				log("----- DIALOGUE DEBUG ------   Saving Dialogue Index of : "@Dlg@" At  : "@SavedDialogue[i].SavedIndex, 'Story_Debug' );
			}

			for(idx = 0 ; idx < SavedDialogue[i].DialogueTriggerStates.length ; idx ++ )
			{
				SavedDialogue[i].DialogueTriggerStates[idx] = byte(Dlg.Dialogues[idx].bWasTriggered) ;
			}

		}
	}

    // store players current equipment and cash amounts so we can restore it all when they spawn from this checkpoint
	for (C = Level.ControllerList; C != None; C = C.NextController)
	{
        SPC = KFPlayerController_Story(C);
        if(SPC != none)
        {
            SPC.SaveLoadOut();
        }

        if(KF_StoryNPC(C.Pawn) != none)
        {
            KF_StoryNPC(C.Pawn).SaveHealthState();
        }
	}
}

function ModifyPlayer( pawn aPlayer)
{
    local float CheckPointHealthModifier;
    local KFPlayerController_Story SPC;

	SPC = KFPlayerController_Story(aPlayer.Controller);
	if(SPC == none)
	{
	   return;
	}

    if(bRespawnOnWipe)
    {
	   aPlayer.Health = SPC.SavedHealth;
	   aPlayer.ShieldStrength = SPC.SavedArmor;
	   SPC.PlayerReplicationInfo.Score = SPC.SavedCash;
    }

    if (RespawnHealthModifier != 1.f )
	{
        CheckPointHealthModifier = RespawnHealthModifier ;
		if(bCumulativeHealthModifier)
		{
			CheckpointHealthModifier = CheckPointHealthModifier ** SPC.NumCheckPointRespawns ;
		}

		aPlayer.Health =  Max(aPlayer.Health * CheckPointHealthModifier,1) ;
	}
}


function		int			GetSavedDialogueIndexFor(KF_DialogueSpot		DialogueSpot , out array<byte>	WasTriggeredArray)
{
	local int i;

	if(DialogueSpot == none)
	{
		return -1;
	}

	for( i = 0 ; i < SavedDialogue.length ; i ++)
	{
		if(SavedDialogue[i].DialogueActor != none &&
		SavedDialogue[i].DialogueActor == DialogueSpot)
		{
			WasTriggeredArray = SavedDialogue[i].DialogueTriggerStates ;
			return SavedDialogue[i].SavedIndex ;

		}
	}
}

/* 	Called when this volume has been set as the new active checkpoint zone in the map
	Enables encompassed playerstarts & disables all others.
*/

function CheckPointActivated( Pawn CheckPointInstigator, bool bForceActivate, optional bool bShowMessage)
{
	local KF_StoryCheckPointVolume	OldCheckpoint;
	local Controller C;

	/* Check for a human controlled pawn */
	if(CheckPointInstigator.Controller != none)
	{
		ActivatingPlayer = CheckPointInstigator.Controller;
		if(ActivatingPlayer != none && PlayerController(ActivatingPlayer) != none &&
		ActivatingPlayer.Pawn != none )
		{
			Instigator = ActivatingPlayer.Pawn ;
		}
	}

	if(!bForceActivate &&
	bRequiresWholeTeam &&
	GetNumPlayersInVolume() < StoryGI.GetTotalActivePlayers())
	{
		return;
	}

	if(!bIsActive || bForceActivate || !bSingleActivationOnly)
	{
        log("===============================================",'Story_Debug');
	    log("CheckPointActivated! - "@CheckPointName,'Story_Debug');

		bIsActive = true;

		if(!bPendingFullRestart)
		{
			TriggerActivationEvents();

			if(bRespawnOnWipe)
			{
                SaveStoryState();
            }
        }

		if(StoryGI != none)
		{
			OldCheckPoint = StoryGI.CurrentCheckPoint ;
			StoryGI.CurrentCheckPoint = self ;

            for ( C=Level.ControllerList; C!=None; C=C.NextController )
            {
                if(KFPlayerController_Story(C) != none)
                {
                    KFPlayerController_Story(C).CurrentCheckPoint = self;
                }
            }

			if(bShowMessage)
			{
				BroadcastLocalizedMessage( StoryGI.default.CheckPointMessageClass , 0, ActivatingPlayer.PlayerReplicationinfo, None, self );
			}
		}

		UpdateSpawnAvailability();
		ResetPlayerCheckpointStats();

		if( bRespawnPlayers )
		{
			DelayedRespawnDeadPlayers();
		}

		if( bTeleportstragglers)
		{
			TeleportLivingPlayers();
		}

		if(Instigator == none)
		{
			log("Warning - No human instigator found when Activating "@self@".  Some actors require a human instigator to trigger successfully . (Movers) ");
		}

		if(bDebugCheckPoint)
		{
			PrintDebugText(ActivatingPlayer.PlayerReplicationInfo.PlayerName@"activated"@CheckPointName);
		}
	}
}

/* Fire off a set of events when this checkpoint is activated */

function TriggerActivationEvents()
{
	local int i;

	TriggerEvent(Event,self, Instigator);

	for(i = 0 ; i < ActivationEvents.length ; i ++)
	{
		TriggerEvent(ActivationEvents[i],self,Instigator);
	}

}


function DelayedRespawnDeadPlayers()
{
	if(!bPendingRespawn)
	{
		bPendingRespawn = true;

		if ( RespawnDelayTimer == None )
		{
			RespawnDelayTimer = spawn(class'RespawnTimer', self);
			if(RespawnDelayTimer != none)
			{
				RespawnDelayTimer.TimerFrequency = RespawnDelay ;
			}
		}
		else
		{
			RespawnDelayTimer.Reset();
		}
	}
}

/* Called from ReSpawnTimer.Timer() -  notification that the timer expired
and it is now time to perform the actual respawn.*/

function RespawnTimerPop()
{
	RespawnDeadPlayers();

	/* if this is a full-team-restart, we need to reset certain actors in the map
	as well - Notify the gameinfo that this would be a good time to do that*/
	if(StoryGI != none && StoryGI.bPendingTeamRespawn)
	{
		StoryGI.bPendingTeamRespawn = false ;
		TriggerActivationEvents();
	}

}


/* Brings bOutLives players back from the dead. They will spawn at one of the player starts inside this volume's bounds */

function RespawnDeadPlayers()
{
	local Controller C;
	local KFPlayerController KFPC;
	local PlayerController PC;
	local KFPlayerReplicationInfo KFPRI;

	bPendingRespawn = false;

	For ( C= Level.ControllerList; C!=None; C=C.NextController )
	{
		if ( C.PlayerReplicationInfo != none )
		{
			/* I'm guessing we are still using Perks in Story mode ? ... will leave this in for now */
			KFPC = KFPlayerController(C);
			if ( KFPC != none )
			{
				KFPRI = KFPlayerReplicationInfo(C.PlayerReplicationinfo);
				if ( KFPRI != none )
				{
					KFPC.bChangedVeterancyThisWave = false;

					if ( KFPRI.ClientVeteranSkill != KFPC.SelectedVeterancy )
					{
						KFPC.SendSelectedVeterancyToServer();
					}
				}
			}

			if(C.PlayerReplicationInfo.bOnlySpectator ||
			!C.PlayerReplicationInfo.bOutOfLives ||
			(C.PlayerReplicationInfo.bBot && !bIncludeBots))
			{
				continue;
			}

			C.PlayerReplicationInfo.bOutOfLives = false;
			C.PlayerReplicationInfo.NumLives = 0;

            PC = PlayerController(C);
			if( PC != none )
			{
				PC.GotoState('PlayerWaiting');
				PC.SetViewTarget(C);
				PC.ClientSetBehindView(false);
				PC.bBehindView = False;
				//	PC.ClientSetViewTarget(C.Pawn);	 <-  that's all well and good but .. At this point 'C'  has no pawn ... Gonna move this down after RestartPlayer()
			}

			if(KFPlayerController_Story(C) != none)
			{
				KFPLayerController_Story(C).NumCheckPointRespawns ++ ;
			}

			LastRespawnedPlayer = C;

			// Make sure the dude we're respawning hast at least some cash.
		    C.PlayerReplicationInfo.Score = Max(KFGameType(Level.Game).MinRespawnCash, int(C.PlayerReplicationInfo.Score));
			C.ServerReStartPlayer();

            if(PC != none && PC.Pawn != none)
			{
				PC.ClientSetViewTarget(PC.Pawn);
			}
		}
	}

	LastRespawnedPlayer = none;

	/* Full Checkpoint restart (everyone was wiped out) */
	if(bPendingFullRestart && StoryGI != none)
	{
		bPendingFullRestart = false;
		StoryGI.NotifyTeamRestarted();
	}
}

/* Teleports all living players in the map (outside of the volume) to a playerstart in this volume. */

function TeleportLivingPlayers()
{
	local NavigationPoint	TeleportSpot;
	local Controller		C;
    local bool bTeleportMe;

	For ( C= Level.ControllerList; C!=None; C=C.NextController )
	{
        bTeleportMe = false;

		if ( C.PlayerReplicationInfo != none )
		{
			if(C.bIsPlayer &&
			!C.PlayerReplicationInfo.bOutOfLives &&
			!C.PlayerReplicationInfo.bOnlySpectator &&
			C.Pawn != none && C.Pawn.Health > 0 &&
			C.Pawn.PhysicsVolume != self )
			{
                if(TeleportExclusionVolume != none)
                {
                    bTeleportMe = !TeleportExclusionVolume.Encompasses(C.Pawn);
                }
                else
                {
                    bTeleportMe = VSize(C.Pawn.Location - Location) >= TeleportStragglerDist;
                }

                if(bTeleportMe)
                {
                    TeleportSpot = Level.Game.FindPlayerStart(C,C.GetTeamNum());
                    if(TeleportSpot != none)
                    {
                        C.Pawn.SetLocation(TeleportSpot.Location);
                    }
				}
			}
		}
	}
}

function	PrintDebugText( string Message)
{
	local Controller C;
	local PlayerController P;

	for ( C=Level.ControllerList; C!=None; C=C.NextController )
	{
		P = PlayerController(C);
		if( P != None )
		{
			P.TeamMessage(C.PlayerReplicationInfo, Message, 'CriticalEvent');
		}
	}
}

defaultproperties
{
     bRespawnPlayers=True
     bIncludeBots=True
     bRespawnOnWipe=True
     RespawnDelay=2.000000
     RespawnHealthModifier=1.000000
     bCumulativeHealthModifier=True
     bRemoveDroppedWeapons=True
     TeleportStragglerDist=2000.000000
     bShowActivationMsg=True
     bSingleActivationOnly=True
     CheckPointName="a checkpoint"
     bStatic=False
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fri 13-10-2023 03:17:28.000 - Creation time: Fri 13-10-2023 03:19:04.618 - Created with UnCodeX