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

UPak.Cloak


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
//=============================================================================
// Cloak.uc
// $Author: Deb $
// $Date: 4/23/99 12:13p $
// $Revision: 1 $
//=============================================================================
class Cloak expands Pickup;

#exec TEXTURE IMPORT NAME=I_Cloak FILE=TEXTURES\CLOAK\i_invisi.PCX GROUP="Icons"  MIPS=OFF
#exec TEXTURE IMPORT NAME=CloakTexture FILE=TEXTURES\CLOAK\CloakTexture.PCX GROUP="CLOAK" 

#forceexec AUDIO IMPORT FILE="Sounds\Cloak\CloakOn.WAV" NAME="CloakOn" GROUP="Cloak"
#forceexec AUDIO IMPORT FILE="Sounds\Cloak\CloakOff.WAV" NAME="CloakOff" GROUP="Cloak"
#forceexec AUDIO IMPORT FILE="Sounds\Cloak\CloakLoop2.WAV" NAME="CloakLoop2" GROUP="Cloak"
#forceexec AUDIO IMPORT FILE="Sounds\Cloak\CloakLoop3.WAV" NAME="CloakLoop3" GROUP="Cloak"
#forceexec AUDIO IMPORT FILE="Sounds\Cloak\CloakLoop1a.WAV" NAME="CloakLoop1a" GROUP="Cloak"
#forceexec AUDIO IMPORT FILE="Sounds\Cloak\CloakLoop1b.WAV" NAME="CloakLoop1b" GROUP="Cloak"
// add fade-in effect for respawning? 

var weapon LastWeapon;			// Last Weapon wielded by owner
var int CountDown;				// Used in timing the "back to visible" routine
var rotator LastOwnerRotation;	// Used in checking owner's rotation vs last rotation
var bool bExpanding, bEngaging;	// Used in going invis routines (tick)
var Weapon InvisWeaponList[25];	// Array holding all affected weapons
var int ArrayCounter;			// Counter for array
var() float JumpZAdjustment;

function PostBeginPlay()
{
	if( JumpZAdjustment <= 1 )
		JumpZAdjustment = 1.5;
}


event float BotDesireability(Pawn Bot)
{
	local Cloak AlreadyHas;

	AlreadyHas = Cloak(Bot.FindInventoryType(Class));
	if( AlreadyHas == None )
		return MaxDesireability;
	else return 0;
}




function PickupFunction(Pawn Other)
{
	if( Other.IsA( 'Bots' ) )
	{
		// Small chance of activating on Pickup, else it heads to Idle2 state.
		if( FRand() < 0.13 )
			GotoState( 'Activated' );
	}
}

// ================================================================================================
// Activated State
// ================================================================================================

state Activated
{
	function BeginState()
	{
		AmbientSound = None;
		Enable( 'Tick' );
		
		// new sound stuff:
		
		Owner.PlaySound( sound'CloakOn' );
		// Invisible to bots/scriptedpawns
		if( Level.Game.IsA( 'CloakMatch' ) )
			Pawn( Owner ).Visibility = 100;
		else Pawn( Owner ).Visibility = 0;
		Pawn( Owner ).Style = STY_Translucent;
		
		Pawn( Owner ).AirControl = 6;
		Pawn( Owner ).JumpZ = Pawn( Owner ).Default.JumpZ * JumpZAdjustment;
		
		// "Turn on" the bEngaging part of the Tick function below..
		bEngaging = True;

		// Set their current weapon to be invisible
		if( Pawn( Owner ).Weapon != None )
			InvisWeapons( Pawn( Owner ).Weapon );
		
		SetTimer( 0.7, True );
	}
	
	function Activate()
	{
		if( !Level.Game.IsA( 'CloakMatch' ) )
			Super.Activate();	
	}

	function Timer()
	{
		local Bots SP;
		
		if( Pawn( Owner ).AmbientSound == none )
			Pawn( Owner ).AmbientSound = sound'CloakLoop3';
	
		if( !Level.Game.IsA( 'CloakMatch' ) )
			Charge--;
		foreach AllActors( class'Bots', SP )
		{
			if( SP.Enemy == Pawn( Owner ) )
			{
				SP.Enemy = None;
				SP.Target = None;
			}
		}
		
		// If the charge is <= 0, use the bEngaging routine in TICK for the flicker effect again..
		// Run the bEngaging routine for about 5 seconds, then destroy it.

		if( Charge <= 0 )
		{
			CountDown++;

			if( CountDown >= 10 )
				Destroy();
			else bEngaging = True;	
		}
	}	

	simulated function Tick( float DeltaTime )
	{
		local int i;
		
		// If they're using a new weapon, be sure to set it to invis here.
		
		if( Pawn( Owner ).Weapon != None && Pawn( Owner ).Weapon != LastWeapon )
			InvisWeapons( Pawn( Owner ).Weapon );
		
		for( i = 0; i <= ArrayCounter; i++ )
		{
			if( InvisWeaponlist[ i ] != None && InvisWeaponList[ i ].Owner == None )
			{
				InvisWeaponList[ i ].Texture = InvisWeaponlist[ i ].Default.Texture;
				InvisWeaponlist[ i ].ScaleGlow = InvisWeaponList[ i ].Default.ScaleGlow;
				InvisWeaponList[ i ].bMeshEnviroMap = False;
				InvisWeaponlist[ i ].Style = STY_Normal;
			}			
		}
			
		// Keep the weapon's scaleglow at the same level the players is..
		if( Pawn( Owner ).Weapon != None )
			Pawn( Owner ).Weapon.ScaleGlow = Pawn( Owner ).ScaleGlow;
		if( bEngaging )
		{
			Pawn( Owner ).Fatness = Rand( 254 );

			if( FRand() < 0.5 )
			{
				Pawn( Owner ).bMeshEnviroMap = True;
				Pawn( Owner ).Texture = Texture'CloakTexture';
				Pawn( Owner ).ScaleGlow = 0.08;
			}

			else
			{
				Pawn( Owner ).Fatness = Pawn( Owner ).Default.Fatness;
				Pawn( Owner ).bMeshEnviroMap = False;
				Pawn( Owner ).Texture = Pawn( Owner ).Default.Texture;
				Pawn( Owner ).ScaleGlow = 0.95;
			}
		}		
		
		// Normal checks for normal invisible state. Firing, rotation, speed.
		else
		{
			if( Pawn( Owner ).bFire != 0 || Pawn( Owner ).bAltFire != 0 )
				Pawn( Owner ).ScaleGlow = 0.13;

			if( Pawn( Owner ).Rotation != LastOwnerRotation && Pawn( Owner ).ScaleGlow < 0.15 )
			{
				Pawn( Owner ).ScaleGlow = 0.4;
				LastOwnerRotation = Pawn( Owner ).Rotation;
			}
			else if( VSize( Pawn( Owner ).Velocity ) <= 0 && Pawn( Owner ).ScaleGlow > 0.02 )
			{
				Pawn( Owner ).ScaleGlow -= 0.01;	
			}
			// Extra subtle flickering/slight expanding for effect.
			else
			{
				if( Pawn( Owner ).Fatness > 115 && !bExpanding )
				{
					Pawn( Owner ).Fatness -= 2;

					if( Pawn( Owner ).ScaleGlow >= 0.02 )
						Pawn(Owner).ScaleGlow -= 0.01;
				}
				else
				{
					bExpanding = True;

					if( Pawn( Owner ).Fatness < 128 )
					{
						Pawn( Owner ).Fatness += 2;
						if( Pawn( Owner ).ScaleGlow < 0.19 )
							Pawn(Owner).ScaleGlow += 0.01;
					}
					else bExpanding = False;
				}		
			}
		}
	}
	
	// Set a weapon to invis stats, and add it to the affected weapon array.
	function InvisWeapons( Weapon ChangeWeapon )
	{
		ChangeWeapon.Style = STY_Translucent;
		ChangeWeapon.bMeshEnviroMap = True;
		ChangeWeapon.Texture = Texture'CloakTexture';
		ChangeWeapon.ScaleGlow = 0.12;
		AddWeaponToList( Pawn( Owner ).Weapon );
		LastWeapon = ChangeWeapon;
	}	
	
	// Search the array, make sure no weapon is duplicated in it; if no match, add it to the array and
	// increment arraycounter.
	
	function AddWeaponToList(Weapon AddWeapon)
	{
		local int i;
		local bool MatchFound;
		
		for( i = 0; i <= ArrayCounter; i++ )
		{
			if( InvisWeaponList[ i ] == AddWeapon )
				MatchFound = True;
		}
		
		if( !MatchFound )
		{
			InvisWeaponList[ ArrayCounter ] = AddWeapon;
			ArrayCounter++;
		}
	}

Begin:

	Sleep( 2.0 + FRand() );
	bEngaging = False;
	Disable( 'Tick' );
	Pawn( Owner ).Fatness = Pawn(Owner).Default.Fatness;
	Pawn( Owner ).Texture = Texture'CloakTexture';
	Pawn( Owner ).bMeshEnviroMap = True;
	Pawn( Owner ).ScaleGlow = 0.75;

	if( Pawn( Owner ).Weapon != None )
	{
		Pawn( Owner ).Weapon.ScaleGlow = 0.75;
	}

	Sleep( 0.5 );
	Pawn( Owner ).SoundVolume = 250;
	Pawn( Owner ).SoundRadius = 500;
	Enable( 'Tick' );	
}

function RestoreVis()
{
	Pawn( Owner ).AirControl = Pawn( Owner ).Default.AirControl;
	Pawn( Owner ).JumpZ = Pawn( Owner ).Default.JumpZ;

	if( Pawn( Owner ) != None )
	{
		Pawn( Owner ).Style = STY_Normal;
		Pawn( Owner ).ScaleGlow = Pawn( Owner ).Default.ScaleGlow;
		Pawn( Owner ).Texture = Pawn( Owner ).Default.Texture;
		Pawn( Owner ).Fatness = Pawn( Owner ).Default.Fatness;
		Pawn( Owner ).Visibility = Pawn( Owner ).Default.Visibility;
		Pawn( Owner ).bMeshEnviroMap = False;
		Pawn( Owner ).Visibility = Pawn( Owner ).Default.Visibility;
	}
}

function WeaponRestore()
{
	local int i;

	for( i = 0; i <= ArrayCounter; i++ )
	{
		if( InvisWeaponList[ i ] != None )
		{
			InvisWeaponList[ i ].Texture = InvisWeaponList[ i ].Default.Texture;
			InvisWeaponList[ i ].ScaleGlow = InvisWeaponList[ i ].Default.ScaleGlow;
			InvisWeaponList[ i ].bMeshEnviroMap = False;
			InvisWeaponList[ i ].Style = STY_Normal;
		}
	}
}

// Important! This makes sure that the weapon list and player are both restored when the Cloak item is destroyed.
// It's destroyed when a player dies (natural to Unreal pickup inv items) or when it's expired.

event Destroyed()
{
	Pawn( Owner ).AmbientSound = None;
	Disable( 'Tick' );
	RestoreVis();
	WeaponRestore();
	Super.Destroyed();
}

// ================================================================================================
// Deactivated State
// ================================================================================================

state Deactivated
{
	function BeginState()
	{
		Enable('Tick');
		bEngaging = True;
		SetTimer( 0.5, True );
	}
	function Timer()
	{
		CountDown++;

		if( CountDown >= 10 )
		{
			Restorevis();
			WeaponRestore();
			if( Pawn( Owner ).AmbientSound != none )
			{
				Owner.PlaySound( sound'CloakOff' );
				Pawn( Owner ).AmbientSound = none;
			}
			Disable('Tick');
			if( Charge <= 0 )
		}				
		else bEngaging = True;	
	}
	function Tick( float DeltaTime )
	{
		if( bEngaging )
		{
			// Keep the weapon's scaleglow at the same level the players' is..
				
			Pawn( Owner ).Weapon.ScaleGlow = Pawn( Owner ).ScaleGlow;
			Pawn( Owner ).Fatness = Rand( 254 );

			if( FRand() < 0.5 )
			{
				Pawn( Owner ).bMeshEnviroMap = True;
				Pawn( Owner ).Texture = Texture'CloakTexture';
				Pawn( Owner ).ScaleGlow = 0.12;
			}
			else
			{
				Pawn( Owner ).Fatness = Pawn( Owner ).Default.Fatness;
				Pawn( Owner ).bMeshEnviroMap = False;
				Pawn( Owner ).Texture = Pawn( Owner ).Default.Texture;
				Pawn( Owner ).ScaleGlow = 0.95;
			}
		}		
	}
}

// ================================================================================================
// Idle2 State
// ================================================================================================

// If a bot owns this, this stuff executes to determine when it activates the item
state Idle2
{
	function BeginState()
	{
		if( Pawn( Owner ).IsA( 'Bots' ) )
			SetTimer( 1 + FRand(), True );
	}
	
	
	
	
	// Scan the Radius every 1 + FRand() seconds for any other targets, if any are found, activate the item.
	function Timer()
	{
		local Pawn P;
		
		// Radius could use tweaking
		ForEach RadiusActors( class'Pawn', P, 10000 )
		{
			if( P != None && P != Pawn( Owner ) && P.Visibility > 0 )
				GotoState( 'Activated' );
		}
	}
}

//=============================================================================
// Sleeping state: Sitting hidden waiting to respawn.

State Sleeping
{
	ignores Touch;

	function BeginState()
	{
		BecomePickup();
		LightType = LT_None;
		bUnlit = false;
		bHidden = true;
	}

	function EndState()
	{
		local int i;

		LightType = Default.LightType;
		bUnlit = true;
		
		bSleepTouch = false;
		for( i=0; i<4; i++ )
		{
			if ( (Touching[i] != None) && Touching[i].IsA('Pawn') )
			{
				bSleepTouch = true;
			}
		}
	}			
Begin:
	Sleep( ReSpawnTime );
	PlaySound( RespawnSound );	
	Level.Game.PlaySpawnEffect(self);
	Sleep( 0.3 );
	GoToState( 'Pickup' );
}

defaultproperties
{
				JumpZAdjustment=3.000000
				bCanActivate=True
				ExpireMessage="disengaged."
				bActivatable=True
				bDisplayableInv=True
				bAmbientGlow=False
				PickupMessage="You got the Cloaking Device."
				ItemName="Cloaking Device"
				RespawnTime=30.000000
				PickupViewMesh=LodMesh'UPak.pyramid'
				Charge=100
				PickupSound=Sound'UnrealShare.Pickups.GenPickSnd'
				Icon=Texture'UPak.Icons.I_Cloak'
				M_Activated=" engaged"
				M_Deactivated=" disengaged"
				Mesh=LodMesh'UPak.pyramid'
				SoundRadius=64
				SoundVolume=96
				CollisionRadius=19.799999
				CollisionHeight=13.700000
				LightRadius=4
				LightPeriod=5
				LightPhase=5
				LightCone=8
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: zo 11-11-2012 21:10:30.000 - Creation time: zo 11-11-2012 21:14:17.928 - Created with UnCodeX