47 lines
1.6 KiB
Text
47 lines
1.6 KiB
Text
----------------------------------------------------------------------------------------------------
|
|
-- Mob combat
|
|
----------------------------------------------------------------------------------------------------
|
|
-- Ðàçðàáîò÷èê: Andrey Fidrya (Zmey) af@svitonline.com
|
|
----------------------------------------------------------------------------------------------------
|
|
|
|
class "mob_combat"
|
|
|
|
function mob_combat:__init(obj, storage)
|
|
self.object = obj
|
|
self.st = storage
|
|
end
|
|
|
|
function mob_combat:combat_callback()
|
|
printf("_bp: mob_combat:combat_callback()")
|
|
if self.st.enabled and self.object:get_enemy() then
|
|
if db.storage[self.object:id()].active_scheme then
|
|
if xr_logic.try_switch_to_another_section(self.object, self.st, db.actor) then
|
|
return
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
---------------------------------------------------------------------------------------------------------------------
|
|
function add_to_binder(npc, ini, scheme, section, storage)
|
|
printf("DEBUG: add_to_binder: npc:name()='%s', scheme='%s', section='%s'", npc:name(), scheme, section)
|
|
|
|
local new_action = mob_combat(npc, storage)
|
|
storage.action = new_action
|
|
|
|
xr_logic.subscribe_action_for_events(npc, storage, new_action)
|
|
end
|
|
|
|
function set_scheme(npc, ini, scheme, section, gulag_name)
|
|
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
|
|
end
|
|
|
|
function disable_scheme(npc, scheme)
|
|
local st = db.storage[npc:id()][scheme]
|
|
if st then
|
|
st.enabled = false
|
|
end
|
|
end
|
|
|