class Pickup_Bomb extends Pickup_Default;

#exec OBJ LOAD FILE=..\Textures\RcTextures.utx

var Emitter Candel;
var Pawn P;
var Material OriginalSkin;
var bool bReadyToBlow;

replication
{
    reliable if(Role == ROLE_Authority)
        bReadyToBlow,Candel,P,BlowUp,OriginalSkin;
}

auto state Pickup
{
	function Touch( actor Other )
	{
       	if ( ValidTouch(Other) && Inventory == None )
		{
      	    P = Pawn(Other);
      	    SetRespawn();
            Car_R(p).activePowerup = self;
            Car_R(p).bCanPickupInventory = false;
            setbomb();
        }
 }
 }

simulated function setBomb()
{
Candel = Spawn(class'Trail_Smoke', Car_R(P), '', Car_R(P).Location);
Candel.SetBase(Car_R(P));
originalskin = Car_R(p).skins[Car_R(p).SkinOffset];
Car_R(p).repskin=texture'RcTextures.RcRacing.bombblack';
Car_R(p).skins[0]=texture'RcTextures.RcRacing.bombblack';
Car_R(p).skins[1]=texture'RcTextures.RcRacing.bombblack';
settimer(3,false);
}

simulated function BlowUp(vector HitLocation)
{
  local vector tempV;
  local rotator rota,rotb;

  if ( Role == ROLE_Authority )

  //Begin:

  tempv = vector(Car_R(Instigator).GetViewRotation());

  tempV.X*=4000;
  tempV.Y*=200000;
  tempV.Z*=0;

  rota.pitch=rotator(tempv).pitch;
  rota.yaw=rotator(tempv).yaw;
  rota.pitch+=32767.5;

  Car_R(P).Kaddimpulse(tempV+vector(rota),location);

  tempv = vector(Car_R(Instigator).GetViewRotation());

  MakeNoise(1.0);
  Car_R(P).PlaySound(sound'WeaponSounds.redeemer_explosionsound',SLOT_None,2);
  HurtRadius(0,0,class'XWeapons.DamTypeRedeemer',0,Car_R(P).Location);
  Spawn(class'Emitter_BombExplosion',Car_R(P),,Car_R(P).Location - 100 * Normal(Velocity), Rot(0,16384,0));

}

simulated function timer()
{
  bReadyToBlow=true;
}

simulated function tick(float deltatime)
{


 if (bReadyToBlow)
 {
   bReadyToBlow=false;
   //
   //Spawn(class'Emitter_BombExplosion',Car_R(P),,Car_R(P).Location);
   BlowUp(Car_R(P).Location);

   Car_R(p).repskin=originalskin;
   Car_R(p).Skins[0]=Car_R(p).repskin;
   Car_R(p).Skins[1]=Car_R(p).repskin;
   Car_R(p).bCanPickupInventory = true;

   if (Candel != none)
   {
      Candel.Destroy();
   }
   Car_R(p).activePowerup = none;

 }
}

defaultproperties
{
     HudIcon=Texture'RcTextures.HUD.Bomb'
     MaxDesireability=0.300000
     RespawnTime=5.000000
     PickupSound=Sound'PickupSounds.AdrenelinPickup'
     PickupForce="Pickup_Bomb"
     DrawType=DT_StaticMesh
     StaticMesh=StaticMesh'RcStatic.Powerups.RacePowerup'
     CullDistance=5500.000000
     Physics=PHYS_Rotating
     DrawScale=0.050000
     AmbientGlow=128
     ScaleGlow=0.600000
     Style=STY_AlphaZ
     CollisionRadius=32.000000
     CollisionHeight=23.000000
     Mass=10.000000
     RotationRate=(Yaw=24000)
     PickupMessage="Bomb"
}
