local coughs={
	[[rotting\rotting_1]],
	[[rotting\rotting_2]],
	[[rotting\rotting_3]],
	[[rotting\rotting_4]],
	[[rotting\rotting_6]],
	[[rotting\rotting_7]],
	[[rotting\rotting_8]],
	[[rotting\rotting_9]],
	[[rotting\rotting_10]]
}
local smoke_sound = {
	[[zwuk\inv_smoke_1]],
	[[zwuk\inv_smoke_2]]
}

function get_smoke_snd()
	local data=keyvals("smoking"):get("data")
	if data then
		local voice_str
		math.randomseed(screen:time_global())
		if data["count"] < 7 then
			voice_str=table.random(smoke_sound)
		else
			voice_str=table.random(coughs)
		end
		if data["count"] > 9 then
			sms("sms_no_smoke_"..math.random(4), 0, "meceniy", 20000)
		end
		return voice(voice_str)
	end
end

local sound = {
	medkit				= {"zwuk\\inv_medic"},
	medkit_army			= {"zwuk\\inv_medic"},
	medkit_scientic		= {"zwuk\\inv_medic"},
	kolbasa				= {"zwuk\\inv_food","zwuk\\inv_kolbasa"},
	vodka				= {"zwuk\\inv_vodka","zwuk\\inv_flaska"},
	chernobyl_wine				= {"zwuk\\inv_vodka","zwuk\\inv_flaska"},
	beloe_wine				= {"zwuk\\inv_vodka","zwuk\\inv_flaska"},
	energy_drink		= {"zwuk\\inv_drinking","zwuk\\inv_softdrink"},
	sguschenka		= {"zwuk\\inv_canned_milk"},
	bandage				= {"zwuk\\inv_bandage"},
	antirad				= {"zwuk\\inv_pills"},
	drug_booster				= {"zwuk\\inv_softdrink"},
	conserva			= {"zwuk\\inv_conserva"},
	bread				= {"zwuk\\inv_sandwich","zwuk\\inv_kolbasa"},
	sandwich			= {"zwuk\\inv_sandwich"},
	flaska				= {"zwuk\\inv_drinking","zwuk\\inv_flaska","zwuk\\inv_water"},
	beer_a				= {"zwuk\\inv_vodka","zwuk\\inv_softdrink","zwuk\\inv_water"},
	suvorotka			= {"zwuk\\inv_pills"},
	antizombie			= {"zwuk\\inv_pills"},
	d_pantenol			= {"zwuk\\inv_pills"},
	mozg				= {"zwuk\\inv_food"},
	bezoar				= {"zwuk\\inv_food"},
	mushroom			= {"zwuk\\inv_food"},
	sweetness			= {"zwuk\\inv_kolbasa","zwuk\\inv_sandwich"},
	repair_item_outfit	= {"zwuk\\inv_repair_outfit_1","zwuk\\inv_repair_outfit_2","zwuk\\inv_repair_outfit_3"},
	repair_item_weapon	= {"zwuk\\inv_repair_weapon_1","zwuk\\inv_repair_weapon_2","zwuk\\inv_repair_weapon_3","zwuk\\inv_repair_weapon_4"},
	money_loot			= {"zwuk\\inv_money_1","zwuk\\inv_money_2","zwuk\\inv_money_3","zwuk\\inv_money_4"},
	money_usa			= {"zwuk\\inv_money_1","zwuk\\inv_money_2","zwuk\\inv_money_3","zwuk\\inv_money_4"},
	money_euro			= {"zwuk\\inv_money_1","zwuk\\inv_money_2","zwuk\\inv_money_3","zwuk\\inv_money_4"},
	repair_item_xo		= {"weapons\\kniferep"},
	cigara				= {
		func=function(obj)
			return get_smoke_snd()
		end
	},
	sigaret				= {
		func=function(obj)
			return get_smoke_snd()
		end
	}
}

function use_snd(obj)
	if obj and not has_info("biznes_remove_special_item") and sound[obj:section()] then 
		Timer:remove("zvuki")
		if db.eat_snd and db.eat_snd:playing() then
			db.eat_snd:stop()
		end
		local data=sound[obj:section()]
		if data["func"] then
			db.eat_snd = data["func"]()
		else
			db.eat_snd = voice(table.random(data))
		end
		db.eat_snd:play_at_pos(db.actor, vector(), 0, sound_object.s2d)
		-- третья рука, прятание оружия при съедании. на новичке не убирается, далее по нарастающей
		local difficulty = level.get_game_difficulty()
		if difficulty > 0 then
			hide_wpn.on_info("rm_mp_start")
			local delay_time=db.eat_snd:length()/1000
			if delay_time<difficulty*3 then
				delay_time=difficulty*3
			end
			timer("zvuki", delay_time, "zvuki.restore_weapon()")
		end
		--if has_info("ui_inventory") then
			--level.start_stop_menu(level.main_input_receiver(), true)
		--end		
	end
end

function restore_weapon()
	-- поел/вылечился - достаем оружие, если можно
	hide_wpn.on_info("rm_mp_end")
end
