local actor = nil
local helmet = nil
local section = nil
local curcond = nil

local outfit_table = {{"helm_respirator",
                       "helm_hardhat",
                       "helm_protective",
                       "helm_tactic",
                       "helm_battle",
                       "helm_respirator_joker",
                       "helm_hardhat_snag"
                       },
                      {"hud_gas1",
                       "hud_mil1",
                       "hud_sci1",
                       "hud_exo1",
                       "hud_exo1",
                       "hud_gas1",
                       "hud_mil1"
                       },
                      {"hud_gas2",
                       "hud_mil2",
                       "hud_sci2",
                       "hud_exo2",
                       "hud_exo2",
                       "hud_gas2",
                       "hud_mil2"
                       },
                      {"hud_gas3",
                       "hud_mil3",
                       "hud_sci3",
                       "hud_exo3",
                       "hud_exo3",
                       "hud_gas3",
                       "hud_mil3"
                       },
                      {"hud_gas4",
                       "hud_mil4",
                       "hud_sci4",
                       "hud_exo4",
                       "hud_exo4",
                       "hud_gas4",
                       "hud_mil4"
                       },
                      {"hud_gas5",
                       "hud_mil5",
                       "hud_sci5",
                       "hud_exo5",
                       "hud_exo5",
                       "hud_gas5",
                       "hud_mil5"
                       },
                      {"hud_gas6",
                       "hud_mil6",
                       "hud_sci6",
                       "hud_exo6",
                       "hud_exo6",
                       "hud_gas6",
                       "hud_mil6"
                       }}

local nohud_table = {nil}

function main()
	actor = db.actor
	helmet  = actor:item_in_slot(12)
	section=nil
	if helmet ~= nil then
		section = helmet:section()
		curcond = helmet:condition()
                  end
               for a=1,7 do
                   if section==outfit_table[1][a] and curcond >= 0.75 then
                               add_static(outfit_table[2][a])
                   elseif section==outfit_table[1][a] and curcond >= 0.55 and curcond < 0.75 then
                               add_static(outfit_table[3][a])
                   elseif section==outfit_table[1][a] and curcond >= 0.35 and curcond < 0.55 then
                               add_static(outfit_table[4][a])
                   elseif section==outfit_table[1][a] and curcond >= 0.15 and curcond < 0.35 then
                               add_static(outfit_table[5][a])
                   elseif section==outfit_table[1][a] and curcond >= 0.5 and curcond < 0.15 then
                               add_static(outfit_table[6][a])
                   elseif section==outfit_table[1][a] and curcond < 0.5 then
                               add_static(outfit_table[7][a])
                              end
                end
   for b=1,1 do
      if section==nohud_table[b] then
         del_static()
      end
   end
end

function add_static(static)
   local hud = get_hud()
   if hud:GetCustomStatic(static)~=nil then return end
   del_static()
   hud:AddCustomStatic(static, true)
end

function del_static()
   local hud = get_hud()
   for a=1,7 do
      if hud:GetCustomStatic(outfit_table[2][a])~=nil then
         hud:RemoveCustomStatic(outfit_table[2][a])
      elseif hud:GetCustomStatic(outfit_table[3][a])~=nil then
             hud:RemoveCustomStatic(outfit_table[3][a])
      elseif hud:GetCustomStatic(outfit_table[4][a])~=nil then
             hud:RemoveCustomStatic(outfit_table[4][a])
      elseif hud:GetCustomStatic(outfit_table[5][a])~=nil then
             hud:RemoveCustomStatic(outfit_table[5][a])
      elseif hud:GetCustomStatic(outfit_table[6][a])~=nil then
             hud:RemoveCustomStatic(outfit_table[6][a])
      elseif hud:GetCustomStatic(outfit_table[7][a])~=nil then
             hud:RemoveCustomStatic(outfit_table[7][a])
      end
   end
end

function breath()

end
