Botpack
Class UT_BioRifle

source: e:\games\UnrealTournament\Botpack\Classes\ut_biorifle.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Weapon
            |
            +--Botpack.TournamentWeapon
               |
               +--Botpack.UT_BioRifle
Direct Known Subclasses:None

class UT_BioRifle
extends Botpack.TournamentWeapon

//============================================================================= // UT_BioRifle. //=============================================================================
Variables
 ChargeSize, Count
 bool bBurst

States
ShootLoad, AltFiring, ClientAltFiring

Function Summary
 void AltFire(float Value)
 bool ClientAltFire(float Value)
 
simulated
PlayAltFiring()
 
simulated
PlayIdleAnim()
 float RateSelf(out int)
 float SuggestAttackStyle()
     
// return delta to combat style
 float SuggestDefenseStyle()


State ShootLoad Function Summary
 void Finish()
     
// Finish a firing sequence
 void BeginState()
 void AnimEnd()
 void Timer()
 void AltFire(float F)
 void Fire(float F)
 void ForceAltFire()
 void ForceFire()


State AltFiring Function Summary
 void EndState()
 void BeginState()
 void Tick(float DeltaTime)


State ClientAltFiring Function Summary



Source Code


00001	//=============================================================================
00002	// UT_BioRifle.
00003	//=============================================================================
00004	class UT_BioRifle extends TournamentWeapon;
00005	
00006	#exec MESH IMPORT MESH=BRifle2 ANIVFILE=MODELS\Biorifle2_a.3D DATAFILE=MODELS\BioRifle2_d.3D X=0 Y=0 Z=0
00007	#exec MESH ORIGIN MESH=BRifle2 X=0 Y=0 Z=0 YAW=67 ROLL=6 PITCH=0
00008	#exec MESH SEQUENCE MESH=BRifle2 SEQ=All       STARTFRAME=0   NUMFRAMES=90
00009	#exec MESH SEQUENCE MESH=BRifle2 SEQ=Select    STARTFRAME=0   NUMFRAMES=22 RATE=45 GROUP=Select
00010	#exec MESH SEQUENCE MESH=BRifle2 SEQ=Still     STARTFRAME=22  NUMFRAMES=1
00011	#exec MESH SEQUENCE MESH=BRifle2 SEQ=Walking   STARTFRAME=23  NUMFRAMES=18
00012	#exec MESH SEQUENCE MESH=BRifle2 SEQ=Charging  STARTFRAME=41  NUMFRAMES=30
00013	#exec MESH SEQUENCE MESH=BRifle2 SEQ=Loaded    STARTFRAME=70  NUMFRAMES=1
00014	#exec MESH SEQUENCE MESH=BRifle2 SEQ=UnLoading STARTFRAME=71  NUMFRAMES=1
00015	#exec MESH SEQUENCE MESH=BRifle2 SEQ=Fire      STARTFRAME=72  NUMFRAMES=9
00016	#exec MESH SEQUENCE MESH=BRifle2 SEQ=Down      STARTFRAME=80  NUMFRAMES=10
00017	#exec TEXTURE IMPORT NAME=JBRifle2 FILE=MODELS\Bio.PCX GROUP=Skins LODSET=2
00018	#exec TEXTURE IMPORT NAME=JBRifle21 FILE=MODELS\Bio1.PCX GROUP=Skins LODSET=2
00019	#exec TEXTURE IMPORT NAME=JBRifle22 FILE=MODELS\Bio2.PCX GROUP=Skins LODSET=2
00020	#exec TEXTURE IMPORT NAME=JBRifle23 FILE=MODELS\Bio3.PCX GROUP=Skins LODSET=2
00021	#exec TEXTURE IMPORT NAME=JBRifle24 FILE=MODELS\Bio4.PCX GROUP=Skins LODSET=2
00022	#exec MESHMAP SCALE MESHMAP=BRifle2  X=0.0025 Y=0.0018 Z=0.005
00023	#exec MESHMAP SETTEXTURE MESHMAP=BRifle2 NUM=0 TEXTURE=JBRifle21
00024	#exec MESHMAP SETTEXTURE MESHMAP=BRifle2 NUM=1 TEXTURE=JBRifle22
00025	#exec MESHMAP SETTEXTURE MESHMAP=BRifle2 NUM=2 TEXTURE=JBRifle23
00026	#exec MESHMAP SETTEXTURE MESHMAP=BRifle2 NUM=3 TEXTURE=JBRifle24
00027	
00028	#exec MESH IMPORT MESH=BRifle2Pick ANIVFILE=MODELS\Biopick_a.3D DATAFILE=MODELS\Biopick_d.3D X=0 Y=0 Z=0
00029	#exec MESH ORIGIN MESH=BRifle2Pick X=0 Y=0 Z=0 YAW=64
00030	#exec MESH SEQUENCE MESH=BRifle2pick SEQ=All    STARTFRAME=0   NUMFRAMES=1
00031	#exec MESH SEQUENCE MESH=BRifle2pick SEQ=Still  STARTFRAME=0   NUMFRAMES=1
00032	#exec MESHMAP SCALE MESHMAP=BRifle2pick X=0.05 Y=0.05 Z=0.1
00033	#exec MESHMAP SETTEXTURE MESHMAP=BRifle2pick NUM=1 TEXTURE=JBRifle2
00034	
00035	#exec MESH IMPORT MESH=BRifle23 ANIVFILE=MODELS\Biohand_a.3D DATAFILE=MODELS\Biohand_d.3D X=0 Y=0 Z=0
00036	#exec MESH ORIGIN MESH=BRifle23 X=15 Y=280 Z=-80 YAW=64 PITCH=0 ROLL=0
00037	#exec MESH SEQUENCE MESH=BRifle23 SEQ=All  STARTFRAME=0  NUMFRAMES=11
00038	#exec MESH SEQUENCE MESH=BRifle23 SEQ=Still  STARTFRAME=0  NUMFRAMES=1
00039	#exec MESH SEQUENCE MESH=BRifle23 SEQ=Fire  STARTFRAME=1  NUMFRAMES=10
00040	#exec MESHMAP SCALE MESHMAP=BRifle23 X=0.035 Y=0.035 Z=0.07
00041	#exec MESHMAP SETTEXTURE MESHMAP=BRifle23 NUM=1 TEXTURE=JBRifle2
00042	
00043	#exec TEXTURE IMPORT NAME=IconBio FILE=TEXTURES\HUD\WpnBio.PCX GROUP="Icons" MIPS=OFF
00044	#exec TEXTURE IMPORT NAME=UseBio FILE=TEXTURES\HUD\UseBio.PCX GROUP="Icons" MIPS=OFF
00045	
00046	#exec AUDIO IMPORT FILE="Sounds\biorifle\biopowerupmix1.WAV" NAME="BioAltRep" GROUP="BioRifle"
00047	
00048	var float ChargeSize, Count;
00049	var bool bBurst;
00050	
00051	simulated function PlayIdleAnim()
00052	{
00053		if ( Mesh == PickupViewMesh )
00054			return;
00055		if ( (Owner != None) && (VSize(Owner.Velocity) > 10) )
00056			PlayAnim('Walking',0.3,0.3);
00057		else 
00058			TweenAnim('Still', 1.0);
00059		Enable('AnimEnd');
00060	}
00061	
00062	function float RateSelf( out int bUseAltMode )
00063	{
00064		local float EnemyDist;
00065		local bool bRetreating;
00066		local vector EnemyDir;
00067	
00068		if ( AmmoType.AmmoAmount <=0 )
00069			return -2;
00070		bUseAltMode = 0;
00071		if ( Pawn(Owner).Enemy == None )
00072			return AIRating;
00073	
00074		EnemyDir = Pawn(Owner).Enemy.Location - Owner.Location;
00075		EnemyDist = VSize(EnemyDir);
00076		if ( EnemyDist > 1400 )
00077			return 0;
00078	
00079		bRetreating = ( ((EnemyDir/EnemyDist) Dot Owner.Velocity) < -0.6 );
00080		if ( (EnemyDist > 600) && (EnemyDir.Z > -0.4 * EnemyDist) )
00081		{
00082			// only use if enemy not too far and retreating
00083			if ( !bRetreating )
00084				return 0;
00085	
00086			return AIRating;
00087		}
00088	
00089		bUseAltMode = int( FRand() < 0.3 );
00090	
00091		if ( bRetreating || (EnemyDir.Z < -0.7 * EnemyDist) )
00092			return (AIRating + 0.18);
00093		return AIRating;
00094	}
00095	
00096	// return delta to combat style
00097	function float SuggestAttackStyle()
00098	{
00099		return -0.3;
00100	}
00101	
00102	function float SuggestDefenseStyle()
00103	{
00104		return -0.4;
00105	}
00106	
00107	function AltFire( float Value )
00108	{
00109		bPointing=True;
00110		if ( AmmoType == None )
00111		{
00112			// ammocheck
00113			GiveAmmo(Pawn(Owner));
00114		}
00115		if ( AmmoType.UseAmmo(1) ) 
00116		{
00117			GoToState('AltFiring');
00118			bCanClientFire = true;
00119			ClientAltFire(Value);
00120		}
00121	}
00122	
00123	simulated function bool ClientAltFire( float Value )
00124	{
00125		local bool bResult;
00126	
00127		InstFlash = 0.0;
00128		bResult = Super.ClientAltFire(value);
00129		InstFlash = Default.InstFlash;
00130		return bResult;
00131	}
00132	
00133	function Projectile ProjectileFire(class<projectile> ProjClass, float ProjSpeed, bool bWarn)
00134	{
00135		local Vector Start, X,Y,Z;
00136	
00137		Owner.MakeNoise(Pawn(Owner).SoundDampening);
00138		GetAxes(Pawn(owner).ViewRotation,X,Y,Z);
00139		Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z; 
00140		AdjustedAim = pawn(owner).AdjustToss(ProjSpeed, Start, 0, True, (bWarn || (FRand() < 0.4)));	
00141		return Spawn(ProjClass,,, Start,AdjustedAim);
00142	}
00143	
00144	simulated function PlayAltFiring()
00145	{
00146		PlayOwnedSound(Sound'Botpack.BioRifle.BioAltRep', SLOT_Misc, 1.3*Pawn(Owner).SoundDampening);	 //loading goop	
00147		PlayAnim('Charging',0.24,0.05);
00148	}
00149	
00150	///////////////////////////////////////////////////////
00151	state ClientAltFiring
00152	{
00153		simulated function Tick(float DeltaTime)
00154		{
00155			if ( bBurst )
00156				return;
00157			if ( !bCanClientFire || (Pawn(Owner) == None) )
00158				GotoState('');
00159			else if ( Pawn(Owner).bAltFire == 0 )
00160			{
00161				PlayAltBurst();
00162				bBurst = true;
00163			}
00164		}
00165	
00166		simulated function AnimEnd()
00167		{
00168			if ( bBurst )
00169			{
00170				bBurst = false;
00171				Super.AnimEnd();
00172			}
00173			else
00174				TweenAnim('Loaded', 0.5);
00175		}
00176	}
00177	
00178	state AltFiring
00179	{
00180		ignores AnimEnd;
00181	
00182		function Tick( float DeltaTime )
00183		{
00184			//SetLocation(Owner.Location);
00185			if ( ChargeSize < 4.1 )
00186			{
00187				Count += DeltaTime;
00188				if ( (Count > 0.5) && AmmoType.UseAmmo(1) )
00189				{
00190					ChargeSize += Count;
00191					Count = 0;
00192					if ( (PlayerPawn(Owner) == None) && (FRand() < 0.2) )
00193						GoToState('ShootLoad');
00194				}
00195			}
00196			if( (pawn(Owner).bAltFire==0) ) 
00197				GoToState('ShootLoad');
00198		}
00199	
00200		function BeginState()
00201		{
00202			ChargeSize = 0.0;
00203			Count = 0.0;
00204		}
00205	
00206		function EndState()
00207		{
00208			ChargeSize = FMin(ChargeSize, 4.1);
00209		}
00210	
00211	Begin:
00212		FinishAnim();
00213	}
00214	
00215	state ShootLoad
00216	{
00217		function ForceFire()
00218		{
00219			bForceFire = true;
00220		}
00221	
00222		function ForceAltFire()
00223		{
00224			bForceAltFire = true;
00225		}
00226	
00227		function Fire(float F) 
00228		{
00229		}
00230	
00231		function AltFire(float F) 
00232		{
00233		}
00234	
00235		function Timer()
00236		{
00237			local rotator R;
00238			local vector start, X,Y,Z;
00239	
00240			GetAxes(Pawn(owner).ViewRotation,X,Y,Z);
00241			R = Owner.Rotation;
00242			R.Yaw = R.Yaw + Rand(8000) - 4000;
00243			R.Pitch = R.Pitch + Rand(1000) - 500;
00244			Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z; 
00245			Spawn(AltProjectileClass,,, Start,R);
00246	
00247			R = Owner.Rotation;
00248			R.Yaw = R.Yaw + Rand(8000) - 4000;
00249			R.Pitch = R.Pitch + Rand(1000) - 500;
00250			Start = Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z; 
00251			Spawn(AltProjectileClass,,, Start,R);
00252		}
00253	
00254		function AnimEnd()
00255		{
00256			Finish();
00257		}
00258	
00259		function BeginState()
00260		{
00261			Local Projectile Gel;
00262	
00263			Gel = ProjectileFire(AltProjectileClass, AltProjectileSpeed, bAltWarnTarget);
00264			Gel.DrawScale = 1.0 + 0.8 * ChargeSize;
00265			PlayAltBurst();
00266		}
00267	
00268	Begin:
00269	}
00270	
00271	
00272	// Finish a firing sequence
00273	function Finish()
00274	{
00275		local bool bForce, bForceAlt;
00276	
00277		bForce = bForceFire;
00278		bForceAlt = bForceAltFire;
00279		bForceFire = false;
00280		bForceAltFire = false;
00281	
00282		if ( bChangeWeapon )
00283			GotoState('DownWeapon');
00284		else if ( PlayerPawn(Owner) == None )
00285		{
00286			Pawn(Owner).bAltFire = 0;
00287			Super.Finish();
00288		}
00289		else if ( (AmmoType.AmmoAmount<=0) || (Pawn(Owner).Weapon != self) )
00290			GotoState('Idle');
00291		else if ( (Pawn(Owner).bFire!=0) || bForce )
00292			Global.Fire(0);
00293		else if ( (Pawn(Owner).bAltFire!=0) || bForceAlt )
00294			Global.AltFire(0);
00295		else 
00296			GotoState('Idle');
00297	}
00298	
00299	simulated function PlayAltBurst()
00300	{
00301		if ( Owner.IsA('PlayerPawn') )
00302			PlayerPawn(Owner).ClientInstantFlash( InstFlash, InstFog);
00303		PlayOwnedSound(FireSound, SLOT_Misc, 1.7*Pawn(Owner).SoundDampening);	//shoot goop
00304		PlayAnim('Fire',0.4, 0.05);
00305	}
00306	
00307	simulated function PlayFiring()
00308	{
00309		PlayOwnedSound(AltFireSound, SLOT_None, 1.7*Pawn(Owner).SoundDampening);	//fast fire goop
00310		LoopAnim('Fire',0.65 + 0.4 * FireAdjust, 0.05);
00311	}
00312	
00313	defaultproperties
00314	{
00315	     WeaponDescription="Classification: Toxic Rifle\n\nPrimary Fire: Wads of Tarydium byproduct are lobbed at a medium rate of fire.\n\nSecondary Fire: When trigger is held down, the BioRifle will create a much larger wad of byproduct. When this wad is launched, it will burst into smaller wads which will adhere to any surfaces.\n\nTechniques: Byproducts will adhere to walls, floors, or ceilings. Chain reactions can be caused by covering entryways with this lethal green waste."
00316	     InstFlash=-0.150000
00317	     InstFog=(X=139.000000,Y=218.000000,Z=72.000000)
00318	     AmmoName=Class'Botpack.BioAmmo'
00319	     PickupAmmoCount=25
00320	     bAltWarnTarget=True
00321	     bRapidFire=True
00322	     FiringSpeed=1.000000
00323	     FireOffset=(X=12.000000,Y=-11.000000,Z=-6.000000)
00324	     ProjectileClass=Class'Botpack.UT_BioGel'
00325	     AltProjectileClass=Class'Botpack.BioGlob'
00326	     AIRating=0.600000
00327	     RefireRate=0.900000
00328	     AltRefireRate=0.700000
00329	     FireSound=Sound'UnrealI.BioRifle.GelShot'
00330	     AltFireSound=Sound'UnrealI.BioRifle.GelShot'
00331	     CockingSound=Sound'UnrealI.BioRifle.GelLoad'
00332	     SelectSound=Sound'UnrealI.BioRifle.GelSelect'
00333	     DeathMessage="%o drank a glass of %k's dripping green load."
00334	     NameColor=(R=0,B=0)
00335	     AutoSwitchPriority=3
00336	     InventoryGroup=3
00337	     PickupMessage="You got the GES BioRifle."
00338	     ItemName="GES Bio Rifle"
00339	     PlayerViewOffset=(X=1.700000,Y=-0.850000,Z=-0.950000)
00340	     PlayerViewMesh=LodMesh'Botpack.BRifle2'
00341	     BobDamping=0.972000
00342	     PickupViewMesh=LodMesh'Botpack.BRifle2Pick'
00343	     ThirdPersonMesh=LodMesh'Botpack.BRifle23'
00344	     StatusIcon=Texture'Botpack.Icons.UseBio'
00345	     PickupSound=Sound'UnrealShare.Pickups.WeaponPickup'
00346	     Icon=Texture'Botpack.Icons.UseBio'
00347	     Mesh=LodMesh'Botpack.BRifle2Pick'
00348	     bNoSmooth=False
00349	     CollisionHeight=19.000000
00350	}

End Source Code