class CeaselessLeadAmmoEffector extends Effector
{
	var m_percentToRefund : Float;

	protected override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		m_percentToRefund = TweakDBInterface.GetFloat( record + T".percentToRefund", 0.0 );
	}

	protected export override function ActionOn( owner : GameObject )
	{
		ProcessAction( owner );
	}

	protected export override function RepeatedAction( owner : GameObject )
	{
		ProcessAction( owner );
	}

	private function ProcessAction( owner : GameObject )
	{
		var weapon : weak< WeaponObject >;
		var refundEvent : SetAmmoCountEvent;
		weapon = ScriptedPuppet.GetWeaponRight( owner );
		if( ( ( weapon && WeaponObject.HasAvailableAmmoInInventory( weapon ) ) && ( WeaponObject.GetMagazineCapacity( weapon ) > WeaponObject.GetMagazineAmmoCount( weapon ) ) ) && ( ( ( ( Float )( WeaponObject.GetMagazineCapacity( weapon ) ) ) * m_percentToRefund ) >= 1.0 ) )
		{
			refundEvent = new SetAmmoCountEvent;
			refundEvent.ammoTypeID = WeaponObject.GetAmmoType( weapon );
			refundEvent.count = ( ( Uint32 )( ( ( ( Float )( WeaponObject.GetMagazineCapacity( weapon ) ) ) * m_percentToRefund ) ) ) + WeaponObject.GetMagazineAmmoCount( weapon );
			weapon.QueueEvent( refundEvent );
			GameObject.PlaySoundEvent( owner, 'w_gun_perk_ceaseless_lead' );
		}
	}

}

