--[[
****************************************************
* Atem- und Herzgeraeusche bei grosser Anstrengung *
*           by ThunderFreak, 04/2009               *
*                                                  *
*    fuer S.T.A.L.K.E.R. - Shadow of Chernobyl     *
****************************************************
]]
local init_breath = false
local breath_time
local heartbeat_set
local info2_send = false
local verschnaufpause = {
	[0] = "I need a rest urgently.",
	[1] = "Damn, I am exhausted.",
	[2] = "Fucking Zone! I have to rush here like in a big city.",
	[4] = "Puh, Rush hour in the Zone. Damn, damn."
}

function atmen1()
	local vol = 0
	local ausdauer = db.actor.power
	if init_breath == false then 
		breath_time = time_global() + 2300 
		init_breath = true
	end
	if time_global() > breath_time and ausdauer < .7 then
		if ausdauer < .7 and ausdauer >= .6 then
			vol = 2.0
		elseif ausdauer < .6 and ausdauer >= .5 then
			vol = 3.0
		elseif ausdauer < .5 and ausdauer >= .35 then
			vol = 5.0
		elseif ausdauer < .35 and ausdauer >= .2 then
			vol = 7.0
		elseif ausdauer < .2 then
			vol = 9.0
		end
		
		local snd_obj = xr_sound.get_safe_sound_object([[actor\breath_1]])  -- characters_voice\human_03\stalker\states\breath\breath_1
		snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), vol)
		breath_time = time_global() + 2300
	end
end

function atmen2()
	local vol = 0
	local ausdauer = db.actor.power
	if init_breath == false then 
		breath_time = time_global() + 2300 
		heartbeat_set = time_global() + 7800
		init_breath = true
	end
	if time_global() > breath_time and ausdauer < .7 then
		if ausdauer < .7 and ausdauer >= .6 then
			vol = 2.0
		elseif ausdauer < .6 and ausdauer >= .5 then
			vol = 3.0
		elseif ausdauer < .5 and ausdauer >= .35 then
			vol = 5.0
		elseif ausdauer < .35 and ausdauer >= .2 then
			vol = 7.0
		elseif ausdauer < .2 then
			vol = 9.0
		end
		
		local snd_obj = xr_sound.get_safe_sound_object([[actor\breath_1]])  -- characters_voice\human_03\stalker\states\breath\breath_1
		snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), vol)
		breath_time = time_global() + 2300
	end
	if ausdauer < .3 and time_global() > heartbeat_set then 
		local snd_obj = xr_sound.get_safe_sound_object([[heart\2]])
		snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 3.0)
		heartbeat_set = time_global() + 7800
	end
	if ausdauer < .2 and info2_send == false then
		db.actor:give_game_news(verschnaufpause[math.random(1, 4)], "ui\\ui_iconstotal", Frect():set(x,y,83,47), 2000, 6000)	
		info2_send = true
	end
	if ausdauer > .2 then info2_send = false end
end
