Botpack
Class Enforcer

source: e:\games\UnrealTournament\Botpack\Classes\enforcer.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Weapon
            |
            +--Botpack.TournamentWeapon
               |
               +--Botpack.Enforcer
Direct Known Subclasses:DoubleEnforcer

class Enforcer
extends Botpack.TournamentWeapon

//============================================================================= // Enforcer //=============================================================================
Variables
 float AltAccuracy
 string DoubleName
           used for setting display properties
 int DoubleSwitchPriority
           used for setting display properties
 Texture MuzzleFlashVariations[5]
           used for setting display properties
 Enforcer SlaveEnforcer
           The left (second) Enforcer is a slave to the right.
 bFirstFire, bBringingUp
           used for setting display properties
 bool bIsSlave
           The left (second) Enforcer is a slave to the right.
 bool bSetup
           used for setting display properties
 int hitdamage

States
ClientDown, ClientActive, Idle, AltFiring, ClientAltFiring, ClientFiring, NormalFire, DownWeapon, Active

Function Summary
 void AltFire(float Value)
 
simulated
AnimEnd()
 void BringUp()
 void Destroyed()
 void DropFrom(vector StartLocation)
 void Fire(float Value)
 bool HandlePickupQuery(Inventory Item)
 
simulated
PlayAltFiring()
 
simulated
PlayFiring()
 
simulated
PlayRepeatFiring()
 void ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
 void SetDefaultDisplayProperties()
 void SetDisplayProperties(ERenderStyle NewStyle, Texture NewTexture, bool bLighting, bool bEnviroMap)
 void SetSwitchPriority(Pawn Other)
 void SetTwoHands()
 void SetUpSlave(bool bBringUp)
 float SwitchPriority()
     
// Return the switch priority of the weapon (normally AutoSwitchPriority, but may be
// modified by environment (or by other factors for bots)
 void TraceFire(float Accuracy)
 bool WeaponSet(Pawn Other)
 void setHand(float Hand)


State ClientDown Function Summary


State ClientActive Function Summary


State Idle Function Summary
 bool PutDown()
 void AnimEnd()


State AltFiring Function Summary
 void EndState()
 void Timer()


State ClientAltFiring Function Summary
 bool ClientFire(float Value)


State ClientFiring Function Summary
 bool ClientAltFire(float Value)


State NormalFire Function Summary
 void EndState()
 void Timer()


State DownWeapon Function Summary
 void BeginState()


State Active Function Summary
 void EndState()
 void BeginState()
 bool PutDown()



Source Code


00001	//=============================================================================
00002	// Enforcer
00003	//=============================================================================
00004	class Enforcer extends TournamentWeapon;
00005	
00006	#exec TEXTURE IMPORT NAME=IconAutoM FILE=TEXTURES\HUD\WpnAutoM.PCX GROUP="Icons" MIPS=OFF
00007	#exec TEXTURE IMPORT NAME=UseAutoM FILE=TEXTURES\HUD\UseAutoM.PCX GROUP="Icons" MIPS=OFF
00008	
00009	#exec TEXTURE IMPORT NAME=Muz1 FILE=MODELS\muz1.PCX GROUP="Skins"  LODSET=2
00010	#exec TEXTURE IMPORT NAME=Muz2 FILE=MODELS\muz2.PCX GROUP="Skins"  LODSET=2
00011	#exec TEXTURE IMPORT NAME=Muz3 FILE=MODELS\muz3.PCX GROUP="Skins"  LODSET=2
00012	#exec TEXTURE IMPORT NAME=Muz4 FILE=MODELS\muz4.PCX GROUP="Skins"  LODSET=2
00013	#exec TEXTURE IMPORT NAME=Muz5 FILE=MODELS\muz5.PCX GROUP="Skins"  LODSET=2
00014	
00015	// pickup version
00016	#exec MESH IMPORT MESH=MagPick ANIVFILE=MODELS\autopick_a.3D DATAFILE=MODELS\autopick_d.3D X=0 Y=0 Z=0
00017	#exec MESH ORIGIN MESH=MagPick X=0 Y=0 Z=0 YAW=64
00018	#exec MESH SEQUENCE MESH=MagPick SEQ=All  STARTFRAME=0  NUMFRAMES=1
00019	#exec TEXTURE IMPORT NAME=Jautot1 FILE=MODELS\mag0.PCX GROUP="Skins"  LODSET=2
00020	#exec MESHMAP SCALE MESHMAP=MagPick X=0.05 Y=0.05 Z=0.1
00021	#exec MESHMAP SETTEXTURE MESHMAP=MagPick NUM=1 TEXTURE=Jautot1
00022	
00023	// 3rd person perspective version 
00024	#exec MESH IMPORT MESH=AutoHand ANIVFILE=MODELS\autopick_a.3D DATAFILE=MODELS\autopick_d.3D X=0 Y=0 Z=0
00025	#exec MESH ORIGIN MESH=AutoHand X=0 Y=250 Z=-60 YAW=64 PITCH=0 ROLL=0
00026	#exec MESH SEQUENCE MESH=AutoHand SEQ=All  STARTFRAME=0    NUMFRAMES=6
00027	#exec MESH SEQUENCE MESH=AutoHand SEQ=Still  STARTFRAME=0  NUMFRAMES=1
00028	#exec MESH SEQUENCE MESH=AutoHand SEQ=Shoot  STARTFRAME=1  NUMFRAMES=6
00029	#exec MESH SEQUENCE MESH=AutoHand SEQ=Shot2  STARTFRAME=1  NUMFRAMES=6
00030	#exec MESHMAP SCALE MESHMAP=AutoHand X=0.025 Y=0.025 Z=0.05
00031	#exec MESHMAP SETTEXTURE MESHMAP=AutoHand NUM=1 TEXTURE=Jautot1
00032	
00033	//  player view version
00034	#exec MESH IMPORT MESH=AutoML ANIVFILE=MODELS\mag_a.3D DATAFILE=MODELS\mag_d.3D unmirror=1
00035	#exec MESH ORIGIN MESH=AutoML X=0 Y=0 Z=0 YAW=64 ROLL=0
00036	
00037	#exec MESH DROPFRAMES MESH=AutoML STARTFRAME=130    NUMFRAMES=35
00038	#exec MESH DROPFRAMES MESH=AutoML STARTFRAME=144    NUMFRAMES=10
00039	
00040	#exec MESH SEQUENCE MESH=AutoML SEQ=All     STARTFRAME=0  NUMFRAMES=151
00041	#exec MESH SEQUENCE MESH=AutoML SEQ=Still   STARTFRAME=0  NUMFRAMES=1
00042	#exec MESH SEQUENCE MESH=AutoML SEQ=Shoot   STARTFRAME=6  NUMFRAMES=10
00043	#exec MESH SEQUENCE MESH=AutoML SEQ=Eject   STARTFRAME=22  NUMFRAMES=28
00044	#exec MESH SEQUENCE MESH=AutoML SEQ=Select  STARTFRAME=60  NUMFRAMES=28 RATE=36 GROUP=Select
00045	#exec MESH SEQUENCE MESH=AutoML SEQ=Twiddle STARTFRAME=87  NUMFRAMES=25
00046	#exec MESH SEQUENCE MESH=AutoML SEQ=Sway    STARTFRAME=86  NUMFRAMES=2 RATE=3
00047	#exec MESH SEQUENCE MESH=AutoML SEQ=Down    STARTFRAME=115  NUMFRAMES=12 RATE=45
00048	#exec MESH SEQUENCE MESH=AutoML SEQ=T1      STARTFRAME=130  NUMFRAMES=6
00049	#exec MESH SEQUENCE MESH=AutoML SEQ=Shot2   STARTFRAME=136  NUMFRAMES=8
00050	#exec MESH SEQUENCE MESH=AutoML SEQ=T2      STARTFRAME=144  NUMFRAMES=7
00051	#exec TEXTURE IMPORT NAME=Jtutot1 FILE=MODELS\mag1.PCX GROUP="Skins"   LODSET=2
00052	#exec TEXTURE IMPORT NAME=Jtutot2 FILE=MODELS\mag2.PCX GROUP="Skins"   LODSET=2
00053	#exec TEXTURE IMPORT NAME=Jtutot3 FILE=MODELS\mag3.PCX GROUP="Skins"   LODSET=2
00054	#exec TEXTURE IMPORT NAME=Jtutot4 FILE=MODELS\mag4.PCX GROUP="Skins"   LODSET=2
00055	#exec MESHMAP SCALE MESHMAP=AutoML X=0.007 Y=0.0045 Z=0.012
00056	#exec MESHMAP SETTEXTURE MESHMAP=AutoML NUM=0 TEXTURE=Jtutot1
00057	#exec MESHMAP SETTEXTURE MESHMAP=AutoML NUM=1 TEXTURE=Jtutot2
00058	#exec MESHMAP SETTEXTURE MESHMAP=AutoML NUM=2 TEXTURE=Jtutot3
00059	#exec MESHMAP SETTEXTURE MESHMAP=AutoML NUM=3 TEXTURE=Jtutot4
00060	
00061	// right handed player view version
00062	#exec MESH IMPORT MESH=AutoMR ANIVFILE=MODELS\mag_a.3D DATAFILE=MODELS\mag_d.3D
00063	#exec MESH ORIGIN MESH=AutoMR X=0 Y=0 Z=0 YAW=64 ROLL=0
00064	
00065	#exec MESH DROPFRAMES MESH=AutoMR STARTFRAME=130    NUMFRAMES=35
00066	#exec MESH DROPFRAMES MESH=AutoMR STARTFRAME=144    NUMFRAMES=10
00067	
00068	#exec MESH SEQUENCE MESH=AutoMR SEQ=All     STARTFRAME=0  NUMFRAMES=151
00069	#exec MESH SEQUENCE MESH=AutoMR SEQ=Still   STARTFRAME=0  NUMFRAMES=1
00070	#exec MESH SEQUENCE MESH=AutoMR SEQ=Shoot   STARTFRAME=6  NUMFRAMES=10
00071	#exec MESH SEQUENCE MESH=AutoMR SEQ=Eject   STARTFRAME=22  NUMFRAMES=28
00072	#exec MESH SEQUENCE MESH=AutoMR SEQ=Select  STARTFRAME=60  NUMFRAMES=28 RATE=36 GROUP=Select
00073	#exec MESH SEQUENCE MESH=AutoMR SEQ=Twiddle STARTFRAME=87  NUMFRAMES=25
00074	#exec MESH SEQUENCE MESH=AutoMR SEQ=Sway   STARTFRAME=86  NUMFRAMES=2   RATE=3
00075	#exec MESH SEQUENCE MESH=AutoMR SEQ=Down    STARTFRAME=115  NUMFRAMES=12 RATE=45
00076	#exec MESH SEQUENCE MESH=AutoMR SEQ=T1      STARTFRAME=130  NUMFRAMES=6
00077	#exec MESH SEQUENCE MESH=AutoMR SEQ=Shot2   STARTFRAME=136  NUMFRAMES=8
00078	#exec MESH SEQUENCE MESH=AutoMR SEQ=T2      STARTFRAME=144  NUMFRAMES=7
00079	#exec MESHMAP SCALE MESHMAP=AutoMR X=0.007 Y=0.0045 Z=0.012
00080	#exec MESHMAP SETTEXTURE MESHMAP=AutoMR NUM=0 TEXTURE=Jtutot1
00081	#exec MESHMAP SETTEXTURE MESHMAP=AutoMR NUM=1 TEXTURE=Jtutot2
00082	#exec MESHMAP SETTEXTURE MESHMAP=AutoMR NUM=2 TEXTURE=Jtutot3
00083	#exec MESHMAP SETTEXTURE MESHMAP=AutoMR NUM=3 TEXTURE=Jtutot4
00084	
00085	#exec TEXTURE IMPORT NAME=EMuz1 FILE=MODELS\muz1.PCX GROUP="Skins"
00086	
00087	#exec AUDIO IMPORT FILE="..\UnrealShare\Sounds\automag\cocking.WAV" NAME="Cocking" GROUP="enforcer"
00088	#exec AUDIO IMPORT FILE="Sounds\Enforcer\enforcershot.WAV" NAME="E_Shot" GROUP="enforcer"
00089	#exec AUDIO IMPORT FILE="..\UnrealShare\Sounds\flak\click.WAV" NAME="click" GROUP="flak"
00090	#exec AUDIO IMPORT FILE="..\UnrealShare\Sounds\automag\reload1.WAV" NAME="Reload" GROUP="enforcer"
00091	
00092	#exec MESH IMPORT MESH=muzzEF3 ANIVFILE=MODELS\muzzle2_a.3d DATAFILE=MODELS\Muzzle2_d.3d X=0 Y=0 Z=0
00093	#exec MESH LODPARAMS MESH=muzzEF3 MINVERTS=8 STRENGTH=0.7 ZDISP=800.0
00094	
00095	#exec MESH ORIGIN MESH=muzzEF3 X=0 Y=740 Z=-90 YAW=64
00096	#exec MESH SEQUENCE MESH=muzzEF3 SEQ=All                      STARTFRAME=0 NUMFRAMES=3
00097	#exec MESH SEQUENCE MESH=muzzEF3 SEQ=Shoot                   STARTFRAME=0 NUMFRAMES=3
00098	#exec MESHMAP NEW   MESHMAP=muzzEF3 MESH=muzzEF3
00099	#exec MESHMAP SCALE MESHMAP=muzzEF3 X=0.02 Y=0.05 Z=0.04
00100	#exec TEXTURE IMPORT NAME=Muzzy2 FILE=MODELS\Muzzy2.PCX GROUP=Skins
00101	
00102	var() int hitdamage;
00103	var  float AltAccuracy;
00104	var Enforcer SlaveEnforcer;		// The left (second) Enforcer is a slave to the right.
00105	var bool bIsSlave;
00106	var bool bSetup;				// used for setting display properties
00107	var bool bFirstFire, bBringingUp;
00108	var() localized string DoubleName;
00109	var() texture MuzzleFlashVariations[5];
00110	var int DoubleSwitchPriority;
00111	
00112	replication
00113	{
00114		reliable if ( bNetOwner && (Role == ROLE_Authority) )
00115			SlaveEnforcer, bIsSlave, bBringingUp;
00116	}
00117	
00118	function Destroyed()
00119	{
00120		Super.Destroyed();
00121		if ( SlaveEnforcer != None )
00122			SlaveEnforcer.Destroy();
00123	}
00124	
00125	simulated function AnimEnd()
00126	{
00127		if ( (Level.NetMode == NM_Client) && bBringingUp  && (Mesh != PickupViewMesh) )
00128		{
00129			bBringingUp = false;
00130			PlaySelect();
00131		}
00132		else
00133			Super.AnimEnd();
00134	}
00135	
00136	function bool WeaponSet(Pawn Other)
00137	{
00138		if ( bIsSlave )
00139			return false;
00140		else
00141			Super.WeaponSet(Other);
00142	}
00143	
00144	function SetSwitchPriority(pawn Other)
00145	{
00146		local int i;
00147		local name temp, carried;
00148	
00149		if ( PlayerPawn(Other) != None )
00150		{
00151			Super.SetSwitchPriority(Other);
00152	
00153			// also set double switch priority
00154	
00155			for ( i=0; i<20; i++)
00156				if ( PlayerPawn(Other).WeaponPriority[i] == 'doubleenforcer' )
00157				{
00158					DoubleSwitchPriority = i;
00159					return;
00160				}
00161		}		
00162	}
00163	
00164	// Return the switch priority of the weapon (normally AutoSwitchPriority, but may be
00165	// modified by environment (or by other factors for bots)
00166	function float SwitchPriority() 
00167	{
00168		local float temp;
00169		local int bTemp;
00170	
00171		if ( bIsSlave )
00172			return -10;
00173		if ( !Owner.IsA('PlayerPawn') )
00174			return RateSelf(bTemp);
00175		else if ( (AmmoType != None) && (AmmoType.AmmoAmount<=0) )
00176		{
00177			if ( Pawn(Owner).Weapon == self )
00178				return -0.5;
00179			else
00180				return -1;
00181		}
00182		else if ( SlaveEnforcer != None )
00183			return DoubleSwitchPriority;
00184		else
00185			return AutoSwitchPriority;
00186	}
00187	
00188	function DropFrom(vector StartLocation)
00189	{
00190		if ( !SetLocation(StartLocation) )
00191			return; 
00192		if ( SlaveEnforcer != None )
00193			SlaveEnforcer.Destroy();
00194		AIRating = Default.AIRating;
00195		SlaveEnforcer = None;
00196		Super.DropFrom(StartLocation);
00197	}
00198	
00199	function SetDisplayProperties(ERenderStyle NewStyle, texture NewTexture, bool bLighting, bool bEnviroMap )
00200	{
00201		if ( !bSetup )
00202		{
00203			bSetup = true;
00204			if ( SlaveEnforcer != None )
00205				SlaveEnforcer.SetDisplayProperties(NewStyle, NewTexture, bLighting, bEnviromap);
00206			bSetup = false;
00207		}			
00208		Super.SetDisplayProperties(NewStyle, NewTexture, bLighting, bEnviromap);
00209	}
00210	
00211	function SetDefaultDisplayProperties()
00212	{
00213		if ( !bSetup )
00214		{
00215			bSetup = true;
00216			if ( SlaveEnforcer != None )
00217				SlaveEnforcer.SetDefaultDisplayProperties();
00218			bSetup = false;
00219		}			
00220		Super.SetDefaultDisplayProperties();
00221	}
00222	
00223	event float BotDesireability(Pawn Bot)
00224	{
00225		local Enforcer AlreadyHas;
00226		local float desire;
00227	
00228		desire = MaxDesireability + Bot.AdjustDesireFor(self);
00229		AlreadyHas = Enforcer(Bot.FindInventoryType(class));
00230		if ( AlreadyHas != None )
00231		{
00232			if ( (!bHeldItem || bTossedOut) && bWeaponStay )
00233				return 0;
00234			if ( AlreadyHas.SlaveEnforcer != None )
00235			{
00236				if ( (RespawnTime < 10)
00237					&& ( bHidden || (AlreadyHas.AmmoType == None)
00238						|| (AlreadyHas.AmmoType.AmmoAmount < AlreadyHas.AmmoType.MaxAmmo)) )
00239					return 0;
00240				if ( AlreadyHas.AmmoType == None )
00241					return 0.25 * desire;
00242	
00243				if ( AlreadyHas.AmmoType.AmmoAmount > 0 )
00244					return FMax( 0.25 * desire, 
00245							AlreadyHas.AmmoType.MaxDesireability
00246							 * FMin(1, 0.15 * AlreadyHas.AmmoType.MaxAmmo/AlreadyHas.AmmoType.AmmoAmount) ); 
00247			}
00248		}
00249		if ( (Bot.Weapon == None) || (Bot.Weapon.AIRating <= 0.4) )
00250			return 2*desire;
00251	
00252		return desire;
00253	}
00254	
00255	function ProcessTraceHit(Actor Other, Vector HitLocation, Vector HitNormal, Vector X, Vector Y, Vector Z)
00256	{
00257		local UT_Shellcase s;
00258		local vector realLoc;
00259	
00260		realLoc = Owner.Location + CalcDrawOffset();
00261		s = Spawn(class'UT_ShellCase',, '', realLoc + 20 * X + FireOffset.Y * Y + Z);
00262		if ( s != None )
00263			s.Eject(((FRand()*0.3+0.4)*X + (FRand()*0.2+0.2)*Y + (FRand()*0.3+1.0) * Z)*160);              
00264		if (Other == Level) 
00265		{
00266			if ( bIsSlave || (SlaveEnforcer != None) )
00267				Spawn(class'UT_LightWallHitEffect',,, HitLocation+HitNormal, Rotator(HitNormal));
00268			else
00269				Spawn(class'UT_WallHit',,, HitLocation+HitNormal, Rotator(HitNormal));
00270		}
00271		else if ((Other != self) && (Other != Owner) && (Other != None) ) 
00272		{
00273			if ( FRand() < 0.2 )
00274				X *= 5;
00275			Other.TakeDamage(HitDamage, Pawn(Owner), HitLocation, 3000.0*X, MyDamageType);
00276			if ( !Other.bIsPawn && !Other.IsA('Carcass') )
00277				spawn(class'UT_SpriteSmokePuff',,,HitLocation+HitNormal*9);
00278			else
00279				Other.PlaySound(Sound 'ChunkHit',, 4.0,,100);
00280	
00281		}		
00282	}
00283	
00284	function bool HandlePickupQuery( inventory Item )
00285	{
00286		local Pawn P;
00287		local Inventory Copy;
00288	
00289		if ( (Item.class == class) && (SlaveEnforcer == None) ) 
00290		{
00291			P = Pawn(Owner);
00292			// spawn a double
00293			Copy = Spawn(class, P);
00294			Copy.BecomeItem();
00295			ItemName = DoubleName;
00296			SlaveEnforcer = Enforcer(Copy);
00297			SetTwoHands();
00298			AIRating = 0.4;
00299			SlaveEnforcer.SetUpSlave( Pawn(Owner).Weapon == self );
00300			SlaveEnforcer.SetDisplayProperties(Style, Texture, bUnlit, bMeshEnviromap);
00301			SetTwoHands();
00302			P.ReceiveLocalizedMessage( class'PickupMessagePlus', 0, None, None, Self.Class );
00303			Item.PlaySound(Item.PickupSound);
00304			if (Level.Game.LocalLog != None)
00305				Level.Game.LocalLog.LogPickup(Item, Pawn(Owner));
00306			if (Level.Game.WorldLog != None)
00307				Level.Game.WorldLog.LogPickup(Item, Pawn(Owner));
00308			Item.SetRespawn();
00309			return true;
00310		}
00311		return Super.HandlePickupQuery(Item);
00312	}
00313	
00314	function SetUpSlave(bool bBringUp)
00315	{
00316		bIsSlave = true;
00317		ItemName = DoubleName;
00318		GiveAmmo(Pawn(Owner));
00319		AmbientGlow = 0;
00320		if ( bBringUp )
00321			BringUp();
00322		else
00323			GotoState('Idle2');
00324	}
00325	
00326	function SetTwoHands()
00327	{
00328		if ( SlaveEnforcer == None )
00329			return;
00330	
00331		if ( (PlayerPawn(Owner) != None) && (PlayerPawn(Owner).Handedness == 2) )
00332		{
00333			SetHand(2);
00334			return;
00335		}
00336	
00337		if ( Mesh == mesh'AutoML' )
00338			SetHand(1);
00339		else
00340			SetHand(-1);
00341	}
00342	
00343	function setHand(float Hand)
00344	{
00345		local rotator newRot;
00346	
00347		if ( Hand == 2 )
00348		{
00349			bHideWeapon = true;
00350			Super.SetHand(Hand);
00351			return;
00352		}
00353	
00354		if ( SlaveEnforcer != None )
00355		{
00356			if ( Hand == 0 )
00357				Hand = -1;
00358			SlaveEnforcer.SetHand(-1 * Hand);
00359		}
00360		bHideWeapon = false;
00361		Super.SetHand(Hand);
00362		if ( Hand == 1 )
00363			Mesh = mesh'AutoML';
00364		else
00365			Mesh = mesh'AutoMR';
00366	}
00367	
00368	function BringUp()
00369	{
00370		if (SlaveEnforcer != none ) 
00371		{
00372			SetTwoHands();
00373			SlaveEnforcer.BringUp();
00374		}
00375		bBringingUp = true;
00376		Super.BringUp();
00377	}
00378	
00379	function TraceFire( float Accuracy )
00380	{
00381		local vector RealOffset;
00382	
00383		RealOffset = FireOffset;
00384		FireOffset *= 0.35;
00385		if ( (SlaveEnforcer != None) || bIsSlave )
00386			Accuracy = FClamp(3*Accuracy,0.75,3);
00387		else if ( Owner.IsA('Bot') && !Bot(Owner).bNovice )
00388			Accuracy = FMax(Accuracy, 0.45);
00389	
00390		Super.TraceFire(Accuracy);
00391		FireOffset = RealOffset;
00392	}
00393	
00394	function Fire(float Value)
00395	{
00396		if ( AmmoType == None )
00397		{
00398			// ammocheck
00399			GiveAmmo(Pawn(Owner));
00400		}
00401		if ( AmmoType.UseAmmo(1) )
00402		{
00403			GotoState('NormalFire');
00404			bCanClientFire = true;
00405			bPointing=True;
00406			ClientFire(value);
00407			if ( SlaveEnforcer != None )
00408				Pawn(Owner).PlayRecoil(2 * FiringSpeed);
00409			else if ( !bIsSlave )
00410				Pawn(Owner).PlayRecoil(FiringSpeed);
00411			TraceFire(0.2);
00412		}
00413	}
00414	
00415	simulated function PlayFiring()
00416	{
00417		PlayOwnedSound(FireSound, SLOT_None,2.0*Pawn(Owner).SoundDampening);
00418		bMuzzleFlash++;
00419		PlayAnim('Shoot',0.5 + 0.31 * FireAdjust, 0.02);
00420	}
00421	
00422	simulated function PlayAltFiring()
00423	{
00424		PlayAnim('T1', 1.3, 0.05);
00425		bFirstFire = true;
00426	}
00427	
00428	simulated function PlayRepeatFiring()
00429	{
00430		if ( Affector != None )
00431			Affector.FireEffect();
00432		if ( PlayerPawn(Owner) != None )
00433		{
00434			PlayerPawn(Owner).ClientInstantFlash( -0.2, vect(325, 225, 95));
00435			PlayerPawn(Owner).ShakeView(ShakeTime, ShakeMag, ShakeVert);
00436		}
00437		bMuzzleFlash++;
00438		PlayOwnedSound(FireSound, SLOT_None,2.0*Pawn(Owner).SoundDampening);
00439		PlayAnim('Shot2', 0.7 + 0.3 * FireAdjust, 0.05);
00440	}
00441	
00442	function AltFire( float Value )
00443	{
00444		bPointing=True;
00445		bCanClientFire = true;
00446		AltAccuracy = 0.4;
00447		if ( AmmoType == None )
00448		{
00449			// ammocheck
00450			GiveAmmo(Pawn(Owner));
00451		}
00452		if (AmmoType.AmmoAmount>0)
00453		{
00454			if ( SlaveEnforcer != None )
00455				Pawn(Owner).PlayRecoil(3 * FiringSpeed);
00456			else if ( !bIsSlave )
00457				Pawn(Owner).PlayRecoil(1.5 * FiringSpeed);
00458			ClientAltFire(value);
00459			GotoState('AltFiring');
00460		}
00461	}
00462	
00463	state Active
00464	{
00465		function bool PutDown()
00466		{
00467			if ( bWeaponUp || (AnimFrame < 0.75) ) 
00468				GotoState('DownWeapon');
00469			else
00470				bChangeWeapon = true;
00471			return True;
00472		}
00473	
00474		function BeginState()
00475		{
00476			bChangeWeapon = false;
00477		}
00478	
00479		function EndState()
00480		{
00481			Super.EndState();
00482			bBringingUp = false;
00483		}
00484	
00485	Begin:
00486		FinishAnim();
00487		if ( bChangeWeapon )
00488			GotoState('DownWeapon');
00489		bWeaponUp = True;
00490		bCanClientFire = true;
00491		if ( !bIsSlave && (Level.Netmode != NM_Standalone) && (Owner != None)
00492			&& Owner.IsA('TournamentPlayer')
00493			&& (PlayerPawn(Owner).Player != None)
00494			&& !PlayerPawn(Owner).Player.IsA('ViewPort') )
00495		{
00496			if ( Pawn(Owner).bFire != 0 )
00497				TournamentPlayer(Owner).SendFire(self);
00498			else if ( Pawn(Owner).bAltFire != 0 )
00499				TournamentPlayer(Owner).SendAltFire(self);
00500			else if ( !bChangeWeapon )
00501				TournamentPlayer(Owner).UpdateRealWeapon(self);
00502		} 
00503		Finish();
00504	}
00505	
00506	State DownWeapon
00507	{
00508	ignores Fire, AltFire, Animend;
00509	
00510		function BeginState()
00511		{
00512			Super.BeginState();
00513			if ( Slaveenforcer != none )
00514				Slaveenforcer.GoToState('DownWeapon');
00515		}
00516	}
00517	
00518	////////////////////////////////////////////////////////
00519	state NormalFire
00520	{
00521	ignores Fire, AltFire, AnimEnd;
00522	
00523		function Timer()
00524		{
00525			if ( SlaveEnforcer != none )
00526				SlaveEnforcer.Fire(0);
00527		}
00528	
00529		function EndState()
00530		{
00531			Super.EndState();
00532			OldFlashCount = FlashCount;
00533		}
00534	
00535	Begin:
00536		FlashCount++;
00537		if ( SlaveEnforcer != none )
00538			SetTimer(0.20, false);
00539		FinishAnim();
00540		if ( bIsSlave )
00541			GotoState('Idle');
00542		else 
00543			Finish();
00544	}
00545	
00546	state ClientFiring
00547	{
00548		simulated function bool ClientAltFire(float Value)
00549		{
00550			if ( bIsSlave )
00551				Global.ClientAltFire(Value);
00552			return false;
00553		}
00554	
00555		simulated function Timer()
00556		{
00557			if ( (SlaveEnforcer != none) && SlaveEnforcer.ClientFire(0) )
00558				return;
00559			SetTimer(0.5, false);
00560		}
00561	
00562		simulated function AnimEnd()
00563		{
00564			if ( (Pawn(Owner) == None) || (Ammotype.AmmoAmount <= 0) )
00565			{
00566				PlayIdleAnim();
00567				GotoState('');
00568			}
00569			else if ( !bIsSlave && !bCanClientFire )
00570				GotoState('');
00571			else if ( bFirstFire || (Pawn(Owner).bAltFire != 0) )
00572			{
00573				PlayRepeatFiring();
00574				bFirstFire = false;
00575			}
00576			else if ( Pawn(Owner).bFire != 0 )
00577				Global.ClientFire(0);
00578			else
00579			{
00580				PlayIdleAnim();
00581				GotoState('');
00582			}
00583		}
00584	
00585		simulated function BeginState()
00586		{
00587			Super.BeginState();
00588			if ( SlaveEnforcer != None )
00589				SetTimer(0.2, false);
00590			else 
00591				SetTimer(0.5, false);
00592		}
00593	
00594		simulated function EndState()
00595		{
00596			Super.EndState();
00597			if ( SlaveEnforcer != None )
00598				SlaveEnforcer.GotoState('');
00599		}
00600	}
00601	
00602	state ClientAltFiring
00603	{
00604		simulated function bool ClientFire(float Value)
00605		{
00606			if ( bIsSlave )
00607				Global.ClientFire(Value);
00608			return false;
00609		}
00610	
00611		simulated function Timer()
00612		{
00613			if ( (SlaveEnforcer != none) && SlaveEnforcer.ClientAltFire(0) )
00614				return;
00615			SetTimer(0.5, false);
00616		}
00617	
00618		simulated function AnimEnd()
00619		{
00620			if ( Pawn(Owner) == None )
00621				GotoState('');
00622			else if ( Ammotype.AmmoAmount <= 0 )
00623			{
00624				PlayAnim('T2', 0.9, 0.05);	
00625				GotoState('');
00626			}
00627			else if ( !bIsSlave && !bCanClientFire )
00628				GotoState('');
00629			else if ( bFirstFire || (Pawn(Owner).bAltFire != 0) )
00630			{
00631				PlayRepeatFiring();
00632				bFirstFire = false;
00633			}
00634			else if ( Pawn(Owner).bFire != 0 )
00635				Global.ClientFire(0);
00636			else
00637			{
00638				PlayAnim('T2', 0.9, 0.05);	
00639				GotoState('');
00640			}
00641		}
00642	
00643		simulated function BeginState()
00644		{
00645			Super.BeginState();
00646			if ( SlaveEnforcer != None )
00647				SetTimer(0.2, false);
00648			else 
00649				SetTimer(0.5, false);
00650		}
00651	
00652		simulated function EndState()
00653		{
00654			Super.EndState();
00655			if ( SlaveEnforcer != None )
00656				SlaveEnforcer.GotoState('');
00657		}
00658	}
00659	
00660	state AltFiring
00661	{
00662	ignores Fire, AltFire, AnimEnd;
00663	
00664		function Timer()
00665		{
00666			if ( Slaveenforcer != none )
00667				Slaveenforcer.AltFire(0);
00668		}
00669	
00670		function EndState()
00671		{
00672			Super.EndState();
00673			OldFlashCount = FlashCount;
00674		}
00675	
00676	Begin:
00677		if ( SlaveEnforcer != none )
00678			SetTimer(0.20, false);
00679		FinishAnim();
00680	Repeater:	
00681		if (AmmoType.UseAmmo(1)) 
00682		{
00683			FlashCount++;
00684			if ( SlaveEnforcer != None )
00685				Pawn(Owner).PlayRecoil(3 * FiringSpeed);
00686			else if ( !bIsSlave )
00687				Pawn(Owner).PlayRecoil(1.5 * FiringSpeed);
00688			TraceFire(AltAccuracy);
00689			PlayRepeatFiring();
00690			FinishAnim();
00691		}
00692	
00693		if ( AltAccuracy < 3 ) 
00694			AltAccuracy += 0.5;
00695		if ( bIsSlave )
00696		{
00697			if ( (Pawn(Owner).bAltFire!=0) 
00698				&& AmmoType.AmmoAmount>0 )
00699				Goto('Repeater');
00700		}
00701		else if ( bChangeWeapon )
00702			GotoState('DownWeapon');
00703		else if ( (Pawn(Owner).bAltFire!=0) 
00704			&& AmmoType.AmmoAmount>0 )
00705		{
00706			if ( PlayerPawn(Owner) == None )
00707				Pawn(Owner).bAltFire = int( FRand() < AltReFireRate );
00708			Goto('Repeater');	
00709		}
00710		PlayAnim('T2', 0.9, 0.05);	
00711		FinishAnim();
00712		Finish();
00713	}
00714	
00715	simulated event RenderOverlays(canvas Canvas)
00716	{
00717		local PlayerPawn PlayerOwner;
00718		local int realhand;
00719	
00720		if ( (bMuzzleFlash > 0) && !Level.bDropDetail )
00721			MFTexture = MuzzleFlashVariations[Rand(5)];
00722		PlayerOwner = PlayerPawn(Owner);
00723		if ( PlayerOwner != None )
00724		{
00725			if ( PlayerOwner.DesiredFOV != PlayerOwner.DefaultFOV )
00726				return;
00727			realhand = PlayerOwner.Handedness;
00728			if (  (Level.NetMode == NM_Client) && (realHand == 2) )
00729			{
00730				bHideWeapon = true;
00731				return;
00732			}
00733			if ( !bHideWeapon )
00734			{
00735				if ( Mesh == mesh'AutoML' )
00736					PlayerOwner.Handedness = 1;
00737				else if ( bIsSlave || (SlaveEnforcer != None) )
00738					PlayerOwner.Handedness = -1;
00739			}
00740		}
00741		if ( (PlayerOwner == None) || (PlayerOwner.Handedness == 0) )
00742		{
00743			if ( AnimSequence == 'Shot2' )
00744			{
00745				FlashO = -2 * Default.FlashO;
00746				FlashY = Default.FlashY * 2.5;
00747			}
00748			else
00749			{
00750				FlashO = 1.9 * Default.FlashO;
00751				FlashY = Default.FlashY;
00752			}
00753		}
00754		else if ( AnimSequence == 'Shot2' )
00755		{
00756			FlashO = Default.FlashO * 0.3;
00757			FlashY = Default.FlashY * 2.5;
00758		}
00759		else
00760		{
00761			FlashO = Default.FlashO;
00762			FlashY = Default.FlashY;
00763		}
00764		if ( !bHideWeapon && ( (SlaveEnforcer != None) || bIsSlave ) )
00765		{
00766			if ( PlayerOwner == None )
00767				bMuzzleFlash = 0;
00768	
00769			Super.RenderOverlays(Canvas);
00770			if ( SlaveEnforcer != None )
00771			{
00772				if ( SlaveEnforcer.bBringingUp )
00773				{
00774					SlaveEnforcer.bBringingUp = false;
00775					SlaveEnforcer.PlaySelect();
00776				}
00777				SlaveEnforcer.RenderOverlays(Canvas);
00778			}
00779		}
00780		else
00781			Super.RenderOverlays(Canvas);
00782	
00783		if ( PlayerOwner != None )
00784			PlayerOwner.Handedness = realhand;
00785	}
00786	
00787	simulated function PlayIdleAnim()
00788	{
00789		if ( Mesh == PickupViewMesh )
00790			return;
00791		if ( (FRand()>0.96) && (AnimSequence != 'Twiddle') ) 
00792			PlayAnim('Twiddle',0.6,0.3);
00793		else 
00794			LoopAnim('Sway',0.2, 0.3);
00795	}
00796	
00797	
00798	state Idle
00799	{
00800		function AnimEnd()
00801		{
00802			PlayIdleAnim();
00803		}
00804	
00805		function bool PutDown()
00806		{
00807			GotoState('DownWeapon');
00808			return True;
00809		}
00810		
00811	Begin:
00812		bPointing=False;
00813		if ( (AmmoType != None) && (AmmoType.AmmoAmount<=0) ) 
00814			Pawn(Owner).SwitchToBestWeapon();  //Goto Weapon that has Ammo
00815		LoopAnim('Sway',0.2, 0.1);
00816		if ( Pawn(Owner).bFire!=0 ) Global.Fire(0.0);
00817		if ( Pawn(Owner).bAltFire!=0 ) Global.AltFire(0.0);	
00818	}
00819	
00820	State ClientActive
00821	{
00822		simulated function AnimEnd()
00823		{
00824			bBringingUp = false;
00825			if ( !bIsSlave )
00826			{
00827				Super.AnimEnd();
00828				if ( (SlaveEnforcer != None) && !IsInState('ClientActive') )
00829				{
00830					if ( (GetStateName() == 'None') || (GetStateName() == 'Enforcer') )
00831						SlaveEnforcer.GotoState('');
00832					else
00833						SlaveEnforcer.GotoState(GetStateName());
00834				}
00835			}
00836		}
00837	
00838		simulated function BeginState()
00839		{
00840			Super.BeginState();
00841			bBringingUp = false;
00842			if ( SlaveEnforcer != None )
00843				SlaveEnforcer.GotoState('ClientActive');
00844		}
00845	}
00846	
00847	State ClientDown
00848	{
00849		simulated function AnimEnd()
00850		{
00851			if ( !bIsSlave )
00852				Super.AnimEnd();
00853		}
00854	
00855		simulated function EndState()
00856		{
00857			if ( SlaveEnforcer != None )
00858				SlaveEnforcer.GotoState('');
00859		}
00860	}
00861	
00862	// End Class
00863	//=============================================================================
00864	
00865	defaultproperties
00866	{
00867	     hitdamage=17
00868	     DoubleName="Double Enforcer"
00869	     MuzzleFlashVariations(0)=Texture'Botpack.Skins.Muz1'
00870	     MuzzleFlashVariations(1)=Texture'Botpack.Skins.Muz2'
00871	     MuzzleFlashVariations(2)=Texture'Botpack.Skins.Muz3'
00872	     MuzzleFlashVariations(3)=Texture'Botpack.Skins.Muz4'
00873	     MuzzleFlashVariations(4)=Texture'Botpack.Skins.Muz5'
00874	     DoubleSwitchPriority=2
00875	     WeaponDescription="Classification: Light Pistol\n\nPrimary Fire: Accurate but slow firing instant hit.\n\nSecondary Fire: Sideways, or 'Gangsta' firing mode, shoots twice as fast and half as accurate as the primary fire.\n\nTechniques: Collect two for twice the damage."
00876	     InstFlash=-0.200000
00877	     InstFog=(X=325.000000,Y=225.000000,Z=95.000000)
00878	     AmmoName=Class'Botpack.Miniammo'
00879	     PickupAmmoCount=30
00880	     bInstantHit=True
00881	     bAltInstantHit=True
00882	     FiringSpeed=1.500000
00883	     FireOffset=(Y=-10.000000,Z=-4.000000)
00884	     MyDamageType=shot
00885	     shakemag=200.000000
00886	     shakevert=4.000000
00887	     AIRating=0.250000
00888	     RefireRate=0.800000
00889	     AltRefireRate=0.870000
00890	     FireSound=Sound'Botpack.enforcer.E_Shot'
00891	     AltFireSound=Sound'UnrealShare.AutoMag.shot'
00892	     CockingSound=Sound'Botpack.enforcer.Cocking'
00893	     SelectSound=Sound'Botpack.enforcer.Cocking'
00894	     DeathMessage="%k riddled %o full of holes with the %w."
00895	     NameColor=(R=200,G=200)
00896	     bDrawMuzzleFlash=True
00897	     MuzzleScale=1.000000
00898	     FlashY=0.100000
00899	     FlashO=0.020000
00900	     FlashC=0.035000
00901	     FlashLength=0.020000
00902	     FlashS=128
00903	     MFTexture=Texture'Botpack.Skins.Muz1'
00904	     AutoSwitchPriority=2
00905	     InventoryGroup=2
00906	     PickupMessage="You picked up another Enforcer!"
00907	     ItemName="Enforcer"
00908	     PlayerViewOffset=(X=3.300000,Y=-2.000000,Z=-3.000000)
00909	     PlayerViewMesh=LodMesh'Botpack.AutoML'
00910	     PickupViewMesh=LodMesh'Botpack.MagPick'
00911	     ThirdPersonMesh=LodMesh'Botpack.AutoHand'
00912	     StatusIcon=Texture'Botpack.Icons.UseAutoM'
00913	     bMuzzleFlashParticles=True
00914	     MuzzleFlashStyle=STY_Translucent
00915	     MuzzleFlashMesh=LodMesh'Botpack.muzzEF3'
00916	     MuzzleFlashScale=0.080000
00917	     MuzzleFlashTexture=Texture'Botpack.Skins.Muzzy2'
00918	     PickupSound=Sound'UnrealShare.Pickups.WeaponPickup'
00919	     Icon=Texture'Botpack.Icons.UseAutoM'
00920	     bHidden=True
00921	     Mesh=LodMesh'Botpack.MagPick'
00922	     bNoSmooth=False
00923	     CollisionRadius=24.000000
00924	     CollisionHeight=12.000000
00925	     Mass=15.000000
00926	}

End Source Code