Перейти к контенту

Скриптование


Svoboда

Рекомендуемые сообщения

Помогите! Не работает в скрипте функция запотевания динамического худа. Если не трудно, объясните на пальцах что да как!

 

--------------------------------------------------------------------------------
--Dinamic HUD from ABC Inferno and AMK
--by Rulix aka Bak
--------------------------------------------------------------------------------
-- чтобы отключить эффект, поставьте вместо единицы ноль:
local suithud_enable = 1 -- худ шлема
local blurs_enable = 0 -- эффект запотевани¤ - не работает
local blood_enable = 1 -- эффект ранени¤
local bleed_enable = 1 -- эффект плохого самочувстви¤
local hit_enable = 1 -- эффект попадани¤ по игроку
--------------------------------------------------------------------------------

local helmets = {helm_respirator = {hud = "hud_gas",breakable = true},
helm_hardhat = {hud = "hud_mil",breakable = true},
helm_protective = {hud = "hud_sci",breakable = true},
helm_tactic = {hud = "hud_kill",breakable = true},
helm_battle = {hud = "hud_kill",breakable = true},
scientific_outfit = {hud = "hud_sci",breakable = true},
exo_outfit = {hud = "hud_exo",breakable = true}}

local no_drop_items = {bolt = true,
wpn_knife = true}

local seldom_upd_time,often_upd_time
function update()
if db.actor then
local tg = time_global()
if tg > (seldom_upd_time or 100) then
seldom_upd_time = tg+300
helmet_hud()
bleedcondition()
end
if tg > (often_upd_time or 30) then
often_upd_time = tg+50
init_blurs()
blood()
set_blood()
hit_effect()
end
end
end

local prev_health = 0
function hit_effect()
if hit_enable == 0 then
return
end
if prev_health > db.actor.health+0.05 then
level.add_pp_effector("amk_shoot.ppe",2011,false)
level.set_pp_effector_factor(2011,(prev_health-db.actor.health)*100)
if prev_health > db.actor.health+0.2 then
local cameffs,sounds
if prev_health > db.actor.health+0.5 then
cameffs = {"head_shot","fusker"}
sounds = {"pain_4","pain_1","hit_5","hit_6"}
else
cameffs ={"shell_shock","hit_front","hit_right","hit_back","hit_left","hit_front_left","hit_back_left","hit_front_right","hit_back_right"}
sounds = {"pain_2","pain_3","pain_5","pain_6","pain_7","pain_8"}
end
level.add_cam_effector("camera_effects\\"..cameffs[math.random(#cameffs)]..".anm",999,false,"")
local snd_obj = sound_object("actor\\"..sounds[math.random(#sounds)])
snd_obj:play(db.actor,0,sound_object.s2d)
if math.random() < (prev_health-db.actor.health)/2.5 then
local active_item = db.actor:active_item()
if active_item and not no_drop_items[active_item:section()] then
db.actor:drop_item(active_item)
end
end
end
end
prev_health = db.actor.health
end

local current_suithud
local helmet_condition
local pre_hud_type = ""
function helmet_hud()
if suithud_enable == 0 then
return
end
local hud_type
local helmet = db.actor:alive() and (db.actor:item_in_slot(12) or db.actor:get_current_outfit())
if helmet then
local sect = helmet:section()
if helmets[sect] then
helmet_condition = "blue"
if helmets[sect].breakable == true then
local cond = helmet:condition()
if cond > 0.87 then helmet_condition = "blue"
elseif cond > 0.69 then helmet_condition = "green"
elseif cond > 0.60 then helmet_condition = "yellow"
elseif cond > 0.40 then helmet_condition = "red"
elseif cond > 0.25 then helmet_condition = "red2"
else helmet_condition = "red3" end
end
hud_type = helmets[sect].hud.."_"..helmet_condition
pre_hud_type = helmets[sect].hud
end
end
setmysuithud(hud_type)
end

local suitfirstrun = true
function setmysuithud(hudtype)
local hud = get_hud()
if not hudtype then
local wchud = hud:GetCustomStatic(current_suithud)
if wchud then
hud:RemoveCustomStatic(current_suithud)
end
current_suithud = nil
suitfirstrun = true
elseif hudtype ~= current_suithud then
if current_suithud then
hud:RemoveCustomStatic(current_suithud)
end
hud:AddCustomStatic(hudtype)
if string.find(hudtype,pre_hud_type) then
if suitfirstrun == false and helmet_condition ~= "green" and helmet_condition ~= "blue" then
local snd_obj = sound_object("material\\glass\\glass_fall03hl")
snd_obj:play(db.actor,0,sound_object.s2d)
end
if suitfirstrun == true then
suitfirstrun = false
end
end
current_suithud = hudtype
end
end

local actor_last_health = 0
local bloodtime = 0
local bloodtimeb = 0
local isbleeding = "no"
local countblood = 0
function blood()
if blood_enable == 0 then return end
local radwidth = db.actor.radiation
if radwidth == 0 then
if db.actor:alive() then
local current_health = math.floor(db.actor.health*100)
local cbloodtime = time_global()
if cbloodtime > bloodtime and isbleeding == "stopit" then
for i=1,4 do
if get_hud():GetCustomStatic("hud_blood"..i) then
get_hud():RemoveCustomStatic("hud_blood"..i)
isbleeding = "no"
end
end
end
if cbloodtime > bloodtime then
bloodtime = time_global() + 1500
if actor_last_health > current_health and actor_last_health ~= 0 then
isbleeding = "yes"
end
actor_last_health = math.floor(db.actor.health * 100)
end
end
end
end

local m_blood = nil
function set_blood()
if blood_enable == 0 then return end
local radwidth = db.actor.radiation
local cbloodtimed = time_global()
if cbloodtimed > bloodtimeb and isbleeding == "yes" and radwidth == 0 then
bloodtimeb = time_global() + 170
m_blood = {}
countblood = countblood + 1
get_hud():AddCustomStatic("hud_blood"..countblood)
m_blood[countblood] = get_hud():GetCustomStatic("hud_blood"..countblood):wnd()
local chudblood = "hud_blood"..countblood
if countblood == 4 then
isbleeding = "stopit"
countblood = 0
end
end
end

local isactcondset = false
local radeffect = false
function bleedcondition()
if bleed_enable == 0 then return end
if db.actor.health < 0.31 and isactcondset ~= true then
level.add_pp_effector("alcohol.ppe",2012,true)
isactcondset = true
end
if db.actor.health > 0.30 and isactcondset ~= false then
level.remove_pp_effector(2012)
isactcondset = false
end
if db.actor.radiation > 0.3 and radeffect ~= true then
level.add_pp_effector("alcohol.ppe", 2013,true)
radeffect = true
end
if db.actor.radiation == 0 and radeffect ~= false then
level.remove_pp_effector(2013)
radeffect = false
end
end

function init_blurs()
if blurs_enable == 0 then return end
if current_suithud and not string.find(current_suithud,"_red3") then
local zoom=67.5/device().fov
zoom = (zoom-1)*1.5+1
if zoom < 1.001 then
zoom = 1.001
end
local stretchy = 0.75/(math.floor(device().aspect_ratio*1000)/1000)
if stretchy < 1 then
stretchy = 1
end
local rect = {x = -768*zoom+768,y = (-512*zoom+512)*stretchy-(stretchy-1)*300,w = 1024*zoom,h = 768*zoom*stretchy}
set_blurs(true,rect)
else
set_blurs(false)
end
end

local blurs
local blurval = 0 -- уровень запотевани¤ от 0 до 1
local blurlt = 0 -- врем¤ последнего обновлени¤
local blurcyctime = 0 -- врем¤ начала последнего цикла дыхани¤ (выдох)
local blurlastphase = 0
function set_blurs(enabled,rect)
local hud = get_hud()
if not enabled then
for i=1,4 do
local bh = hud:GetCustomStatic("hud_blur"..i)
if bh then
hud:RemoveCustomStatic("hud_blur"..i)
end
end
return
end
if not (blurs and hud:GetCustomStatic("hud_blur1")) then
blurs = {}
for i=1,4 do
hud:AddCustomStatic("hud_blur"..i)
blurs = hud:GetCustomStatic("hud_blur"..i):wnd()
-- blurs:SetWidth(0)
end
end
-- ÷иклы в зависимости от силы дыхани¤: 0->1->0 0->1->2->4->5->0 0->1->2->3->4->5->0 5->4->3->4->5 4->3->4
local power = db.actor.power
local period = 1.0+power*power*1.0 -- текуща¤ частота дыхани¤ от 30 до 120 циклов в минуту
local expirt = 0.3
local breathpower = 3
local delta = (time_global()-blurlt)/1000 -- дельта в секундах
local phase = (time_global()-blurcyctime)/1000 -- фаза дыхательного цикла в сек.
blurlt = time_global()
if phase > period then
phase = phase%period
blurcyctime = blurlt-phase*1000
end
if blurlastphase > phase then
blurlastphase = 0
end
local blurdelta = delta*-0.7 -- работа вентилл¤ции
if blurlastphase < expirt and phase < expirt then
blurdelta = blurdelta+(phase-blurlastphase)*breathpower
elseif blurlastphase < expirt then
blurdelta = blurdelta+(expirt-blurlastphase)*breathpower
end
blurlastphase = phase
blurval = blurval+blurdelta
if blurval > 0.999 then
blurval = 0.999
elseif blurval < 0 then
blurval = 0
end
local tm = math.floor(blurval*3)
local tmn = (tm+1)
local v = blurval*3-math.floor(blurval*3)
v = 1-v
local v1 = 1-v
if tm ~= 0 then
blurs[tm]:SetColor(GetARGB(v*255,255,255,255))
end
if tmn ~= 0 then
blurs[tmn]:SetColor(GetARGB(v1*255,255,255,255))
end
for i=1,4 do
if i == tm or i == tmn then
blurs:SetWndRect(Frect():set(rect.x,rect.y,rect.w,rect.h))
else
blurs:SetWndRect(Frect():set(rect.x,rect.y,0,0))
end
end
end

 

Изменено пользователем Дедушка Тапок

Поделиться этим сообщением


Ссылка на сообщение
  • Недавно просматривали   0 пользователей

    • Ни один зарегистрированный пользователь не просматривает эту страницу.
×
×
  • Создать...