Skip to content

Commit b7aff60

Browse files
committed
xrGame/ai/monsters/monster_enemy_memory.cpp: monsters now calculating distance to enemy that created sound they hear
Calculating distance to actor is wrong Also, I moved actor presence check to be earlier, so we don't do unneeded calculations
1 parent 2363442 commit b7aff60

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/xrGame/ai/monsters/monster_enemy_memory.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ void CMonsterEnemyMemory::update()
5555
}
5656
}
5757

58-
if (monster->SoundMemory.IsRememberSound())
58+
if (monster->SoundMemory.IsRememberSound() && g_actor
59+
&& g_actor->memory().visual().visible_now(monster))
5960
{
6061
SoundElem sound;
6162
bool dangerous;
@@ -64,12 +65,11 @@ void CMonsterEnemyMemory::update()
6465
{
6566
if (CEntityAlive const* enemy = smart_cast<CEntityAlive const*>(sound.who))
6667
{
67-
float const xz_dist = monster->Position().distance_to_xz(g_actor->Position());
68-
float const y_dist = _abs(monster->Position().y - g_actor->Position().y);
68+
float const xz_dist = monster->Position().distance_to_xz(enemy->Position());
69+
float const y_dist = _abs(monster->Position().y - enemy->Position().y);
6970

7071
if (monster->CCustomMonster::useful(&monster->memory().enemy(), enemy) && y_dist < 10 &&
71-
xz_dist < monster->get_feel_enemy_who_made_sound_max_distance() &&
72-
g_actor->memory().visual().visible_now(monster))
72+
xz_dist < monster->get_feel_enemy_who_made_sound_max_distance())
7373
{
7474
add_enemy(enemy);
7575

0 commit comments

Comments
 (0)