Properly exit medic healing when schedule is changed forcibly

This commit is contained in:
Roman Chistokhodov 2019-11-12 08:55:17 +03:00
parent 5ba209e66f
commit 3c6ad215d1
3 changed files with 9 additions and 2 deletions

View File

@ -172,6 +172,7 @@ public:
void ClearSchedule( void ); void ClearSchedule( void );
BOOL FScheduleDone( void ); BOOL FScheduleDone( void );
void ChangeSchedule( Schedule_t *pNewSchedule ); void ChangeSchedule( Schedule_t *pNewSchedule );
virtual void OnChangeSchedule( Schedule_t *pNewSchedule ) {}
void NextScheduledTask( void ); void NextScheduledTask( void );
Schedule_t *ScheduleInList( const char *pName, Schedule_t **pList, int listCount ); Schedule_t *ScheduleInList( const char *pName, Schedule_t **pList, int listCount );

View File

@ -250,6 +250,7 @@ public:
void StartTask( Task_t *pTask ); void StartTask( Task_t *pTask );
Schedule_t *GetSchedule ( void ); Schedule_t *GetSchedule ( void );
Schedule_t *GetScheduleOfType(int Type); Schedule_t *GetScheduleOfType(int Type);
void OnChangeSchedule( Schedule_t *pNewSchedule );
void StopFollowing( BOOL clearSchedule ); void StopFollowing( BOOL clearSchedule );
void SetAnswerQuestion(CTalkMonster *pSpeaker); void SetAnswerQuestion(CTalkMonster *pSpeaker);
@ -3623,12 +3624,16 @@ void CMedic::RunTask(Task_t *pTask)
} }
} }
Schedule_t *CMedic::GetSchedule() void CMedic::OnChangeSchedule( Schedule_t *pNewSchedule )
{ {
if (m_fHealing) { if (m_fHealing) {
StopHealing(); StopHealing();
} }
CHFGrunt::OnChangeSchedule( pNewSchedule );
}
Schedule_t *CMedic::GetSchedule()
{
Schedule_t* prioritizedSchedule = PrioritizedSchedule(); Schedule_t* prioritizedSchedule = PrioritizedSchedule();
if (prioritizedSchedule) if (prioritizedSchedule)
return prioritizedSchedule; return prioritizedSchedule;
@ -3866,7 +3871,6 @@ void CMedic::StartFollowingHealTarget(CBaseEntity *pTarget)
m_hTargetEnt = pTarget; m_hTargetEnt = pTarget;
ClearConditions( bits_COND_CLIENT_PUSH ); ClearConditions( bits_COND_CLIENT_PUSH );
ClearSchedule(); ClearSchedule();
ChangeSchedule(GetScheduleOfType(SCHED_MEDIC_HEAL));
ALERT(at_aiconsole, "Medic started to follow injured %s\n", STRING(pTarget->pev->classname)); ALERT(at_aiconsole, "Medic started to follow injured %s\n", STRING(pTarget->pev->classname));
} }

View File

@ -79,6 +79,8 @@ void CBaseMonster::ChangeSchedule( Schedule_t *pNewSchedule )
{ {
ASSERT( pNewSchedule != NULL ); ASSERT( pNewSchedule != NULL );
OnChangeSchedule( pNewSchedule );
m_pSchedule = pNewSchedule; m_pSchedule = pNewSchedule;
m_iScheduleIndex = 0; m_iScheduleIndex = 0;
m_iTaskStatus = TASKSTATUS_NEW; m_iTaskStatus = TASKSTATUS_NEW;