diff --git a/src/xrGame/alife_monster_brain_script.cpp b/src/xrGame/alife_monster_brain_script.cpp index cb337304c61..91e51cae432 100644 --- a/src/xrGame/alife_monster_brain_script.cpp +++ b/src/xrGame/alife_monster_brain_script.cpp @@ -14,10 +14,13 @@ using namespace luabind; CALifeMonsterMovementManager* get_movement(const CALifeMonsterBrain* brain) { return (&brain->movement()); } -SCRIPT_EXPORT(CALifeMonsterBrain, (), { - module(luaState)[class_("CALifeMonsterBrain") - .def("movement", &get_movement) - .def("update", &CALifeMonsterBrain::update) - .def("can_choose_alife_tasks", - (void (CALifeMonsterBrain::*)(bool)) & CALifeMonsterBrain::can_choose_alife_tasks)]; +SCRIPT_EXPORT(CALifeMonsterBrain, (), +{ + module(luaState) + [ + class_("CALifeMonsterBrain") + .def("movement", &get_movement) + .def("update", &CALifeMonsterBrain::update_script) + .def("can_choose_alife_tasks", (void (CALifeMonsterBrain::*)(bool)) & CALifeMonsterBrain::can_choose_alife_tasks) + ]; }); diff --git a/src/xrServerEntities/alife_monster_brain.cpp b/src/xrServerEntities/alife_monster_brain.cpp index cb1194aa786..3916027637c 100644 --- a/src/xrServerEntities/alife_monster_brain.cpp +++ b/src/xrServerEntities/alife_monster_brain.cpp @@ -96,7 +96,7 @@ void CALifeMonsterBrain::process_task() movement().detail().target(*task); } -void CALifeMonsterBrain::select_task() +void CALifeMonsterBrain::select_task(const bool forced) { if (object().m_smart_terrain_id != 0xffff) return; @@ -106,7 +106,7 @@ void CALifeMonsterBrain::select_task() ALife::_TIME_ID current_time = ai().alife().time_manager().game_time(); - if (m_last_search_time + m_time_interval > current_time) + if (!forced && m_last_search_time + m_time_interval > current_time) return; m_last_search_time = current_time; @@ -134,7 +134,7 @@ void CALifeMonsterBrain::select_task() } } -void CALifeMonsterBrain::update() +void CALifeMonsterBrain::update(const bool forced) { #if 0 // def DEBUG if (!Level().MapManager().HasMapLocation("debug_stalker",object().ID)) { @@ -148,7 +148,7 @@ void CALifeMonsterBrain::update() } #endif - select_task(); + select_task(forced); if (object().m_smart_terrain_id != 0xffff) process_task(); diff --git a/src/xrServerEntities/alife_monster_brain.h b/src/xrServerEntities/alife_monster_brain.h index b5da072b906..1bf18609f5f 100644 --- a/src/xrServerEntities/alife_monster_brain.h +++ b/src/xrServerEntities/alife_monster_brain.h @@ -35,7 +35,7 @@ class CALifeMonsterBrain // sad, but true public: - void select_task(); + void select_task(const bool forced = false); private: void process_task(); @@ -56,7 +56,8 @@ class CALifeMonsterBrain void on_switch_offline(); public: - void update(); + void update(const bool forced = false); + void update_script() { this->update(true); } bool perform_attack(); ALife::EMeetActionType action_type( CSE_ALifeSchedulable* tpALifeSchedulable, const int& iGroupIndex, const bool& bMutualDetection);