NSMonster: Fix oversight where targets would get overriden by AlertNearby()

Make it so Pain() has a random chance to change targets.
This commit is contained in:
Marco Cawthorne 2022-01-31 10:12:41 -08:00
parent 3fc7c477f0
commit 7ce222007c
Signed by: eukara
GPG key ID: C196CD8BA993248A

View file

@ -160,6 +160,11 @@ NSMonster::AlertNearby(void)
//dprint(sprintf("Alert! %s get %s\n", w.classname, m_eEnemy.classname));
NSMonster f = (NSMonster)w;
/* we shouldn't override this when they already got a target */
if (f.m_eEnemy != __NULL__)
continue;
f.m_eEnemy = m_eEnemy;
}
}
@ -619,7 +624,7 @@ NSMonster::touch(void)
void
NSMonster::Pain(void)
{
if (!m_eEnemy)
if (!m_eEnemy || (random() < 0.5))
m_eEnemy = g_dmg_eAttacker;
AlertNearby();