Skip to content

Commit

Permalink
Update immediately when calling sobj:brain():update()
Browse files Browse the repository at this point in the history
  • Loading branch information
xrSimpodin authored and Xottab-DUTY committed Dec 23, 2017
1 parent f22f495 commit 429e640
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
15 changes: 9 additions & 6 deletions src/xrGame/alife_monster_brain_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
using namespace luabind;

CALifeMonsterMovementManager* get_movement(const CALifeMonsterBrain* brain) { return (&brain->movement()); }
SCRIPT_EXPORT(CALifeMonsterBrain, (), {
module(luaState)[class_<CALifeMonsterBrain>("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>("CALifeMonsterBrain")
.def("movement", &get_movement)
.def("update", &CALifeMonsterBrain::update_script)
.def("can_choose_alife_tasks", (void (CALifeMonsterBrain::*)(bool)) & CALifeMonsterBrain::can_choose_alife_tasks)
];
});
8 changes: 4 additions & 4 deletions src/xrServerEntities/alife_monster_brain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)) {
Expand All @@ -148,7 +148,7 @@ void CALifeMonsterBrain::update()
}
#endif

select_task();
select_task(forced);

if (object().m_smart_terrain_id != 0xffff)
process_task();
Expand Down
5 changes: 3 additions & 2 deletions src/xrServerEntities/alife_monster_brain.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CALifeMonsterBrain

// sad, but true
public:
void select_task();
void select_task(const bool forced = false);

private:
void process_task();
Expand All @@ -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);
Expand Down

0 comments on commit 429e640

Please sign in to comment.