
class MDCrushed extends Projectile;

#exec audio import file="Sounds\candrop.wav" name="candrop" group="Sounds"
#exec audio import file="Sounds\cantink.wav" name="cantink" group="Sounds"

var bool bCanHitOwner, bHitWater;
var float Count, SmokeRate;
var int NumExtraGrenades;

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

   Super.PostBeginPlay();

   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 ZoneChange(Zoneinfo NewZone)
{
   local waterring w;
    
   if (!NewZone.bWaterZone || bHitWater) Return;

   bHitWater = True;
   w = Spawn(class'WaterRing',,,,rot(16384,0,0));
   w.DrawScale = 0.2;
   w.RemoteRole = ROLE_None;
   Velocity=0.6*Velocity;
}

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

simulated function HitWall(vector HitNormal, actor Wall)
{
   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(sound'cantink', SLOT_Misc, 1.5);
   if (Velocity.Z > 400)
      Velocity.Z = 0.5 * (400 + Velocity.Z);
   else if (speed < 20)
   {
      bBounce = False;
      SetPhysics(PHYS_None);
      SetCollision(false,false,false);
      PlaySound(sound'candrop');
   }
}

defaultproperties
{
	speed=300.000000
   AmbientGlow=64
   bBounce=True
   bFixedRotationDir=True
   DesiredRotation=(Pitch=12000,Yaw=5666,Roll=2334)
   ImpactSound=Sound'UnrealShare.Eightball.GrenadeFloor'
   Physics=PHYS_Falling
   RemoteRole=ROLE_SimulatedProxy
	Lifespan=10
   AnimSequence=dented
   DrawType=DT_Mesh
	Mesh=Mesh'RBull'
	bCollideActors=True
	bCollideWorld=True
	bBlockActors=True
	bBlockPlayers=True
	CollisionRadius=6.0
	CollisionHeight=10.0
	Mass=35.000000
}
