KF2-Server-Extension/ServerExt/Classes/MS_PC.uc

136 lines
3.5 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
Class MS_PC extends KFPlayerController;
var localized string ConnectingTo;
var localized string ConnectionAborted;
var localized string UserAbortedConnection;
var localized string ConnectionError;
var localized string Disconnecting;
2017-10-20 02:00:49 +00:00
var MS_PendingData TravelData;
var byte ConnectionCounter;
var bool bConnectionFailed;
simulated event ReceivedPlayer();
simulated function ReceivedGameClass(class<GameInfo> GameClass);
2020-11-28 20:04:55 +00:00
simulated function HandleNetworkError(bool bConnectionLost)
2017-10-20 02:00:49 +00:00
{
ConsoleCommand("Disconnect");
}
2020-11-28 20:04:55 +00:00
event PlayerTick(float DeltaTime)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (ConnectionCounter<3 && ++ConnectionCounter==3)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (TravelData.PendingURL!="")
2017-10-20 02:00:49 +00:00
{
MS_HUD(myHUD).ShowProgressMsg(ConnectingTo@TravelData.PendingURL);
2017-10-20 02:00:49 +00:00
ConsoleCommand("Open "$TravelData.PendingURL);
}
2020-11-28 20:12:58 +00:00
if (TravelData.PendingSong!=None)
2017-10-20 02:00:49 +00:00
StartMusicTrack(TravelData.PendingSong);
// Reset all cached data.
TravelData.Reset();
}
PlayerInput.PlayerInput(DeltaTime);
MS_HUD(myHUD).ActiveGame.UpdateMouse(PlayerInput.aTurn,PlayerInput.aLookUp);
}
2020-11-28 20:04:55 +00:00
simulated final function StartMusicTrack(SoundCue Music)
2017-10-20 02:00:49 +00:00
{
local AudioComponent A;
2020-11-28 20:12:58 +00:00
if (WorldInfo.MusicComp!=None)
2017-10-20 02:00:49 +00:00
{
WorldInfo.MusicComp.FadeOut(WorldInfo.CurrentMusicTrack.FadeOutTime,WorldInfo.CurrentMusicTrack.FadeOutVolumeLevel);
WorldInfo.MusicComp = None;
}
Music.SoundClass = 'Music'; // Force music group for this.
A = WorldInfo.CreateAudioComponent(Music,false,false,false,,false);
2020-11-28 20:12:58 +00:00
if (A!=None)
2017-10-20 02:00:49 +00:00
{
// update the new component with the correct settings
A.bAutoDestroy = true;
A.bShouldRemainActiveIfDropped = true;
A.bIsMusic = true;
A.bAutoPlay = true;
A.bIgnoreForFlushing = false;
2020-11-28 20:04:55 +00:00
A.FadeIn(0.25, 1.f);
2017-10-20 02:00:49 +00:00
}
WorldInfo.MusicComp = A;
WorldInfo.CurrentMusicTrack.TheSoundCue = Music;
WorldInfo.CurrentMusicTrack.FadeInTime = 1;
WorldInfo.CurrentMusicTrack.FadeOutTime = 1;
}
final function AbortConnection()
{
2020-11-28 20:12:58 +00:00
if (bConnectionFailed)
2017-10-20 02:00:49 +00:00
HandleNetworkError(false);
else
{
ShowConnectionProgressPopup(PMT_ConnectionFailure,ConnectionAborted,UserAbortedConnection,true);
2017-10-20 02:00:49 +00:00
ConsoleCommand("Cancel");
}
}
2020-11-28 20:04:55 +00:00
reliable client event TeamMessage(PlayerReplicationInfo PRI, coerce string S, name Type, optional float MsgLifeTime );
2017-10-20 02:00:49 +00:00
2020-11-28 20:04:55 +00:00
reliable client event bool ShowConnectionProgressPopup(EProgressMessageType ProgressType, string ProgressTitle, string ProgressDescription, bool SuppressPasswordRetry = false)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (bConnectionFailed)
2017-10-20 02:00:49 +00:00
return false;
2020-11-28 20:12:58 +00:00
switch (ProgressType)
2017-10-20 02:00:49 +00:00
{
case PMT_ConnectionFailure:
case PMT_PeerConnectionFailure:
bConnectionFailed = true;
MS_HUD(myHUD).ShowProgressMsg(ConnectionError@ProgressTitle$"|"$ProgressDescription$"|"$Disconnecting,true);
2017-10-20 02:00:49 +00:00
SetTimer(4,false,'HandleNetworkError');
return true;
case PMT_DownloadProgress:
case PMT_AdminMessage:
MS_HUD(myHUD).ShowProgressMsg(ProgressTitle$"|"$ProgressDescription);
return true;
}
return false;
}
2020-11-28 20:04:55 +00:00
exec function CustomStartFire(optional byte FireModeNum)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (!MS_HUD(myHUD).ActiveGame.bGameStarted)
2017-10-20 02:00:49 +00:00
MS_HUD(myHUD).ActiveGame.StartGame();
}
exec function SelectNextWeapon()
{
MS_HUD(myHUD).ActiveGame.AdjustSensitivity(true);
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
exec function SelectPrevWeapon()
{
MS_HUD(myHUD).ActiveGame.AdjustSensitivity(false);
}
auto state PlayerWaiting
{
ignores SeePlayer, HearNoise, NotifyBump, TakeDamage, PhysicsVolumeChange, NextWeapon, PrevWeapon, SwitchToBestWeapon;
2020-11-28 20:04:55 +00:00
reliable server function ServerChangeTeam(int N);
2017-10-20 02:00:49 +00:00
reliable server function ServerRestartPlayer();
function PlayerMove(float DeltaTime)
{
}
}
defaultproperties
{
InputClass=class'MS_Input'
2023-05-14 02:49:12 +00:00
2017-10-20 02:00:49 +00:00
Begin Object Class=MS_PendingData Name=UserPendingData
End Object
TravelData=UserPendingData
}