add game&rawdata
This commit is contained in:
parent
0133cd976c
commit
49b34b5546
45731 changed files with 709831 additions and 0 deletions
299
gamedata/scripts/xr_smartcover.script
Normal file
299
gamedata/scripts/xr_smartcover.script
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
----------------------------------------------------------------------------------------------------
|
||||
-- smartcovers
|
||||
---------------------------------------------------------------------------------------------------------------------
|
||||
--function printf()
|
||||
--end
|
||||
local cover_substate_table = {}
|
||||
cover_substate_table["fire_target"] = "fire"
|
||||
cover_substate_table["fire_no_lookout_target"] = "fire"
|
||||
cover_substate_table["idle_target"] = "idle"
|
||||
cover_substate_table["lookout_target"] = "idle"
|
||||
|
||||
class "evaluator_use_smartcover_in_combat" (property_evaluator)
|
||||
function evaluator_use_smartcover_in_combat:__init(storage, name) super(nil, name)
|
||||
self.st = storage
|
||||
end
|
||||
function evaluator_use_smartcover_in_combat:evaluate()
|
||||
if xr_logic.is_active(self.object, self.st) then
|
||||
return self.st.use_in_combat
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
class "evaluator_need_smartcover" (property_evaluator)
|
||||
function evaluator_need_smartcover:__init(storage, name) super(nil, name)
|
||||
self.st = storage
|
||||
end
|
||||
function evaluator_need_smartcover:evaluate()
|
||||
return xr_logic.is_active(self.object, self.st)
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
class "action_smartcover_activity" (action_base)
|
||||
function action_smartcover_activity:__init (npc, action_name, storage) super(nil, action_name)
|
||||
self.st = storage
|
||||
end
|
||||
function action_smartcover_activity:initialize()
|
||||
action_base.initialize(self)
|
||||
|
||||
self.initialized = true
|
||||
|
||||
self:activate_scheme()
|
||||
end
|
||||
function action_smartcover_activity:target_selector(obj)
|
||||
if not obj:alive() then return end
|
||||
--printf("target_selector:using state [%s] for npc[%s]!!!", self.cover_state, obj:name())
|
||||
if self.cover_state == "idle_target" then
|
||||
obj:set_smart_cover_target_idle()
|
||||
elseif self.cover_state == "lookout_target" then
|
||||
self:check_target()
|
||||
obj:set_smart_cover_target_lookout()
|
||||
elseif self.cover_state == "fire_target" then
|
||||
obj:set_smart_cover_target_fire()
|
||||
elseif self.cover_state == "fire_no_lookout_target" then
|
||||
self:check_target()
|
||||
obj:set_smart_cover_target_fire_no_lookout()
|
||||
else
|
||||
self:check_target()
|
||||
obj:set_smart_cover_target_default(true)
|
||||
end
|
||||
|
||||
end
|
||||
function action_smartcover_activity:activate_scheme()
|
||||
self.st.signals = {}
|
||||
if self.initialized == nil then return end
|
||||
|
||||
local used
|
||||
local object = self.object
|
||||
object:set_smart_cover_target()
|
||||
--object:set_smart_cover_target_selector()
|
||||
self.target_enemy_id = nil
|
||||
self.cover_name, used = get_param_string(self.st.cover_name, object)
|
||||
printf("setting smartcover [gps] [%s] used [%s] for npc[%s]", self.cover_name , tostring(used), object:name())
|
||||
|
||||
--' Ïðîâåðÿåì cover_name , åñëè get_param_string âåðíóë íå òàêîå æå çíà÷åíèå èëè âîîáùå íå èñïîëüçîâàëñÿ, òî èäåì äàëüøå.
|
||||
if self.cover_name ~= self.st.cover_name or used == false then
|
||||
if se_smart_cover.registered_smartcovers[self.cover_name] == nil then
|
||||
abort("There is no smart_cover with name [%s]", self.cover_name)
|
||||
end
|
||||
|
||||
-- ÂÕÎÄ Â ÑÌÀÐÒÊÀÂÅÐ ×ÅÐÅÇ ÑÒÅÉÒ ÌÅÍÅÄÆÅÐ (ïåðåäàåì èìÿ ñìàðòêàâåðà, ëóïõîëó)
|
||||
state_mgr.set_state(self.object, "smartcover")
|
||||
|
||||
|
||||
self.target_path_condlist = xr_logic.parse_condlist(object, self.st.active_section, "target_path", self.st.target_path)
|
||||
self:check_target()
|
||||
|
||||
--' Âû÷èòûâàåì êîíäëèñò êîòîðûé âåðíåò ïîâåäåíèå ÷óâàêà â ñìàðòêàâåðå.
|
||||
self.cover_condlist = xr_logic.parse_condlist(object, self.st.active_section, "cover_state", self.st.cover_state)
|
||||
self.cover_state = xr_logic.pick_section_from_condlist(db.actor, object ,self.cover_condlist)
|
||||
self:target_selector(self.object)
|
||||
self:check_target_selector()
|
||||
|
||||
-- Íàçíà÷èì ìèíèìàëüíûå è ìàêñèìàëüíûå çíà÷åíèÿ âðåìåíè ñèäåíèÿ â àéäëå è âûãëÿäûâàíèÿ.
|
||||
--printf("idle_min[%s] idle_max[%s] lookout_min[%s] lookout_max[%s]", self.st.idle_min_time, self.st.idle_max_time, self.st.lookout_min_time, self.st.lookout_max_time )
|
||||
object:idle_min_time(self.st.idle_min_time)
|
||||
object:idle_max_time(self.st.idle_max_time)
|
||||
object:lookout_min_time(self.st.lookout_min_time)
|
||||
object:lookout_max_time(self.st.lookout_max_time)
|
||||
end
|
||||
|
||||
end
|
||||
function action_smartcover_activity:check_target_selector()
|
||||
local object = self.object
|
||||
--if object:in_smart_cover() == false then
|
||||
-- printf("DEFAULT_BEHAVIOUR")
|
||||
-- return
|
||||
--end
|
||||
if self.cover_state == "nil" then
|
||||
object:set_smart_cover_target_selector()
|
||||
else
|
||||
object:set_smart_cover_target_selector(self.target_selector, self)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function action_smartcover_activity:check_target()
|
||||
local object = self.object
|
||||
|
||||
local target_path = xr_logic.pick_section_from_condlist(db.actor, self.object, self.target_path_condlist)
|
||||
|
||||
if target_path ~= "nil" and target_path ~= nil then
|
||||
self.target_path, used = get_param_string(target_path, object)
|
||||
if self.target_path ~= "nil" then
|
||||
if level.patrol_path_exists(self.target_path) then
|
||||
--printf("target_selector:using fire_point[%s] for npc[%s]!!!", self.target_path, self.object:name())
|
||||
object:set_smart_cover_target (patrol(self.target_path):point(0))
|
||||
self.fire_pos = patrol(self.target_path):point(0)
|
||||
return true
|
||||
else
|
||||
abort("There is no patrol path [%s] for npc [%s]", self.target_path, object:name())
|
||||
end
|
||||
end
|
||||
elseif self.st.target_enemy ~= nil then
|
||||
--printf("setting target_enemy [actor] for npc[%s]", object:name())
|
||||
self.target_enemy_id = get_story_object(self.st.target_enemy) and get_story_object(self.st.target_enemy):id()
|
||||
if self.target_enemy_id ~= nil and level.object_by_id(self.target_enemy_id):alive() then
|
||||
--printf("setting target_enemy [%s] for npc[%s]", level.object_by_id(self.target_enemy_id):name(), object:name())
|
||||
object:set_smart_cover_target(level.object_by_id(self.target_enemy_id))
|
||||
self.fire_pos = level.object_by_id(self.target_enemy_id):position()
|
||||
return true
|
||||
end
|
||||
elseif self.st.target_position ~= nil then
|
||||
object:set_smart_cover_target(self.st.target_position)
|
||||
self.fire_pos = self.st.target_position
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
function action_smartcover_activity:execute()
|
||||
action_base.execute(self)
|
||||
local storage = db.storage[self.object:id()]
|
||||
|
||||
local need_cover_state = xr_logic.pick_section_from_condlist(db.actor, self.object ,self.cover_condlist)
|
||||
|
||||
if need_cover_state == "default_behaviour" or cover_substate_table[self.cover_state] ~= cover_substate_table[need_cover_state] then
|
||||
self.cover_state = need_cover_state
|
||||
end
|
||||
|
||||
self:check_target_selector()
|
||||
|
||||
if self.target_enemy_id ~= nil and self.object:in_smart_cover() then
|
||||
if level.object_by_id(self.target_enemy_id) and self.object:in_current_loophole_fov(level.object_by_id(self.target_enemy_id):position()) == true then
|
||||
self.st.signals["enemy_in_fov"] = true
|
||||
self.st.signals["enemy_not_in_fov"] = nil
|
||||
else
|
||||
self.st.signals["enemy_in_fov"] = nil
|
||||
self.st.signals["enemy_not_in_fov"] = true
|
||||
end
|
||||
end
|
||||
|
||||
if self.st.sound_idle ~= nil then
|
||||
xr_sound.set_sound_play(self.object:id(), self.st.sound_idle)
|
||||
end
|
||||
end
|
||||
function action_smartcover_activity:finalize()
|
||||
--self.move_mgr:finalize()
|
||||
|
||||
self.initialized = nil
|
||||
action_base.finalize(self)
|
||||
end
|
||||
--' Âîçâðàùàåò äîñòèã ëè ïåðñîíàæ òî÷êè íà÷àëà ðàáîòû ñõåìû
|
||||
function action_smartcover_activity:position_riched()
|
||||
return self.object:in_smart_cover()
|
||||
end
|
||||
-- Îáíóëåíèå ïîëåé ïðè äåàêòèâàöèè ñõåìû
|
||||
function action_smartcover_activity:deactivate()
|
||||
self.st.cover_name = nil
|
||||
self.st.loophole_name = nil
|
||||
end
|
||||
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
-- Smartcover binder
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
function add_to_binder(npc, ini, scheme, section, storage)
|
||||
printf("DEBUG: add_to_binder: scheme='%s', section='%s'", scheme, section)
|
||||
local operators = {}
|
||||
local properties = {}
|
||||
|
||||
local manager = npc:motivation_action_manager()
|
||||
|
||||
properties["need_smartcover"] = xr_evaluators_id.smartcover_action + 1
|
||||
properties["use_smartcover_in_combat"] = xr_evaluators_id.smartcover_action + 2
|
||||
properties["state_mgr_logic_active"] = xr_evaluators_id.state_mgr + 4
|
||||
|
||||
operators["action_smartcover"] = xr_actions_id.smartcover_action
|
||||
operators["action_combat_smartcover"] = xr_actions_id.smartcover_action + 2
|
||||
|
||||
-- -- evaluators
|
||||
manager:add_evaluator(properties["need_smartcover"], this.evaluator_need_smartcover(storage, "smartcover_need"))
|
||||
manager:add_evaluator(properties["use_smartcover_in_combat"], this.evaluator_use_smartcover_in_combat(storage, "use_smartcover_in_combat"))
|
||||
|
||||
|
||||
local new_action = this.action_smartcover_activity(npc, "action_smartcover_activity", storage)
|
||||
new_action:add_precondition(world_property(stalker_ids.property_alive, true))
|
||||
new_action:add_precondition(world_property(stalker_ids.property_anomaly,false))
|
||||
new_action:add_precondition(world_property(properties["need_smartcover"], true))
|
||||
new_action:add_precondition(world_property(properties["use_smartcover_in_combat"], false))
|
||||
new_action:add_precondition(world_property(stalker_ids.property_enemy,false))
|
||||
|
||||
new_action:add_precondition (world_property(xr_evaluators_id.stohe_meet_base + 1,false))
|
||||
new_action:add_precondition (world_property(xr_evaluators_id.sidor_wounded_base + 0, false))
|
||||
new_action:add_precondition (world_property(xr_evaluators_id.abuse_base, false))
|
||||
|
||||
new_action:add_effect (world_property(properties["need_smartcover"], false))
|
||||
new_action:add_effect (world_property(properties["state_mgr_logic_active"], false))
|
||||
--new_action:add_effect (world_property(stalker_ids.property_danger,false))
|
||||
manager:add_action(operators["action_smartcover"], new_action)
|
||||
|
||||
-- Çàðåãèñòðèðîâàòü âñå actions, â êîòîðûõ äîëæåí áûòü âûçâàí ìåòîä reset_scheme ïðè èçìåíåíèè íàñòðîåê ñõåìû:
|
||||
xr_logic.subscribe_action_for_events(npc, storage, new_action)
|
||||
|
||||
new_action = this.action_smartcover_activity(npc, "action_combat_smartcover", storage)
|
||||
new_action:add_precondition(world_property(stalker_ids.property_alive, true))
|
||||
new_action:add_precondition(world_property(stalker_ids.property_anomaly,false))
|
||||
new_action:add_precondition(world_property(properties["need_smartcover"], true))
|
||||
new_action:add_precondition(world_property(properties["use_smartcover_in_combat"], true))
|
||||
|
||||
new_action:add_precondition (world_property(xr_evaluators_id.stohe_meet_base + 1,false))
|
||||
new_action:add_precondition (world_property(xr_evaluators_id.sidor_wounded_base + 0, false))
|
||||
new_action:add_precondition (world_property(xr_evaluators_id.abuse_base, false))
|
||||
|
||||
new_action:add_effect (world_property(properties["need_smartcover"], false))
|
||||
new_action:add_effect (world_property(stalker_ids.property_enemy,false))
|
||||
new_action:add_effect (world_property(stalker_ids.property_danger,false))
|
||||
new_action:add_effect (world_property(properties["state_mgr_logic_active"], false))
|
||||
-- new_action:add_effect (world_property(properties["state_mgr_idle_smartcover"], false))
|
||||
manager:add_action(operators["action_combat_smartcover"], new_action)
|
||||
|
||||
-- Çàðåãèñòðèðîâàòü âñå actions, â êîòîðûõ äîëæåí áûòü âûçâàí ìåòîä reset_scheme ïðè èçìåíåíèè íàñòðîåê ñõåìû:
|
||||
xr_logic.subscribe_action_for_events(npc, storage, new_action)
|
||||
|
||||
new_action = manager:action(xr_actions_id.alife)
|
||||
new_action:add_precondition(world_property(properties["need_smartcover"], false))
|
||||
|
||||
new_action = manager:action (stalker_ids.action_combat_planner)
|
||||
new_action:add_precondition (world_property(properties["use_smartcover_in_combat"], false))
|
||||
end
|
||||
|
||||
|
||||
function set_scheme(npc, ini, scheme, section, gulag_name)
|
||||
printf("DEBUG: set_scheme: scheme='%s', section='%s'", scheme, section)
|
||||
local st = xr_logic.assign_storage_and_bind(npc, ini, scheme, section)
|
||||
--printf("DEBUG: set_scheme: storage assigned")
|
||||
|
||||
st.logic = xr_logic.cfg_get_switch_conditions(ini, section, npc)
|
||||
|
||||
st.cover_name = utils.cfg_get_string (ini, section, "cover_name", npc, false, "", "$script_id$_cover" )
|
||||
st.loophole_name = utils.cfg_get_string (ini, section, "loophole_name", npc, false, "", nil)
|
||||
st.cover_state = utils.cfg_get_string (ini, section, "cover_state", npc, false, "", "default_behaviour")
|
||||
st.target_enemy = utils.cfg_get_string (ini, section, "target_enemy", npc, false, "", nil)
|
||||
st.target_path = utils.cfg_get_string (ini, section, "target_path", npc, false, "", "nil")
|
||||
st.idle_min_time = utils.cfg_get_number (ini, section, "idle_min_time", npc, false, 6)
|
||||
st.idle_max_time = utils.cfg_get_number (ini, section, "idle_max_time", npc, false, 10)
|
||||
st.lookout_min_time = utils.cfg_get_number (ini, section, "lookout_min_time", npc, false, 6)
|
||||
st.lookout_max_time = utils.cfg_get_number (ini, section, "lookout_max_time", npc, false, 10)
|
||||
st.exit_body_state = utils.cfg_get_string (ini, section, "exit_body_state", npc ,false, "", "stand")
|
||||
st.use_precalc_cover = utils.cfg_get_bool (ini, section, "use_precalc_cover", npc, false, false)
|
||||
st.use_in_combat = utils.cfg_get_bool (ini, section, "use_in_combat", npc, false, false)
|
||||
st.weapon_type = utils.cfg_get_string (ini, section, "weapon_type", npc, false, false)
|
||||
st.moving = utils.cfg_get_string (ini, section, "def_state_moving", npc, false, "", "sneak")
|
||||
st.sound_idle = utils.cfg_get_string (ini, section, "sound_idle", npc, false, "")
|
||||
|
||||
--[[
|
||||
if st.use_precalc_cover == true then
|
||||
local smart = sim_board.get_sim_board():get_smart_by_name(gulag_name)
|
||||
local tcover = cover_manager.get_cover(npc, smart)
|
||||
if tcover ~= nil and tcover.is_smart_cover then
|
||||
local level_id = game_graph():vertex(smart.m_game_vertex_id):level_id()
|
||||
printf("precalc cover:lvl_id[%s] vertex_id[%s]", tostring(level_id), tostring(tcover.cover_vertex_id))
|
||||
cover = se_smart_cover.registered_smartcovers_by_lv_id[level_id][tcover.cover_vertex_id]
|
||||
printf("precalc cover_name [%s]", cover:name())
|
||||
st.cover_name = cover:name()
|
||||
st.target_position = tcover.look_pos
|
||||
end
|
||||
end
|
||||
]]--
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue