Для начала создадим скрипт. Например 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 ]]--
Отвечает за воспроизводимый звук. Так что если его нет, поймаете вылет. Теперь создаёте скрипт 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. После
---------------------------------------------------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------------------------------------------------
Затем надо найти звуки и прописать их в директории \sounds\interface\
Далее идем в файл config\misc\items.ltx, ищем секции аптечек ([medkit],[medkit_army],[medkit_scientic]) и меняем в них параметр eat_health на 0.0, иначе актер будет лечится дважды (сначала сразу, по стандартному, а потом уже постепенно)
Автор статьи: Fireman3000, дополнил Darkscape, а так же спасибо Lurk моду и ABC. Статья взята из stalker inside
Сообщение отредактировал supei-sa - Среда, 07.09.2011, 16:18
мод конечно хорош.Ну без худа как-то тупо смотрится.Я его в своем моде модифицировал,что бы еще и худ был.Получилось неплохо.А ABC_MEDKIT лучше убрать. ним не работает.
Хотя,если люди знакомы со скриптами,можно сделать простенький биндер для предметов,и через use_callback в данном биндере прописать,что будет происходить во время использования предмета.Так как биндер актора не резиновый.И просто потеря милисекунд.Просто если предметы будут иметь собственный биндер,то возможности значительно вырастают.Преимущество данного способа велики.Но не все модеры хорошо в скриптах разбираються.
Сообщение отредактировал panzyuza - Вторник, 27.09.2011, 19:10
Вот пример.Создаем скрипт bind_item.script и пишем следующее
--//---------------------------------------- --//Биндер предметов --//Автор: malandrinus --//Последнее редакторование Panzyuza --//-----------------------------------------
function init(obj) local new_binder = item_binder(obj) obj:bind_object(new_binder) end
class "item_binder" (object_binder) function item_binder:__init(obj) super(obj) -- get_console():execute("item_binder:__init") end
function item_binder:reload(section) -- get_console():execute("item_binder:reload") object_binder.reload(self, section) end
function item_binder:reinit() -- get_console():execute("item_binder:reinit") object_binder.reinit(self) self.object:set_callback(callback.use_object, self.use_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) end
function item_binder:update(delta) local actor_pos = db.actor:position() local obj_pos = self.object:position() local dist = actor_pos:distance_to(obj_pos) -- get_console():execute("item_binder:update_dist="..dist.."_delta="..delta) object_binder.update(self, delta) end
function item_binder:net_spawn(data) -- get_console():execute("item_binder:net_spawn") return object_binder.net_spawn(self, data) end
function item_binder:net_destroy() -- get_console():execute("item_binder:net_destroy") object_binder.net_destroy(self) 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) end
function item_binder:net_save_relevant() -- get_console():execute("item_binder:net_save_relevant") return true end
function item_binder:save(packet) -- get_console():execute("item_binder:save") object_binder.save(self, packet) end
function item_binder:load(reader) -- get_console():execute("item_binder:load") object_binder.load(self, reader) end
function item_binder:on_item_take (obj) end
function item_binder:on_item_drop (obj) end
function item_binder:use_callback(obj, who) -- get_console():execute("item_binder:use_callback") end
А в секцию предмета вставляем
Code
script_binding = bind_item.init
Таким образом наш предмет будет обрабатываться через данный биндер. На практике не проверял,но тоеритически должно работать.И в use_callback() вставляем heal_regen.start(obj) И в апдейт биндера heal_regen.weapontimer() Но стоит учитывать,что все предметы,прописанные в скрипте heal_regen стоит апдейтить через данный биндер.
Сообщение отредактировал panzyuza - Вторник, 27.09.2011, 20:40
да нефига че то неполучается вроде исправил первы раз жму востанавливает медлено здоровье но когда гг делают хит то здоровье продолжает самое востанавливатся а когда жму второй раз использовать то здоровье уже невостанавливается