Botpack
Class ControlPoint

source: e:\games\UnrealTournament\Botpack\Classes\ControlPoint.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.NavigationPoint
         |
         +--Botpack.ControlPoint
Direct Known Subclasses:None

class ControlPoint
extends Engine.NavigationPoint

//============================================================================= // ControlPoint. //=============================================================================
Variables
 Name BlueEvent
 Sound ControlSound
 Pawn Controller
 TeamInfo ControllingTeam
 Name GoldEvent
 Name GreenEvent
 String PointName
 Name RedEvent
 int ScoreTime
 bool bScoreReady
 bool bSelfDisplayed


Function Summary
 string GetHumanName()
 void PostBeginPlay()
 void Timer()
 void Touch(Actor Other)
 void UpdateStatus()



Source Code


00001	//=============================================================================
00002	// ControlPoint.
00003	//=============================================================================
00004	class ControlPoint extends NavigationPoint;
00005	
00006	#exec TEXTURE IMPORT NAME=GoldSkin2 FILE=..\unrealshare\models\gold.PCX GROUP="None"
00007	#exec TEXTURE IMPORT NAME=RedSkin2 FILE=..\unrealshare\MODELS\ChromR.PCX GROUP=Skins 
00008	#exec TEXTURE IMPORT NAME=BlueSkin2 FILE=..\unrealshare\MODELS\ChromB.PCX GROUP=Skins 
00009	
00010	// Red Team
00011	#exec MESH IMPORT MESH=DomR ANIVFILE=MODELS\DomR_a.3d DATAFILE=MODELS\DomR_d.3d X=0 Y=0 Z=0
00012	#exec MESH ORIGIN MESH=DomR X=0 Y=0 Z=0
00013	#exec MESH SEQUENCE MESH=DomR SEQ=All  STARTFRAME=0 NUMFRAMES=1
00014	#exec MESH SEQUENCE MESH=DomR SEQ=DomR STARTFRAME=0 NUMFRAMES=1
00015	#exec MESHMAP NEW   MESHMAP=DomR MESH=DomR
00016	#exec MESHMAP SCALE MESHMAP=DomR X=0.1 Y=0.1 Z=0.2
00017	#exec MESHMAP SETTEXTURE MESHMAP=DomR NUM=0 TEXTURE=RedSkin2
00018	
00019	// Blue Team
00020	#exec MESH IMPORT MESH=DomB ANIVFILE=MODELS\DomB_a.3d DATAFILE=MODELS\DomB_d.3d X=0 Y=0 Z=0
00021	#exec MESH ORIGIN MESH=DomB X=0 Y=0 Z=0
00022	#exec MESH SEQUENCE MESH=DomB SEQ=All  STARTFRAME=0 NUMFRAMES=1
00023	#exec MESH SEQUENCE MESH=DomB SEQ=DomB STARTFRAME=0 NUMFRAMES=1
00024	#exec MESHMAP NEW   MESHMAP=DomB MESH=DomB
00025	#exec MESHMAP SCALE MESHMAP=DomB X=0.1 Y=0.1 Z=0.2
00026	#exec MESHMAP SETTEXTURE MESHMAP=DomB NUM=0 TEXTURE=BlueSkin2
00027	
00028	// Gold Team
00029	#exec MESH IMPORT MESH=MercSymbol ANIVFILE=MODELS\MercSymbol_a.3d DATAFILE=MODELS\MercSymbol_d.3d X=0 Y=0 Z=0
00030	#exec MESH ORIGIN MESH=MercSymbol X=0 Y=0 Z=0
00031	#exec MESH SEQUENCE MESH=MercSymbol SEQ=All                      STARTFRAME=0 NUMFRAMES=1
00032	#exec MESH SEQUENCE MESH=MercSymbol SEQ=DomY                     STARTFRAME=0 NUMFRAMES=1
00033	#exec MESHMAP NEW   MESHMAP=MercSymbol MESH=MercSymbol
00034	#exec MESHMAP SCALE MESHMAP=MercSymbol X=0.1 Y=0.1 Z=0.2
00035	#exec MESHMAP SETTEXTURE MESHMAP=MercSymbol NUM=0 TEXTURE=GoldSkin2
00036	
00037	// Neutral
00038	#exec MESH IMPORT MESH=DomN ANIVFILE=MODELS\DomN_a.3d DATAFILE=MODELS\DomN_d.3d X=0 Y=0 Z=0
00039	#exec MESH ORIGIN MESH=DomN X=0 Y=0 Z=0
00040	#exec MESH SEQUENCE MESH=DomN SEQ=All  STARTFRAME=0 NUMFRAMES=1
00041	#exec MESH SEQUENCE MESH=DomN SEQ=DomN STARTFRAME=0 NUMFRAMES=1
00042	#exec TEXTURE IMPORT NAME=JDomN0 FILE=MODELS\ChromX.PCX GROUP=Skins
00043	#exec MESHMAP NEW   MESHMAP=DomN MESH=DomN
00044	#exec MESHMAP SCALE MESHMAP=DomN X=0.1 Y=0.1 Z=0.2
00045	#exec MESHMAP SETTEXTURE MESHMAP=DomN NUM=0 TEXTURE=JDomN0
00046	
00047	#exec AUDIO IMPORT FILE="Sounds\Domination\takeDP2.WAV" NAME="ControlSound" GROUP="Domination"
00048	
00049	var TeamInfo ControllingTeam;
00050	var Pawn Controller;
00051	var() Name RedEvent;
00052	var() Name BlueEvent;
00053	var() Name GreenEvent;
00054	var() Name GoldEvent;
00055	var() bool bSelfDisplayed;
00056	var() localized String PointName;
00057	var() Sound ControlSound;	
00058	var   int ScoreTime;
00059	var   bool bScoreReady;
00060	
00061	replication
00062	{
00063		// Variables the server should send to the client.
00064		reliable if( Role==ROLE_Authority )
00065			ControllingTeam, PointName;
00066	}
00067	
00068	function PostBeginPlay()
00069	{
00070		if ( !Level.Game.IsA('Domination') )
00071			return;
00072		else
00073		{
00074			Super.PostBeginPlay();
00075			bHidden = !bSelfDisplayed;
00076		}
00077	
00078		// Log the event.
00079		if (Level.Game.LocalLog != None)
00080		{
00081			Level.Game.LocalLog.LogSpecialEvent("controlpoint_created", PointName);
00082		}
00083		if (Level.Game.WorldLog != None)
00084		{
00085			Level.Game.WorldLog.LogSpecialEvent("controlpoint_created", PointName);
00086		}
00087	}
00088	
00089	function string GetHumanName()
00090	{
00091		return PointName;
00092	}
00093	
00094	function Touch(Actor Other)
00095	{
00096		if ( !Other.bIsPawn || !Pawn(Other).bIsPlayer || !Level.Game.IsA('Domination') )
00097			return;
00098	
00099		Controller = Pawn(Other);
00100		if ( Controller.IsA('Bot') && (Controller.MoveTarget == self) )
00101			Controller.MoveTimer = -1.0; // stop moving toward this
00102		UpdateStatus();
00103	}
00104	
00105	function UpdateStatus()
00106	{
00107		local Actor A;
00108		local Name E;
00109		local TeamInfo NewTeam;
00110		local TeamGamePlus T;
00111		local Bot B, B2;
00112		local Pawn P;
00113		local bool bNeedDefense, bTempDefense;
00114	
00115		T = TeamGamePlus(Level.Game);
00116		if ( Controller == None )
00117			NewTeam = None;
00118		else
00119	        NewTeam = T.GetTeam(Controller.PlayerReplicationInfo.Team);
00120	
00121		if ( NewTeam == ControllingTeam )
00122			return;
00123	
00124		ControllingTeam = NewTeam;
00125		if ( ControllingTeam != None )
00126		{
00127			// Log the event.
00128			if (Level.Game.LocalLog != None)
00129			{
00130				Level.Game.LocalLog.LogSpecialEvent("controlpoint_capture", PointName, Controller.PlayerReplicationInfo.PlayerID);
00131			}
00132			if (Level.Game.WorldLog != None)
00133			{
00134				Level.Game.WorldLog.LogSpecialEvent("controlpoint_capture", PointName, Controller.PlayerReplicationInfo.PlayerID);
00135			}
00136			PlaySound(ControlSound, SLOT_None, 12.0);
00137			BroadcastLocalizedMessage( class'ControlPointMessage', Controller.PlayerReplicationInfo.Team, None, None, Self );
00138			B = Bot(Controller);
00139			if ( B != None )
00140			{
00141				bNeedDefense = false;
00142				bTempDefense = false;
00143				B.SendTeamMessage(None, 'OTHER', 11, 15);
00144				if ( (B.Orders != 'Follow') && (B.Orders != 'Hold') )
00145				{
00146					for ( P=Level.PawnList; P!=None; P=P.NextPawn )
00147						if ( P.bIsPlayer && (P.PlayerReplicationInfo.Team == ControllingTeam.TeamIndex) )
00148						{
00149							bNeedDefense = true; // only defend if at least one other player on team
00150							B2 = Bot(P);
00151							if ( B2 == None ) 
00152								bTempDefense = true;
00153							else if ( ((B2.OrderObject == self) && (B2.Orders == 'Defend'))
00154									|| ((B2.OrderObject == B) && (B2.Orders == 'Follow')) )
00155							{
00156								bNeedDefense = false;
00157								break;
00158							}
00159						}
00160					if ( bNeedDefense )
00161					{
00162						if ( bTempDefense || (FRand() < 0.35) )
00163						{
00164							B.SetOrders('Freelance', None);
00165							B.Orders = 'Defend';
00166						}
00167						else
00168						{
00169							B.SetOrders('Defend', None);
00170							BotReplicationInfo(B.PlayerReplicationInfo).OrderObject = self;
00171						}
00172						B.OrderObject = self;
00173					}
00174				}
00175			}
00176			else if ( Controller.IsA('TournamentPlayer') )
00177			{
00178				if ( TournamentPlayer(Controller).bAutoTaunt )
00179					Controller.SendTeamMessage(None, 'OTHER', 11, 15);
00180				if ( DeathMatchPlus(Level.Game).bRatedGame
00181						&& (Controller == DeathMatchPlus(Level.Game).RatedPlayer) )
00182					DeathMatchPlus(Level.Game).bFulfilledSpecial = true;
00183			}
00184		}
00185		if ( bSelfDisplayed )
00186			bHidden = false;
00187	
00188		if ( ControllingTeam == None )
00189		{
00190			bScoreReady = false;
00191			E = '';
00192			if ( bSelfDisplayed ) 
00193			{
00194				DrawScale=0.4;
00195				Mesh = mesh'DomN';
00196				Texture=texture'JDomN0';
00197				LightHue=0;
00198			    LightSaturation=255;
00199			}
00200		}	
00201		else
00202		{
00203			ScoreTime = 2;
00204			SetTimer(1.0, true);
00205			if ( bSelfDisplayed )
00206			{
00207				LightBrightness=255;
00208				LightSaturation=0;
00209			}
00210			if ( Controller.PlayerReplicationInfo.Team == T.TEAM_Red )
00211			{
00212				E = RedEvent;
00213				if ( bSelfDisplayed )
00214				{
00215					DrawScale=0.4;
00216					Mesh = mesh'DomR';
00217					Texture = texture'RedSkin2';
00218					LightHue=0;
00219				}
00220			}
00221			else if ( Controller.PlayerReplicationInfo.Team == T.TEAM_Blue )
00222			{
00223				E = BlueEvent;
00224				if ( bSelfDisplayed )
00225				{
00226					DrawScale=0.4;
00227					Mesh = mesh'DomB';
00228					Texture = texture'BlueSkin2'; 
00229					LightHue=170;
00230				}
00231			}
00232			else if ( Controller.PlayerReplicationInfo.Team == T.TEAM_Green )
00233			{
00234				E = GreenEvent;
00235				if ( bSelfDisplayed )
00236				{
00237					DrawScale=1.0;
00238					Mesh=mesh'UDamage';
00239					Texture=Texture'UnrealShare.Belt_fx.ShieldBelt.NewGreen'; //FireTexture'UnrealShare.Belt_fx.ShieldBelt.Greenshield'; 
00240					LightHue=85;
00241				}
00242			}
00243			else if ( Controller.PlayerReplicationInfo.Team == T.TEAM_Gold )
00244			{
00245				E = GoldEvent;
00246				if ( bSelfDisplayed )
00247				{
00248					DrawScale=0.7;
00249					Mesh=mesh'MercSymbol';
00250					Texture=texture'GoldSkin2';
00251					LightHue=35;
00252				}
00253			}
00254		}
00255		if ( E != '' )
00256			foreach AllActors(class'Actor', A, E )
00257			 Trigger(self, Controller);
00258	}
00259	
00260	function Timer()
00261	{
00262		ScoreTime--;
00263		if (ScoreTime > 0)
00264			bScoreReady = false;
00265		else 
00266		{
00267			ScoreTime = 0;
00268			bScoreReady = true;
00269			SetTimer(0.0, false);
00270		}
00271	}
00272	
00273	defaultproperties
00274	{
00275	     bSelfDisplayed=True
00276	     PointName="Position"
00277	     ControlSound=Sound'Botpack.Domination.ControlSound'
00278	     bStatic=False
00279	     bNoDelete=True
00280	     bAlwaysRelevant=True
00281	     Physics=PHYS_Rotating
00282	     RemoteRole=ROLE_SimulatedProxy
00283	     DrawType=DT_Mesh
00284	     Texture=Texture'Botpack.Skins.JDomN0'
00285	     Mesh=LodMesh'Botpack.DomN'
00286	     DrawScale=0.400000
00287	     AmbientGlow=255
00288	     bUnlit=True
00289	     bMeshEnviroMap=True
00290	     SoundRadius=64
00291	     SoundVolume=255
00292	     bCollideActors=True
00293	     LightType=LT_SubtlePulse
00294	     LightEffect=LE_NonIncidence
00295	     LightBrightness=255
00296	     LightHue=170
00297	     LightSaturation=255
00298	     LightRadius=7
00299	     bFixedRotationDir=True
00300	     RotationRate=(Yaw=5000)
00301	     DesiredRotation=(Yaw=30000)
00302	}

End Source Code