Skip to content

Commit

Permalink
xrGame/ai/monsters/monster_enemy_memory.cpp: monsters now calculating…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Xottab-DUTY committed May 12, 2018
1 parent 2363442 commit b7aff60
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/xrGame/ai/monsters/monster_enemy_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ void CMonsterEnemyMemory::update()
}
}

if (monster->SoundMemory.IsRememberSound())
if (monster->SoundMemory.IsRememberSound() && g_actor
&& g_actor->memory().visual().visible_now(monster))
{
SoundElem sound;
bool dangerous;
Expand All @@ -64,12 +65,11 @@ void CMonsterEnemyMemory::update()
{
if (CEntityAlive const* enemy = smart_cast<CEntityAlive const*>(sound.who))
{
float const xz_dist = monster->Position().distance_to_xz(g_actor->Position());
float const y_dist = _abs(monster->Position().y - g_actor->Position().y);
float const xz_dist = monster->Position().distance_to_xz(enemy->Position());
float const y_dist = _abs(monster->Position().y - enemy->Position().y);

if (monster->CCustomMonster::useful(&monster->memory().enemy(), enemy) && y_dist < 10 &&
xz_dist < monster->get_feel_enemy_who_made_sound_max_distance() &&
g_actor->memory().visual().visible_now(monster))
xz_dist < monster->get_feel_enemy_who_made_sound_max_distance())
{
add_enemy(enemy);

Expand Down

0 comments on commit b7aff60

Please sign in to comment.