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

UTDom.DominationFactory


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
/**
 * Base class for the actor that LD can place into a map.
 * This factory, at runtime, will spawn the ControlPoint needed by the game.
 * 
 * Writen by Brian 'Snake' Alexander. Copyright(c) 2007-2010 All Rights Reserved.
 */
class DominationFactory extends UTGameObjective
   abstract
   hidecategories(Collision);

/** The displayed name of this point. ObjectiveName is localized and can also be used. */
var() string PointName;
/** Reference to the ControlPoint or xDomPointA/B that is spawned during the begining of play */
var ControlPoint myControlPoint;
/** ControlPoint class that will be spawned by this factory.
 * if LD require a way to control what point will be A or B in DoubleDom games, then use this.
 * NOTE: Set ONLY ONE ControlPointFactory actor to xDomPointA and there must also be another ControlPointFactory actor set to xDomPointB (ONLY ONE ACTOR).
 * All other ControlPointFactory actors must be set to none.
 */
var(Advanced) class<ControlPoint> ControlPointClass;
/** Allows LD to specify the ControlPointClass to be used when testing the map in the Play-In-Editor gamemode. None=ControlPoint*/
var(Debug) class<ControlPoint> PIEControlPointClass;
/** mesh that is only used with the UnrealEditor/Play in Editor, and should not be displayed during gameplay. */
var StaticMeshComponent EditorDomMesh;
var PointLightComponent DomLight;
var DynamicLightEnvironmentComponent LightEnvironment;
/** whether to render this points name above this point on HUD beacon (using PostRenderFor()) */
var() bool bDrawBeaconName;

replication
{
   if (bNetInitial && (Role == ROLE_Authority))
      PointName;
   if (Role==ROLE_Authority)
      myControlPoint;
}

simulated function PreBeginPlay()
{
   Super.PreBeginPlay();

   // Hide the EditorDomMesh for game play.
   if (EditorDomMesh != None)
      EditorDomMesh.SetHidden(True);

   if (ROLE == ROLE_Authority)
      SpawnControlPoint();
}

/** 
 * spawns the needed type of DominationObjective
 */
function SpawnControlPoint()
{
   local int i;

   // if this is a Play-In-Editor game, force it to use class defined by the PIEControlPointClass setting
   if (WorldInfo != None && WorldInfo.IsPlayInEditor())
   {
      if (PIEControlPointClass == None)
         PIEControlPointClass = class'UTDom.ControlPoint';

      LogInternal("WorldInfo.IsPlayInEditor() is True!  Setting ControlPointClass to "$string(PIEControlPointClass),);
      ControlPointClass = PIEControlPointClass;
   }

   if ( !bHidden )
   {
      if (ControlPointClass != None && myControlPoint == None)
      {
         myControlPoint = Spawn(ControlPointClass, self);
         if (myControlPoint != None)
         {
            bIsActive = True;
            // Copy any properties that a LD may have set
            myControlPoint.PointName = GetHumanReadableName();
            myControlPoint.HomeBase = self;
            myControlPoint.DefensePriority = DefensePriority;
            myControlPoint.bIsActive = bIsActive;
            myControlPoint.DefenderTeamIndex = DefenderTeamIndex;
            myControlPoint.MyBaseVolume = MyBaseVolume;
            myControlPoint.BaseRadius = BaseRadius;
            myControlPoint.AttackAnnouncement = AttackAnnouncement;
            myControlPoint.DefendAnnouncement = DefendAnnouncement;
            myControlPoint.bBlocked = bBlocked;
            myControlPoint.bOneWayPath = bOneWayPath;
            myControlPoint.bVehicleDestination = bVehicleDestination;
            myControlPoint.bMakeSourceOnly = bMakeSourceOnly;
            myControlPoint.bBlockedForVehicles = bBlockedForVehicles;
            myControlPoint.bPreferredVehiclePath = bPreferredVehiclePath;
            myControlPoint.ExtraCost = ExtraCost;
            myControlPoint.bDrawBeaconName = bDrawBeaconName;
            for (i=0; i < LocationSpeech.Length; i++)
            {
               myControlPoint.LocationSpeech.AddItem(LocationSpeech[i]);
            }

            for (i=0; i < VehicleParkingSpots.Length; i++)
            {
               myControlPoint.VehicleParkingSpots.AddItem(VehicleParkingSpots[i]);
            }
            DomLight.SetLightProperties(0.0);
            DomLight.SetEnabled(False);
            bForceNetUpdate = True;
         }
      }
   }
   else if (myControlPoint != None)
   {
      // we shouldn't have a DominationObjective in this case, so destroy it
      myControlPoint.Destroy();
   }
}

simulated function string GetHumanReadableName()
{
   if (PointName != "")
      return PointName;
   else
      return ObjectiveName;
}

simulated function bool PoweredBy(byte Team)
{
   if (myControlPoint != None && myControlPoint.ControllingTeam != None)
   {
      if ( (myControlPoint.ControllingTeam.TeamIndex != 255 && Team == myControlPoint.ControllingTeam.TeamIndex) ||
         (myControlPoint.ControllingTeam.TeamIndex != 4 && Team == myControlPoint.ControllingTeam.TeamIndex) )
         return True;
   }

   return False;
}

static function byte IsValidDOMTeamID(byte TeamID)
{
   // 255 is Neutral but we need a value between 0-5
   if (TeamID > 5)
      return 4;

   return TeamID;
}

/**
 * this gets called by GetTeamNum()
 */
simulated event byte ScriptGetTeamNum()
{
   local byte b;

   b = 254;
   if (myControlPoint != None)
   {
      if (myControlPoint.bIsDisabled)
         b = 5;
      else if (myControlPoint.ControllingTeam != None && myControlPoint.DefenderTeamIndex != 255)
         b = myControlPoint.ControllingTeam.TeamIndex;
      else
         b = 4;
   }

   if (b == 254)
   {
      if ( IsDisabled() )
         b = 5;
      else if ( IsNeutral() || DefenderTeamIndex == 255 )
         b = 4;
      else
         b = DefenderTeamIndex;
   }
   return IsValidDOMTeamID(b);
}

simulated function int GetControllingTeamNum()
{
   if (myControlPoint != None)
   {
      if (myControlPoint.bIsDisabled)
         return 5;

      if (myControlPoint.ControllingTeam != None && myControlPoint.DefenderTeamIndex != 255)
         return myControlPoint.ControllingTeam.TeamIndex;
   }
   return 4;
}

simulated function bool IsNeutral()
{
   if (myControlPoint != none && myControlPoint.bIsActive && myControlPoint.ControllingTeam != none)
   {
      if (myControlPoint.ControllingTeam.TeamIndex == 4 || myControlPoint.ControllingTeam.TeamIndex == 255)
         return True;
   }
   else if (DefenderTeamIndex == 4 || DefenderTeamIndex == 255)
   {
      return True;
   }

   return False;
}

simulated function bool IsDisabled()
{
   if (myControlPoint == None)
      return True;
   if (myControlPoint != None)
      return (myControlPoint.bIsDisabled);
   else if (DefenderTeamIndex == 5)
      return True;

   return False;
}

/** 
 * triggers all DOMSeqEvent_ControlPointEvent attached to this objective with the given Controlling Team event type
 * 
 * @param TeamIndex        The TeamID of the EventInstigator
 * @param EventInstigator  The Controller that triggered this to go off
 */
function TriggerKismetEvent(byte TeamIndex, Controller EventInstigator)
{
   local DOMSeqEvent_ControlPointEvent DomEvent;
   local int i;
   local name EventType;

   switch (TeamIndex)
   {
      case 0:
         EventType = 'Red';
         break;
      case 1:
         EventType = 'Blue';
         break;
      case 2:
         EventType = 'Green';
         break;
      case 3:
         EventType = 'Gold';
         break;
      case 5:
         EventType = 'Disabled';
         break;
      default:
         EventType = 'Neutral';
         break;
   }

   for (i = 0; i < GeneratedEvents.length; i++)
   {
      DomEvent = DOMSeqEvent_ControlPointEvent(GeneratedEvents[i]);
      if (DomEvent != None)
         DomEvent.Trigger(EventType, EventInstigator);
   }
}

/**
 * triggers all DOMSeqEvent_ControlPointEvent attached to this objective with the given flag event type 
 */
function TriggerFlagEvent(name EventType, Controller EventInstigator)
{
   local DOMSeqEvent_ControlPointEvent DOMEvent;
   local int i;

   for (i = 0; i < GeneratedEvents.length; i++)
   {
      DOMEvent = DOMSeqEvent_ControlPointEvent(GeneratedEvents[i]);
      if (DOMEvent != None)
         DOMEvent.Trigger(EventType, EventInstigator);
   }
}

/**
 * adds the given team static mesh to our list and initializes its team
 * 11/13/2008 - Changed to now use the AddItem() for adding to the TeamStaticMeshes array.
 *              Safer then using TeamStaticMeshes[TeamStaticMeshes.length]
 */
simulated function AddTeamStaticMesh(UTTeamStaticMesh SMesh)
{
   local int d;

   TeamStaticMeshes.AddItem(SMesh);
   d = DefenderTeamIndex;
   SMesh.SetTeamNum(d);
}

/**
 * updates TeamStaticMeshes array for a change in our team
 * 11/13/2008 - Removed the IsValidDOMTeamID checks and returned to the original logic in UTGameObjective.UpdateTeamStaticMeshes()
 */
simulated function UpdateTeamStaticMeshes()
{
   local int i, d;

   d = DefenderTeamIndex;
   for (i = 0; i < TeamStaticMeshes.length; i++)
   {
      TeamStaticMeshes[i].SetTeamNum(d);
   }
}

/**
 * TellBotHowToDisable()
 * tell bot what to do to disable me.
 * 
 * @return  true if valid/useable instructions were given
 */
function bool TellBotHowToDisable(UTBot B)
{
   local UTVehicle VehicleEnemy;
/* The following variables are Not used. Kept for backwards conform compatibility */
   local DOMSquadAI DOM_SquadAI;
   local UTBot OtherB;
   local bool bCloserTeammate;
   local float Dist;
   local DominationFactory DF; 
   local Pawn Pw;
   local UTGameObjective SqOb;

   if (DefenderTeamIndex == B.Squad.Team.TeamIndex)
      return False;

   if (!PoweredBy(B.Squad.Team.TeamIndex))
       return B.Squad.FindPathToObjective(B, self);

   //take out defensive turrets first
   VehicleEnemy = UTVehicle(B.Enemy);
   if ( VehicleEnemy != None && (VehicleEnemy.bStationary || VehicleEnemy.bIsOnTrack) &&
      (VehicleEnemy.AIPurpose == AIP_Defensive || VehicleEnemy.AIPurpose == AIP_Any) && B.LineOfSightTo(B.Enemy) )
   {
      return False;
   }

   if ( StandGuard(B) )
      return TooClose(B);

   // The following code is never used.
   // This is only here so there are no compiler warnings
   if (DefenderTeamIndex == 142)
   {
      DOM_SquadAI = None;
      OtherB = None;
      bCloserTeammate = False;
      Dist = 0.0f;
      DF = None;
      Pw = None;
      SqOb = None;
      if (DOM_SquadAI != None && OtherB != None && bCloserTeammate && DF != None && Pw != None && SqOb != None && Dist != 0.0)
         return False;
   }
}

/** 
 *  if bot is in important vehicle, and other bots can do the dirty work,
 *  return false if within get out distance
 *  @note based from UTOnslaughtObjective
 */
function bool StandGuard(UTBot B)
{
   local UTBot SquadMate;
   local float Dist;
   local int i;
   local UTVehicle BotVehicle;
   local UTVehicle_Deployable DeployableVehicle;

   if (DefenderTeamIndex != B.PlayerReplicationInfo.GetTeamNum() && DefenderTeamIndex < 2)
   {
      return False;
   }

   BotVehicle = UTVehicle(B.Pawn);
   if (BotVehicle != None && BotVehicle.ImportantVehicle())
   {
      Dist = VSize(BotVehicle.Location - Location);
      if (ReachedParkingSpot(BotVehicle) || (Dist < BotVehicle.ObjectiveGetOutDist && B.LineOfSightTo(self)))
      {
         if (BotVehicle.bKeyVehicle && BotVehicle.CanAttack(self))
         {
            DeployableVehicle = B.GetDeployableVehicle();
            if (DeployableVehicle != None && DeployableVehicle.DeployedState == EDS_Undeployed)
            {
               DeployableVehicle.SetTimer(0.01, False, 'ServerToggleDeploy');
            }
            return True;
         }
         if ( DefenderTeamIndex == B.PlayerReplicationInfo.Team.TeamIndex ||
            (B.Enemy != None && WorldInfo.TimeSeconds - B.LastSeenTime < 2) )
         {
            return True;
         }

         // check if there's a passenger
         if (BotVehicle.Seats.length > 1)
         {
            for (i = 1; i < BotVehicle.Seats.length; i++)
            {
               if (BotVehicle.Seats[i].SeatPawn != None)
               {
                  SquadMate = UTBot(BotVehicle.Seats[i].SeatPawn.Controller);
                  if (SquadMate != None)
                  {
                     BotVehicle.Seats[i].SeatPawn.DriverLeave(False);
                     return True;
                  }
               }
            }
         }

         // check if there's another bot around to do it
         for (SquadMate = B.Squad.SquadMembers; SquadMate != None; SquadMate = SquadMate.NextSquadMember)
         {
            if ( SquadMate.Pawn != None && (UTVehicle(SquadMate.Pawn) == None || !UTVehicle(SquadMate.Pawn).ImportantVehicle())
               && VSize(SquadMate.Pawn.Location - Location) < Dist + 2000.0 && SquadMate.RouteGoal == self )
            {
               return True;
            }
         }
      }
   }

   return False;
}

/**
 * @note based off UTOnslaughtObjective 
 */
function bool TooClose(UTBot B)
{
   local UTBot SquadMate;
   local int R;

   if ( (VSize(Location - B.Pawn.Location) < 2*B.Pawn.GetCollisionRadius()) && (PathList.Length > 1) )
   {
      //standing right on top of it, move away a little
      B.GoalString = "Move away from "$self;
      R = Rand(PathList.Length-1);
      B.MoveTarget = PathList[R].End.Nav;
      for ( SquadMate=B.Squad.SquadMembers; SquadMate!=None; SquadMate=SquadMate.NextSquadMember )
      {
         if ( (SquadMate.Pawn != None) && (VSize(SquadMate.Pawn.Location - B.MoveTarget.Location) < B.Pawn.GetCollisionRadius()) )
         {
            B.MoveTarget = PathList[R+1].End.Nav;
            break;
         }
      }
      B.SetAttractionState();
      return True;
   }
   return False;
}

function DisableThisPoint()
{
   ControlPointClass = None;
   bIsActive = False;
   bIsDisabled = True;
   DomLight.SetLightProperties(0.0);
   SetHidden(True);
   SetCollision(false,false);
   DefenderTeamIndex = 255;
   bForceNetUpdate = TRUE;
   if (myControlPoint != none && myControlPoint.bIsActive)
      myControlPoint.DisableThisPoint();

   GotoState('Disabled');
}

State Disabled
{
   ignores Touch;
}

function Reset()
{
   super.Reset();
   bIsActive = True;
   bIsDisabled = False;
   DefenderTeamIndex = 255;
}

DefaultProperties
{
   Components.Remove(Sprite)
   GoodSprite=None
   Begin Object Name=Sprite2
      Scale=0.85
   End Object
   Begin Object Name=CollisionCylinder
      CollisionRadius=+60.0
      CollisionHeight=+80.0
      CollideActors=True
      BlockRigidBody=False
   End Object
   CollisionType=COLLIDE_TouchAll
   CollisionComponent=CollisionCylinder
   Components.Add(CollisionCylinder)
   Begin Object Class=DynamicLightEnvironmentComponent Name=DomPointLightEnvironment
      LightDesaturation=20.0
   End Object
   LightEnvironment=DomPointLightEnvironment
   Components.Add(DomPointLightEnvironment)
   Begin Object Class=StaticMeshComponent Name=EditorStaticMeshComponent0
      StaticMesh=StaticMesh'DOM_Content.Meshes.DomN'
      CastShadow=False
      bCastDynamicShadow=False
      bAcceptsLights=False
      bAcceptsDynamicLights=False
      LightEnvironment=DomPointLightEnvironment
      CollideActors=False
      CullDistance=7000
      bUseAsOccluder=False
      BlockRigidBody=False
      HiddenEditor=False
      AlwaysLoadOnClient=False
      AlwaysLoadOnServer=False
   End Object
   EditorDomMesh=EditorStaticMeshComponent0
   Components.Add(EditorStaticMeshComponent0)
   Begin Object Class=PointLightComponent Name=DomLightComponent
      Radius=400
      Brightness=5.0
      LightColor=(B=180,G=180,R=180)
      LightingChannels=(BSP=TRUE,Static=TRUE,Dynamic=TRUE,CompositeDynamic=TRUE)
      CastShadows=True
      UseDirectLightMap=False
      CastDynamicShadows=True
      bForceDynamicLight=True
   End Object
   DomLight=DomLightComponent
   Components.Add(DomLightComponent)
   bStatic=True
   bStasis=False
   bNoDelete=True
   bCollideActors=True
   bCollideWorld=True
   bWorldGeometry=False
   bPushedByEncroachers=False
   bCollideWhenPlacing=True
   bIgnoreEncroachers=True
   bPathColliding=True
   bDestinationOnly=True
   bNotBased=True
   bHasSensor=True
   bCanWalkOnToReach=True
   NetUpdateFrequency=1
   bBlockActors=False
   bEdShouldSnap=True
   bAlwaysRelevant=True
   bGameRelevant=True
   bDrawBeaconName=True
   RemoteRole=ROLE_SimulatedProxy
   DrawScale=0.44
   CameraViewDistance=320.0
   DefenderTeamIndex=255
   StartTeam=255
   DefensePriority=2
   PIEControlPointClass=class'UTDom.ControlPoint'
   SupportedEvents.Add(class'UTDom.DOMSeqEvent_ControlPointEvent')
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 13/12/2010 01:43:24.000 - Creation time: Fri 23/12/2011 20:31:26.304 - Created with UnCodeX