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

U2Weapons.WeaponInvSniperRifle


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
//=============================================================================
// WeaponInvSniperRifle.uc
// $Author: Aleiby $
// $Date: 12/02/02 5:28p $
// $Revision: 47 $
//=============================================================================
class WeaponInvSniperRifle extends U2Weapon;

#exec OBJ LOAD File=..\Meshes\GlmWeaponsG.ugx
#exec OBJ LOAD File=..\System\ParticleRes\SniperFX.u
#exec OBJ LOAD File=..\System\ParticleRes\SniperTracer.u
#exec OBJ LOAD File=..\Textures\WeaponFXT.utx

var vector PawnLocation;			// track Pawn location to compute "StillTime"
var float StillTime, StillStart;	// adjust WeaponAimSpread for Bots based on StillTime

var bool bZoomed, bWasZoomed;
var float ZoomFOV;

var vector RingLoc;
var() float RingDelayFactor;
var float Angle, Radius;
var Point RingLocation;

var() Sound ZoomInSound;
var() Sound ZoomOutSound;
var() Sound AdjustZoomSound;

simulated function int GetFireAmmoUsed() 
{ 
	if( U2NPCController(Instigator.Controller) != None )
		return AmmoType.AmmoAmount; // force NPCs to reload after every shot?
	else
		return Super.GetFireAmmoUsed();
}

/*mdf-tbd: not used currently?
event Timer()
{
	local Actor Target;
	local float bestAim, bestDist;
	local vector FireDir;

	bestAim = 0.95;
	if( Instigator == None )
	{
		GotoState('');
		return;
	}
	if( VSize( Instigator.Location - PawnLocation ) < 6 )
	{
		StillTime += FMin( 2.0, Level.TimeSeconds - StillStart );
	}
	else
	{
		StillTime = 0;
	}
	StillStart = Level.TimeSeconds;
	PawnLocation = Instigator.Location;
	FireDir = vector(Instigator.GetViewRotation());
	Target = Instigator.Controller.PickTarget( bestAim, bestDist, FireDir, Instigator.Location );
	if( Pawn(Target) != None )
	{
		SetTimer(1 + 4 * FRand(), false);
		bPointing = true;
		//!!mdf-tbd: I'm not sure what the reasoning is behind warning the target here (see also UT calls to WarnTarget)
		Pawn(Target).Controller.ShotFiredNotification( Instigator, FireDir, None, 200 );
	}
	else 
	{
		SetTimer( 0.4 + 1.6 * FRand(), false );
		if( Instigator.Controller.bFire == 0 && Instigator.Controller.bAltFire == 0 )
		{
			bPointing = false;
		}
	}
}	
*/

/*mdf-tbd: if we want to do something like this it should be factored into the TryToHit
  function used by NPCs (spread no longer used for anything except the weapon's firing
  characteristics). Also, from what I can tell the above Timer is never being called
  (where is SetTimer called apart from inside the timer itself) and the StillTime
  isn't being set.function AdjustAimError()
{
	if( Instigator != None && U2NPCController(Instigator.Controller) != None )
	{
		// simulate bot using zoom
		if( false U2NPCController(Instigator.Controller).GetIsSniping() && FRand() < 0.65 )
			WeaponAimSpread = default.WeaponAimSpread / FClamp( StillTime, 1.0, 8.0 );
		else if( VSize( Instigator.Location - PawnLocation ) < 6 )
			WeaponAimSpread = default.WeaponAimSpread / FClamp( 0.5 * StillTime, 1.0, 3.0 );
		else
			StillTime = 0;
	}
}
*/

//------------------------------------------------------------------------------
simulated function HandleTargetDetails( Actor A, Canvas Canvas, vector ViewLoc, rotator ViewRot )
{
	local vector ScreenLoc;
	if( bZoomed )
	{
		// Update delayed ring.
		// Fix ARL: Factor in DeltaTime.
		RingLoc += ((ViewLoc+(vect(300,0,0)>>ViewRot))-RingLoc)*RingDelayFactor;
		ScreenLoc = (Normal(RingLoc-ViewLoc)*50) << ViewRot;
		RingLocation.X = ScreenLoc.Y;
		RingLocation.Y = -ScreenLoc.Z;

		// Update big ring.
		Angle = PlayerController(Pawn(Owner).Controller).FOVAngle;

		// Update zoom bars.
		Radius = (PlayerController(Pawn(Owner).Controller).FOVAngle/120 * 196) - 2;
	}
}

simulated function float GetCrosshairAngle0(){ return Angle + 0; }
simulated function float GetCrosshairAngle24(){ return Angle + 24; }
simulated function float GetCrosshairAngle48(){ return Angle + 48; }
simulated function float GetCrosshairAngle72(){ return Angle + 72; }
simulated function float GetCrosshairAngle96(){ return Angle + 96; }
simulated function float GetCrosshairAngle120(){ return Angle + 120; }
simulated function float GetCrosshairAngle144(){ return Angle + 144; }
simulated function float GetCrosshairAngle168(){ return Angle + 168; }
simulated function float GetCrosshairAngle192(){ return Angle + 192; }
simulated function float GetCrosshairAngle216(){ return Angle + 216; }
simulated function float GetCrosshairAngle240(){ return Angle + 240; }
simulated function float GetCrosshairAngle264(){ return Angle + 264; }
simulated function float GetCrosshairAngle288(){ return Angle + 288; }
simulated function float GetCrosshairAngle312(){ return Angle + 312; }
simulated function float GetCrosshairAngle336(){ return Angle + 336; }
simulated function float GetCrosshairRadius(){ return Radius; }
simulated function Point GetCrosshairRingLocation(){ return RingLocation; }

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

	if( bZoomed && U2PCOwner != None )
		U2PCOwner.SendEvent("Rotate");
}

simulated state Firing
{
ignores Fire; //don't ignore AltFire, so that zooming effects will work
	
	//this is because the parent firing state basically sticks in a dummy 'AltFire' with its use of ignores,
	//which we need to override to call the global.altfire
	simulated function AltFire()
	{
		Global.AltFire();
	}
}


simulated function vector CalcFireOffset( vector X, vector Y, vector Z )
{
//NEW MJL: make the sniper rifle shoot accurately in unzoomed mode
	return Instigator.EyeHeight * vect(0,0,1);
/*OLD
	if( bZoomed )
	{
		return Instigator.EyeHeight * vect(0,0,1);
	}

	return Super.CalcFireOffset( X, Y, Z );
*/
}


simulated function vector CalcShellOffset( vector X, vector Y, vector Z )
{
	if( bZoomed )
	{
		return Instigator.EyeHeight * vect(0,0,1);
	}

	return Super.CalcShellOffset( X, Y, Z );
}


function ProcessTraceHitEx( vector HitDirection, CheckResult Hit, float EffectiveDamage )
{
	if( Pawn(Hit.Actor) != None && Hit.Location.Z - Hit.Actor.Location.Z > 0.62 * Hit.Actor.CollisionHeight ) //CDH head shot (replace with mesh trace damage)
	{
		EffectiveDamage *= 1.5;
	}
	Super.ProcessTraceHitEx( HitDirection, Hit, EffectiveDamage );
}

//override so altfiring state is not used, and so that we don't use ammo or switch weapons
simulated function AltFire()
{
	if( bZoomed )
		UnZoom();
	else
		Zoom();
}

simulated function NotifyCutsceneBegin()
{
	if( bZoomed )
		UnZoom(true);
}

//prevents weapon switching for the sniper rifle
simulated function bool PutDown()
{
	if (bZoomed)
	{
		Pawn(Owner).PendingWeapon = None;
		return false;
	}
	return Super.PutDown();
}

simulated function SetPlayerFOV( float NewFOV )
{
	assert( bZoomed );

	ZoomFOV = FClamp( NewFOV, 1.0, 60.0 );

	if( PlayerController(Instigator.Controller) != None )
	{
		PlayerController(Instigator.Controller).DesiredFOV = ZoomFOV;
	}
}


exec simulated function ZoomIn()
{
	if( bZoomed )
	{
		if( ZoomFOV > 20 )
		{
			// 90 --> 20 by 10
			SetPlayerFOV( ZoomFOV - 10 );
		}
		else if( ZoomFOV > 5 )
		{
			// 20 --> 5 by 5
			SetPlayerFOV( ZoomFOV - 5 );
		}
		else
		{
			// 5 --> 1 by 2
			SetPlayerFOV( ZoomFOV - 2 );
		}
		PlaySound( AdjustZoomSound );
	}
}


exec simulated function ZoomOut()
{
	if( bZoomed )
	{
		if( ZoomFOV >= 20 )
		{
			// 20 --> 90 by 10
			SetPlayerFOV( ZoomFOV + 10 );
		}
		else if( ZoomFOV >= 5 )
		{
			// 5 --> 20 by 5
			SetPlayerFOV( ZoomFOV + 5 );
		}
		else
		{
			// 1 --> 5 by 2
			SetPlayerFOV( ZoomFOV + 2 );
		}
		PlaySound( AdjustZoomSound );
	}	
}

simulated function Zoom()
{
	//only execute this code on the local machine and server ... not the third-person players
	if ( !bZoomed && Instigator.Controller != None )
	{
		bZoomed = true;
		SetPlayerFOV( ZoomFOV );
		if( U2PCOwner != None ) U2PCOwner.SendEvent("Rotate");
		PlaySound( ZoomInSound );
	}	
}

simulated function UnZoom( optional bool bForce )
{
	//only execute this code on the local machine and server ... not the third-person players
	if ( bZoomed && Instigator.Controller != None )
	{
		bZoomed = false;
		if( PlayerController(Instigator.Controller) != None )
		{
			PlayerController(Instigator.Controller).DesiredFOV = PlayerController(Instigator.Controller).DefaultFOV;
			if( bForce )
				PlayerController(Instigator.Controller).FOVAngle = PlayerController(Instigator.Controller).DefaultFOV;
		}
		if( U2PCOwner != None ) U2PCOwner.SendEvent("UnRotate");
		PlaySound( ZoomOutSound );
	}	
}

simulated function ClearWeaponEffects()
{
	Super.ClearWeaponEffects();
	UnZoom();
}

simulated state Unloading
{
	simulated event BeginState()
	{
		Super.BeginState();
		bWasZoomed = bZoomed;
		UnZoom();
	}
	simulated event EndState()
	{
		Super.EndState();
		if (bWasZoomed)
			Zoom();
	}
}

simulated state Reloading
{
	simulated event BeginState()
	{
		Super.BeginState();
		bWasZoomed = bZoomed;
		UnZoom();
	}
	simulated event EndState()
	{
		Super.EndState();
		if (bWasZoomed)
			Zoom();
	}
}

simulated state DownWeapon
{
ignores Fire, AltFire;

	simulated event BeginState()
	{
		UnZoom();
		Super.BeginState();
	}
}

simulated function ClientTraceImpact( CheckResult Hit )
{
	UpdateTracer(Hit,1);
//	UpdateTracer(Hit,2);
//	UpdateTracer(Hit,3);
}

simulated function UpdateTracer( CheckResult Hit, int Index )
{
	local PulseLineGenerator Tracer;
	Tracer = PulseLineGenerator(DecoEffects[Index].Effect);
	if (!Tracer) return;

	if (Tracer.Connections.length!=1)
		Tracer.Connections.length = 1;

	Tracer.Connections[0].StartActor = Tracer;
	Tracer.Connections[0].End = Hit.Location;
	Tracer.BeamTexture.ResetModifiers();
}

defaultproperties
{
	ZoomFOV=30.000000
	RingDelayFactor=0.050000
	ZoomInSound=Sound'U2WeaponsA.SniperRifle.SR_ScopeOn'
	ZoomOutSound=Sound'U2WeaponsA.SniperRifle.SR_ScopeOff'
	AdjustZoomSound=Sound'U2WeaponsA.SniperRifle.SR_Zoom'
	FireTime=1.400000
	AltFireTime=0.000000
	FireLastDownTime=2.437000
	AltFireLastDownTime=0.000000
	FireLastReloadTime=2.529000
	AltFireLastReloadTime=0.000000
	ReloadTime=1.875000
	FlashSkin=Shader'WeaponFXT.Sniper.SR_Skin2FX'
	FireLastRoundSound=Sound'U2WeaponsA.SniperRifle.SR_FireLastRound'
	ReloadUnloadedSound=Sound'U2WeaponsA.SniperRifle.SR_ReloadUnloaded'
     GunButtSounds(0)=Sound'U2WeaponsA.GunButt.GunButt01'
     GunButtSounds(1)=Sound'U2WeaponsA.GunButt.GunButt02'
     GunButtSounds(2)=Sound'U2WeaponsA.GunButt.GunButt03'
     GunButtSounds(3)=Sound'U2WeaponsA.GunButt.GunButt04'
     DecoEffects(0)=(AnimSequence=Fire,DecoClass=Class'ParticleSystems.ParticleSalamander',Particles=ParticleSalamander'SniperFX.ParticleSalamander0',MountNode="#Muzzleflash")
     DecoEffects(1)=(AnimSequence=Fire,DecoClass=Class'ParticleSystems.PulseLineGenerator',Particles=PulseLineGenerator'SniperTracer.PulseLineGenerator1',MountNode="#Muzzleflash",bTriggerUpdateOnly=true,bRequiresWorldZBuffer=true)
     DecoEffects(2)=(AnimSequence=Fire,DecoClass=Class'U2Weapons.SR_LightEffect',MountNode="#Muzzleflash",MountOffset=(X=15.000000,Z=15.000000))
	FirstPersonOffset=(X=-70.000000,Y=-8.000000,Z=14.000000)
	bRepeatAltFire=false
	bCrosshairGlows=true
	WeaponAnimationType=AT_Shoulder
	ImpactHandlerClass=Class'U2Weapons.impactSniperRifle'
	Damage=80.000000
	MomentumTransfer=25000.000000
	TraceRange=28800.000000
	AltShakeMag=0.000000
	AltShakeTime=0.000000
     TargetableTypes(0)='Pawn'
	CrosshairName="SR_Cross"
	RangeMinFire=0.000000
	RangeIdealFire=256.000000
	RangeMaxFire=2048.000000
	RangeLimitFire=32767.000000
	RatingRangeMinFire=0.500000
	RatingRangeIdealFire=0.500000
	RatingRangeMaxFire=0.150000
	AIRatingFire=0.500000
	AIRatingAltFire=-50.000000
	AmmoName=Class'U2Weapons.ammoInvSniperRifle'
	PickupAmmoCount=10
	AutoSwitchPriority=9
	bInstantHit=true
	bSnipe=true
	PreferProneMultiplier=3.000000
	FiringSpeed=1.800000
	FireOffset=(X=62.000000,Y=14.000000,Z=-8.000000)
	MyDamageType=Class'U2.DamageTypeSniperRifle'
	ShakeMag=3.000000
	ShakeTime=0.150000
	AIRating=0.500000
	RefireRate=1.000000
	AltRefireRate=99.900002
	FireSound=Sound'U2WeaponsA.SniperRifle.SR_Fire'
	CockingSound=Sound'U2WeaponsA.SniperRifle.SR_Reload'
	SelectSound=Sound'U2WeaponsA.SniperRifle.SR_Select'
	InventoryGroup=4
	GroupOffset=1
	PickupClass=Class'U2Weapons.weaponSniperRifle'
	PlayerViewOffset=(X=0.000000,Z=0.000000)
	BobDamping=0.975000
	ThirdPersonMesh=LegendMesh'GlmWeaponsG.SR_TP'
	ItemName="Sniper Rifle"
	ItemID="SR"
	IconIndex=14
	Mesh=LegendMesh'GlmWeaponsG.SR_FP'
     UseReticleOnEvents(0)="UseReticleText"
     UseReticleOnEvents(1)="UseReticleCorners"
     UseReticleOnEvents(2)="UseReticleTopBars"
     ProximityReticleOnEvents(0)="ProximityReticleCorners"
     ProximityReticleOnEvents(1)="ProximityReticleTopBars"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: sk 3-1-2016 10:38:42.000 - Creation time: sk 3-1-2016 10:48:43.967 - Created with UnCodeX