Главная » Статьи » Статьи » Моддинг

Система постепенной регенерации жизни из Lurk mod и ABC
Система постепенной регенерации жизни из Lurk mod и ABC
Материал из S.T.A.L.K.E.R. Inside Wiki.
Перейти к: навигация, поиск

Для начала создадим скрипт. Например health_effect.scripts:

 
---Система еды и постепенного лечения из Лурк мода---
 
objectinuse=0
objectused=0
 
--If/then statements for finding the item.
function start(obj)
snd = xr_sound.get_safe_sound_object([[$no_sound]])
if (db.actor~=nil) and (obj~=nil) then
slotinuse=db.actor:active_slot()
slot_div=1
if obj:section() == "medkit" or obj:section() == "medkit_army" or obj:section() == "medkit_scientic" then
snd= xr_sound.get_safe_sound_object([[interface\inv_medkit]])
holster_time=time_global()+7000
if (objectinuse==1) then
holster_time=holster_time+7000
end
soundhub()
 
elseif obj:section() == "antirad" then
snd= xr_sound.get_safe_sound_object([[interface\inv_pills]])
holster_time=time_global()+6000
if (objectinuse==1) then
holster_time=holster_time+6000
end
soundhub()
 
elseif obj:section() == "bandage" then
snd= xr_sound.get_safe_sound_object([[interface\inv_bandage]])
holster_time=time_global()+6000
if (objectinuse==1) then
holster_time=holster_time+6000
end
soundhub()
 
elseif obj:section() == "vodka" then
snd= xr_sound.get_safe_sound_object([[interface\inv_vodka]])
holster_time=time_global()+4000
if (objectinuse==1) then
holster_time=holster_time+4000
end
soundhub()
 
elseif obj:section() == "energy_drink" then
snd= xr_sound.get_safe_sound_object([[interface\inv_softdrink]])
holster_time=time_global()+4000
if (objectinuse==1) then
holster_time=holster_time+4000
end
soundhub()
 
elseif obj:section() == "bread" or obj:section() == "conserva" or obj:section() == "kolbasa" then
snd= xr_sound.get_safe_sound_object([[interface\inv_food]]) 
holster_time=time_global()+7000
if (objectinuse==1) then
holster_time=holster_time+7000
end
soundhub()
end
 
end
end
 
--Other stuff executes from here.
function soundhub()
if db.actor:alive() then
snd:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)
snd = xr_sound.get_safe_sound_object([[$no_sound]])
if (objectinuse==0) then
db.actor:hide_weapon()
objectinuse=1
if slotinuse == 1 then
slot_div = ((holster_time-time_global())/1.5)
else
slot_div = 0
end
end
objectused=objectused+1
weapontimer()
end
end
 
--Holster time. Its set up as additive: A food and a drink taken together will apply instantly, but your gun is holstered for 9 seconds.
function weapontimer()
if (holster_time~=nil) and (time_global()>(holster_time-slot_div)) and level.present() then
objectused=objectused-1
if (objectused==0) then
db.actor:restore_weapon()
objectinuse=0
holster_time=nil
end
end
end
 
--Message for time remaining and math.Round function. Not used.
--[[
function message()
news_manager.send_tip(db.actor, tostring(math.Round((holster_time - time_global())/1000)).."s", nil, nil, 1000)
end
 
--Math.round
function math.Round(num)
local floored = math.floor(num)
if (num - floored) >= 0.5 then
return math.ceil(num)
else
return floored
end
end
]]--
 

Стоит, кстати, учесть параметр

 
snd = xr_sound.get_safe_sound_object([[interface\inv_food]])
 

Отвечает за воспроизводимый звук. Так что если его нет, поймаете вылет. Теперь создаёте скрипт abc_medkit.script:

 
-- Shortened Creds: ABC Mod made this, LURK team just cleaned up the indentions.
 
-- Should the use of the same medkit accumulate over the previous one?
multiple_medkit = "yes" --Не пробовал ставить no. Но почти уверен что будет вылет
 
-- How many minutes should take to complete the healing process.
hp_fullhealth_time = 0.125 --Кол-во в течении которого будет юзаться аптечка
 
--0.25
 
-- Health update time in MS. 1000 = 1 Second.
hupd_time = 50 --Апдейт времени.Лучше не трогать
 
-- Time modulation
time_mod=0
 
-- HP Healed. No higher than 1.
hp_med_kit = 0.65 --Параметр отвечающий за восстановление жизней одной аптечкой.Точнее за скорость восстановления
hp_med_army = 0.75
hp_med_sci = 0.80
 
-- Is Army faster than Normal?
army_fast = "yes"
 
-- Is Science faster than Normal?
sci_fast = "yes"
 
-- Is Science faster than Army?
sci_fast_than_army = "yes"
 
-- Should medkit_scientic anti-radiation process be progressive?
sci_antirad = "yes"
 
-- EOF
 
 
local med_kit, med_band, med_army, med_sci, medused, medid, medname
local objdtc = 0
function chk_medlot_object(obj)
if db.actor ~= nil then  
local objdt = time_global() 
if obj ~= nil and obj ~= "load" then
medname = obj:section()
if medname == "medkit" or medname == "medkit_army" or medname == "medkit_scientic" then
if objdtc == 0 then objdtc = time_global() + 350 end
med_used = "yes"
med_id = obj:id()
end
end
if med_used == "yes" and objdt > objdtc then
objdtc = 0
med_used = "no" 
if level.object_by_id(med_id) == nil then
if medname == "medkit" then  med_kit = "yes" end
if medname == "medkit_army" then  med_army = "yes" end
if medname == "medkit_scientic" then  med_sci = "yes" end
time_mod=0
end
end
new_medkit()
end
end
 
local time_mkit, time_army, time_sci, count_mkit, count_army, count_sci
function new_medkit()
if db.actor ~= nil and level.present() then
local cgametimemed = time_global()
local hft = (hp_fullhealth_time * 60000) / hupd_time
--normal
if med_kit == "yes" then
if time_mkit == nil then time_mkit = time_global() + hupd_time end
if cgametimemed > time_mkit then
time_mkit = time_global() + hupd_time
local player_hp = db.actor.health
if player_hp < 1 then
if count_mkit == nil then count_mkit = 0 end
if count_mkit < (hft + 1) then
db.actor.health = (hp_med_kit/(hft + time_mod))
count_mkit = count_mkit + 1
--abort("TimeMod: "..time_mod)
--abort("Health: "..hp_med_kit/(hft + time_mod))
time_mod = math.clamp(time_mod+0.23,0,35)
else
med_kit = nil
time_mkit = nil
count_mkit = nil
end
else
med_kit = nil
time_mkit = nil
count_mkit = nil
end
end
end
--army
if med_army == "yes" then
if time_army == nil then time_army = time_global() + hupd_time end
if cgametimemed > time_army then
time_army = time_global() + hupd_time
local player_hp = db.actor.health
if player_hp < 1 then
if count_army == nil then count_army = 0 end
if count_army < (hft + 1) then
local mamf = 0
if army_fast == "yes" then mamf = (hp_med_army/hft) / 4 end
db.actor.health = (hp_med_army/hft) + mamf
count_army = count_army + 1
time_mod = math.clamp(time_mod+0.23,0,35)
else
med_kit = nil
time_mkit = nil
count_mkit = nil
end
else
med_kit = nil
time_mkit = nil
count_mkit = nil
end
end
end
--science
if med_sci == "yes" then
if time_sci == nil then time_sci = time_global() + hupd_time end
if cgametimemed > time_sci then
time_sci = time_global() + hupd_time
local player_hp = db.actor.health
if player_hp < 1 then
if count_sci == nil then count_sci = 0 end
if count_sci < (hft + 1) then
local mamf = 0
local sfta = 4
if sci_fast_than_army == "yes" then sfta = 2 end
if sci_fast == "yes" then mamf = (hp_med_army/hft) / sfta end
db.actor.health = (hp_med_sci/hft) + mamf
if sci_antirad == "yes" then db.actor.radiation = -(hp_med_sci/hft) end
count_sci = count_sci + 1
time_mod = math.clamp(time_mod+0.23,0,35)
else
med_kit = nil
time_mkit = nil
count_mkit = nil
end
else
med_kit = nil
time_mkit = nil
count_mkit = nil
end
end
end
 end
end
 
function math.clamp (value,mini,maxi)
local clamped = value
if clamped < mini then clamped = mini end
if clamped > maxi then clamped = maxi end
return clamped
end
 

Теперь самое сложное. Лезем в bind_stalker.scripts. После

 
self.object:set_callback(callback.on_item_drop, nil)
 

Пишем

 
self.object:set_callback(callback.use_object, nil)
 

В итоге получается вот так:

 
self.object:set_callback(callback.inventory_info, nil)
self.object:set_callback(callback.article_info, nil)
self.object:set_callback(callback.on_item_take, nil)
self.object:set_callback(callback.on_item_drop, nil)
    self.object:set_callback(callback.use_object, nil)
--self.object:set_callback(callback.actor_sleep, nil)
self.object:set_callback(callback.task_state, nil)
self.object:set_callback(callback.level_border_enter, nil)
self.object:set_callback(callback.level_border_exit, nil)
self.object:set_callback(callback.take_item_from_box, nil)
 

После

 
self.object:set_callback(callback.on_item_drop, self.on_item_drop, self)
 

Пишем

 
self.object:set_callback(callback.use_object, self.use_object, self)
 

В итоге:

 
self.object:set_callback(callback.inventory_info, self.info_callback, self)
self.object:set_callback(callback.article_info, self.article_callback, self)
self.object:set_callback(callback.on_item_take, self.on_item_take, self)
self.object:set_callback(callback.on_item_drop, self.on_item_drop, self)
    self.object:set_callback(callback.use_object, self.use_object, self)
self.object:set_callback(callback.trade_sell_buy_item, self.on_trade, self) -- for game stats
--self.object:set_callback(callback.actor_sleep, self.sleep_callback, self)
self.object:set_callback(callback.task_state, self.task_callback, self)
--self.object:set_callback(callback.map_location_added, self.map_location_added_callback, self)
self.object:set_callback(callback.level_border_enter, self.level_border_enter, self)
self.object:set_callback(callback.level_border_exit, self.level_border_exit, self)
self.object:set_callback(callback.take_item_from_box, self.take_item_from_box, self)
 

Ищем функцию:

 
function actor_binder:on_item_drop (obj)
 

и после ее завершения пишем:

 
----------------------------------------------------------------------------------------------------------------------
function actor_binder:use_object(obj)
heal_regen.start(obj)
end
----------------------------------------------------------------------------------------------------------------------
 

В итоге:

 
----------------------------------------------------------------------------------------------------------------------
function actor_binder:on_item_drop (obj)
    level_tasks.proceed(self.object)
    --game_stats.update_drop_item (obj, self.object)
    abc_medkit.chk_medlot_object(obj)
abc_sleep.uptabc(obj)
end
----------------------------------------------------------------------------------------------------------------------
function actor_binder:use_object(obj)
heal_regen.start(obj)
end
----------------------------------------------------------------------------------------------------------------------
 

После

 
--game_stats.update_drop_item (obj, self.object)
 

Пишем

 
abc_medkit.chk_medlot_object(obj)
 

После

 
function actor_binder:update(delta)
 

Пишем

 
abc_medkit.chk_medlot_object()
heal_regen.weapontimer()
 

И все. Осталось лишь найти звуки и прописать их в директории \sounds\interface\

Автор статьи: Fireman3000, а так же спасибо Lurk моду и ABC.
Получено с http://stalkerin.gameru.net/wiki/index.php/%D0%A1%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%B0_%D0%BF%D0%BE%D1%81%D1%82%D0%B5%D0%BF%D0%B5%D0%BD%D0%BD%D0%BE%D0%B9_%D1%80%D0%B5%D0%B3%D0%B5%D0%BD%D0%B5%D1%80%D0%B0%D1%86%D0%B8%D0%B8_%D0%B6%D0%B8%D0%B7%D0%BD%D0%B8_%D0%B8%D0%B7_Lurk_mod_%D0%B8_ABC

Категория: Скрипты
Категория: Моддинг | Добавил: Hardtmuth (13.07.2012)
Просмотров: 1048 | Рейтинг: 0.0/0
Всего комментариев: 0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]

Меню сайта

Свежие прохождения






Категории раздела

Мини-чат

Наш опрос
Какое прохождение писать следующим?
Всего ответов: 2924

Поиск

Статистика

Онлайн всего: 11
Гостей: 11
Пользователей: 0








Тот самый S.T.A.L.K.E.R.







Форма входа

Войти Зарегистрироваться