Skip to content

Commit 429e640

Browse files
xrSimpodinXottab-DUTY
authored andcommitted
Update immediately when calling sobj:brain():update()
1 parent f22f495 commit 429e640

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/xrGame/alife_monster_brain_script.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
using namespace luabind;
1515

1616
CALifeMonsterMovementManager* get_movement(const CALifeMonsterBrain* brain) { return (&brain->movement()); }
17-
SCRIPT_EXPORT(CALifeMonsterBrain, (), {
18-
module(luaState)[class_<CALifeMonsterBrain>("CALifeMonsterBrain")
19-
.def("movement", &get_movement)
20-
.def("update", &CALifeMonsterBrain::update)
21-
.def("can_choose_alife_tasks",
22-
(void (CALifeMonsterBrain::*)(bool)) & CALifeMonsterBrain::can_choose_alife_tasks)];
17+
SCRIPT_EXPORT(CALifeMonsterBrain, (),
18+
{
19+
module(luaState)
20+
[
21+
class_<CALifeMonsterBrain>("CALifeMonsterBrain")
22+
.def("movement", &get_movement)
23+
.def("update", &CALifeMonsterBrain::update_script)
24+
.def("can_choose_alife_tasks", (void (CALifeMonsterBrain::*)(bool)) & CALifeMonsterBrain::can_choose_alife_tasks)
25+
];
2326
});

src/xrServerEntities/alife_monster_brain.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void CALifeMonsterBrain::process_task()
9696
movement().detail().target(*task);
9797
}
9898

99-
void CALifeMonsterBrain::select_task()
99+
void CALifeMonsterBrain::select_task(const bool forced)
100100
{
101101
if (object().m_smart_terrain_id != 0xffff)
102102
return;
@@ -106,7 +106,7 @@ void CALifeMonsterBrain::select_task()
106106

107107
ALife::_TIME_ID current_time = ai().alife().time_manager().game_time();
108108

109-
if (m_last_search_time + m_time_interval > current_time)
109+
if (!forced && m_last_search_time + m_time_interval > current_time)
110110
return;
111111

112112
m_last_search_time = current_time;
@@ -134,7 +134,7 @@ void CALifeMonsterBrain::select_task()
134134
}
135135
}
136136

137-
void CALifeMonsterBrain::update()
137+
void CALifeMonsterBrain::update(const bool forced)
138138
{
139139
#if 0 // def DEBUG
140140
if (!Level().MapManager().HasMapLocation("debug_stalker",object().ID)) {
@@ -148,7 +148,7 @@ void CALifeMonsterBrain::update()
148148
}
149149
#endif
150150

151-
select_task();
151+
select_task(forced);
152152

153153
if (object().m_smart_terrain_id != 0xffff)
154154
process_task();

src/xrServerEntities/alife_monster_brain.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CALifeMonsterBrain
3535

3636
// sad, but true
3737
public:
38-
void select_task();
38+
void select_task(const bool forced = false);
3939

4040
private:
4141
void process_task();
@@ -56,7 +56,8 @@ class CALifeMonsterBrain
5656
void on_switch_offline();
5757

5858
public:
59-
void update();
59+
void update(const bool forced = false);
60+
void update_script() { this->update(true); }
6061
bool perform_attack();
6162
ALife::EMeetActionType action_type(
6263
CSE_ALifeSchedulable* tpALifeSchedulable, const int& iGroupIndex, const bool& bMutualDetection);

0 commit comments

Comments
 (0)