Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When finding nearest friend, skip the dying ones as well #398

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

FreeSlave
Copy link
Member

Some talkmonster code leads to the monster changing their schedule.

CBaseEntity *pFriend = FindNearestFriend( FALSE );
if( pFriend && pFriend->IsAlive() )
{
// only if not dead or dying!
CTalkMonster *pTalkMonster = (CTalkMonster *)pFriend;
pTalkMonster->ChangeSchedule( slIdleStopShooting );
}

void CTalkMonster::SetAnswerQuestion( CTalkMonster *pSpeaker )
{
if( !m_pCine )
ChangeSchedule( slIdleResponse );
m_hTalkTarget = (CBaseMonster *)pSpeaker;
}

The FindNearestFriend (used in both cases) can return a dying (but not dead yet) monster because IsAlive is implemented differently for monsters (it returns true if monster is in dying animation).

To reproduce the bug:

  1. Have two monster_barneys nearby
  2. Kill one of them.
  3. Kill the second one while the first one is still in dying animation.

The first barney will play a death sound two times because at the time when the second barney takes damage, it makes the first barney change his schedule to slIdleStopShooting, and then he gets back to the dying schedule since he's in the dead state, playing the death sound again via TASK_SOUND_DIE.
Same thing potentially can happen if the monster that is chosen to answer the question is dying at the moment of question being asked, but it's harder to reproduce.

@nekonomicon nekonomicon merged commit 3cf40cc into FWGS:master Oct 17, 2023
4 checks passed
@FreeSlave FreeSlave deleted the dying_talkmonster_fix branch October 17, 2023 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants