Skocz do zawartości

System stopniowej regeneracji życia [SoC]


Gość Diegtiariow

Rekomendowane odpowiedzi

NAZWA: System stopniowej regeneracji życia [SoC]
AUTOR ARTYKUŁU: Fireman3000
DOPEŁNIŁ: Darkscape
PODZIĘKOWANIA: Lurk mod, ABC mod
ARTYKUŁ WZIĘTY Z: stalker inside

 

OPIS DZIAŁAŃ:

Spoiler

KROK 1:

Spoiler

Na początek stworzymy skrypt. Np. health_effects.scripts:

---System jedzenia i stopniowego leczenia z LURK mod---

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
]]--

Parametr:

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

jest odpowiedzialny za odtwarzany dźwięk.

 

KROK 2:

Spoiler

Teraz tworzymy skrypt 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" -- Nie testowano wariantu no. Ale prawie jest pewne, że będzie wylot

-- How many minutes should take to complete the healing process.
hp_fullhealth_time = 0.125 -- Ilość podczas której zostanie użyta apteczka

--0.25

-- Health update time in MS. 1000 = 1 Second.
hupd_time = 50 -- Update czasu. Lepiej nie ruszać

-- Time modulation
time_mod=0

-- HP Healed. No higher than 1.
hp_med_kit = 0.65 -- Parametr odpowiadający za przywrócenia życia jedną apteczką. Dokładniej za prędkość przywrócenia
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

 

 

KROK 3:

Spoiler

Leziemy do bind_stalker.script:

1) Po:

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

piszemy:

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

 

W efekcie otrzymujemy to:

Spoiler
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)

 

2) Po:

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

piszemy:

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

 

W efekcie otrzymujemy to:

Spoiler
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)

 

3) Szukamy funkcji:

function actor_binder:on_item_drop (obj)

i po jej zakończeniu piszemy:

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

 

Efekt:

----------------------------------------------------------------------------------------------------------------------
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
----------------------------------------------------------------------------------------------------------------------

4) Po:

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

piszemy:

abc_medkit.chk_medlot_object(obj)

 

5) Po:

function actor_binder:update(delta)

piszemy:

abc_medkit.chk_medlot_object()
heal_regen.weapontimer()

Następnie musisz znaleźć dźwięki i dodać je do katalogu \sounds\interface\

 

KROK 4:

Spoiler

Następnie przechodzimy do pliku config\misc\items.ltx:

Szukamy sekcji apteczek:

 ([medkit],[medkit_army],[medkit_scientic])

i zmień w nich parametr eat_health na 0.0, w przeciwnym razie aktor zostanie uleczony dwukrotnie (najpierw od razu, zgodnie ze standardem, a potem stopniowo).

 

 

ŹRÓDŁO:

https://ap-pro.ru/forums/topic/1207-soc-sistema-postepennoy-regeneracii-zhizni/

Odnośnik do komentarza
Udostępnij na innych stronach

Dołącz do dyskusji

Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.
Uwaga: Twój wpis zanim będzie widoczny, będzie wymagał zatwierdzenia moderatora.

Gość
Dodaj odpowiedź do tematu...

×   Wklejono zawartość z formatowaniem.   Usuń formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Odnośnik został automatycznie osadzony.   Przywróć wyświetlanie jako odnośnik

×   Przywrócono poprzednią zawartość.   Wyczyść edytor

×   Nie możesz bezpośrednio wkleić grafiki. Dodaj lub załącz grafiki z adresu URL.

×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Korzystając z tej strony, zgadzasz się na nasze Warunki użytkowania.