//
class AirdropCrate extends Decoration;

#exec mesh import mesh=AirdropCrate anivfile=Models\AirdropCrate_a.3d datafile=Models\AirdropCrate_d.3d x=0 y=0 z=0 mlod=0
#exec mesh origin mesh=AirdropCrate x=0 y=0 z=0
#exec mesh sequence mesh=AirdropCrate seq=All startframe=0 numframes=1

#exec meshmap new meshmap=AirdropCrate mesh=AirdropCrate
#exec meshmap scale meshmap=AirdropCrate x=0.12500 y=0.12500 z=0.25000

#exec TEXTURE IMPORT NAME=CrateSide FILE=Textures\CrateSide.BMP GROUP=Skins
#exec TEXTURE IMPORT NAME=CrateTop FILE=Textures\CrateTop.BMP GROUP=Skins

#exec AUDIO IMPORT NAME=BoxBreak1 FILE=Sounds\BoxBreak1.wav

var() int Health;
var() int FragChunks;
var() Float Fragsize;

function PreBeginPlay()
{
	if (Buoyancy == Default.Buoyancy)
		Buoyancy = Mass * (0.9 + 0.6 * FRand());
	
	Super.PreBeginPlay();
}

Auto State Animate
{
	function TakeDamage(int NDamage, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType)
	{
		if (bStatic || bDeleteme)
			return;
		Instigator = InstigatedBy;
		if (Health<0)
			Return;
		if (Instigator != None)
			MakeNoise(1.0);
		bBobbing = false;
		Health -= NDamage;
		if (Health <0)
		{
			PlaySound(sound'BoxBreak1');
			Frag(Class'WoodFragmentsBRUT',Momentum,FragSize,FragChunks);
			if (FRand() < 0.5)
				Spawn(Class'BRUT.HeavyRifle_M249',,,Location);
			else
				Spawn(Class'BRUT.HeavyRifle_M60',,,Location);
			if (FRand() < 0.5)
				Spawn(Class'BRUT.Medkit',,,Location + 20 * Vect(0,1,0));
			else
				Spawn(Class'BRUT.PainPills',,,Location + 20 * Vect(0,1,0));
			Disable('Tick');
		}
		else
		{
			SetPhysics(PHYS_Falling);
			Momentum.Z = 1000;
			Velocity=Momentum*0.016;
		}
	}

   function Bump(actor Other)
	{
   	local Actor A;
   	local Vector momentum;
   	
   	if(Other.bIsPawn && Pawn(Other).bIsPlayer && (Pawn(Other).Health > 0))
      {
 			PlaySound(sound'BoxBreak1');
			Frag(Class'WoodFragmentsBRUT',Momentum,FragSize,FragChunks);
			if (FRand() < 0.5)
				Spawn(Class'BRUT.HeavyRifle_M249',,,Location);
			else
				Spawn(Class'BRUT.HeavyRifle_M60',,,Location);
			if (FRand() < 0.5)
				Spawn(Class'BRUT.Medkit',,,Location + 20 * Vect(0,1,0));
			else
				Spawn(Class'BRUT.PainPills',,,Location + 20 * Vect(0,1,0));
			Disable('Tick');
      }
   }
}

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

	if (FRand()<0.30)
	{
		b = Spawn(class'AirdropSmokePuff',,,Location + vect(0,0,50));
		b.RemoteRole = ROLE_None;
	}
}

defaultproperties
{
	AmbientGlow=102
  	DrawType=DT_Mesh
  	Mesh=Mesh'AirdropCrate'
	Health=20
	FragChunks=12
	Fragsize=1.750000
	bPushable=False
	bStatic=False
  	bCollideWhenPlacing=True
  	bCollideActors=True
  	bCollideWorld=True
  	bBlockActors=True
  	bBlockPlayers=True
  	CollisionRadius=32.00000
  	CollisionHeight=32.00000
  	MultiSkins(0)=Texture'UnrealI.Skins.JFlag31'
  	MultiSkins(1)=Texture'CrateSide'
  	MultiSkins(2)=Texture'CrateTop'
  	Mass=50.000000
   LightType=LT_SubtlePulse
   LightBrightness=154
   LightHue=24
   LightSaturation=0
   LightRadius=10
}
