UnrealShare
Class Grenade

source: e:\games\UnrealTournament\UnrealShare\Classes\Grenade.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Projectile
         |
         +--UnrealShare.Grenade
Direct Known Subclasses:None

class Grenade
extends Engine.Projectile

//============================================================================= // Grenade. //=============================================================================
Variables
 int NumExtraGrenades
           warn this pawn away
 Count, SmokeRate
 ScriptedPawn WarnTarget
           warn this pawn away
 bCanHitOwner, bHitWater


Function Summary
 
simulated
BeginPlay()
 void BlowUp(vector HitLocation)
     
///////////////////////////////////////////////////////
 
simulated
Explosion(vector HitLocation)
 
simulated
HitWall(vector HitNormal, Actor Wall)
 
simulated
Landed(vector HitNormal)
 
simulated
PostBeginPlay()
 
simulated
ProcessTouch(Actor Other, vector HitLocation)
 
simulated
Tick(float DeltaTime)
 
simulated
Timer()
 
simulated
ZoneChange(ZoneInfo NewZone)



Source Code


00001	//=============================================================================
00002	// Grenade.
00003	//=============================================================================
00004	class Grenade extends Projectile;
00005	
00006	#exec MESH IMPORT MESH=GrenadeM ANIVFILE=MODELS\rocket_a.3D DATAFILE=MODELS\rocket_d.3D X=0 Y=0 Z=0
00007	#exec MESH ORIGIN MESH=GrenadeM X=0 Y=0 Z=0 YAW=-64
00008	
00009	#exec MESH SEQUENCE MESH=GrenadeM SEQ=All       STARTFRAME=0   NUMFRAMES=6
00010	#exec MESH SEQUENCE MESH=GrenadeM SEQ=Still     STARTFRAME=0   NUMFRAMES=1
00011	#exec MESH SEQUENCE MESH=GrenadeM SEQ=WingIn    STARTFRAME=1   NUMFRAMES=1
00012	#exec MESH SEQUENCE MESH=GrenadeM SEQ=Armed     STARTFRAME=1   NUMFRAMES=3
00013	#exec MESH SEQUENCE MESH=GrenadeM SEQ=SpinCCW   STARTFRAME=4   NUMFRAMES=1
00014	#exec MESH SEQUENCE MESH=GrenadeM SEQ=SpinCW    STARTFRAME=5   NUMFRAMES=1
00015	
00016	#exec TEXTURE IMPORT NAME=JRocket1 FILE=MODELS\Rocket.PCX
00017	#exec MESHMAP SCALE MESHMAP=GrenadeM X=0.025 Y=0.025 Z=0.05 YAW=128
00018	#exec MESHMAP SETTEXTURE MESHMAP=GrenadeM NUM=1 TEXTURE=JRocket1 TLOD=50
00019	
00020	#exec AUDIO IMPORT FILE="Sounds\EightBal\grenflor.wav" NAME="GrenadeFloor" GROUP="Eightball"
00021	
00022	var bool bCanHitOwner, bHitWater;
00023	var float Count, SmokeRate;
00024	var ScriptedPawn WarnTarget;	// warn this pawn away
00025	var int NumExtraGrenades;
00026	
00027	simulated function PostBeginPlay()
00028	{
00029		local vector X,Y,Z;
00030		local rotator RandRot;
00031	
00032		Super.PostBeginPlay();
00033		if ( Level.NetMode != NM_DedicatedServer )
00034			PlayAnim('WingIn');
00035		SetTimer(2.5+FRand()*0.5,false);                  //Grenade begins unarmed
00036	
00037		if ( Role == ROLE_Authority )
00038		{
00039			GetAxes(Instigator.ViewRotation,X,Y,Z);	
00040			Velocity = X * (Instigator.Velocity Dot X)*0.4 + Vector(Rotation) * (Speed +
00041				FRand() * 100);
00042			Velocity.z += 210;
00043			RandRot.Pitch = FRand() * 1400 - 700;
00044			RandRot.Yaw = FRand() * 1400 - 700;
00045			RandRot.Roll = FRand() * 1400 - 700;
00046			MaxSpeed = 1000;
00047			Velocity = Velocity >> RandRot;
00048			RandSpin(50000);	
00049			bCanHitOwner = False;
00050			if (Instigator.HeadRegion.Zone.bWaterZone)
00051			{
00052				bHitWater = True;
00053				Disable('Tick');
00054				Velocity=0.6*Velocity;			
00055			}
00056		}	
00057	}
00058	
00059	simulated function BeginPlay()
00060	{
00061		if (Level.bHighDetailMode) SmokeRate = 0.03;
00062		else SmokeRate = 0.15;
00063	}
00064	
00065	simulated function ZoneChange( Zoneinfo NewZone )
00066	{
00067		local waterring w;
00068		
00069		if (!NewZone.bWaterZone || bHitWater) Return;
00070	
00071		bHitWater = True;
00072		w = Spawn(class'WaterRing',,,,rot(16384,0,0));
00073		w.DrawScale = 0.2;
00074		w.RemoteRole = ROLE_None;
00075		Velocity=0.6*Velocity;
00076	}
00077	
00078	simulated function Timer()
00079	{
00080		Explosion(Location+Vect(0,0,1)*16);
00081	}
00082	
00083	simulated function Tick(float DeltaTime)
00084	{
00085		local BlackSmoke b;
00086	
00087		if (bHitWater) 
00088		{
00089			Disable('Tick');
00090			Return;
00091		}
00092		Count += DeltaTime;
00093		if ( (Count>Frand()*SmokeRate+SmokeRate+NumExtraGrenades*0.03) && (Level.NetMode!=NM_DedicatedServer) ) 
00094		{
00095			b = Spawn(class'BlackSmoke');
00096			b.RemoteRole = ROLE_None;		
00097			Count=0;
00098		}
00099	}
00100	
00101	simulated function Landed( vector HitNormal )
00102	{
00103		HitWall( HitNormal, None );
00104	}
00105	
00106	simulated function ProcessTouch( actor Other, vector HitLocation )
00107	{
00108		if ( (Other!=instigator) || bCanHitOwner )
00109			Explosion(HitLocation);
00110	}
00111	
00112	simulated function HitWall( vector HitNormal, actor Wall )
00113	{
00114		bCanHitOwner = True;
00115		Velocity = 0.8*(( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity);   // Reflect off Wall w/damping
00116		RandSpin(100000);
00117		speed = VSize(Velocity);
00118		if ( Level.NetMode != NM_DedicatedServer )
00119			PlaySound(ImpactSound, SLOT_Misc, FMax(0.5, speed/800) );
00120		if ( Velocity.Z > 400 )
00121			Velocity.Z = 0.5 * (400 + Velocity.Z);	
00122		else if ( speed < 20 ) 
00123		{
00124			bBounce = False;
00125			SetPhysics(PHYS_None);
00126		}
00127	}
00128	
00129	///////////////////////////////////////////////////////
00130	function BlowUp(vector HitLocation)
00131	{
00132		HurtRadius(damage, 200, 'exploded', MomentumTransfer, HitLocation);
00133		MakeNoise(1.0);
00134	}
00135	
00136	simulated function Explosion(vector HitLocation)
00137	{
00138		local SpriteBallExplosion s;
00139	
00140		BlowUp(HitLocation);
00141	  	s = spawn(class'SpriteBallExplosion',,,HitLocation);
00142		s.RemoteRole = ROLE_None;
00143	 	Destroy();
00144	}
00145	
00146	defaultproperties
00147	{
00148	     speed=600.000000
00149	     MaxSpeed=1000.000000
00150	     Damage=100.000000
00151	     MomentumTransfer=50000
00152	     ImpactSound=Sound'UnrealShare.Eightball.GrenadeFloor'
00153	     Physics=PHYS_Falling
00154	     RemoteRole=ROLE_SimulatedProxy
00155	     AnimSequence=WingIn
00156	     Mesh=LodMesh'UnrealShare.GrenadeM'
00157	     AmbientGlow=64
00158	     bUnlit=True
00159	     bBounce=True
00160	     bFixedRotationDir=True
00161	     DesiredRotation=(Pitch=12000,Yaw=5666,Roll=2334)
00162	}

End Source Code