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

KFStoryGame.KFPlayerController_Story


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
/*
	--------------------------------------------------------------
	KFPlayerController_Story
	--------------------------------------------------------------

	Custom PlayerController class for use in Killing Floor 'Story' maps.

	Author :  Alex Quick

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

class KFPlayerController_Story extends KFPlayerController ;

/* number of times this player has been respawned by the current CheckpointVolume */
var			int						    NumCheckPointRespawns;

/* reference to the last Trader Shop we used */
var			KFShopVolume_Story		    CurrentShopVolume;

var         KF_StoryCheckPointVolume    CurrentCheckPoint;

var         bool                        bShowObjectiveDebug;

/* == Checkpoint Data ===================================================================

Stuff we want to keep track of when this player is 'checkpointed' during a story mission.

=========================================================================================
*/

/* array of equipment the pawn was holding when he last activated a checkpoint */
var			array<String>           SavedLoadOut;

/* the ammo counts for weapons this player had at the time they last activated a checkpoint */
var         array<Int>              SavedAmmo;

/* the magazine ammo counts for weapons this player had at the time they last activated a checkpoint */
var         array<Int>              SavedMagAmmo;

/* the cash this player had at the time he last activated a checkpoint */
var         float                   SavedCash;

/* the amount of health this player had at the time he last activated a checkpoint */
var         int                     SavedHealth;

/* the amount of body armor this player had at the time he last activated a checkpoint */
var         int                     SavedArmor;

/* If we are doing a trader time objective this is the number of seconds left before it completes */
var         float                   RemainingTraderTime;


replication
{
	unreliable if(Role == Role_Authority)
		SetClientWhispClr,ClientSetUV2Tex,UnReliableConditionUpdate;

	reliable if(Role == Role_Authority)
	   CurrentShopVolume,ReliableConditionUpdate,ClientShowStoryDialogue, ClientPlayStorySound;

	unreliable if( Role<ROLE_Authority )
		ServerStopUsing,ServerCompleteObj,ServerFFObj;

	reliable if (Role <ROLE_Authority)
	   ServerReadyLateJoiner;
}

simulated function ClientSetUV2Tex(Actor TargetActor , Material NewUV2Tex)
{
    TargetActor.UV2Texture = NewUV2Tex;
}

simulated function ClientShowStoryDialogue(name DialogueActor, int DlgIndex, float DisplayDuration)
{
	if(HUD_StoryMode(myHUD)  != none)
	{
		HUD_StoryMode(myHUD).AddDialogue(DialogueActor,DlgIndex,DisplayDuration);
	}
}

// Play a story mode sound on the client
// If bAdjustPitch = true then the sound will be adjusted to the game pitch
// based on the game speed (i.e. lower pitch if zed time is enabled). If it
// is false it will not be adjusted with the game speed
simulated function ClientPlayStorySound(sound ASound, float Volume, bool bAdjustPitch )
{
    local float UsedPitch;

    UsedPitch = 1.0;

    if( bAdjustPitch )
    {
        UsedPitch = 1.0;
    }
    else
    {
        UsedPitch = 1.1 / Level.TimeDilation;
    }

	if ( ViewTarget != None )
		ViewTarget.PlayOwnedSound(ASound,Slot_Interface,Volume,true,,UsedPitch,false);
	else
        PlayOwnedSound(ASound,Slot_Interface,Volume,true,, 1.1 / Level.TimeDilation, false);
}

exec simulated function ToggleConditionStack()
{
	if(HUD_StoryMode(myHUD)  != none)
	{
        HUD_StoryMode(myHUD).bCollapseConditions = !HUD_StoryMode(myHUD).bCollapseConditions;
	}
}

/* Called on the client - Updates condition data unreliably */
simulated function UnreliableConditionUpdate(
KF_ObjectiveCondition UpdatedCondition,
KF_StoryObjective ObjOwner,
float NewProgressPct,
Actor NewLocActor,
string NewDataString,
bool NewComplete)
{
    DoConditionUpdate(UpdatedCondition,ObjOwner.Name,NewProgressPct,NewLocActor,UpdatedCondition.GetHUDHint()@NewDataString,NewComplete, '');
}

/* Called on the client - Updates condition data reliably */
simulated function ReliableConditionUpdate(
KF_ObjectiveCondition UpdatedCondition,
KF_StoryObjective ObjOwner,
float NewProgressPct,
Actor NewLocActor,
string NewDataString,
bool NewComplete)
{
	local name PendingLocActorTag;
	/*
    log(" *** RELIABLE CONDITION UPDATE ******************************************************");
    log(" >>> "@UpdatedCondition);
    log(" *** Progress Percent :"@NewProgressPct);
    log(" *** Data String      :"@NewDataString);
    log(" *** Complete?        :"@NewComplete);
    */
    // If we have an actors tag, but no actor Queue him with PendingLocActorTag to grab his reference later.
    // This is pretty much a hack to get around cases where we are trying to grab a reference to an actor which
    // does not yet exist on the client .

	if (NewLocActor == none )
	{
	    if( UpdatedCondition.IsA('ObjCondition_ActorHealth') )
	    {
		    PendingLocActorTag = ObjCondition_ActorHealth(UpdatedCondition).TargetPawnTag;
		}
		else if( UpdatedCondition.IsA('ObjCondition_Use') )
		{
		    PendingLocActorTag = ObjCondition_Use(UpdatedCondition).UsePawn_Tag;
		}
    }

    DoConditionUpdate(UpdatedCondition,ObjOwner.Name,NewProgressPct,NewLocActor,UpdatedCondition.GetHUDHint()@NewDataString,NewComplete,PendingLocActorTag);
}

simulated function DoConditionUpdate(
KF_ObjectiveCondition UpdatedCondition,
name ObjOwner,
float NewProgressPct,
Actor NewLocActor,
string NewDataString,
bool NewComplete,
name PendingLocActorTag)
{
    local ObjCondition_Timed  TimeCondition;

    if(HUD_StoryMode(myHUD) == none)
    {
        log(" WARNING -  NO HUD AVAILABLE FOR : "@self@" CLIENT CONDITION UPDATE WILL FAIL. ",'Story_Debug');
    }

    if(Level.NetMode == NM_DedicatedServer ||
    HUD_StoryMode(myHUD) == none ||
    UpdatedCondition == none ||
    ObjOwner == '')
    {
        return;
    }

    TimeCondition = ObjCondition_Timed(UpdatedCondition);
    if(TimeCondition != none &&
    TimeCondition.bTraderTime)
    {
        RemainingTraderTime = TimeCondition.Duration - (TimeCondition.Duration * NewProgressPct);
    }

    HUD_StoryMode(myHUD).UpdateConditionHint(
    UpdatedCondition.name,
    ObjOwner,
    NewProgressPct,
    NewLocActor,
    NewDataString,
    NewComplete,
	PendingLocActorTag);
}


simulated function SetClientWhispClr(color NewWhispClr)
{
    Class'Objective_Whisp'.default.mColorRange[0] = NewWhispClr;
	Class'Objective_Whisp'.default.mColorRange[1] = NewWhispClr;
}


/* This player's progress was saved at a checkpoint */
function SaveLoadOut()
{
    if(PlayerReplicationInfo != none)
    {
        SavedCash = PlayerReplicationInfo.Score;
    }

    if(KFHumanPawn_Story(Pawn) != none)
    {
        KFHumanPawn_Story(Pawn).SaveLoadOut() ;
    }
}

/* Overriden to ensure it opens up the story-friendly version of the Trader Buy Menu */

function ShowBuyMenu(string wlTag,float maxweight)
{
	StopForceFeedback();  // jdf - no way to pause feedback

	// Open menu
	ClientOpenMenu("KFStoryUI.GUIBuyMenu_Story",,wlTag,string(maxweight));
}

// Send a voice message of a certain type to a certain player.

/* Added a hack to filter out trader voices */

function ServerSpeech( name Type, int Index, string Callsign )
{
	if(Type != 'TRADER')
	{
		Super.ServerSpeech(Type,Index,Callsign);
	}
}

function SetPawnClass(string inClass, string inCharacter)
{
	Super.SetPawnClass(inClass,inCharacter);
	/* @todo -  why doesn't GetDefaultPlayerClass() work ? */
//	PawnClass = Level.Game.GetDefaultPlayerClass(self);  //	PawnClass = Class'KFHumanPawn';
	PawnClass = class 'KFStoryGame.KFHumanPawn_Story';
}


/*
	Helper function for quickly determining whether a player is looking at a point in space.
	original author :  Ron Prestenback.

 * @param	TargetLocation	the location to check
 * @param	MinDotResult	a value between 0 and 1 representing the minimum dot result value that should be
 *							considered acceptable for testing whether the location is within our field of
 *							view.  (Default value is corresponds to a maximum angle of around 47 degrees)
 *
 * @return	TRUE if the location is within the angle specified from the player's line of sight.
 */
simulated function bool IsLookingAtLocation( vector TargetLocation, optional float MinDotResult)
{
	local vector DirectionNormal, EyesLoc;
	local rotator EyesRot;
	local float ViewAngleCosine;

	// get the location and rotation of the camera
	EyesLoc = CalcViewLocation;;
	EyesRot = CalcViewRotation;

	// get the normalized distance between the two locations
	DirectionNormal = Normal(TargetLocation - EyesLoc);

	// get the dot result of the player's view location and the target location
	ViewAngleCosine = DirectionNormal dot vector(EyesRot);

	// determine if the angle between our camera's rotation and the target location is within range.
//	log("IS LOOKING AT LOCATION - "@ViewAngleCosine@" Required : "@MinDotResult);
	return ViewAngleCosine >= MinDotResult;
}


simulated function bool HasLineOfSightTo( vector TargetLocation)
{
	return IsLookingAtLocation(TargetLocation,0.5f) && FastTrace(CalcViewLocation, TargetLocation) && FastTrace(TargetLocation,CalcViewLocation);	//EyePostion() is returning a funny value sometimes.  Not sure why. C.Pawn./*EyePosition()*/Location
}

/* Extended 'Use' functionality - Support for OnRelease events */

// The player wants to stop using something in the level.
exec function StopUsing()
{
	ServerStopUsing();
//	log(self@"stopped pressing Use");
}


/* === Server Debug Commands ==================
===============================================*/

/* Fast Forward*/
exec function FFObj(name ObjName)
{
    if( !class'ROEngine.ROLevelInfo'.static.RODebugMode() )
    {
        return;
    }

    ServerFFObj(ObjName);
}

/* Helpful function for level Designers testing objectives at different stages in their map

Changes the active objective to the one provided.  If bSimulateCompletion,  it will also fast forward
through the Objective chain in an attempt to simulate actual player progression.  */

function ServerFFObj(name ObjName)
{
    local KF_StoryObjective NewObj;
    local KFStoryGameInfo StoryGI;

    StoryGI = KFStoryGameInfo(Level.Game);
    if(StoryGI == none)
    {
        return;
    }

    NewObj = StoryGI.FindObjectiveNamed(ObjName);
    if(NewObj != none && !StoryGI.bGameEnded )
    {
        if(!NewObj.IsValidForActivation())
        {
            ClientMessage("WARNING : ["@NewObj.ObjectiveName@"] has already been completed and is a non-recurring objective. It cannot be activated");
            return ;
        }

        if(NewObj != StoryGI.CurrentObjective)
        {
            StoryGI.ForcedTargetObj = NewObj;
            StoryGI.bSkipDialogue = true;

            if(KF_StoryGRI(StoryGI.GameReplicationInfo) != none)
            {
                KF_StoryGRI(StoryGI.GameReplicationInfo).SetDebugTargetObj(NewObj);
            }

            StoryGI.GoToForcedObj();
            ClientMessage("Fast tracking to ... "@NewObj.ObjectiveName,'CriticalEventPlus');
        }
    }
    else
    {
        ClientMessage("WARNING : cannot find objective : "@ObjName);
    }
}



exec function CompleteObj()
{
    if( !class'ROEngine.ROLevelInfo'.static.RODebugMode() )
    {
        return;
    }

    ServerCompleteObj();
}

function ServerCompleteObj()
{
    local KF_StoryObjective CurrentObjective;

    if(KFStoryGameInfo(Level.Game) != none )
    {
        CurrentObjective = KFStoryGameInfo(Level.Game).CurrentObjective ;
        if(CurrentObjective != none)
        {
            if(CurrentObjective.bCompleted)
            {
                Level.GetLocalPlayerController().ClientMessage("WARNING : ["@CurrentObjective.ObjectiveName@"] is already COMPLETE.  ",'Story_Debug');
                return ;
            }

              CurrentObjective.ForceCompleteObjective();
        }
    }
}

exec function StartUsing()
{
	Super.ServerUse();
}

function ServerUse()
{
    Super.ServerUse();

    /* Hackey hack time!*/
    if(KFStoryGameInfo(Level.Game) != none &&
    KFStoryGameInfo(Level.Game).CurrentObjective != none)
    {
        KFStoryGameInfo(Level.Game).CurrentObjective.UsedBy(pawn);
    }
}

function ServerStopUsing()
{
	if ( Role < ROLE_Authority )
		return;

	if ( Level.Pauser == PlayerReplicationInfo )
	{
		SetPause(false);
		return;
	}

	if (Pawn == None || !Pawn.bCanUse)
		return;

   /* Hackey hack time!*/
   if(KFStoryGameInfo(Level.Game) != none &&
   KFStoryGameInfo(Level.Game).CurrentObjective != none)
   {
       KFStoryGameInfo(Level.Game).CurrentObjective.StoppedUsing(pawn);
   }
}

exec function SoakAI()
{
	local AIController Bot;

	log("Start Soaking");
	UnrealMPGameInfo(Level.Game).bSoaking = true;
	ForEach DynamicActors(class'AIController',Bot)
		Bot.bSoaking = true;
}

exec function ObjDebug()
{
    bShowObjectiveDebug = !bShowObjectiveDebug;
}

simulated function DisplayDebug(Canvas Canvas, out float YL, out float YPos)
{
    local KFStoryGameInfo StoryGI;
    local int i;

    StoryGI = KFStoryGameInfo(Level.Game);
	if (StoryGI != none && bShowObjectiveDebug)
	{
		Canvas.SetDrawColor(50, 255, 50);
		Canvas.DrawText("========== OBJECTIVE LIST ======================");

		for(i = 0 ; i < StoryGI.AllObjectives.length ; i ++)
		{
            Canvas.DrawText("["$i+1$"]"@StoryGI.AllObjectives[i].ObjectiveName);
		}

		YPos += YL/2;
		Canvas.SetPos(4, YPos);
	}
	else
	{
	   Super.DisplayDebug(Canvas, YL, YPos);
	}
}

simulated function UpdateHintManagement(bool bUseHints)
{
    if (Level.GetLocalPlayerController() == self)
    {
        if (bUseHints && HintManager == none)
        {
            HintManager = spawn(class'KFHintManager_Story', self);
            if (HintManager == none)
                warn("Unable to spawn hint manager");
        }
        else if (!bUseHints && HintManager != none)
        {
            HintManager.Destroy();
            HintManager = none;
        }

        if (!bUseHints)
            if (HUDKillingFloor(myHUD) != none)
                HUDKillingFloor(myHUD).bDrawHint = false;
    }
}

function ServerThrowWeapon()
{
	// If we have any story items, throw them one at a time
    if( KFHumanPawn_Story(Pawn) != none &&
		KFHumanPawn_Story(Pawn).IsCarryingThrowableInventory())
    {
    	KFHumanPawn_Story(Pawn).TossSingleCarriedItem();
    }
    else
    {
	    super.ServerThrowWeapon();
    }
}

/* A late joining client wants to tell the server he's ready to play .. */
function ServerReadyLateJoiner()
{
	if ( !Level.Game.bWaitingToStartMatch )
		PlayerReplicationInfo.bReadyToPlay = true;
}

function SelectVeterancy(class<KFVeterancyTypes> VetSkill, optional bool bForceChange)
{
	if ( VetSkill == none || KFPlayerReplicationInfo(PlayerReplicationInfo) == none )
	{
		return;
	}

	if ( KFSteamStatsAndAchievements(SteamStatsAndAchievements) != none )
	{
		SetSelectedVeterancy( VetSkill );

		if ( KFStoryGameInfo(Level.Game) != none &&              // another place where we gotta use IsTraderObj()  instead of bWaveInProgress ...
        !KFStoryGameInfo(Level.Game).IsTraderTime() &&
         VetSkill != KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill )
		{
			bChangedVeterancyThisWave = false;
			ClientMessage(Repl(YouWillBecomePerkString, "%Perk%", VetSkill.Default.VeterancyName));
		}
		else if ( !bChangedVeterancyThisWave || bForceChange )
		{
			if ( VetSkill != KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill )
			{
				ClientMessage(Repl(YouAreNowPerkString, "%Perk%", VetSkill.Default.VeterancyName));
			}

			if ( GameReplicationInfo.bMatchHasBegun )
			{
				bChangedVeterancyThisWave = true;
			}

			KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkill = VetSkill;
			KFPlayerReplicationInfo(PlayerReplicationInfo).ClientVeteranSkillLevel = KFSteamStatsAndAchievements(SteamStatsAndAchievements).PerkHighestLevelAvailable(VetSkill.default.PerkIndex);

			if( KFHumanPawn(Pawn) != none )
			{
				KFHumanPawn(Pawn).VeterancyChanged();
			}
		}
		else
		{
			ClientMessage(PerkChangeOncePerWaveString);
		}
	}
}


state Dead
{     /*
	function Timer()
	{
			There was some forced respawn code in KFGameType's implementation ...
			I'm trying to cut out anything that could interfere with
			the Story game's checkpoint respawn system

		super(PlayerController).Timer();
	} 	*/

	function Timer()
	{
        /* I REALLY hate to do this, but it's the only way to get it to work like it does in KFGameType*/
	    if ( KFGameType(Level.Game) != none && Level.Game.GameReplicationInfo.bMatchHasBegun &&
			 Role == ROLE_Authority && KFStoryGameInfo(Level.Game).IsTraderTime() )
		{
			PlayerReplicationInfo.Score = Max(KFGameType(Level.Game).MinRespawnCash, int(PlayerReplicationInfo.Score));
			SetViewTarget(self);
			ClientSetBehindView(false);
			bBehindView = False;
			ClientSetViewTarget(Pawn);
			PlayerReplicationInfo.bOutOfLives = false;
			Pawn = none;
			ServerReStartPlayer();
		}

		super.Timer();
	}

}

defaultproperties
{
     LobbyMenuClassString="KFStoryUI.LobbyMenu_Story"
     PlayerReplicationInfoClass=Class'KFStoryGame.KF_StoryPRI'
}

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:03.946 - Created with UnCodeX