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

UTGame.UTCarriedObject


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
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
/**
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */
class UTCarriedObject extends Actor
    native 
	abstract 
	notplaceable
    dependson(UTPlayerController);

var const NavigationPoint LastAnchor;		// recent nearest path
var		float	LastValidAnchorTime;	// last time a valid anchor was found

var repnotify bool bHome;
var bool			bLastSecondSave;
/** set when leaving Dropped state, to stop some of its state functions from doing anything during EndState() */
var bool bLeavingDroppedState;

/** Distance within which a bot can toss this to a player teammate */
var float		TossDistance;

var repnotify UTPlayerReplicationInfo HolderPRI;
var Pawn      Holder;

var UTGameObjective   HomeBase;
/** offset for placing object when at home */
var vector HomeBaseOffset;
var float           TakenTime;
var float           MaxDropTime;
var Controller FirstTouch;			// Who touched this objective first
var array<Controller> Assists;		// Who touches it after

// HUD Rendering
var vector HUDLocation;
var float MapSize;
var TextureCoordinates IconCoords;	/** Coordiates of the icon associated with this object */
var Texture2D IconTexture;

var name 	GameObjBone3P;       /**  Bone to which this carriedobject should be attached in third person */
var vector	GameObjOffset3P;     /**  Offset from attachment bone in third person */
var rotator	GameObjRot3P;        /**  Rotation from attachment bone in third person */
var vector GameObjOffset1P; /** Offset from holder Location in first person */
var rotator GameObjRot1P; /** Offset from holder Rotation in first person */

/** sound to play when we are picked up */
var SoundCue PickupSound;
/** sound to play when we are dropped */
var SoundCue DroppedSound;
/** sound to play when we are sent home */
var SoundCue ReturnedSound;

var Pawn 			OldHolder;
var PointLightComponent FlagLight;
var float			DefaultRadius, DefaultHeight;

var repnotify UTTeamInfo 		Team;

/** announcements used when telling player to pick this object up */
var array<ObjectiveAnnouncementInfo> NeedToPickUpAnnouncements;

// Keep track of our base-most actor.
var Actor	OldBase;
var Actor	OldBaseBase;

/** Used for highlighting on minimap */
var float HighlightScale;
var float MaxHighlightScale;
var float HighlightSpeed;
var float LastHighlightUpdate;

var bool bUseTeamColorForIcon;

/** Used by bots sending voice messages about enemy flag carrier */
var float LastFlagSeeTime;
var int LastSeeMessageIndex;

var LinearColor RedColor, BlueColor, GoldColor;

var ForceFeedbackWaveform PickUpWaveForm;

// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)

replication
{
    if (Role == ROLE_Authority)
		bHome, HolderPRI, Team, HomeBase;
}

// Initialization
function PostBeginPlay()
{
    HomeBase = UTGameObjective(Owner);
    SetOwner(None);

    Super.PostBeginPlay();

	if ( CylinderComponent(CollisionComponent) != None )
	{
		DefaultRadius = CylinderComponent(CollisionComponent).CollisionRadius;
		DefaultHeight = CylinderComponent(CollisionComponent).CollisionHeight;
	}
}

/**
  * Called when player "uses" this flag
  * Return true if use had an effect
  */
function bool FlagUse(Controller C)
{
	return false;
}

/** returns true if should be rendered for passed in player */
simulated function bool ShouldMinimapRenderFor(PlayerController PC)
{
	return true;
}

/** function used to update where icon for this actor should be rendered on the HUD
 *  @param NewHUDLocation is a vector whose X and Y components are the X and Y components of this actor's icon's 2D position on the HUD
 */
simulated native function SetHUDLocation(vector NewHUDLocation);

simulated function HighlightOnMinimap(int Switch)
{
	if ( HighlightScale < 1.25 )
	{
		HighlightScale = MaxHighlightScale;
		LastHighlightUpdate = WorldInfo.TimeSeconds;
	}
}

simulated function Texture2D GetIconTexture()
{
	return class'UTHUD'.default.IconHudTexture;
}

simulated function DrawIcon(Canvas Canvas, vector IconLocation, float IconWidth, float IconAlpha)
{
	local float YoverX;
	local LinearColor DrawColor;

	if ( bUseTeamColorForIcon )
	{
		DrawColor = (Team.TeamIndex == 0) ? RedColor : BlueColor;
	}
	else
	{
		DrawColor = GoldColor;
	}
	DrawColor.A = IconAlpha;
	YoverX = IconCoords.VL / IconCoords.UL;
	Canvas.SetPos(IconLocation.X - 0.5 * IconWidth, IconLocation.Y - 0.5 * IconWidth * YoverX);
	Canvas.DrawColorizedTile(IconTexture, IconWidth, IconWidth * YoverX , IconCoords.U, IconCoords.V, IconCoords.UL, IconCoords.VL, DrawColor);
}

simulated function RenderMapIcon(UTMapInfo MP, Canvas Canvas, UTPlayerController PlayerOwner)
{
	local float CurrentScale;

	if ( HighlightScale > 1.0 )
	{
		CurrentScale = (WorldInfo.TimeSeconds - LastHighlightUpdate)/HighlightSpeed;
		HighlightScale = FMax(1.0, HighlightScale - CurrentScale * MaxHighlightScale);
		CurrentScale = HighlightScale;
	}
	else
	{
		CurrentScale = 1.0;
	}
	DrawIcon(Canvas, HUDLocation, IconCoords.UL * (Canvas.ClipY / 768) * MapSize * CurrentScale, 1.0);

}

simulated function RenderEnemyMapIcon(UTMapInfo MP, Canvas Canvas, UTPlayerController PlayerOwner, UTGameObjective NearbyObjective)
{
	local float YoverX,IconWidth;
	local float FlashScale, CurrentScale;
	local LinearColor DrawColor;

	FlashScale = 0.5*abs(cos(2*WorldInfo.TimeSeconds));
	DrawColor = (Team.TeamIndex == 0) ? RedColor : BlueColor;
	DrawColor.G = FlashScale;

	if ( HighlightScale > 1.0 )
	{
		CurrentScale = (WorldInfo.TimeSeconds - LastHighlightUpdate)/HighlightSpeed;
		HighlightScale = FMax(1.0, HighlightScale - CurrentScale * MaxHighlightScale);
		CurrentScale = HighlightScale;
	}
	else
	{
		CurrentScale = 1.0;
	}

	IconWidth = IconCoords.UL * (Canvas.ClipY / 768) * MapSize * CurrentScale;
	YoverX = IconCoords.VL / IconCoords.UL;
	Canvas.SetPos(HudLocation.X - 0.5 * IconWidth, HudLocation.Y - 0.5 * IconWidth * YoverX);
	Canvas.DrawColorizedTile(IconTexture, IconWidth, IconWidth * YoverX , IconCoords.U, IconCoords.V, IconCoords.UL, IconCoords.VL, DrawColor);
}

/** GetTeamNum()
* returns teamindex of team with which this UTCarriedObject is associated.
*/
simulated native function byte GetTeamNum();

// State transitions
function SetHolder(Controller C)
{
	local int i;
	local UTPlayerController PC;
	local UTBot B;
	local Controller OtherC;

	//`log(self$" setholder c="$c,, 'GameObject');
	LogTaken(c);
	Holder = C.Pawn;
	if ( UTPawn(Holder) != None )
	{
		UTPawn(Holder).DeactivateSpawnProtection();
	}
	HolderPRI = UTPlayerReplicationInfo(Holder.PlayerReplicationInfo);
	HolderPRI.SetFlag(self);
	HolderPRI.bForceNetUpdate = TRUE;
	LastFlagSeeTime = WorldInfo.TimeSeconds - 11;
	GotoState('Held');

	// AI Related
	C.MoveTimer = -1;
	Holder.MakeNoise(2.0);

	// update players and bots that were coming for this object
	PC = UTPlayerController(C);
	if (PC != None)
	{
		PC.CheckAutoObjective(false);

		PC.ClientPlayForceFeedbackWaveform(PickUpWaveForm);
	}
	foreach WorldInfo.AllControllers(class'Controller', OtherC)
	{
		PC = UTPlayerController(OtherC);
		if (PC != None)
		{
			if (PC.LastAutoObjective == self)
			{
				PC.CheckAutoObjective(true);
			}
		}
		else if (OtherC.MoveTarget == self || OtherC.MoveTarget == HomeBase || OtherC.RouteGoal == self || OtherC.RouteGoal == HomeBase)
		{
			B = UTBot(OtherC);
			if (B != None && B.Squad != None)
			{
				B.Squad.Retask(B);
			}
		}
	}

	// Track First Touch
	if (FirstTouch == None)
		FirstTouch = C;

	// Track Assists
	for (i=0;i<Assists.Length;i++)
		if (Assists[i] == C)
		  return;

	Assists.Length = Assists.Length+1;
  	Assists[Assists.Length-1] = C;

	SendFlagMessage(C);
}

function SendFlagMessage(Controller C)
{
	C.SendMessage(None, 'HOLDINGFLAG', 10);
}

function Score()
{
	GetKismetEventObjective().TriggerFlagEvent('Captured', Holder != None ? Holder.Controller : None);
	//`log(self$" score holder="$holder,, 'GameObject');

	// Don't return the flag if the game has ended
	if ( !WorldInfo.Game.bGameEnded )
	{
		Disable('Touch');
		SetLocation(HomeBase.Location + (HomeBaseOffset >> HomeBase.Rotation));
		SetRotation(HomeBase.Rotation);
		CalcSetHome();
		GotoState('Home');
	}
}

/** called to drop the flag
 */
function Drop(optional Controller Killer)
{
	local UTPlayerController PC;

	OldHolder = Holder;
	HomeBase.ObjectiveChanged();
	RotationRate.Yaw = Rand(200000) - 100000;
	RotationRate.Pitch = Rand(200000 - Abs(RotationRate.Yaw)) - 0.5 * (200000 - Abs(RotationRate.Yaw));

	if ( (OldHolder != None) && (OldHolder.health > 0) )
	{
		Velocity = 0.5 * Holder.Velocity;
		if ( Holder.Health > 0 )
			Velocity += 300*vector(Holder.Rotation) + 100 * (0.5 + FRand()) * VRand();
	}
	Velocity.Z = 250;
	if ( PhysicsVolume.bWaterVolume )
		Velocity *= 0.5;

	//`log(self$" drop holder="$holder,, 'GameObject');
	BaseBoneName = '';
	BaseSkelComponent = None;

	SetLocation(Holder.Location);
	if ( Killer != None )
	{
		LogDropped(Killer);
	}
	else
	{
		LogDropped(Holder.Controller);
	}
	GotoState('Dropped');

	ForEach WorldInfo.AllControllers(class'UTPlayerController', PC)
	{
		PC.CheckAutoObjective(true);
	}
}

/** called to send the flag to its home base
 * @param Returner the player responsible for returning the flag (may be None)
 */
function SendHome(Controller Returner)
{
	local UTPlayerController PC;

	CalcSetHome();
	LogReturned(Returner);
	PlaySound(ReturnedSound);
	GotoState('Home');

	ForEach WorldInfo.AllControllers(class'UTPlayerController', PC)
	{
		if ( PC.LastAutoObjective == self )
		{
			PC.CheckAutoObjective(true);
		}
	}
}

/** called when a Kismet action returns the flag */
function KismetSendHome()
{
	BroadcastReturnedMessage();
	SendHome(None);
}

function BroadcastReturnedMessage()
{
	if ( !WorldInfo.GRI.bMatchIsOver )
	{
		BroadcastLocalizedMessage(MessageClass, 3 + 7 * GetTeamNum(), None, None, Team);
	}
}

function BroadcastDroppedMessage(Controller EventInstigator)
{
	if ( !WorldInfo.GRI.bMatchIsOver )
	{
		if ( EventInstigator == None )
			BroadcastLocalizedMessage(MessageClass, 2 + 7 * GetTeamNum(), HolderPRI, None, Team);
		else
			BroadcastLocalizedMessage(MessageClass, 2 + 7 * GetTeamNum(), HolderPRI, EventInstigator.PlayerReplicationInfo, Team);
	}
}

function BroadcastTakenFromBaseMessage(Controller EventInstigator)
{
	BroadcastLocalizedMessage(MessageClass, 6 + 7 * GetTeamNum(), EventInstigator.PlayerReplicationInfo, None, Team);
}

function BroadcastTakenDroppedMessage(Controller EventInstigator)
{
	if ( !WorldInfo.GRI.bMatchIsOver )
	{
		BroadcastLocalizedMessage(MessageClass, 4 + 7 * GetTeamNum(), EventInstigator.PlayerReplicationInfo, None, Team);
	}
}

// Helper funcs
protected function CalcSetHome()
{
	local Controller c;

	// AI Related
	foreach WorldInfo.AllControllers(class'Controller', C)
	{
		if (c.MoveTarget == self)
		{
			c.MoveTimer = -1.0;
		}
	}

	OldHolder = None;

	// Reset the assists and First Touch
	FirstTouch = None;
	while (Assists.Length!=0)
	  Assists.Remove(0,1);
}

function ClearHolder()
{
	local int i;
	local UTGameReplicationInfo GRI;
	local UTPlayerReplicationInfo PRI;
	local UTBot B;

	if (Holder == None)
		return;

	if ( Holder.PlayerReplicationInfo == None )
	{
		GRI = UTGameReplicationInfo(WorldInfo.Game.GameReplicationInfo);
		for (i=0; i<GRI.PRIArray.Length; i++)
		{
			PRI = UTPlayerReplicationInfo(GRI.PRIArray[i]);
			if ( PRI.GetFlag() == self )
			{
				PRI.SetFlag(None);
				PRI.bForceNetUpdate = TRUE;
				B = UTBot(PRI.Owner);
			}
		}
	}
	else
	{
		UTPlayerReplicationInfo(Holder.PlayerReplicationInfo).SetFlag(None);
		Holder.PlayerReplicationInfo.bForceNetUpdate = TRUE;
		B = UTBot(Holder.Controller);
	}

	Holder = None;
	HolderPRI = None;

	if ( B != None )
	{
		B.SetMaxDesiredSpeed();
	}
}

function Actor Position()
{
	if (Holder != None)
	{
		return Holder;
	}
	else if (bHome)
	{
		return HomeBase;
	}
	else
	{
		return self;
	}
}

function bool ValidHolder(Actor other)
{
	local Pawn p;
	local UTPawn UTP;
	local UTBot B;

	p = Pawn(other);
	if ( p == None || p.Health <= 0 || !p.bCanPickupInventory || !p.IsPlayerPawn() || Vehicle(p.base) != None || p == OldHolder
		|| (UTVehicle(p) != None && !UTVehicle(p).bCanCarryFlag) )
	{
		return false;
	}

	// feigning death pawns can't pick up flags
	UTP = UTPawn(Other);
	if (UTP != None && UTP.IsInState('FeigningDeath'))
	{
		return false;
	}

	B = UTBot(P.Controller);
	if (B != None)
	{
		B.NoVehicleGoal = None;
	}

	return true;
}

// Events
singular event Touch( Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal )
{
    if (!ValidHolder(Other))
	return;

    SetHolder(Pawn(Other).Controller);
}

simulated event FellOutOfWorld(class<DamageType> dmgType)
{
	if ( Role == ROLE_Authority )
	{
		AutoSendHome();
	}
}

simulated event ReplicatedEvent(name VarName)
{
	if (VarName == 'bHome')
	{
		if (bHome)
		{
			ClientReturnedHome();
		}
	}
	else
	{
		Super.ReplicatedEvent(VarName);
	}
}

/** called on the client when the flag is returned */
simulated function ClientReturnedHome()
{
	// things can go a little screwy with replication ordering due to all the base/physics/location changes that go on
	// so we use this to make sure the flag's where it should be clientside
	if (HomeBase != None)
	{
		SetLocation(HomeBase.Location + (HomeBaseOffset >> HomeBase.Rotation));
		SetRotation(HomeBase.Rotation);
		SetPhysics(PHYS_None);
	}
}

event NotReachableBy(Pawn P)
{
	if ( (Physics != PHYS_Falling) && (WorldInfo.Game.NumBots > 0)
		&& (!UTGame(WorldInfo.Game).bAllowTranslocator || (UTBot(P.Controller) == None) || UTBot(P.Controller).CanUseTranslocator()) )
	{
		SendHome(None);
	}
}

event Landed(vector HitNormal, actor FloorActor)
{
	local UTBot B;
	local rotator NewRot;

	NewRot = Rot(16384,0,0);
	NewRot.Yaw = Rotation.Yaw;
	SetRotation(NewRot);
	OldHolder = None;

	//`log(self$" landed",, 'GameObject');

	// tell nearby bots about this
	foreach WorldInfo.AllControllers(class'UTBot', B)
	{
		if ( B.Pawn != None && B.RouteGoal != self && B.MoveTarget != self
			&& VSize(B.Pawn.Location - Location) < 1600.f && B.LineOfSightTo(self) )
		{
			B.Squad.Retask(B);
		}
	}
}

/** returns the game objective we should trigger Kismet flag events on */
function UTGameObjective GetKismetEventObjective()
{
	return HomeBase;
}

simulated event OnBaseChainChanged();

// Logging
function LogTaken(Controller EventInstigator)
{
	GetKismetEventObjective().TriggerFlagEvent('Taken', EventInstigator);
}

function LogReturned(Controller EventInstigator)
{
	GetKismetEventObjective().TriggerFlagEvent('Returned', EventInstigator);
}

// Logging
function LogDropped(Controller EventInstigator)
{
	GetKismetEventObjective().TriggerFlagEvent('Dropped', EventInstigator);
	if ( bLastSecondSave && (EventInstigator != Holder.Controller) )
	{
		BroadcastLocalizedMessage(class'UTLastSecondMessage', 1, HolderPRI, None, Team);
		if ( UTPlayerReplicationInfo(EventInstigator.PlayerReplicationInfo) != None )
		{
			UTPlayerReplicationInfo(EventInstigator.PlayerReplicationInfo).IncrementEventStat('EVENT_LASTSECONDSAVE');
		}
	}
	else
	{
		BroadcastDroppedMessage(EventInstigator);
	}
	bLastSecondSave = false;
}

function CheckTouching()
{
	local int i;
	local Controller BestToucher;
	local Pawn PastHolder;

	PastHolder = OldHolder;
	OldHolder = None;
	for ( i=0; i<Touching.Length; i++ )
	{
		if ( ValidHolder(Touching[i]) )
		{
			if ( PlayerController(Pawn(Touching[i]).Controller) != None )
			{
				if ( PastHolder != Touching[i] )
				{
					SetHolder(Pawn(Touching[i]).Controller);
				}
				return;
			}
			else if ( BestToucher == None )
			{
				// players get priority over bots
				BestToucher = Pawn(Touching[i]).Controller;
			}
		}
	}

	if ( BestToucher != None )
	{
		SetHolder(BestToucher);
	}
}

/** send home without player intervention (timed out, fell out of world, etc) */
function AutoSendHome()
{
	BroadcastReturnedMessage();
	SendHome(None);
}

// States
auto state Home
{
	ignores SendHome, KismetSendHome, Score, Drop;

	function LogTaken(Controller EventInstigator)
	{
		Global.LogTaken(EventInstigator);
		BroadcastTakenFromBaseMessage(EventInstigator);
	}

	function Timer()
	{
		local vector FinalLoc;

		FinalLoc = HomeBase.Location + (HomeBaseOffset >> HomeBase.Rotation);
		if (VSize2D(Location - FinalLoc) > 10.0 || Abs(Location.Z - FinalLoc.Z) > CylinderComponent(CollisionComponent).CollisionHeight)
		{
			BroadcastReturnedMessage();
			LogInternal(self$" Home.Timer: had to sendhome",'Error');
			BeginState('');
		}
	}

	function BeginState(Name PreviousStateName)
	{
		SetTimer(1.0, true);

		Disable('Touch');
		bHome = true;
		if (SetLocation(HomeBase.Location + (HomeBaseOffset >> HomeBase.Rotation)))
		{
			SetRotation(HomeBase.Rotation);
			SetCollision(true, false);
			Enable('Touch');
		}
		else
		{
			WarnInternal("Failed to return flag home!");
			// let timer try again later
		}
	}

	function EndState(Name NextStateName)
	{
		SetTimer(0.0, false);
		bHome = false;
		TakenTime = WorldInfo.TimeSeconds;
	}

Begin:
	// check if an enemy was standing on the base
	Sleep(0.05);
	CheckTouching();
}

state Held
{
	ignores SetHolder;

	function SendHome(Controller Returner)
	{
		// go through most of the drop code before returning home to make sure everything gets reset properly
		OldHolder = Holder;
		HomeBase.ObjectiveChanged();

		BaseBoneName = '';
		BaseSkelComponent = None;
		SetLocation(Holder.Location);

		GotoState('Dropped');

		Global.SendHome(Returner);
	}

	function KismetSendHome()
	{
		BroadcastReturnedMessage();
		SendHome(None);
	}

	function Timer()
	{
		if (Holder == None)
		{
			LogInternal(self$" Held.Timer: had to sendhome",'Error');
			BroadcastReturnedMessage();
			SendHome(None);
		}
	}

	function BeginState(Name PreviousStateName)
	{
		UTGameReplicationInfo(WorldInfo.GRI).SetFlagHeldEnemy(GetTeamNum());
		WorldInfo.GRI.bForceNetUpdate = TRUE;
		bCollideWorld = false;
		SetCollision(false, false);
		SetLocation(Holder.Location);
		if ( UTPawn(Holder) != None )
		{
			UTPawn(Holder).HoldGameObject(self);
		}
		bForceNetUpdate = TRUE;
		SetTimer(10.0, true);
		HomeBase.ObjectiveChanged();
		if (PickupSound != None)
		{
			PlaySound(PickupSound);
		}
	}

	function EndState(Name NextStateName)
	{
		//`log(self$" held.endstate",, 'GameObject');
		ClearHolder();
		SetBase(None);
		SetHardAttach(FALSE);
		bForceNetUpdate = TRUE;
	}
}

/** stubs for Dropped functions in case the state gets exited early due to flag being in invalid location */
function CheckFit();
function CheckPain();

state Dropped
{
	ignores Drop;

	function LogTaken(Controller EventInstigator)
	{
		Global.LogTaken(EventInstigator);
		BroadcastTakenDroppedMessage(EventInstigator);
	}

	function CheckFit()
	{
		local vector X,Y,Z;

		GetAxes(OldHolder.Rotation, X,Y,Z);
		SetRotation(rotator(-1 * X));
		if ( !SetLocation(OldHolder.Location - 2 * OldHolder.GetCollisionRadius() * X + OldHolder.GetCollisionHeight() * vect(0,0,0.5))
		    && !SetLocation(OldHolder.Location) && (OldHolder.GetCollisionRadius() > 0) )
		{
			SetCollisionSize(FMin(DefaultRadius,0.8 * OldHolder.GetCollisionRadius()), FMin(DefaultHeight, 0.8 * OldHolder.GetCollisionHeight()));
			if ( !SetLocation(OldHolder.Location) )
			{
				//`log(self$" Drop sent flag home",,'Error');
				AutoSendHome();
				return;
			}
		}
	}

	function CheckPain()
	{
		if (IsInPain())
		{
			AutoSendHome();
		}
	}

	event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
	{
		CheckPain();
	}

	singular function PhysicsVolumeChange( PhysicsVolume NewVolume )
	{
		if (!bLeavingDroppedState)
		{
			CheckPain();
		}
	}

	function Timer()
	{
		AutoSendHome();
	}

	singular event BaseChange()
	{
		if (Pawn(Base) != None)
		{
			// landing on Pawns is not allowed
			if (bLeavingDroppedState)
			{
				SetBase(None);
				SetHardAttach(FALSE);
			}
			else
			{
				Velocity = 100.0 * VRand();
				Velocity.Z += 200.0;
				SetPhysics(PHYS_Falling);
			}
		}
	}

	function BeginState(Name PreviousStateName)
	{
		if (DroppedSound != None)
		{
			PlaySound(DroppedSound);
		}
		UTGameReplicationInfo(WorldInfo.GRI).SetFlagDown(GetTeamNum());
		WorldInfo.GRI.bForceNetUpdate = TRUE;
		SetTimer(MaxDropTime, false);
		SetPhysics(PHYS_Falling);
		bCollideWorld = true;
		SetCollisionSize(0.75 * DefaultRadius, DefaultHeight);
		SetCollision(true, false);
		CheckFit();
		CheckPain();
	}

	function EndState(Name NextStateName)
	{
		//`log(self$" dropped.endstate",, 'GameObject');
		bLeavingDroppedState = true;
		SetPhysics(PHYS_None);
		bForceNetUpdate = TRUE;
		bCollideWorld = false;
		SetCollisionSize(DefaultRadius, DefaultHeight);
		ClearTimer();
		bLeavingDroppedState = false;
	}
Begin:
	// check if an enemy was standing on the flag
	Sleep(0.05);
	CheckTouching();
}

defaultproperties
{
   TossDistance=1500.000000
   MaxDropTime=25.000000
   MapSize=1.000000
   IconCoords=(U=599.000000,V=236.000000,UL=25.000000,VL=25.000000)
   IconTexture=Texture2D'UI_HUD.HUD.UI_HUD_BaseA'
   MaxHighlightScale=8.000000
   HighlightSpeed=10.000000
   LastSeeMessageIndex=-1
   RedColor=(R=1.000000,G=0.000000,B=0.000000,A=1.000000)
   BlueColor=(R=0.000000,G=0.000000,B=1.000000,A=1.000000)
   GoldColor=(R=1.000000,G=1.000000,B=0.000000,A=1.000000)
   PickUpWaveForm=ForceFeedbackWaveform'UTGame.Default__UTCarriedObject:ForceFeedbackWaveformPickUp'
   Begin Object Class=CylinderComponent Name=CollisionCylinder ObjName=CollisionCylinder Archetype=CylinderComponent'Engine.Default__CylinderComponent'
      CollisionHeight=30.000000
      CollisionRadius=48.000000
      CollideActors=True
      Name="CollisionCylinder"
      ObjectArchetype=CylinderComponent'Engine.Default__CylinderComponent'
   End Object
   Components(0)=CollisionCylinder
   RemoteRole=ROLE_SimulatedProxy
   bIgnoreRigidBodyPawns=True
   bOrientOnSlope=True
   bAlwaysRelevant=True
   bUpdateSimulatedPosition=True
   CollisionComponent=CollisionCylinder
   CollisionType=COLLIDE_CustomDefault
   Name="Default__UTCarriedObject"
   ObjectArchetype=Actor'Engine.Default__Actor'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:18:20.000 - Creation time: sk 18-3-2018 10:01:19.127 - Created with UnCodeX