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

Onslaught.ONSPlayerReplicationInfo


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
class ONSPlayerReplicationInfo extends xPlayerReplicationInfo
	config(user);

var ONSPowerCore StartCore; //always try to spawn player here. None means auto-select, value ignored if TemporaryStartCore != None
var ONSPowerCore TemporaryStartCore; //next time player respawns try to put him here (then this value is cleared)

enum EMapPreference
{
	MAP_Never,
	MAP_WhenBodyStill,
	MAP_Immediately
};

var globalconfig EMapPreference ShowMapOnDeath;
var bool bPendingMapDisplay;
var globalconfig string LinkDesignerClass;	//class of Link Designer menu
var Material TransMaterials[2];
var float PendingHealBonus; //node healing score bonus that hasn't yet been added to Score

replication
{
	reliable if (bNetDirty && Role == ROLE_Authority)
		StartCore;
	reliable if (Role < ROLE_Authority)
		SetStartCore, ServerSendPowerLinks, ServerReceivePowerLink, ServerRemovePowerLink, ServerClearPowerLinks, ServerSendSetupNames,
		ServerSetPowerLinkSetup, ServerSavePowerLinkSetup, ServerDeletePowerLinkSetup, RequestLinkDesigner, TeleportTo;
	reliable if (Role == ROLE_Authority)
		ClientPrepareToReceivePowerLinks, ClientReceivePowerLink, ClientRemovePowerLink, ClientReceiveSetupName,
		ClientReceiveCurrentSetup, ClientShowMap;
}

//these are set by the link designer
delegate OnReceiveLink( ONSPowerCore A, ONSPowerCore B );
delegate OnRemoveLink( ONSPowerCore A, ONSPowerCore B );
delegate ResetLinks();
delegate ProcessSetupName(string SetupName);
delegate RemoveSetupName(string SetupName);
delegate SetCurrentSetup(string SetupName);
delegate UpdateGUIMapLists(); //listen/standalone servers only

function SetStartCore(ONSPowerCore Core, bool bTemporary)
{
	if ( Core == None || ONSOnslaughtGame(Level.Game).ValidSpawnPoint(Core, Team.TeamIndex))
	{
		if (bTemporary)
			TemporaryStartCore = Core;
		else
			StartCore = Core;
	}
}

// returns the powecore/node the player is currently standing on or in the node teleport trigger radius of,
// if that core/node is currently constructed for the same team as the player
simulated function ONSPowerCore GetCurrentNode()
{
	local ONSPowerCore Core;
	local ONSPCTeleportTrigger T;

	if (Controller(Owner).Pawn != None)
	{
		if (Controller(Owner).Pawn.Base != None)
		{
			Core = ONSPowerCore(Controller(Owner).Pawn.Base);
			if (Core == None)
				Core = ONSPowerCore(Controller(Owner).Pawn.Base.Owner);
		}

		if (Core == None)
			foreach Controller(Owner).Pawn.TouchingActors(class'ONSPCTeleportTrigger', T)
			{
				Core = ONSPowerCore(T.Owner);
				if (Core != None)
					break;
			}
	}

	if (Core != None && Core.CoreStage == 0 && Core.DefenderTeamIndex == Team.TeamIndex)
		return Core;

	return None;
}

function TeleportTo(ONSPowerCore Core)
{
	local ONSPowerCore OldStartCore;
	local ONSPowerCore OwnerBase;

	OwnerBase = GetCurrentNode();
	if (OwnerBase != None && ONSOnslaughtGame(Level.Game).ValidSpawnPoint(Core, Team.TeamIndex))
	{
		OldStartCore = StartCore;
		StartCore = Core;
		if (!DoTeleport() && !DoTeleport()) //two tries
		{
			//FIXME error localmessage here!
		}
		StartCore = OldStartCore;
	}
}

function bool DoTeleport()
{
	local NavigationPoint NewStart;
	local vector PrevLocation;

	PrevLocation = Controller(Owner).Pawn.Location;
	NewStart = Level.Game.FindPlayerStart(Controller(Owner));
	if (NewStart != None && Controller(Owner).Pawn.SetLocation(NewStart.Location))
	{
		Controller(Owner).ClientSetRotation(NewStart.Rotation);
		if (xPawn(Controller(Owner).Pawn) != None)
			xPawn(Controller(Owner).Pawn).DoTranslocateOut(PrevLocation);
		Controller(Owner).Pawn.SetOverlayMaterial(TransMaterials[Team.TeamIndex], 1.0, false);
		Controller(Owner).Pawn.PlayTeleportEffect(false, false);
		return true;
	}

	return false;
}

function OwnerDied()
{
	if (PlayerController(Owner) != None )
		ClientShowMap();
}

simulated function ClientShowMap()
{
	if (ShowMapOnDeath > MAP_Never)
	{
		bPendingMapDisplay = true;
		SetTimer(0.75, true);
	}
}

simulated event Timer()
{
	local PlayerController PC;

	if (bPendingMapDisplay)
	{
		PC = Level.GetLocalPlayerController();
		if (PC != None && !PC.bDemoOwner && PC.Player != None && GUIController(PC.Player.GUIController) != None && !GUIController(PC.Player.GUIController).bActive)
		{
			if (PC.Pawn != None && PC.Pawn.Health > 0) //never automatically pop up map while player is playing!
			{
				bPendingMapDisplay = false;
				SetTimer(0, false);
			}
			else if (ShowMapOnDeath == MAP_Immediately || PC.ViewTarget == None || PC.ViewTarget == PC || VSize(PC.ViewTarget.Velocity) < 100)
			{
				PC.bMenuBeforeRespawn = false;
				bPendingMapDisplay = false;
				SetTimer(0, false);
				PC.ShowMidGameMenu(false);
			}
			else
				PC.bMenuBeforeRespawn = true;
		}
		else
		{
			bPendingMapDisplay = False;
			SetTimer(0, false);
		}
	}

	Super.Timer();
}

simulated function ClientPrepareToReceivePowerLinks()
{
	ResetLinks();
}

function ServerSendPowerLinks()
{
	local int i;
	local ONSOnslaughtGame Game;

	Game = ONSOnslaughtGame(Level.Game);
	for ( i = 0; i < Game.PowerLinks.Length; i++ )
		ClientReceivePowerLink(Game.PowerLinks[i].Nodes[0].Node, Game.PowerLinks[i].Nodes[1].Node);
}

simulated function ClientReceivePowerLink(ONSPowerCore From, ONSPowerCore To)
{
//	log(Name@"ClientReceivePowerLink A:"$From.Name@"B:"$To.Name);
	OnReceiveLink(From,To);
}

simulated function ClientRemovePowerLink(ONSPowerCore From, ONSPowerCore To)
{
	OnRemoveLink(From,To);
}

function ServerReceivePowerLink(ONSPowerCore From, ONSPowerCore To)
{
	local int i;
	local GameReplicationInfo GRI;

	if (PlayerController(Owner) == None || (Owner != Level.GetLocalPlayerController() && !bAdmin) || From == To)
		return;

	if ( ONSOnslaughtGame(Level.Game).AddLink(From,To) )
	{
		ONSOnslaughtGame(Level.Game).UpdateLinks();
		GRI = Level.Game.GameReplicationInfo;
		for ( i = 0; i < GRI.PRIArray.Length; i++ )
		{
			if ( PlayerController(GRI.PRIArray[i].Owner) == None ||
				 ONSPlayerReplicationInfo(GRI.PRIArray[i]) == None )
				continue;

			ONSPlayerReplicationInfo(GRI.PRIArray[i]).ClientReceivePowerLink(From,To);
		}
	}

}

function ServerRemovePowerLink(ONSPowerCore From, ONSPowerCore To)
{
	local int i;
	local GameReplicationInfo GRI;

	if (PlayerController(Owner) == None || (Owner != Level.GetLocalPlayerController() && !bAdmin) || From == To)
		return;

	if ( ONSOnslaughtGame(Level.Game).RemoveLink(From,To) )
	{
		ONSOnslaughtGame(Level.Game).UpdateLinks();
		GRI = Level.Game.GameReplicationInfo;
		for ( i = 0; i < GRI.PRIArray.Length; i++ )
		{
			if ( PlayerController(GRI.PRIArray[i].Owner) == None ||
				 ONSPlayerReplicationInfo(GRI.PRIArray[i]) == None )
				continue;

			ONSPlayerReplicationInfo(GRI.PRIArray[i]).ClientRemovePowerLink(From,To);
		}
	}
}

function ServerClearPowerLinks()
{
	local int i;
	local ONSOnslaughtGame Game;

	Game = ONSOnslaughtGame(Level.Game);

	while (Game.PowerLinks.length > 0)
		ServerRemovePowerLink(Game.PowerLinks[i].Nodes[0].Node, Game.PowerLinks[i].Nodes[1].Node);
}

function ServerSendSetupNames()
{
	local int x;

	for (x = 0; x < ONSOnslaughtGame(Level.Game).OfficialPowerLinkSetups.length && x < 1000; x++)
		ClientReceiveSetupName(ONSOnslaughtGame(Level.Game).OfficialPowerLinkSetups[x].SetupName);

	for (x = 0; x < ONSOnslaughtGame(Level.Game).CustomPowerLinkSetups.length && x < 1000; x++)
		ClientReceiveSetupName(string(ONSOnslaughtGame(Level.Game).CustomPowerLinkSetups[x].Name));

	ClientReceiveSetupName("");		//Indicate end of setup names

	ClientReceiveCurrentSetup(ONSOnslaughtGame(Level.Game).CurrentSetupName);
}

simulated function ClientReceiveSetupName(string SetupName)
{
	ProcessSetupName(SetupName);
}

simulated function ClientReceiveCurrentSetup(string SetupName)
{
	SetCurrentSetup(SetupName);
}

function ServerSetPowerLinkSetup(string SetupName)
{
	if (PlayerController(Owner) == None || (Owner != Level.GetLocalPlayerController() && !bAdmin))
		return;

	ONSOnslaughtGame(Level.Game).SetPowerLinkSetup(SetupName, PlayerController(Owner));
}

function ServerSavePowerLinkSetup(string SetupName)
{
	local array<ONSPowerCore> Traveled;

	if (PlayerController(Owner) == None || (Owner != Level.GetLocalPlayerController() && !bAdmin))
		return;

	if ( !ONSOnslaughtGame(Level.Game).ExistsLinkPathTo( ONSOnslaughtGame(Level.Game).PowerCores[ONSOnslaughtGame(Level.Game).FinalCore[0]],
							     ONSOnslaughtGame(Level.Game).PowerCores[ONSOnslaughtGame(Level.Game).FinalCore[1]],
							     Traveled ) )
	{
		PlayerController(Owner).ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 7);
		return;
	}

	if (ONSOnslaughtGame(Level.Game).SavePowerLinkSetup(SetupName, PlayerController(Owner)))
	{
		ClientReceiveSetupName(SetupName);
		UpdateGUIMapLists();
	}
}

function ServerDeletePowerLinkSetup(string SetupName)
{
	if (PlayerController(Owner) == None || (Owner != Level.GetLocalPlayerController() && !bAdmin))
		return;

	if (ONSOnslaughtGame(Level.Game).DeletePowerLinkSetup(SetupName, PlayerController(Owner)))
	{
		ClientRemoveSetupName(SetupName);
		UpdateGUIMapLists();
	}
}

simulated function ClientRemoveSetupName(string SetupName)
{
	RemoveSetupName(SetupName);
}

function RequestLinkDesigner()
{
	if (PlayerController(Owner) != None && (Owner == Level.GetLocalPlayerController() || bAdmin))
		PlayerController(Owner).ClientOpenMenu(LinkDesignerClass);
}

//scoring bonus for healing powernodes
//we wait until the healing bonus >= 1 point before adding to score to minimize ScoreEvent() calls
function AddHealBonus(float Bonus)
{
	PendingHealBonus += Bonus;
	if (PendingHealBonus >= 1.f)
	{
		Level.Game.ScoreObjective(self, PendingHealBonus);
		Level.Game.ScoreEvent(self, PendingHealBonus, "heal_powernode");
		PendingHealBonus = 0;
	}
}

function Reset()
{
	HasFlag = None;
	NumLives = 0;
	bOutOfLives = false;
}

defaultproperties
{
	ShowMapOnDeath=MAP_WhenBodyStill
	LinkDesignerClass="GUI2K4.UT2K4OnslaughtPowerLinkDesigner"
	TransMaterials(0)=Material'PlayerTransRed'
	TransMaterials(1)=Material'PlayerTrans'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 5.9.2006 22:31:48.000 - Creation time: Do 14.8.2014 09:58:46.970 - Created with UnCodeX