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

UTGame.UTPickupFactory


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
/**
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */
class UTPickupFactory extends PickupFactory
	abstract
	native
	nativereplication
	hidecategories(Display,Collision,PickupFactory);

var		bool			bRotatingPickup;	// if true, the pickup mesh rotates
var		float			YawRotationRate;
var		Controller		TeamOwner[4];		// AI controller currently going after this pickup (for team coordination)

/**  pickup base mesh */
var transient StaticMeshComponent BaseMesh;

/** Used to pulse the emissive on the base */
var MaterialInstanceConstant BaseMaterialInstance;

/** The baseline material colors */
var LinearColor BaseBrightEmissive;		// When the pickup is on the base
var LinearColor	BaseDimEmissive;		// When the pickup isn't on the base

/** When set to true, this base will begin pulsing it's emissive */
var repnotify bool bPulseBase;

/** How fast does the base pulse */
var float BasePulseRate;

/** How much time left in the current pulse */
var float BasePulseTime;

/** This pickup base will begin pulsing when there are PulseThreshold seconds left
    before respawn. */
var float PulseThreshold;

/** The TargetEmissive Color */
var LinearColor BaseTargetEmissive;
var LinearColor BaseEmissive;

/** This material instance parameter for adjusting the emissive */
var name BaseMaterialParamName;

// Used when floating
var	bool	bFloatingPickup;	// if true, the pickup mesh floats (bobs) slightly
var(floating)	bool	bRandomStart;		// if true, this pickup will start at a random height
var				float 	BobTimer;			// Tracks the bob time.  Used to create the position
var				float 	BobOffset;			// How far to bob.  It will go from +/- this number
var				float 	BobSpeed;			// How fast should it bob
var				float	BobBaseOffset;		// The base offset (Translation.Y) cached

/** sound played when the pickup becomes available */
var SoundCue RespawnSound;

/** Sound played on base while available to pickup*/
var AudioComponent PickupReadySound;

/** The pickup's light environment */
var DynamicLightEnvironmentComponent LightEnvironment;

/** In disabled state */
var repnotify bool bIsDisabled;

/** whether this pickup is updating */
var bool bUpdatingPickup;

/** Translation of pivot point */
var vector PivotTranslation;

/** Name used for the stats system */
var name PickupStatName;

/**
 * This determines whether this health pickup fades in or not.
 *
 * NOTE:  need to move this up to the highest pickup factory so all items will fade in
 **/
var bool bDoVisibilityFadeIn;
var name VisibilityParamName;

/** holds the pickups material so parameters can be set **/
var MaterialInstanceConstant MIC_Visibility;
/** holds the pickups 2nd material so parameters can be set **/
var MaterialInstanceConstant MIC_VisibilitySecondMaterial;

var repnotify bool bIsRespawning;

var ParticleSystemComponent Glow; // the glowing effect that comes from the base on spawn
var name GlowEmissiveParam;

var bool bHasLocationSpeech;

var Array<SoundNodeWave> LocationSpeech;

var float LastSeekNotificationTime;

var	ForceFeedbackWaveform	PickUpWaveForm;

var bool bTrackPickup;
var int PickupIndex;


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

replication
{
	if ( bNetDirty && (Role == Role_Authority) )
		bPulseBase,bIsRespawning;
	if (bNetInitial && ROLE==ROLE_Authority )
		bIsDisabled;
}

simulated function PostBeginPlay()
{
	if ( bIsDisabled )
	{
		return;
	}

	Super.PostBeginPlay();

	bUpdatingPickup = (WorldInfo.NetMode != NM_DedicatedServer) && (bRotatingPickup || bFloatingPickup);
	if(Glow != none)
	{
		Glow.SetFloatParameter('LightStrength',0.0f);
		Glow.SetActive(true);
	}

	// Grab a reference to the material so we can adjust the parameter.  This adjustment occurs natively
	// in TickSpecial()
	if ( WorldInfo.NetMode != NM_DedicatedServer && BaseMesh != none && BaseMaterialParamName != '' )
	{
		BaseMaterialInstance = BaseMesh.CreateAndSetMaterialInstanceConstant(0);

		BaseTargetEmissive = bPickupHidden ? BaseDimEmissive : BaseBrightEmissive;
		BaseEmissive = BaseTargetEmissive;

		BaseMaterialInstance.SetVectorParameterValue( BaseMaterialParamName, BaseEmissive );
	}

	if(!bIsSuperItem && PickupReadySound != none)
	{
		PickupReadySound.Play();
	}

	// increase pickup radius on console
	if ( WorldInfo.bUseConsoleInput )
	{
		SetCollisionSize(1.5*CylinderComponent.CollisionRadius, CylinderComponent.CollisionHeight);
	}

	if ( bTrackPickup == true && WorldInfo.NetMode != NM_Client)
	{
		PickupIndex = UTGame(WorldInfo.Game).GetNextPickupIndex();
		//`log("Assigning PickupIndex "$PickupIndex$" to "$self);
	}
}

simulated function SetResOut()
{
	if (bDoVisibilityFadeIn && MIC_Visibility != None)
	{
		MIC_Visibility.SetScalarParameterValue(VisibilityParamName, 1.f);
	}
}

simulated function DisablePickup()
{
	bIsDisabled = true;
	GotoState('Disabled');
}

simulated function ShutDown()
{
	DisablePickup();
}

/**
  * Look for changes in bPulseBase or bPickupHidden and set the TargetEmissive accordingly
  */
simulated function ReplicatedEvent(name VarName)
{
	if ( VarName == 'bIsDisabled' )
	{
		Global.SetInitialState();
	}
	else
	{
		if(VarName == 'bPickupHidden' && bPickupHidden)
		{
			setResOut();
		}
		if ( VarName == 'bPulseBase' || VarName == 'bPickupHidden' )
		{
			StartPulse((bPickupHidden && !bPulseBase) ? BaseDimEmissive : BaseBrightEmissive);
		}
		if(VarName == 'bIsRespawning' )
		{
			if(bIsRespawning)
			{
				RespawnEffect();
			}
		}
		Super.ReplicatedEvent(VarName);
	}
}

/**
  * Returns true if Bot should wait for me
  */
function bool ShouldCamp(UTBot B, float MaxWait)
{
	return ( ReadyToPickup(MaxWait) && (B.RatePickup(self, InventoryType) > 0) && !ReadyToPickup(0) );
}

/* UpdateHUD()
Called for the HUD of the player that picked it up
*/
simulated static function UpdateHUD(UTHUD H)
{
	H.LastPickupTime = H.WorldInfo.TimeSeconds;
}

simulated function RespawnEffect()
{
	bIsRespawning = true;
	PlaySound(RespawnSound, true);
	if (PickupMesh != None)
	{
		PickupMesh.SetHidden(false);
	}
}

/* epic ===============================================
* ::StopsProjectile()
*
* returns true if Projectiles should call ProcessTouch() when they touch this actor
*/
simulated function bool StopsProjectile(Projectile P)
{
	local Actor HitActor;
	local vector HitNormal, HitLocation;

	if ( (P.CylinderComponent.CollisionRadius > 0) || (P.CylinderComponent.CollisionHeight > 0) )
	{
		// only collide if zero extent trace would also collide
		HitActor = Trace(HitLocation, HitNormal, P.Location, P.Location - 100*Normal(P.Velocity), true, vect(0, 0, 0));
		if ( HitActor != self )
			return false;
	}

	return bProjTarget || bBlockActors;
}


/**
 * Pulse to the Brightest point
 */
simulated function StartPulse(LinearColor TargetEmissive)
{
	if ( WorldInfo.NetMode != NM_DedicatedServer && BaseMesh != none && BaseMaterialParamName != '' )
	{
		BaseTargetEmissive = TargetEmissive;
		if ( BasePulseTime <= 0.0 )
		{
			BasePulseTime = BasePulseRate;
		}
		else
		{
			BasePulseTime = BasePulseRate - BasePulseTime;
		}
	}
}

auto state Pickup
{
	function BeginState(Name PreviousStateName)
	{
		Super.BeginState(PreviousStateName);

		bPulseBase = false;
		StartPulse( BaseBrightEmissive );
    }
	simulated function EndState(Name NextStateName)
	{
		Super.EndState(NextStateName);
		bIsRespawning = false;
		SetResOut();
	}

}

State Sleeping
{
	function BeginState(Name PreviousStateName)
	{
		Super.BeginState(PreviousStateName);

		bPulseBase = false;
		StartPulse( BaseDimEmissive );
		SetTimer( GetReSpawnTime() - PulseThreshold, false, 'PulseThresholdMet');
	}

	function EndState(Name NextStateName)
	{
		Super.EndState(NextStateName);
		ClearTimer('PulseThresholdMet');
	}

	function PulseThresholdMet()
	{
		bPulseBase = true;
		StartPulse(BaseBrightEmissive);
	}
}

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

	InitPickupMeshEffects();

}

/**
 * Stats
 */
function name GetPickupStatName()
{
/*	local UTItemPickupFactory myType;

	//TEMP
	MyType = UTItemPickupFactory(self);
	if (MyType != none)
	{
		//A non inventory things (like Ammo/Health/Powerup)
		`log("Pickedup:"@class.name);
	}
	else
	{
		//Actual inventory (like weapons)
		`log("Pickedup Inv:"@InventoryType.name);
	}
	//ENDTEMP
*/
	if ( Default.PickupStatName != '' )
	{
		//`log("Returning:"@Default.PickupStatName);
		return Default.PickupStatName;
	}

	return 'INVALID_PICKUPSTAT';
}

/** split out from SetPickupMesh() for subclasses that don't want to do the base PickupFactory implementation */
simulated event InitPickupMeshEffects()
{
	if ( PickupMesh != none )
	{
		PickupMesh.SetLightEnvironment(LightEnvironment);

		// Create a material instance for the pickup
		if (bDoVisibilityFadeIn && MeshComponent(PickupMesh) != None)
		{
			MIC_Visibility = MeshComponent(PickupMesh).CreateAndSetMaterialInstanceConstant(0);
			MIC_Visibility.SetScalarParameterValue(VisibilityParamName, bIsSuperItem ? 1.f : 0.f);
		}

		BobBaseOffset = PickupMesh.Translation.Y;
		if ( bRandomStart )
		{
			BobTimer = 1000 * frand();
		}
	}
}

simulated function SetPickupVisible()
{
	if(PickupReadySound != none)
	{
		PickupReadySound.Play();
	}

	if(Glow != none)
	{
		Glow.SetFloatParameter('LightStrength', 1.0f);
	}

	Super.SetPickupVisible();
}

simulated function SetPickupHidden()
{
	if(PickupReadySound != none)
	{
		PickupReadySound.Stop();
	}

	if(Glow != none)
	{
		Glow.SetFloatParameter('LightStrength',0.0f);
	}

	// need to hide also for low end video cards
	Super.SetPickupHidden();
}

simulated event SetInitialState()
{
	bScriptInitialized = true;

	if ( bIsDisabled )
	{
		GotoState('Disabled');
	}
	else
	{
		super.SetInitialState();
	}
}

function PickedUpBy(Pawn P)
{
	local UTBot B;
	local PlayerController PC;

	Super.PickedUpBy(P);

	// clear bot NoVehicleGoal so if it got out of vehicle to get a pickup it will consider getting back in now
	B = UTBot(P.Controller);
	if (B != None && B.NoVehicleGoal == self)
	{
		B.NoVehicleGoal = None;
	}

	PC = PlayerController(P.Controller);
	if(PC != None)
   	{
      		UTPlayerReplicationInfo(P.PlayerReplicationInfo).UpdatePickupFlags(PickupIndex);
   	}
}

State Disabled
{
	function float BotDesireability(Pawn P, Controller C)
	{
		return 0;
	}
}

defaultproperties
{
   bDoVisibilityFadeIn=True
   YawRotationRate=32768.000000
   BaseBrightEmissive=(R=0.000000,G=0.000000,B=0.000000,A=1.000000)
   BaseDimEmissive=(R=0.000000,G=0.000000,B=0.000000,A=1.000000)
   BasePulseRate=0.500000
   PulseThreshold=5.000000
   BaseTargetEmissive=(R=0.000000,G=0.000000,B=0.000000,A=1.000000)
   BaseEmissive=(R=0.000000,G=0.000000,B=0.000000,A=1.000000)
   BaseMaterialParamName="BaseEmissiveControl"
   RespawnSound=SoundCue'A_Pickups.Generic.Cue.A_Pickups_Generic_ItemRespawn_Cue'
   Begin Object Class=DynamicLightEnvironmentComponent Name=PickupLightEnvironment ObjName=PickupLightEnvironment Archetype=DynamicLightEnvironmentComponent'Engine.Default__DynamicLightEnvironmentComponent'
      AmbientGlow=(R=0.300000,G=0.300000,B=0.300000,A=1.000000)
      bCastShadows=False
      bDynamic=False
      Name="PickupLightEnvironment"
      ObjectArchetype=DynamicLightEnvironmentComponent'Engine.Default__DynamicLightEnvironmentComponent'
   End Object
   LightEnvironment=PickupLightEnvironment
   VisibilityParamName="ResIn"
   GlowEmissiveParam="LightStrength"
   PickUpWaveForm=ForceFeedbackWaveform'UTGame.Default__UTPickupFactory:ForceFeedbackWaveformPickUp'
   PickupIndex=-1
   Begin Object Class=CylinderComponent Name=CollisionCylinder ObjName=CollisionCylinder Archetype=CylinderComponent'Engine.Default__PickupFactory:CollisionCylinder'
      CollisionHeight=44.000000
      ObjectArchetype=CylinderComponent'Engine.Default__PickupFactory:CollisionCylinder'
   End Object
   CylinderComponent=CollisionCylinder
   GoodSprite=None
   BadSprite=None
   Components(0)=CollisionCylinder
   Begin Object Class=PathRenderingComponent Name=PathRenderer ObjName=PathRenderer Archetype=PathRenderingComponent'Engine.Default__PickupFactory:PathRenderer'
      ObjectArchetype=PathRenderingComponent'Engine.Default__PickupFactory:PathRenderer'
   End Object
   Components(1)=PathRenderer
   Components(2)=PickupLightEnvironment
   Begin Object Class=StaticMeshComponent Name=BaseMeshComp ObjName=BaseMeshComp Archetype=StaticMeshComponent'Engine.Default__StaticMeshComponent'
      LightEnvironment=DynamicLightEnvironmentComponent'UTGame.Default__UTPickupFactory:PickupLightEnvironment'
      CullDistance=7000.000000
      CachedCullDistance=7000.000000
      bUseAsOccluder=False
      CastShadow=False
      bForceDirectLightMap=True
      bCastDynamicShadow=False
      LightingChannels=(BSP=True,Static=True)
      CollideActors=False
      Name="BaseMeshComp"
      ObjectArchetype=StaticMeshComponent'Engine.Default__StaticMeshComponent'
   End Object
   Components(3)=BaseMeshComp
   bMovable=False
   CollisionComponent=CollisionCylinder
   Name="Default__UTPickupFactory"
   ObjectArchetype=PickupFactory'Engine.Default__PickupFactory'
}

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:23.569 - Created with UnCodeX