Botpack
Class ChainSaw

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

class ChainSaw
extends Botpack.TournamentWeapon

//============================================================================= // ChainSaw. //=============================================================================
Variables
 HitSound, DownSound
 PlayerPawn LastHit
 float Range

States
Idle, AltFiring, ClientAltFiring, ClientFiring, NormalFire

Function Summary
 void AltFire(float Value)
 
simulated
EndAltFiring()
 void Fire(float Value)
 
simulated
PlayAltFiring()
 
simulated
PlayFiring()
 float RateSelf(out int)
 float SuggestAttackStyle()
 float SuggestDefenseStyle()


State Idle Function Summary
 void TraceFire(float accuracy)
 void Slash()
 void Finish()
     
// Finish a firing sequence
 bool PutDown()


State AltFiring Function Summary
 void EndState()
 void BeginState()
 void AltFire(float F)
 void Fire(float F)


State ClientAltFiring Function Summary
 void EndState()


State ClientFiring Function Summary


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



Source Code


00001	//=============================================================================
00002	// ChainSaw.
00003	//=============================================================================
00004	class ChainSaw extends TournamentWeapon;
00005	
00006	#exec MESH IMPORT  MESH=chainsawM ANIVFILE=MODELS\chains_a.3D DATAFILE=MODELS\chains_d.3D X=0 Y=0 Z=0 
00007	#exec MESH ORIGIN MESH=chainsawM X=0 Y=0 Z=0 YAW=0 PITCH=0  ROLL=0
00008	#exec MESH SEQUENCE MESH=chainsawM SEQ=All       STARTFRAME=0   NUMFRAMES=70
00009	#exec MESH SEQUENCE MESH=chainsawM SEQ=Select    STARTFRAME=2   NUMFRAMES=15
00010	#exec MESH SEQUENCE MESH=chainsawM SEQ=Idle      STARTFRAME=17  NUMFRAMES=10
00011	#exec MESH SEQUENCE MESH=chainsawM SEQ=Still     STARTFRAME=17  NUMFRAMES=10
00012	#exec MESH SEQUENCE MESH=chainsawM SEQ=Swipe     STARTFRAME=27  NUMFRAMES=11
00013	#exec MESH SEQUENCE MESH=chainsawM SEQ=Jab       STARTFRAME=42  NUMFRAMES=20
00014	#exec MESH SEQUENCE MESH=chainsawM SEQ=Jab2      STARTFRAME=48  NUMFRAMES=13
00015	#exec MESH SEQUENCE MESH=chainsawM SEQ=Down      STARTFRAME=62  NUMFRAMES=6
00016	#exec TEXTURE IMPORT NAME=Jchainsaw1  FILE=MODELS\chain1.PCX GROUP=Skins  LODSET=2
00017	#exec TEXTURE IMPORT NAME=Jchainsaw2 FILE=MODELS\chain2.PCX GROUP=Skins  LODSET=2
00018	#exec TEXTURE IMPORT NAME=Jchainsaw3 FILE=MODELS\chain3.PCX GROUP=Skins  LODSET=2
00019	#exec TEXTURE IMPORT NAME=Jchainsaw4 FILE=MODELS\chain4.PCX GROUP=Skins  LODSET=2
00020	#exec MESHMAP SCALE MESHMAP=chainsawM X=0.004 Y=0.006 Z=0.012
00021	#exec MESHMAP SETTEXTURE MESHMAP=chainsawM NUM=0 TEXTURE=Jchainsaw1
00022	#exec MESHMAP SETTEXTURE MESHMAP=chainsawM NUM=1 TEXTURE=Jchainsaw2
00023	#exec MESHMAP SETTEXTURE MESHMAP=chainsawM NUM=2 TEXTURE=Jchainsaw3
00024	#exec MESHMAP SETTEXTURE MESHMAP=chainsawM NUM=3 TEXTURE=Jchainsaw4
00025	
00026	#exec MESH IMPORT MESH=ChainSawPick ANIVFILE=MODELS\chainpick_a.3D DATAFILE=MODELS\chainpick_d.3D X=0 Y=0 Z=0
00027	#exec MESH ORIGIN MESH=ChainSawPick X=150 Y=-10 Z=0 YAW=0 ROLL=-64
00028	#exec MESH SEQUENCE MESH=ChainSawPick SEQ=All         STARTFRAME=0   NUMFRAMES=1
00029	#exec MESH SEQUENCE MESH=ChainSawPick SEQ=Still       STARTFRAME=0   NUMFRAMES=1
00030	#exec TEXTURE IMPORT NAME=JChainSawPick1 FILE=MODELS\ChainSaw.PCX GROUP=Skins  LODSET=2
00031	#exec MESHMAP SCALE MESHMAP=ChainSawPick X=0.07 Y=0.07 Z=0.14
00032	#exec MESHMAP SETTEXTURE MESHMAP=ChainSawPick NUM=1 TEXTURE=JChainSawPick1
00033	
00034	#exec MESH IMPORT MESH=CSHand ANIVFILE=MODELS\Chainpick_a.3D DATAFILE=MODELS\Chainpick_d.3D
00035	#exec MESH ORIGIN MESH=CSHand X=-430 Y=-70 Z=0 YAW=0 ROLL=-64
00036	#exec MESH SEQUENCE MESH=CSHand SEQ=All         STARTFRAME=0   NUMFRAMES=1
00037	#exec MESH SEQUENCE MESH=CSHand SEQ=Still       STARTFRAME=0   NUMFRAMES=1
00038	#exec MESHMAP SCALE MESHMAP=CSHand X=0.04 Y=0.04 Z=0.08
00039	#exec MESHMAP SETTEXTURE MESHMAP=CSHand NUM=1 TEXTURE=JChainSawPick1
00040	
00041	#exec TEXTURE IMPORT NAME=IconSaw FILE=TEXTURES\HUD\WpnCSaw.PCX GROUP="Icons" MIPS=OFF
00042	#exec TEXTURE IMPORT NAME=UseSaw FILE=TEXTURES\HUD\UseCSaw.PCX GROUP="Icons" MIPS=OFF
00043	
00044	#exec MESH NOTIFY MESH=chainsawM SEQ=Swipe TIME=0.45 FUNCTION=Slash
00045	
00046	#exec AUDIO IMPORT FILE="Sounds\ChainSaw\ChainIdle.WAV" NAME="ChainIdle" GROUP="ChainSaw"
00047	#exec AUDIO IMPORT FILE="Sounds\ChainSaw\ChainPickup.WAV" NAME="ChainPickup" GROUP="ChainSaw"
00048	#exec AUDIO IMPORT FILE="Sounds\ChainSaw\ChainPowerDown.WAV" NAME="ChainPowerDown" GROUP="ChainSaw"
00049	#exec AUDIO IMPORT FILE="Sounds\ChainSaw\SawHit.WAV" NAME="SawHit" GROUP="ChainSaw"
00050	
00051	var() float Range;
00052	var() sound HitSound, DownSound;
00053	var Playerpawn LastHit;
00054	
00055	function float RateSelf( out int bUseAltMode )
00056	{
00057		local float EnemyDist;
00058		local bool bRetreating;
00059		local vector EnemyDir;
00060	
00061		bUseAltMode = 0;
00062	
00063		if ( (Pawn(Owner) == None) || (Pawn(Owner).Enemy == None) )
00064			return 0;
00065	
00066		EnemyDist = VSize(Pawn(Owner).Enemy.Location - Owner.Location);
00067		if ( EnemyDist > 400 )
00068			return -2;
00069	
00070		if ( EnemyDist < 110 )
00071			bUseAltMode = 1;
00072	
00073		return ( FMin(1.0, 81/(EnemyDist + 1)) );
00074	}
00075	
00076	function float SuggestAttackStyle()
00077	{
00078		return 1.0;
00079	}
00080	
00081	function float SuggestDefenseStyle()
00082	{
00083		return -0.7;
00084	}
00085	
00086	function Fire( float Value )
00087	{
00088		GotoState('NormalFire');
00089		bPointing=True;
00090		bCanClientFire = true;
00091		Pawn(Owner).PlayRecoil(FiringSpeed);
00092		ClientFire(value);
00093		TraceFire(0.0);
00094	}
00095	
00096	simulated function PlayFiring()
00097	{
00098		LoopAnim( 'Jab2', 0.7, 0.0 );
00099		AmbientSound = HitSound;
00100		SoundVolume = 255;		
00101	}
00102	
00103	function AltFire( float Value )
00104	{
00105		GotoState('AltFiring');
00106		Pawn(Owner).PlayRecoil(FiringSpeed);
00107		bCanClientFire = true;
00108		bPointing=True;
00109		ClientAltFire(value);
00110	}
00111	
00112	simulated function PlayAltFiring()
00113	{
00114		PlayAnim( 'Swipe', 0.6 );
00115		AmbientSound = HitSound;
00116		SoundVolume = 255;		
00117	}
00118	
00119	simulated function EndAltFiring()
00120	{
00121		AmbientSound = Sound'Botpack.ChainIdle';
00122		TweenAnim('Idle', 1.0);
00123	}
00124	
00125	
00126	state NormalFire
00127	{
00128		ignores AnimEnd;
00129	
00130		function BeginState()
00131		{
00132			Super.BeginState();
00133			AmbientSound = HitSound;
00134			SoundVolume = 255;		
00135		}
00136	
00137		function EndState()
00138		{
00139		    AmbientSound = Sound'Botpack.ChainIdle';
00140			Super.EndState();
00141			SoundVolume = Default.SoundVolume;		
00142		}
00143	
00144	Begin:
00145		Sleep(0.15);
00146		if ( PlayerPawn(Owner) != None )
00147			PlayerPawn(Owner).ShakeView(ShakeTime, ShakeMag, ShakeVert);
00148		TraceFire(0.0);
00149		Sleep(0.15);
00150		if ( PlayerPawn(Owner) != None )
00151			PlayerPawn(Owner).ShakeView(ShakeTime, ShakeMag, ShakeVert);
00152		if ( LastHit != None )
00153		{
00154			LastHit.ClientFlash( -0.38, vect(530, 90, 90));
00155			LastHit.ShakeView(0.25, 600, 6); 
00156		}
00157		if ( Pawn(Owner).bFire == 0 )
00158			Finish();
00159		Goto('Begin');
00160	}
00161	
00162	////////////////////////////////////////////////////////
00163	state ClientFiring
00164	{
00165		simulated function EndState()
00166		{
00167		    AmbientSound = Sound'Botpack.ChainIdle';
00168			Super.EndState();
00169			SoundVolume = Default.SoundVolume;		
00170		}
00171	}
00172	
00173	state ClientAltFiring
00174	{
00175		simulated function AnimEnd()
00176		{
00177			if ( AnimSequence != 'Idle' )
00178			{
00179				EndAltFiring();
00180			}
00181			else if ( !bCanClientFire )
00182				GotoState('');
00183			else if ( Pawn(Owner) == None )
00184			{
00185				PlayIdleAnim();
00186				GotoState('');
00187			}
00188			else if ( Pawn(Owner).bFire != 0 )
00189				Global.ClientFire(0);
00190			else if ( Pawn(Owner).bAltFire != 0 )
00191				Global.ClientAltFire(0);
00192			else
00193			{
00194				PlayIdleAnim();
00195				GotoState('');
00196			}
00197		}
00198	
00199		function EndState()
00200		{
00201		    AmbientSound = Sound'Botpack.ChainIdle';
00202			Super.EndState();
00203			SoundVolume = Default.SoundVolume;		
00204		}
00205	}
00206	
00207	state AltFiring
00208	{
00209		ignores AnimEnd;
00210	
00211		function Fire(float F) 
00212		{
00213		}
00214	
00215		function AltFire(float F) 
00216		{
00217		}
00218	
00219		function BeginState()
00220		{
00221			Super.BeginState();
00222			AmbientSound = HitSound;
00223			SoundVolume = 255;		
00224		}
00225	
00226		function EndState()
00227		{
00228			Super.EndState();
00229		    AmbientSound = Sound'Botpack.ChainIdle';
00230			SoundVolume = Default.SoundVolume;		
00231		}
00232	
00233	Begin:
00234		AmbientSound = HitSound;
00235		Sleep(0.1);
00236		FinishAnim();
00237		EndAltFiring();
00238		FinishAnim();
00239		Finish();
00240	}
00241	
00242	state Idle
00243	{
00244		ignores animend;
00245	
00246		function bool PutDown()
00247		{
00248			GotoState('DownWeapon');
00249			return True;
00250		}
00251	
00252	Begin:
00253		bPointing=False;
00254		if ( (AmmoType != None) && (AmmoType.AmmoAmount<=0) ) 
00255			Pawn(Owner).SwitchToBestWeapon();  //Goto Weapon that has Ammo
00256		if ( Pawn(Owner).bFire!=0 ) 
00257			Fire(0.0);
00258		if ( Pawn(Owner).bAltFire!=0 ) 
00259			AltFire(0.0);
00260		FinishAnim();
00261		AnimFrame=0;
00262		PlayIdleAnim();
00263		Goto('Begin');
00264	}
00265	
00266	simulated function PlayIdleAnim()
00267	{
00268		if ( Mesh != PickupViewMesh )
00269			PlayAnim( 'Idle', 1.0, 0.0 );
00270	}
00271	
00272	// Finish a firing sequence
00273	function Finish()
00274	{
00275		if ( bChangeWeapon )
00276		{
00277			GotoState('DownWeapon');
00278			return;
00279		}
00280	
00281		if ( PlayerPawn(Owner) == None )
00282		{
00283			if ( (Pawn(Owner).bFire != 0) && (FRand() < RefireRate) )
00284				Global.Fire(0);
00285			else if ( (Pawn(Owner).bAltFire != 0) && (FRand() < AltRefireRate) )
00286				Global.AltFire(0);	
00287			else 
00288			{
00289				Pawn(Owner).StopFiring();
00290				GotoState('Idle');
00291			}
00292			return;
00293		}
00294		if ( Pawn(Owner).bFire!=0 )
00295			Global.Fire(0);
00296		else if ( Pawn(Owner).bAltFire!=0 )
00297			Global.AltFire(0);
00298		else 
00299			GotoState('Idle');
00300	}
00301	
00302	function Slash()
00303	{
00304		local vector HitLocation, HitNormal, EndTrace, X, Y, Z, Start;
00305		local actor Other;
00306	
00307		Owner.MakeNoise(Pawn(Owner).SoundDampening);
00308		GetAxes(Pawn(owner).ViewRotation, X, Y, Z);
00309		Start =  Owner.Location + CalcDrawOffset() + FireOffset.X * X + FireOffset.Y * Y + FireOffset.Z * Z;
00310		AdjustedAim = pawn(owner).AdjustAim(1000000, Start, AimError, False, False);	
00311		EndTrace = Owner.Location + (Range * vector(AdjustedAim)); 
00312		Other = Pawn(Owner).TraceShot(HitLocation, HitNormal, EndTrace, Start);
00313	
00314		if ( (Other == None) || (Other == Owner) || (Other == self) )
00315			return;
00316	
00317		if ( PlayerPawn(Owner) != None )
00318			PlayerPawn(Owner).ShakeView(ShakeTime, ShakeMag, ShakeVert);
00319		Other.TakeDamage(110, Pawn(Owner), HitLocation, -10000.0 * Y, AltDamageType);
00320		if ( !Other.bIsPawn && !Other.IsA('Carcass') )
00321			spawn(class'SawHit',,,HitLocation+HitNormal, rotator(HitNormal));
00322	}
00323	
00324	
00325	function TraceFire(float accuracy)
00326	{
00327		local vector HitLocation, HitNormal, EndTrace, X, Y, Z, Start;
00328		local actor Other;
00329	
00330		LastHit = None;
00331		Owner.MakeNoise(Pawn(Owner).SoundDampening);
00332		GetAxes(Pawn(owner).ViewRotation, X, Y, Z);
00333		Start =  Owner.Location + CalcDrawOffset() + FireOffset.Y * Y + FireOffset.Z * Z;
00334		AdjustedAim = pawn(owner).AdjustAim(1000000, Start, 2 * AimError, False, False);	
00335		EndTrace = Owner.Location + (10 + Range) * vector(AdjustedAim); 
00336		Other = Pawn(Owner).TraceShot(HitLocation, HitNormal, EndTrace, Start);
00337	
00338		if ( (Other == None) || (Other == Owner) || (Other == self) )
00339			return;
00340	
00341		Other.TakeDamage(20.0, Pawn(Owner), HitLocation, -15000 * X, MyDamageType);
00342		if ( !Other.bIsPawn && !Other.IsA('Carcass') )
00343			spawn(class'SawHit',,,HitLocation+HitNormal, Rotator(HitNormal));
00344		else if ( Other.IsA('PlayerPawn') && (Pawn(Other).Health > 0) )
00345			LastHit = PlayerPawn(Other);
00346	}
00347	
00348	
00349	simulated function PlayPostSelect()
00350	{
00351	    AmbientSound = Sound'Botpack.ChainIdle';
00352		if ( Level.NetMode == NM_Client )
00353		{
00354			Super.PlayPostSelect();
00355			return;
00356		}
00357	}
00358	
00359	
00360	simulated function TweenDown()
00361	{
00362		Owner.PlayOwnedSound(DownSound,, 4.0 * Pawn(Owner).SoundDampening);
00363		Super.TweenDown();
00364		AmbientSound = None;
00365	}
00366	
00367	defaultproperties
00368	{
00369	     Range=90.000000
00370	     HitSound=Sound'Botpack.ChainSaw.SawHit'
00371	     DownSound=Sound'Botpack.ChainSaw.ChainPowerDown'
00372	     WeaponDescription="Classification: Melee Blade\n\nPrimary Fire: When the trigger is held down, the chain covered blade will rev up. Drive this blade into opponents to inflict massive damage.\n\nSecondary Fire: The revved up blade can be swung horizontally and can cause instant decapitation of foes.\n\nTechniques: The chainsaw makes a loud and recognizable roar and can be avoided by listening for audio cues."
00373	     bMeleeWeapon=True
00374	     bRapidFire=True
00375	     FireOffset=(X=10.000000,Y=-2.500000,Z=5.000000)
00376	     MyDamageType=slashed
00377	     AltDamageType=Decapitated
00378	     RefireRate=1.000000
00379	     AltRefireRate=1.000000
00380	     SelectSound=Sound'Botpack.ChainSaw.ChainPickup'
00381	     DeathMessage="%k ripped into %o with a blood soaked %w."
00382	     PickupMessage="Its been five years since I've seen one of these."
00383	     ItemName="Chainsaw"
00384	     PlayerViewOffset=(X=2.000000,Y=-1.100000,Z=-0.900000)
00385	     PlayerViewMesh=LodMesh'Botpack.chainsawM'
00386	     PickupViewMesh=LodMesh'Botpack.ChainSawPick'
00387	     ThirdPersonMesh=LodMesh'Botpack.CSHand'
00388	     StatusIcon=Texture'Botpack.Icons.UseSaw'
00389	     PickupSound=Sound'UnrealShare.Pickups.WeaponPickup'
00390	     Icon=Texture'Botpack.Icons.UseSaw'
00391	     Mesh=LodMesh'Botpack.ChainSawPick'
00392	     bNoSmooth=False
00393	     SoundVolume=100
00394	}

End Source Code