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

UnrealI.QuadShot


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
//============================================================
// QuadShot.
//============================================================
class QuadShot extends Weapon;

#exec TEXTURE IMPORT NAME=GunPick1 FILE=Models\quadhand.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=QuadHand1 FILE=Models\quadhand.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=InvisibleTexture FILE=Models\Invisible.pcx GROUP=Skins FLAGS=2

// Pickup View
#exec MESH IMPORT MESH=QuadShotPickupC ANIVFILE=Models\QuadShotPickup_a.3d DATAFILE=Models\QuadShotPickup_d.3d MLOD=1
// 108 Vertices, 180 Triangles
#exec MESH LODPARAMS MESH=QuadShotPickupC STRENGTH=0.1 MINVERTS=54 MORPH=0.0 ZDISP=500.0
#exec MESH ORIGIN MESH=QuadShotPickupC X=0 Y=0 Z=0
#exec MESH SEQUENCE MESH=QuadShotPickupC SEQ=All STARTFRAME=0 NUMFRAMES=1
#exec MESH SEQUENCE MESH=QuadShotPickupC SEQ=Still STARTFRAME=0 NUMFRAMES=1
#exec MESHMAP NEW MESHMAP=QuadShotPickupC MESH=QuadShotPickupC
#exec MESHMAP SCALE MESHMAP=QuadShotPickupC X=0.02 Y=0.02 Z=0.04
#exec MESHMAP SETTEXTURE MESHMAP=QuadShotPickupC NUM=4 TEXTURE=GunPick1

// Third Person View
// Mesh re-animated by .:..:
#exec MESH IMPORT MESH=QuadShotThird ANIVFILE=Models\QuadThirdT_a.3d DATAFILE=Models\QuadThirdT_d.3d X=0 Y=0 Z=0
#exec MESH LODPARAMS MESH=QuadShotThird STRENGTH=0.3
#exec MESH ORIGIN MESH=QuadShotThird X=0 Y=700 Z=-100 YAW=64

#exec MESH SEQUENCE MESH=QuadShotThird SEQ=All STARTFRAME=0 NUMFRAMES=8
#exec MESH SEQUENCE MESH=QuadShotThird SEQ=Idle STARTFRAME=0 NUMFRAMES=1
#exec MESH SEQUENCE MESH=QuadShotThird SEQ=Reload STARTFRAME=3 NUMFRAMES=5

#exec MESHMAP NEW MESHMAP=QuadShotThird MESH=QuadShotThird
#exec MESHMAP SCALE MESHMAP=QuadShotThird X=0.02 Y=0.02 Z=0.04

#exec MESHMAP SETTEXTURE MESHMAP=QuadShotThird NUM=1 TEXTURE=QuadHand1
#exec MESHMAP SETTEXTURE MESHMAP=QuadShotThird NUM=2 TEXTURE=QuadHand1
#exec MESHMAP SETTEXTURE MESHMAP=QuadShotThird NUM=3 TEXTURE=QuadHand1

// Right Handed First Person View
// Mesh re-animated by .:..:
#exec MESH IMPORT MESH=QuadShotHeldR ANIVFILE=Models\QuadHandT_a.3d DATAFILE=Models\QuadHandT_d.3d X=0 Y=0 Z=0
#exec MESH ORIGIN MESH=QuadShotHeldR X=0 Y=0 Z=0 YAW=128

#exec MESH SEQUENCE MESH=QuadShotHeldR SEQ=All STARTFRAME=0 NUMFRAMES=42
#exec MESH SEQUENCE MESH=QuadShotHeldR SEQ=Down STARTFRAME=1 NUMFRAMES=5 RATE=8
#exec MESH SEQUENCE MESH=QuadShotHeldR SEQ=Select STARTFRAME=7 NUMFRAMES=6 RATE=8
#exec MESH SEQUENCE MESH=QuadShotHeldR SEQ=Idle STARTFRAME=12 NUMFRAMES=6 RATE=3
#exec MESH SEQUENCE MESH=QuadShotHeldR SEQ=Fire STARTFRAME=18 NUMFRAMES=10 RATE=22
#exec MESH SEQUENCE MESH=QuadShotHeldR SEQ=Reload STARTFRAME=28 NUMFRAMES=13 RATE=18
#exec MESH SEQUENCE MESH=QuadShotHeldR SEQ=PreReload STARTFRAME=28 NUMFRAMES=3 RATE=15
#exec MESH SEQUENCE MESH=QuadShotHeldR SEQ=ReloadLoop STARTFRAME=31 NUMFRAMES=7 RATE=15
#exec MESH SEQUENCE MESH=QuadShotHeldR SEQ=ReloadEnd STARTFRAME=38 NUMFRAMES=3 RATE=15

#exec MESHMAP NEW MESHMAP=QuadShotHeldR MESH=QuadShotHeldR
#exec MESHMAP SCALE MESHMAP=QuadShotHeldR X=0.007 Y=0.005 Z=0.01

#exec MESHMAP SETTEXTURE MESHMAP=QuadShotHeldR NUM=1 TEXTURE=QuadHand1
#exec MESHMAP SETTEXTURE MESHMAP=QuadShotHeldR NUM=2 TEXTURE=QuadHand1
#exec MESHMAP SETTEXTURE MESHMAP=QuadShotHeldR NUM=3 TEXTURE=QuadHand1

// Left Handed First Person View
#exec MESH IMPORT MESH=QuadShotHeldL ANIVFILE=Models\QuadHandT_a.3d DATAFILE=Models\QuadHandT_d.3d X=0 Y=0 Z=0 UNMIRROR=1
#exec MESH ORIGIN MESH=QuadShotHeldL X=0 Y=0 Z=0 YAW=0

#exec MESH SEQUENCE MESH=QuadShotHeldL SEQ=All STARTFRAME=0 NUMFRAMES=42
#exec MESH SEQUENCE MESH=QuadShotHeldL SEQ=Down STARTFRAME=1 NUMFRAMES=5 RATE=8
#exec MESH SEQUENCE MESH=QuadShotHeldL SEQ=Select STARTFRAME=7 NUMFRAMES=6 RATE=8
#exec MESH SEQUENCE MESH=QuadShotHeldL SEQ=Idle STARTFRAME=12 NUMFRAMES=6 RATE=3
#exec MESH SEQUENCE MESH=QuadShotHeldL SEQ=Fire STARTFRAME=18 NUMFRAMES=10 RATE=22
#exec MESH SEQUENCE MESH=QuadShotHeldL SEQ=Reload STARTFRAME=28 NUMFRAMES=13 RATE=18
#exec MESH SEQUENCE MESH=QuadShotHeldL SEQ=PreReload STARTFRAME=28 NUMFRAMES=3 RATE=15
#exec MESH SEQUENCE MESH=QuadShotHeldL SEQ=ReloadLoop STARTFRAME=31 NUMFRAMES=7 RATE=15
#exec MESH SEQUENCE MESH=QuadShotHeldL SEQ=ReloadEnd STARTFRAME=38 NUMFRAMES=3 RATE=15

#exec MESHMAP NEW MESHMAP=QuadShotHeldL MESH=QuadShotHeldL
#exec MESHMAP SCALE MESHMAP=QuadShotHeldL X=0.007 Y=0.005 Z=0.01

#exec MESHMAP SETTEXTURE MESHMAP=QuadShotHeldL NUM=1 TEXTURE=QuadHand1
#exec MESHMAP SETTEXTURE MESHMAP=QuadShotHeldL NUM=2 TEXTURE=QuadHand1
#exec MESHMAP SETTEXTURE MESHMAP=QuadShotHeldL NUM=3 TEXTURE=QuadHand1

// ------------------------------------------------------------------------------------------------------------------------

// Backwards Compatibility Pickup View - NOT USED
#exec MESH IMPORT MESH=QuadShotPickup ANIVFILE=Models\QuadShotPickup_a.3d DATAFILE=Models\QuadShotPickup_d.3d X=0 Y=0 Z=0
#exec MESH ORIGIN MESH=QuadShotPickup X=0 Y=0 Z=0 YAW=0
#exec MESH SEQUENCE MESH=QuadShotPickup SEQ=All STARTFRAME=0 NUMFRAMES=1
#exec MESHMAP SCALE MESHMAP=QuadShotPickup X=0.04 Y=0.04 Z=0.08
#exec MESHMAP SETTEXTURE MESHMAP=QuadShotPickup NUM=4 TEXTURE=GunPick1



// Backwards Compatibility First Person View - NOT USED
#exec MESH IMPORT MESH=QuadShotHeld ANIVFILE=Models\QuadShotHeld_a.3d DATAFILE=Models\QuadShotHeld_d.3d X=0 Y=0 Z=0
#exec MESH ORIGIN MESH=QuadShotHeld X=0 Y=0 Z=0 YAW=128
#exec MESH SEQUENCE MESH=QuadShotHeld SEQ=All STARTFRAME=0 NUMFRAMES=30
#exec MESH SEQUENCE MESH=QuadShotHeld SEQ=Fire STARTFRAME=0 NUMFRAMES=9
#exec MESH SEQUENCE MESH=QuadShotHeld SEQ=Reload STARTFRAME=8 NUMFRAMES=21
#exec MESHMAP SCALE MESHMAP=QuadShotHeld X=0.04 Y=0.04 Z=0.08
#exec MESHMAP SETTEXTURE MESHMAP=QuadShotHeld NUM=4 TEXTURE=QuadHand1

// ------------------------------------------------------------------------------------------------------------------------

#exec AUDIO IMPORT FILE="Sounds\ShotgunFire.wav" NAME="ShotgunFire" GROUP="Quadshot"
#exec AUDIO IMPORT FILE="Sounds\ShotgunLoad.wav" NAME="ShotgunLoad" GROUP="Quadshot"
#exec AUDIO IMPORT FILE="Sounds\ShotgunActivate.wav" NAME="ShotgunActivate" GROUP="Quadshot"


var travel byte LoadCount;			  // Keeps track of the number of Shells Currently Loaded
var travel int SpentCartridge;		// Keeps track of the number of Spent Cartridges Loaded
var() int HitDamage;			  // Hit Damage induced per Shotgun pellet
var() float HitMomentum;		 // Hit Momentum induced per Shotgun pellet
var() int PelletsPerShell;	  // Number of Pellets per Shotgun Shell
var() int BarrelShotOffset;	 // Offset Adjustment from standard offset to account for multi-barrel
var() float ShotSpread;		  // Shot Spread
var() float OptimalRange;		// Optimal Operational Range

//======================================================================================
// Quadshot.TraceFire
//======================================================================================
function TraceFire( float Accuracy )
{
	local vector HitLocation, HitNormal, StartTrace, EndTrace, X,Y,Z;
	local actor Other;
	local Pawn PawnOwner;

	PawnOwner = Pawn(Owner);

	Owner.MakeNoise(PawnOwner.SoundDampening);
	GetAxes(PawnOwner.ViewRotation,X,Y,Z);
	StartTrace = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z;
	AdjustedAim = PawnOwner.AdjustAim(1000000, StartTrace, 2.75*AimError, False, False);
	EndTrace = StartTrace + Accuracy * (FRand() - 0.5 )* Y * 1000 + Accuracy * (FRand() - 0.5 ) * Z * 1000;
	X = vector(AdjustedAim);
	EndTrace += (OptimalRange * 6 * X);
	Other = PawnOwner.TraceShot(HitLocation,HitNormal,EndTrace,StartTrace);

	ProcessTraceHit(Other, HitLocation, HitNormal, X,Y,Z);
}

//======================================================================================
// Quadshot.ProcessTraceHit
//======================================================================================
function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
{
	local int ModifiedDamage;
	local float EnemyDist, ModifiedMomentum, AddedImpactEffect;
	local vector EnemyDir;
	local vector realLoc;
	local ZoneInfo HitZone;
	local byte HitCount;
	local rotator Dummy;

	/* Check if were passing through zoneportals */
	if ( Other!=None )
	{
		HitZone = Level.GetLocZone(HitLocation+HitNormal).Zone;
		while ( WarpZoneInfo(HitZone)!=None && WarpZoneInfo(HitZone).OtherSideActor!=None && HitCount++<5 )
		{
			realLoc = HitLocation;
			WarpZoneInfo(HitZone).UnWarp(realLoc,X,Dummy);
			WarpZoneInfo(HitZone).OtherSideActor.Warp(realLoc,X,Dummy);
			Z = realLoc+X*8000;
			Other = Trace(HitLocation,HitNormal,Z,realLoc,True); // We dont use owner pawn trace here because we could hit ourselves.
			while ( Other!=None && Other.bIsPawn && !Pawn(Other).AdjustHitLocation(HitLocation, Z - realLoc) )
			{
				realLoc = HitLocation;
				Other = Other.Trace(HitLocation,HitNormal,Z,realLoc,True);
			}
			if ( Other==None )
				Break;
			HitZone = Level.GetLocZone(HitLocation+HitNormal).Zone;
		}
	}

	if (other != none)
	{
		EnemyDir = Other.Location - Owner.Location;
		EnemyDist = FMax((1.f-VSize(EnemyDir)/OptimalRange),0.25f);
	}

	// Modify Damage/Momentum for Long Distance Shots
	ModifiedDamage=Max(int(float(HitDamage)*EnemyDist),1);
	ModifiedMomentum=FMax(HitMomentum*EnemyDist,500.0);
	AddedImpactEffect = FRand();
	if ( AddedImpactEffect < 0.2 )
		ModifiedMomentum *= 2;

	if (Other == Level)
	{
		if ( AddedImpactEffect < 0.2 )
			Spawn(class'WallHitEffect',,, HitLocation+HitNormal*9, Rotator(HitNormal));
		else if ( AddedImpactEffect < 0.5 )
			Spawn(class'LightWallHitEffect',,,HitLocation+HitNormal*9, Rotator(HitNormal));
		else Spawn(class'SpriteSmokePuff',,,HitLocation+HitNormal*9);
	}
	else if ( (Other != None) && (Other != self) && (Other != Owner)  )
	{
		if ( Other.IsA('Pawn') && (HitLocation.Z - Other.Location.Z > 0.62 * Other.CollisionHeight)
				&& (instigator.IsA('PlayerPawn') || (instigator.skill > 1))
				&& (!Other.IsA('ScriptedPawn') || !ScriptedPawn(Other).bIsBoss) )
			Other.TakeDamage(ModifiedDamage*2, Pawn(Owner), HitLocation, ModifiedMomentum*X, 'decapitated');
		else if (Other.IsA('Pawn'))
			Other.TakeDamage(ModifiedDamage, Pawn(Owner), HitLocation, ModifiedMomentum*X, 'shot');
		else if (other != none)
		{
			Other.TakeDamage(HitDamage, Pawn(Owner), HitLocation, ModifiedMomentum*X, 'shot');
			if ( !Other.IsA('Pawn') && !Other.IsA('Carcass') )
				spawn(class'SpriteSmokePuff',,,HitLocation+HitNormal*9);
		}
	}
}

//======================================================================================
// Quadshot.RateSelf
//======================================================================================
// AI Interface
// Determines if Quadshot is a good choice to use
//======================================================================================
function float RateSelf( out int bUseAltMode )
{
	local float EnemyDist, Rating;
	local vector EnemyDir;
	local Pawn P;

	// don't recommend self if out of ammo
	if ( AmmoType.AmmoAmount <=0 && LoadCount==0)
		return -2;

	// Attempt to use regular mode only if Already Loaded otherwise load a random charge up
	if (LoadCount>0)
	{
		if (FRand()>=0.5 || LoadCount==4)
			bUseAltMode = 0;
		else
			bUseAltMode = 1;
	}
	else bUseAltMode = 1;

	P = Pawn(Owner);
	if ( P.Enemy == None )
		return AIRating;
	else
	{
		EnemyDir = P.Enemy.Location - Owner.Location;
		EnemyDist = VSize(EnemyDir);
		Rating = AIRating;

		Rating = FClamp(AIRating - (EnemyDist - OptimalRange) * 0.001 + float(LoadCount)/10.0, 0.2, AIRating);
		return Rating;
	}
}

//======================================================================================
// Quadshot.SuggestAttackStyle
//======================================================================================
// AI Interface
// Determines if Quadshot is a good choice to attack with
//======================================================================================
function float SuggestAttackStyle()
{
	local Pawn P;
	local float EnemyDist;

	P = Pawn(Owner);

	// Move forward at a moderate pace
	if ( P == None || P.Target==None )
	{
		if ( P!=None )
			P.bAltFire=1;
		return 0.4;
	}
	else EnemyDist = VSize(P.Target.Location - P.Location);

	// If enemy outside of optimal fighting range then charge in closer
	if ( EnemyDist > OptimalRange*2 )
	{
		Pawn(Owner).bAltFire=1;
		return 1.0;
	}

	// If enemy too close then back off quickly
	if ( EnemyDist < OptimalRange*0.33 )
		return -1.5;

	// If enemy close then back off with moderately quick speed
	if ( EnemyDist < OptimalRange*0.66 )
		return -0.75;

	// Otherwise close with enemy at slow pace
	P.bAltFire=1;
	return 0.2;

}

//======================================================================================
// Quadshot.SuggestDefenseStyle()
//======================================================================================
// AI Interface
// Determines best defensive action vs Quadshot
//======================================================================================
function float SuggestDefenseStyle()
{
	local Pawn P;
	local float EnemyDist;

	P = Pawn(Owner);

	// No recommended defensive action
	if ( P==None || P.Target == None )
		return 0;
	else if ( P.Target == None )
		return 0;
	else EnemyDist = VSize(P.Target.Location - P.Location);

	// If enemy has not loaded a shell yet - charge them
	if (LoadCount==0)
		return 1;
	else if ( EnemyDist < OptimalRange*1.5 )
		return -0.75; // If enemey is relatively close - retreat moderately quickly away from weapon
	else return 0; // Otherwise no recommended defensive action
}

//======================================================================================
// Quadshot.SetHand
//======================================================================================
function SetHand(float Hand)
{
	if ( Hand == 0 ) // CENTER
	{
		Mesh = LodMesh'QuadShotHeldR';
		bHideWeapon = false;
		PlayerViewOffset.X = Default.PlayerViewOffset.X;
		PlayerViewOffset.Y = 0;
		PlayerViewOffset.Z = Default.PlayerViewOffset.Z;
		PlayerViewOffset *= 100; //scale since network passes vector components as ints
		FireOffset.Y = 0;
	}
	else if ( Hand == 1 )  // LEFT
	{
		Mesh = LodMesh'QuadShotHeldL';
		bHideWeapon = false;
		PlayerViewOffset.X = Default.PlayerViewOffset.X;
		PlayerViewOffset.Y = Default.PlayerViewOffset.Y * Hand;
		PlayerViewOffset.Z = Default.PlayerViewOffset.Z;
		PlayerViewOffset *= 100; //scale since network passes vector components as ints
		FireOffset.Y = Default.FireOffset.Y * Hand;
	}
	else if ( Hand == -1)  // RIGHT
	{
		Mesh = LodMesh'QuadShotHeldR';
		bHideWeapon = false;
		PlayerViewOffset.X = Default.PlayerViewOffset.X;
		PlayerViewOffset.Y = Default.PlayerViewOffset.Y * Hand;
		PlayerViewOffset.Z = Default.PlayerViewOffset.Z;
		PlayerViewOffset *= 100; //scale since network passes vector components as ints
		FireOffset.Y = Default.FireOffset.Y * Hand;
	}
	else if ( Hand == 2 )  // HIDDEN
	{
		bHideWeapon = true;
		PlayerViewOffset.Y = 0;
		PlayerViewOffset *= 100; //scale since network passes vector components as ints
		FireOffset.Y = 0;
	}

}

//======================================================================================
// Quadshot.Fire
//======================================================================================
function Fire( float Value )
{
	GoToState('NormalFire');
}

//======================================================================================
// Quadshot.AltFire
//======================================================================================
function AltFire( float Value )
{
	GoToState('ReLoad');
}

//======================================================================================
// Quadshot.PlayPostSelect
//======================================================================================
function PlayPostSelect()
{
	Super.PlayPostSelect();
	if ( LoadCount==0 )
		GoToState('ReLoad');
	else GotoState('Idle');
}

//======================================================================================
// Quadshot.SetShotPattern
//======================================================================================
function SetShotPattern( int LoadCount, int ShotNum )
{
	FireOffset = default.FireOffset;
	if (LoadCount==1)
		return;
	else if (LoadCount==2)
	{
		if (ShotNum==1)
			FireOffset.Y -= BarrelShotOffset;
		if (ShotNum==2)
			FireOffset.Z += BarrelShotOffset;
	}
	else if (LoadCount==3)
	{
		if (ShotNum==1)
			FireOffset.Y -= BarrelShotOffset;
		if (ShotNum==2)
			FireOffset.Z += BarrelShotOffset;
		if (ShotNum==3)
			FireOffset.Y += BarrelShotOffset;
	}
	else
	{
		if (ShotNum==1)
			FireOffset.Y -= BarrelShotOffset;
		if (ShotNum==2)
			FireOffset.Z += BarrelShotOffset;
		if (ShotNum==3)
			FireOffset.Y += BarrelShotOffset;
		if (ShotNum==4)
			FireOffset.Z -= BarrelShotOffset;
	}
}

//======================================================================================
// Quadshot.EjectCartridge
//======================================================================================
function EjectCartridge()
{
	local shellcase s;
	local vector realLoc, X, Y, Z;
	local Pawn PawnOwner;

	PawnOwner = Pawn(Owner);

	GetAxes(PawnOwner.ViewRotation,X,Y,Z);

	if (SpentCartridge>=3)
	{
		realLoc = Owner.Location + CalcDrawOffset();
		s = Spawn(class'ShotShellCase',PawnOwner, '', realLoc + (20 * X) + (FireOffset.Y * Y) + Z);
		if ( s != None )
			s.Eject(((FRand()*0.3+0.4)*X + (FRand()*0.2+0.2)*Y + (FRand()*0.3+1.0) * Z)*160);
	}
}

//======================================================================================
// Quadshot.PlayIdleAnim
//======================================================================================
function PlayIdleAnim()
{
	if ( AnimSequence!='Idle' )
		LoopAnim('Idle',0.5);
}

//======================================================================================
// Quadshot.Finish
//======================================================================================
function Finish()
{
	if ( bChangeWeapon )
		GotoState('DownWeapon');
	else if ( PlayerPawn(Owner) == None )
		Super(Weapon).Finish();
	else if ( Pawn(Owner).Weapon!=self )
		GotoState('');
	else if ( Pawn(Owner).bFire!=0 )
		Global.Fire(0);
	else if ( Pawn(Owner).bAltFire!=0 )
		Global.AltFire(0);
	else
		GotoState('Idle');
}

//======================================================================================
// Quadshot.DisplayMuzzleFlash
//======================================================================================
function DisplayMuzzleFlash()
{
	local vector Start,X,Y,Z;

	GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
	Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z;

	Spawn(class'WeaponLight',,'',Start+X*20,rot(0,0,0));

	bDrawMuzzleFlash=True;
	bMuzzleFlash=0;
}

//======================================================================================
// Quadshot:NormalFire
//======================================================================================
state NormalFire
{
	ignores Fire, AltFire;

	function DischargeWeapon()
	{
		local int loads,shots;

		CheckVisibility();
		bPointing=True;

		// Shoot all barrels
		for (loads = 0; loads < LoadCount; loads++)
		{
			SetShotPattern(LoadCount, loads);
			DisplayMuzzleFlash();
			for (shots = 0; shots < PelletsperShell; shots++)
				TraceFire(ShotSpread);
		}
		if (PlayerPawn(Owner)!=None)
			PlayerPawn(Owner).ShakeView(ShakeTime*Sqrt(float(LoadCount)), ShakeMag*Sqrt(float(LoadCount)), ShakeVert*Sqrt(float(LoadCount)));

		Owner.MakeNoise(LoadCount * Pawn(Owner).SoundDampening);
		Owner.PlaySound(FireSound,SLOT_Misc,FMin(0.95,Pawn(Owner).SoundDampening*((float(LoadCount)/20.0)+0.7)),,1500.0,1.1-(float(LoadCount)/20.0));

		// Unload the weapon
		LoadCount=0;
	}

Begin:
	if (LoadCount==0)
	{
		PlayIdleAnim();
		Owner.PlaySound(Misc1Sound, SLOT_None,Pawn(Owner).SoundDampening*1.0,False,300.0);
		Sleep(0.5);
		Finish();
	}
	PlayAnim( 'Fire', 0.9, 0.05);
	DischargeWeapon();
	FinishAnim();
	GoToState('ReLoad');
}

//======================================================================================
// Quadshot:Reload
//======================================================================================
state Reload
{
	ignores Fire, AltFire;

Begin:
	if ( LoadCount>=4 || (AmmoType!=None && !AmmoType.UseAmmo(1)) )
	{
		PlayIdleAnim();
		Owner.PlaySound(Misc1Sound, SLOT_None,Pawn(Owner).SoundDampening*1.0,False,300.0);
		Sleep(0.5);
		Finish();
	}
	LoadCount++;
	PlayAnim('Reload',1.2,0);
	Owner.PlaySound(CockingSound, SLOT_None,0.6*Pawn(Owner).SoundDampening);
	SpentCartridge++;
	FinishAnim();
	Finish();
}

//======================================================================================
// Quadshot:Idle
//======================================================================================
state Idle
{
	Ignores AnimEnd;

	function bool PutDown()
	{
		GotoState('DownWeapon');
		return True;
	}

Begin:
	bPointing=False;
	if ( !HasRequiredAmmo() )
		Pawn(Owner).SwitchToBestWeapon();  //Goto Weapon that has Ammo
	if ( Pawn(Owner).bFire!=0 )
		Global.Fire(0.0);
	if ( LoadCount < 4 )
		if ( Pawn(Owner).bAltFire!=0 )
			Global.AltFire(0.0);
	PlayIdleAnim();
	if ( PlayerPawn(Owner)==None && LoadCount<4 && (AmmoType==None || AmmoType.AmmoAmount>0) )
	{
		Sleep(LoadCount*(3+FRand()*5)+2); // Automatic charging up...
		Global.AltFire(0.0);
	}
}

function bool HasRequiredAmmo()
{
	Return (AmmoType==None || AmmoType.AmmoAmount>0 || LoadCount>0);
}

//
// Fix for ammo bugs..
function Weapon WeaponChange( byte F )
{
	local Weapon newWeapon;

	if ( InventoryGroup == F )
	{
		if ( !HasRequiredAmmo() )
		{
			if ( Inventory == None )
				newWeapon = None;
			else
				newWeapon = Inventory.WeaponChange(F);
			if ( newWeapon == None )
				Pawn(Owner).ClientMessage( ItemName$MessageNoAmmo );
			return newWeapon;
		}
		else
			return self;
	}
	else if ( Inventory == None )
		return None;
	else
		return Inventory.WeaponChange(F);
}

function float SwitchPriority()
{
	local int bTemp;

	if ( !Owner.IsA('PlayerPawn') )
		return RateSelf(bTemp);
	else if ( !HasRequiredAmmo() )
	{
		if ( Pawn(Owner).Weapon == self )
			return -0.5;
		else
			return -1;
	}
	else
		return AutoSwitchPriority;
}
function Weapon RecommendWeapon( out float rating, out int bUseAltMode )
{
	local Weapon Recommended;
	local float oldRating;
	local int oldMode;

	if ( Owner.IsA('PlayerPawn') )
		rating = SwitchPriority();
	else
	{
		rating = RateSelf(bUseAltMode);
		if ( (self == Pawn(Owner).Weapon) && (Pawn(Owner).Enemy != None) && HasRequiredAmmo() )
			rating += 0.21; // tend to stick with same weapon
	}
	if ( inventory != None )
	{
		Recommended = inventory.RecommendWeapon(oldRating, oldMode);
		if ( (Recommended != None) && (oldRating > rating) )
		{
			rating = oldRating;
			bUseAltMode = oldMode;
			return Recommended;
		}
	}
	return self;
}

defaultproperties
{
				SpentCartridge=-1
				hitdamage=12
				HitMomentum=18000.000000
				PelletsPerShell=10
				BarrelShotOffset=3
				ShotSpread=1.250000
				OptimalRange=750.000000
				AmmoName=Class'UnrealShare.Shells'
				PickupAmmoCount=12
				MyDamageType="SHOT"
				AltDamageType="Decapitated"
				shakemag=400.000000
				shaketime=0.150000
				shakevert=20.000000
				AIRating=0.300000
				RefireRate=0.700000
				AltRefireRate=0.900000
				FireSound=Sound'UnrealI.QuadShot.ShotgunFire'
				CockingSound=Sound'UnrealI.QuadShot.ShotgunLoad'
				SelectSound=Sound'UnrealI.QuadShot.ShotgunActivate'
				Misc1Sound=Sound'UnrealShare.Flak.Click'
				DeathMessage="%o was blasted to bits by %k's %w."
				bSetFlashTime=True
				bMuzzleFlash=1
				FlashTime=0.500000
				MuzzleScale=1.000000
				FlashY=0.110000
				FlashO=0.140000
				FlashC=0.030000
				FlashLength=0.250000
				FlashS=64
				MFTexture=Texture'UnrealShare.Effects.Arc1'
				AutoSwitchPriority=4
				InventoryGroup=2
				PickupMessage="You got the Quad-Barreled ShotGun"
				ItemName="QuadShot"
				PlayerViewOffset=(X=7.000000,Y=-4.000000,Z=-4.000000)
				PlayerViewMesh=LodMesh'UnrealI.QuadShotHeldR'
				PlayerViewScale=2.000000
				PickupViewMesh=LodMesh'UnrealI.QuadShotPickupC'
				PickupViewScale=1.500000
				ThirdPersonMesh=LodMesh'UnrealI.QuadShotThird'
				PickupSound=Sound'UnrealShare.Pickups.WeaponPickup'
				Mesh=LodMesh'UnrealI.QuadShotPickupC'
				DrawScale=1.500000
				bNoSmooth=False
				bMeshCurvy=True
				SoundRadius=200
				SoundVolume=180
				CollisionHeight=10.000000
				Mass=45.000000
}

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