# SFWeapon.SFGrenadeProjC

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 |
    //=============================================================================
    // Spatial Fear
    // Class: SFGrenadeProjC
    // Descripton: Subclasses of SFProjectile realizes a projectile for the grenade
    //				launcher. Conscussion grenade.
    //
    //
    // Author: Markus Nuebel
    //=============================================================================
    class SFGrenadeProjC extends SFProjectile;

    // NOTE:
    // Mesh imported into the SFGrenadeProjE
    //

    var bool bCanHitOwner, bHitWater;
    var float Count, SmokeRate;
    var int nHurtRadius;
    var float m_nMagnitude;
    var float m_nDuration;
    var bool m_bTimerSet;

    // Updates the range and lifespan of a projectile
    function setRange(int nRange)
    {
    	Range=nRange;
    	//SetTimer(Range/Speed*2, false); // Because speed is not constant for grenade
    }

    simulated function PostBeginPlay()
    {
    	local vector X,Y,Z;
    	local rotator RandRot;

    	Super.PostBeginPlay();
    //	if ( Level.NetMode != NM_DedicatedServer )
    //		PlayAnim('WingIn');
    //	SetTimer(2.5+FRand()*0.5,false);                  //Grenade begins unarmed

    	if ( Role == ROLE_Authority )
    	{
    		GetAxes(Instigator.ViewRotation,X,Y,Z);
    		Velocity = X * (Instigator.Velocity Dot X)*0.4 + Vector(Rotation) * (Speed +
    			FRand() * 100);
    		Velocity.z += 210;
    		MaxSpeed = 1000;
    		RandSpin(50000);
    		bCanHitOwner = False;
    		if (Instigator.HeadRegion.Zone.bWaterZone)
    		{
    			bHitWater = True;
    			Disable('Tick');
    			Velocity=0.6*Velocity;
    		}
    	}
    }

    simulated function BeginPlay()
    {
    	if ( Level.bHighDetailMode && !Level.bDropDetail )
    		SmokeRate = 0.06;
    	else
    		SmokeRate = 0.3;
    }

    simulated function Timer()
    {
    	Explosion(Location+Vect(0,0,1)*16);
    }

    simulated function Tick(float DeltaTime)
    {
    	local SFBlueSmokePuff b;

    	if ( bHitWater || Level.bDropDetail )
    	{
    		Disable('Tick');
    		Return;
    	}
    	Count += DeltaTime;
    	if ( (Count>Frand()*SmokeRate+SmokeRate) && (Level.NetMode!=NM_DedicatedServer) )
    	{
    		b = Spawn(class'SFBlueSmokePuff');

    		b.RemoteRole = ROLE_None;
    		Count=0;
    	}
    }

    simulated function Landed( vector HitNormal )
    {
    	HitWall( HitNormal, None );
    }

    simulated function ProcessTouch( actor Other, vector HitLocation )
    {
    	if ( (Other!=instigator) || bCanHitOwner )
    		Explosion(HitLocation);
    }

    simulated function HitWall( vector HitNormal, actor Wall )
    {

    	// Activate explosion timer
    	if(!m_bTimerSet)
    	{
    		SetTimer(1.3, false);
    		m_bTimerSet=true;
    	}

    	bCanHitOwner = True;
    	Velocity = 0.75*(( Velocity dot HitNormal ) * HitNormal * (-2.0) + Velocity);   // Reflect off Wall w/damping
    	RandSpin(100000);
    	speed = VSize(Velocity);
    	if ( Level.NetMode != NM_DedicatedServer )
    		PlaySound(ImpactSound, SLOT_Misc, 1.5 );
    	if ( Velocity.Z > 400 )
    		Velocity.Z = 0.5 * (400 + Velocity.Z);
    	else if ( speed < 20 )
    	{
    		bBounce = False;
    		SetPhysics(PHYS_None);
    	}

    }

    ///////////////////////////////////////////////////////
    simulated function Explosion(vector HitLocation)
    {
    	local SFSpriteBallExplosion2 	s;
    	local vector 					vecThrow;
    	local float						fDist, fMag;
    	local Actor	A;

    	// Do some damage
    	HurtRadius(damage, nHurtRadius, MyDamageType, MomentumTransfer, HitLocation);
    	// Little noise
    	MakeNoise(1.0);
    	// The sprite effect
    	if ( Level.NetMode != NM_DedicatedServer )
    	{
    		spawn(class'Botpack.BlastMark',,,,rot(16384,0,0));
      		s = spawn(class'SFSpriteBallExplosion2',,,HitLocation);
    		s.RemoteRole = ROLE_None;
    	}
    	// The concussion effect
    	vecThrow = 0.18 * m_nMagnitude * VRand();
    	vecThrow.Z = FMax(Abs(vecThrow.Z), 120);
    	// Shake the pawns
    	foreach visiblecollidingactors(class'Actor', A, nHurtRadius,, true)
    	{
    		// Distance to center
    		fDist	= VSize(A.Location-Location);
    		fMag	= (float(nHurtRadius)-fDist)/float(nHurtRadius);
    		vecThrow	= vecThrow*fMag;
    		// Shake player views
    		if ( A.IsA('PlayerPawn') )
    			PlayerPawn(A).ShakeView(m_nDuration*fMag, m_nMagnitude*fMag, 0.015 * m_nMagnitude*fMag);
    		// Shake pawns
    		if ( A.bIsPawn )
    			Pawn(A).AddVelocity(vecThrow);
    		// Shake deco
    		else if ( A.IsA('Decoration') && Decoration(A).bPushable
    					&& (A.Physics == PHYS_None) )
    		{
    			A.SetPhysics(PHYS_Falling);
    			A.Velocity = vecThrow;
    		}
    	}

     	Destroy();

    }

    //     Mesh=LodMesh'Botpack.UTGrenade'
    //     AnimSequence=WingIn
    //	DrawScale=0.020000

    defaultproperties
    {
         nHurtRadius=350
         m_nMagnitude=2000.000000
         m_nDuration=1.000000
         speed=700.000000
         MaxSpeed=1000.000000
         Damage=15.000000
         MomentumTransfer=10000
         MyDamageType=Lobbed
         ImpactSound=Sound'UnrealShare.Eightball.GrenadeFloor'
         ExplosionDecal=Class'Botpack.BlastMark'
         Physics=PHYS_Falling
         RemoteRole=ROLE_SimulatedProxy
         LifeSpan=999.000000
         AnimSequence=SFGrenade
         Mesh=LodMesh'SFWeapon.SFGrenade'
         DrawScale=0.520000
         AmbientGlow=64
         bUnlit=True
         CollisionRadius=13.000000
         CollisionHeight=5.000000
         bBounce=True
         bFixedRotationDir=True
         DesiredRotation=(Pitch=12000,Yaw=5666,Roll=2334)
    }

class file time: 12/7/2003 3:58:26 PM - creation time: 12/7/2003 4:03:44 PM
Created with UnCodeX