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

UTGame.UTWeap_FlakCannon


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
/**
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */

class UTWeap_FlakCannon extends UTWeapon
native;

var float SpreadDist;
var UTSkeletalMeshComponent SkeletonFirstPersonMesh;

var int curTensOdometer;
var int curOnesOdometer;
var float OdometerMaxPerSecOnes;
var float OdometerMaxPerSecTens;
var name OnesPlaceSkelName;
var name TensPlaceSkelName;
var class<Projectile> CenterShardClass;

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

simulated function Projectile ProjectileFire()
{
	local vector		RealStartLoc;
	local UTProj_FlakShell	SpawnedProjectile;

	// tell remote clients that we fired, to trigger effects
	IncrementFlashCount();

	if( Role == ROLE_Authority )
	{
		// this is the location where the projectile is spawned.
		RealStartLoc = GetPhysicalFireStartLoc();

		// Spawn projectile
		SpawnedProjectile = Spawn(class'UTProj_FlakShell',,, RealStartLoc);
		if( SpawnedProjectile != None && !SpawnedProjectile.bDeleteMe )
		{
			SpawnedProjectile.Init( Vector(GetAdjustedAim( RealStartLoc )) );
		}

		// Return it up the line
		return SpawnedProjectile;
	}

	return None;
}

/**
 * GetAdjustedAim begins a chain of function class that allows the weapon, the pawn and the controller to make
 * on the fly adjustments to where this weapon is pointing.
 */
simulated function Rotator GetAdjustedAim( vector StartFireLoc )
{
	local rotator R;

	// Start the chain, see Pawn.GetAdjustedAimFor()
	if( Instigator != None )
	{
		R = Instigator.GetAdjustedAimFor( Self, StartFireLoc );

		if ( (PlayerController(Instigator.Controller) != None) && (CurrentFireMode == 1) )
		{
			R.Pitch = R.Pitch & 65535;
			if ( R.Pitch < 16384 )
			{
				R.Pitch += (16384 - R.Pitch)/32;
			}
			else if ( R.Pitch > 49152 )
			{
				R.Pitch += 512;
			}
		}
	}

	return R;
}

simulated event ReplicatedEvent(name VarName)
{
	if ( VarName == 'AmmoCount')
	{
		UpdateAmmoCount();
	}

	Super.ReplicatedEvent(VarName);
}

simulated state WeaponFiring
{
	simulated event ReplicatedEvent(name VarName)
	{
		if ( VarName == 'AmmoCount')
		{
			UpdateAmmoCount();
		}
		Super.ReplicatedEvent(VarName);
	}
}

function int AddAmmo( int Amount )
{
	local int rvalue;
	rvalue = super.AddAmmo(Amount);
	UpdateAmmoCount();
	return rvalue;
}

simulated function HideFlakCannonAmmo()
{
    local SkelControlSingleBone SkelControl;
    if (AmmoCount <= 1)
    {
	    //Hide the flak cannon ammo in the chamber
	    SkelControl = SkelControlSingleBone(SkeletonFirstPersonMesh.FindSkelControl('AmmoScale'));
	    if(SkelControl != none)
	    {
	    	SkelControl.SetSkelControlStrength(1.0f, 0.0f);
	    }
    }
}

simulated function UpdateAmmoCount()
{
	local SkelControlSingleBone SkelControl;
	local int AmmoCountOnes;
	local int AmmoCountTens;

	if(Instigator.IsHumanControlled() && Instigator.IsLocallyControlled())
	{
		AmmoCountOnes = AmmoCount%10;
		AmmoCountTens = (AmmoCount - AmmoCountOnes)/10;
		SkelControl = SkelControlSingleBone(SkeletonFirstPersonMesh.FindSkelControl('OnesDisplay'));
		if(SkelControl != none)
		{
			SkelControl.BoneRotation.Pitch = -AmmoCountOnes*6554;
		}
		SkelControl = SkelControlSingleBone(SkeletonFirstPersonMesh.FindSkelControl('TensDisplay'));
		if(SkelControl != none)
		{
			SkelControl.BoneRotation.Pitch = -AmmoCountTens*6554;
		}

	    if (AmmoCount == 1)
    	{
		    //Hide the flak cannon ammo in the chamber
		    //Delay the hiding a fraction of time so the user doesn't see it happen	(time from anim)
	    	SetTimer(0.40f, false, 'HideFlakCannonAmmo');
    	}
    	else if (AmmoCount > 1)
    	{
	    	//Show the flak cannon ammo in the chamber
	    	ClearTimer('HideFlakCannonAmmo');
		    SkelControl = SkelControlSingleBone(SkeletonFirstPersonMesh.FindSkelControl('AmmoScale'));
	    	if(SkelControl != none)
	    	{
	    		SkelControl.SetSkelControlStrength(0.0f, 0.0f);
    		}
	    }
    }
}

simulated function CustomFire()
{
	local int i,j;
   	local vector RealStartLoc, AimDir, YDir, ZDir;
	local Projectile Proj;
	local class<Projectile> ShardProjectileClass;
	local float Mag;

	IncrementFlashCount();

	if (Role == ROLE_Authority)
	{
		// this is the location where the projectile is spawned
		RealStartLoc = GetPhysicalFireStartLoc();
		// get fire aim direction
		GetAxes(GetAdjustedAim(RealStartLoc),AimDir, YDir, ZDir);

		// special center shard
		Proj = Spawn(CenterShardClass,,, RealStartLoc);
		if (Proj != None)
		{
			Proj.Init(AimDir);
		}

		// one shard in each of 9 zones (except center)
		ShardProjectileClass = GetProjectileClass();
		for ( i=-1; i<2; i++)
		{
			for ( j=-1; j<2; j++ )
			{
				if ( (i != 0) || (j != 0) )
				{
					Mag = (abs(i)+abs(j) > 1) ? 0.7 : 1.0;
					Proj = Spawn(ShardProjectileClass,,, RealStartLoc);
					if (Proj != None)
					{
						Proj.Init(AimDir + (0.3 + 0.7*FRand())*Mag*i*SpreadDist*YDir + (0.3 + 0.7*FRand())*Mag*j*SpreadDist*ZDir );
					}
				}
			}
	    }
	}
}

//-----------------------------------------------------------------
// AI Interface

/* BestMode()
choose between regular or alt-fire
*/
function byte BestMode()
{
	local vector EnemyDir;
	local float EnemyDist;
	local UTBot B;

	B = UTBot(Instigator.Controller);
	if ( (B == None) || (B.Enemy == None) )
		return 0;

	EnemyDir = B.Enemy.Location - Instigator.Location;
	EnemyDist = VSize(EnemyDir);
	if ( EnemyDist > 750 )
	{
		if ( EnemyDir.Z < -0.5 * EnemyDist )
			return 1;
		return 0;
	}
	else if ( (B.Enemy.Weapon != None) && B.Enemy.Weapon.bMeleeWeapon )
		return 0;
	else if ( (EnemyDist < 400) || (EnemyDir.Z > 30) )
		return 0;
	else if ( FRand() < 0.65 )
		return 1;
	return 0;
}

function float GetAIRating()
{
	local UTBot B;
	local float EnemyDist;
	local vector EnemyDir;

	B = UTBot(Instigator.Controller);
	if ( B == None )
		return AIRating;

	if ( UTOnslaughtPowerNode(B.Focus) != None )
	{
		EnemyDist = VSize(B.FocalPoint - Instigator.Location);
		if (EnemyDist < 1250.0)
		{
			return 0.9;
		}
		return AIRating * 1500.0/EnemyDist;
	}

	if ( B.Enemy == None )
		return AIRating;

	EnemyDir = B.Enemy.Location - Instigator.Location;
	EnemyDist = VSize(EnemyDir);
	if ( EnemyDist > 750 )
	{
		if ( EnemyDist > 1700 )
		{
			if ( EnemyDist > 2500 )
				return 0.2;
			return (AIRating - 0.3);
		}
		if ( EnemyDir.Z < -0.5 * EnemyDist )
			return (AIRating - 0.3);
	}
	else if ( (B.Enemy.Weapon != None) && B.Enemy.Weapon.bMeleeWeapon )
		return (AIRating + 0.35);
	else if ( EnemyDist < 400 )
		return (AIRating + 0.2);
	return FMax(AIRating + 0.2 - (EnemyDist - 400) * 0.0008, 0.2);
}

function float SuggestAttackStyle()
{
	if ( (AIController(Instigator.Controller) != None)
		&& (AIController(Instigator.Controller).Skill < 3) )
		return 0.4;
    return 0.8;
}

simulated state WeaponEquipping
{
	/**
	 * We want to being this state by setting up the timing and then notifying the pawn
	 * that the weapon has changed.
	 */

	simulated function BeginState(Name PreviousStateName)
	{
		super.BeginState(PreviousStateName);

		if (Instigator.IsLocallyControlled() && Instigator.IsHumanControlled())
		{
			UpdateAmmoCount();
		}
	}

}
function float SuggestDefenseStyle()
{
	return -0.4;
}

function float GetOptimalRangeFor(Actor Target)
{
	// short range so bots try to maximize shards that hit
	return 750.0;
}

defaultproperties
{
   SpreadDist=0.100000
   Begin Object Class=UTSkeletalMeshComponent Name=FirstPersonMesh ObjName=FirstPersonMesh Archetype=UTSkeletalMeshComponent'UTGame.Default__UTWeapon:FirstPersonMesh'
      FOV=70.000000
      SkeletalMesh=SkeletalMesh'WP_FlakCannon.Mesh.SK_WP_FlakCannon_1P'
      AnimTreeTemplate=AnimTree'WP_FlakCannon.Anims.AT_FlakCannon'
      AnimSets(0)=AnimSet'WP_FlakCannon.Anims.K_WP_FlakCannon_1P_Base'
      ObjectArchetype=UTSkeletalMeshComponent'UTGame.Default__UTWeapon:FirstPersonMesh'
   End Object
   SkeletonFirstPersonMesh=FirstPersonMesh
   OdometerMaxPerSecOnes=21845.000000
   OdometerMaxPerSecTens=10950.000000
   OnesPlaceSkelName="OnesDisplay"
   TensPlaceSkelName="TensDisplay"
   CenterShardClass=Class'UTGame.UTProj_FlakShardMain'
   bTargetFrictionEnabled=True
   bTargetAdhesionEnabled=True
   AmmoCount=10
   LockerAmmoCount=20
   MaxAmmoCount=30
   WeaponFireWaveForm=ForceFeedbackWaveform'UTGame.Default__UTWeap_FlakCannon:ForceFeedbackWaveformShooting1'
   IconX=394
   IconY=38
   IconWidth=60
   IconHeight=38
   IconCoordinates=(U=131.000000,V=429.000000,UL=132.000000,VL=52.000000)
   CrossHairCoordinates=(U=64.000000)
   InventoryGroup=7
   AttachmentClass=Class'UTGame.UTAttachment_FlakCannon'
   GroupWeight=0.500000
   QuickPickGroup=4
   QuickPickWeight=0.900000
   ArmsAnimSet=AnimSet'WP_FlakCannon.Anims.K_WP_FlakCannon_1P_Arms'
   WeaponFireSnd(0)=SoundCue'A_Weapon_FlakCannon.Weapons.A_FlakCannon_FireCue'
   WeaponFireSnd(1)=SoundCue'A_Weapon_FlakCannon.Weapons.A_FlakCannon_FireAltCue'
   WeaponPutDownSnd=SoundCue'A_Weapon_FlakCannon.Weapons.A_FlakCannon_LowerCue'
   WeaponEquipSnd=SoundCue'A_Weapon_FlakCannon.Weapons.A_FlakCannon_RaiseCue'
   MaxPitchLag=500.000000
   MaxYawLag=500.000000
   WeaponColor=(B=128,G=255,R=255,A=255)
   MuzzleFlashPSCTemplate=ParticleSystem'WP_FlakCannon.Effects.P_WP_FlakCannon_Muzzle_Flash'
   MuzzleFlashLightClass=Class'UTGame.UTRocketMuzzleFlashLight'
   PlayerViewOffset=(X=-6.000000,Y=-4.000000,Z=0.500000)
   SmallWeaponsOffset=(X=12.000000,Y=6.000000,Z=-6.000000)
   LockerRotation=(Pitch=0,Yaw=0,Roll=-16384)
   CurrentRating=0.750000
   TargetFrictionDistanceMin=64.000000
   TargetFrictionDistancePeak=128.000000
   TargetFrictionDistanceMax=200.000000
   WeaponFireTypes(0)=EWFT_Custom
   WeaponFireTypes(1)=EWFT_Projectile
   WeaponProjectiles(0)=Class'UTGame.UTProj_FlakShard'
   WeaponProjectiles(1)=Class'UTGame.UTProj_FlakShell'
   FireInterval(0)=1.100000
   FireInterval(1)=1.100000
   EquipTime=0.750000
   FireOffset=(X=8.000000,Y=10.000000,Z=-10.000000)
   Mesh=FirstPersonMesh
   Priority=9.000000
   AIRating=0.750000
   ItemName="Flak Cannon"
   MaxDesireability=0.750000
   PickupMessage="Flak Cannon"
   PickupSound=SoundCue'A_Pickups.Weapons.Cue.A_Pickup_Weapons_Flak_Cue'
   Begin Object Class=SkeletalMeshComponent Name=PickupMesh ObjName=PickupMesh Archetype=SkeletalMeshComponent'UTGame.Default__UTWeapon:PickupMesh'
      SkeletalMesh=SkeletalMesh'WP_FlakCannon.Mesh.SK_WP_FlakCannon_3P_Mid'
      ObjectArchetype=SkeletalMeshComponent'UTGame.Default__UTWeapon:PickupMesh'
   End Object
   DroppedPickupMesh=PickupMesh
   PickupFactoryMesh=PickupMesh
   Name="Default__UTWeap_FlakCannon"
   ObjectArchetype=UTWeapon'UTGame.Default__UTWeapon'
}

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