e4s-sdk/gamedata/scripts/xr_combat.script
2026-06-17 23:06:51 +03:00

103 lines
3.7 KiB
Text

--[[------------------------------------------------------------------------------------------------------------------
Ïåðåêëþ÷åíèå áîåâûõ ñõåì
--------------------------------------------------------------------------------------------------------------------]]
function set_combat_type(npc, actor, t)
if t == nil then
return
end
-- ýòî íóæíî äëÿ ôóíêöèé â xr_conditions.script
local storage = db.storage[npc:id()]
storage.enemy = npc:best_enemy()
local script_combat_type = nil
if t.combat_type ~= nil then
script_combat_type = xr_logic.pick_section_from_condlist(actor, npc, t.combat_type.condlist)
if script_combat_type == "nil" then
script_combat_type = nil
end
end
storage.script_combat_type = script_combat_type
t.script_combat_type = script_combat_type
end
----------------------------------------------------------------------------------------------------------------------
-- Ýâàëóàòîð ïåðåêëþ÷åíèÿ ìåæäó ñêðèïòîâûì è äâèæêîâûì áîåì
-- false - engine combat, true - script combat
----------------------------------------------------------------------------------------------------------------------
class "evaluator_check_combat" (property_evaluator)
function evaluator_check_combat:__init(name, storage) super (nil, name)
self.st = storage
end
function evaluator_check_combat:evaluate()
local st = self.st
if st.enabled and self.object:best_enemy() then
local actor = db.actor
if not actor then
return false
end
return st.script_combat_type ~= nil
end
return false
end
----------------------------------------------------------------------------------------------------------------------
-- Äóáëèðóþùèé ýâàëóàòîð âðàãîâ äëÿ ïëàíèðîâùèêà ñêðèïòîâîãî áîÿ
----------------------------------------------------------------------------------------------------------------------
class "evaluator_enemy" (property_evaluator)
function evaluator_enemy:__init(name) super (nil, name)
end
function evaluator_enemy:evaluate()
return self.object:best_enemy() ~= nil
end
----------------------------------------------------------------------------------------------------------------------
-- binder
----------------------------------------------------------------------------------------------------------------------
function add_to_binder(npc, ini, scheme, section, storage)
local manager = npc:motivation_action_manager()
manager:add_evaluator( xr_evaluators_id.script_combat, this.evaluator_check_combat("script_combat",storage) )
local action = manager:action(stalker_ids.action_combat_planner)
action:add_precondition(world_property(xr_evaluators_id.script_combat, false))
xr_combat_zombied.add_to_binder ( npc, ini, storage, manager )
xr_combat_camper.add_to_binder ( npc, ini, storage, manager )
end
function set_combat_checker(npc, ini, scheme, section)
local is_zombied = character_community(npc) == "zombied"
if section or is_zombied then
local st = xr_logic.assign_storage_and_bind(npc, ini, scheme, section)
st.logic = xr_logic.cfg_get_switch_conditions(ini, section, npc)
st.enabled = true
st.combat_type = xr_logic.cfg_get_condlist(ini, section, "combat_type", npc)
if st.combat_type == "monolith" then
st.combat_type = nil
end
-- çîìáèðîâàííûå ñðàæàþòñÿ ïî óìîë÷àíèþ íà çîìáèðîâàííîé áîåâîé ñõåìå
if not st.combat_type and is_zombied then
st.combat_type = { condlist = xr_logic.parse_condlist(npc, section, "", "zombied") }
end
if st.combat_type then
set_combat_type( npc, db.actor, st )
end
end
end
function disable_scheme(npc, scheme)
local st = db.storage[npc:id()][scheme]
if st then
st.enabled = false
end
end