
final class TurokShotgun: TurokWeapon
{
	TurokShotgun( kWeapon@ a )
	{
		super( a );
		BobDamping = 0.975f;
	}

	void AnimProperties( int&out first, int&out last, float&out rate, bool&out bLoop )
	{
		rate = 60; bLoop = false;
		switch ( PlayingID() )
		{
			case anim_weaponSwapIn:  first =  0; last =  30; break;
			case anim_weaponSwapOut: first = 30; last =  44; break;
			case anim_weaponAttack1: first = 45; last =  95; break;
			case anim_weaponAttack2: first = 95; last = 125; break;
			default: /* idle */      first =     last =  30; bLoop = true; break;
		}
	}

	bool Refire()
	{
		switch ( PlayingID() )
		{
			case anim_weaponAttack1: case anim_weaponAttack2:
				return true;
		}
		return false;
	}

	void OnTick()
	{
		TurokWeapon::OnTick();
		switch ( PlayingID() )
		{
			case anim_weaponAttack1: case anim_weaponAttack2: break;
			default: return;
		}
		if ( PlayTime() > 0.5f ) return;
		float f = 1 - PlayTime() / 0.5f;
		f *= f * f;
		OwnerP().RecoilPitch() = Math::Sin(   Math::pi * f ) * f * -0.03f;
		OwnerP().Roll()        = Math::Sin( 2*Math::pi * f ) * f * -0.015f;
	}

	void OnBeginFire()
	{
//		kVec3 offset( 8, 25.696f, -7 );
//		offset -= kVec3(8,0,-7).Normalize()*3;
		kVec3 offset( 5.75f, 25.696f, -5 );
		// primary takes precedence if both are pressed
		if ( bFire1 )
		{
			self.PlaySound( "U1/sounds/ASMD/Shot.ksnd" );
			kStr proj = "UT/fx/ASMD/Beam";
			if ( UDamage() ) proj += "_Amp";
			self.FireProjectile( proj + ".kfx", offset.x, offset.y, offset.z );
			PlayAnim( anim_weaponAttack1 );
		}
		else
		{
			self.PlaySound( "U1/sounds/ASMD/Shot_Alt.ksnd" );
			offset = offset * OwnerP().Rotation();
			offset += EyePos();
			offset.z -= 11;
			kVec3 v = CheckPosition( offset );
			ActorFactory.Spawn( "ShockProj", v.x, v.y, v.z, OwnerP().Yaw(), OwnerP().SectorIndex() );
			PlayAnim( anim_weaponAttack2 );
		}
		self.RunFxEvent( "ASMDFire" );
		UseAmmo( 1 );
		OwnerP().LoudNoiseAlert();
	}
}
