Browse Source

Revert changes in schedule.cpp.

cthulhu
Night Owl 7 years ago
parent
commit
337799d811
  1. 111
      dlls/schedule.cpp

111
dlls/schedule.cpp

@ -237,7 +237,7 @@ void CBaseMonster::MaintainSchedule( void )
( m_IdealMonsterState != MONSTERSTATE_SCRIPT || m_IdealMonsterState == m_MonsterState ) ) ( m_IdealMonsterState != MONSTERSTATE_SCRIPT || m_IdealMonsterState == m_MonsterState ) )
{ {
// if we're here, then either we're being told to do something (besides dying or playing a script) // if we're here, then either we're being told to do something (besides dying or playing a script)
// or our current schedule (besides dying) is invalid. -- LRC // or our current schedule (besides dying) is invalid. -- LRC
if( (m_afConditions && !HasConditions( bits_COND_SCHEDULE_DONE ) ) || if( (m_afConditions && !HasConditions( bits_COND_SCHEDULE_DONE ) ) ||
( m_pSchedule && (m_pSchedule->iInterruptMask & bits_COND_SCHEDULE_DONE ) ) || ( m_pSchedule && (m_pSchedule->iInterruptMask & bits_COND_SCHEDULE_DONE ) ) ||
( ( m_MonsterState == MONSTERSTATE_COMBAT ) && ( m_hEnemy == 0 ) ) ) ( ( m_MonsterState == MONSTERSTATE_COMBAT ) && ( m_hEnemy == 0 ) ) )
@ -522,11 +522,6 @@ void CBaseMonster::RunTask( Task_t *pTask )
if( m_pCine->m_iDelay <= 0 && gpGlobals->time >= m_pCine->m_startTime ) if( m_pCine->m_iDelay <= 0 && gpGlobals->time >= m_pCine->m_startTime )
{ {
TaskComplete(); TaskComplete();
m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszPlay, TRUE );
if( m_fSequenceFinished )
ClearSchedule();
pev->framerate = 1.0;
//ALERT( at_aiconsole, "Script %s has begun for %s\n", STRING( m_pCine->m_iszPlay ), STRING( pev->classname ) );
} }
break; break;
} }
@ -534,7 +529,18 @@ void CBaseMonster::RunTask( Task_t *pTask )
{ {
if( m_fSequenceFinished ) if( m_fSequenceFinished )
{ {
m_pCine->SequenceDone( this ); ALERT( at_console, "Anim Finished\n" );
if( m_pCine->m_iRepeatsLeft > 0 )
{
//ALERT( at_console, "Frame %f; Repeat %d from %f\n", pev->frame, m_pCine->m_iRepeatsLeft, m_pCine->m_fRepeatFrame );
m_pCine->m_iRepeatsLeft--;
pev->frame = m_pCine->m_fRepeatFrame;
ResetSequenceInfo();
}
else
{
TaskComplete();
}
} }
break; break;
} }
@ -892,7 +898,7 @@ void CBaseMonster::StartTask( Task_t *pTask )
{ {
Activity newActivity; Activity newActivity;
if( ( m_hTargetEnt->pev->origin - pev->origin ).Length() < 1 ) if( !m_pGoalEnt || ( m_pGoalEnt->pev->origin - pev->origin ).Length() < 1 )
TaskComplete(); TaskComplete();
else else
{ {
@ -906,12 +912,24 @@ void CBaseMonster::StartTask( Task_t *pTask )
TaskComplete(); TaskComplete();
else else
{ {
if( m_hTargetEnt == 0 || !MoveToTarget( newActivity, 2 ) ) if( m_pGoalEnt != NULL )
{ {
TaskFail(); Vector vecDest;
ALERT( at_aiconsole, "%s Failed to reach target!!!\n", STRING( pev->classname ) ); vecDest = m_pGoalEnt->pev->origin;
RouteClear();
if( !MoveToLocation( newActivity, 2, vecDest ) )
{
TaskFail();
ALERT( at_aiconsole, "%s Failed to reach script!!!\n", STRING( pev->classname ) );
RouteClear();
}
} }
else
{
TaskFail();
ALERT( at_aiconsole, "%s: MoveTarget is missing!?!\n", STRING( pev->classname ) );
RouteClear();
}
} }
} }
TaskComplete(); TaskComplete();
@ -1029,7 +1047,7 @@ void CBaseMonster::StartTask( Task_t *pTask )
break; break;
case TASK_GET_PATH_TO_SPOT: case TASK_GET_PATH_TO_SPOT:
{ {
CBaseEntity *pPlayer = CBaseEntity::Instance( FIND_ENTITY_BY_CLASSNAME( NULL, "player" ) ); CBaseEntity *pPlayer = UTIL_FindEntityByClassname( 0, "player" );
if( BuildRoute( m_vecMoveGoal, bits_MF_TO_LOCATION, pPlayer ) ) if( BuildRoute( m_vecMoveGoal, bits_MF_TO_LOCATION, pPlayer ) )
{ {
TaskComplete(); TaskComplete();
@ -1057,6 +1075,21 @@ void CBaseMonster::StartTask( Task_t *pTask )
} }
break; break;
} }
case TASK_GET_PATH_TO_SCRIPT:
{
RouteClear();
if( m_pCine != 0 && MoveToLocation( m_movementActivity, 1, m_pCine->pev->origin ) )
{
TaskComplete();
}
else
{
// no way to get there =(
ALERT( at_aiconsole, "GetPathToSpot failed!!\n" );
TaskFail();
}
break;
}
case TASK_GET_PATH_TO_HINTNODE: case TASK_GET_PATH_TO_HINTNODE:
// for active idles! // for active idles!
{ {
@ -1247,11 +1280,11 @@ void CBaseMonster::StartTask( Task_t *pTask )
} }
case TASK_WAIT_FOR_SCRIPT: case TASK_WAIT_FOR_SCRIPT:
{ {
if ( m_pCine->m_iDelay <= 0 && gpGlobals->time >= m_pCine->m_startTime ) if( m_pCine->m_iDelay <= 0 && gpGlobals->time >= m_pCine->m_startTime )
{ {
TaskComplete(); //LRC - start playing immediately TaskComplete(); //LRC - start playing immediately
} }
if( m_pCine->m_iszIdle ) else if( !m_pCine->IsAction() && m_pCine->m_iszIdle )
{ {
m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszIdle, FALSE ); m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszIdle, FALSE );
if( FStrEq( STRING( m_pCine->m_iszIdle ), STRING( m_pCine->m_iszPlay ) ) ) if( FStrEq( STRING( m_pCine->m_iszIdle ), STRING( m_pCine->m_iszPlay ) ) )
@ -1265,10 +1298,50 @@ void CBaseMonster::StartTask( Task_t *pTask )
} }
case TASK_PLAY_SCRIPT: case TASK_PLAY_SCRIPT:
{ {
pev->movetype = MOVETYPE_FLY; if( m_pCine->IsAction() )
ClearBits( pev->flags, FL_ONGROUND ); {
m_scriptState = SCRIPT_PLAYING; // ALERT( at_console, "PlayScript: setting idealactivity %d\n",m_pCine->m_fAction );
break; switch( m_pCine->m_fAction )
{
case 0:
m_IdealActivity = ACT_RANGE_ATTACK1;
break;
case 1:
m_IdealActivity = ACT_RANGE_ATTACK2;
break;
case 2:
m_IdealActivity = ACT_MELEE_ATTACK1;
break;
case 3:
m_IdealActivity = ACT_MELEE_ATTACK2;
break;
case 4:
m_IdealActivity = ACT_SPECIAL_ATTACK1;
break;
case 5:
m_IdealActivity = ACT_SPECIAL_ATTACK2;
break;
case 6:
m_IdealActivity = ACT_RELOAD;
break;
case 7:
m_IdealActivity = ACT_HOP;
break;
}
pev->framerate = 1.0; // shouldn't be needed, but just in case
pev->movetype = MOVETYPE_FLY;
ClearBits( pev->flags, FL_ONGROUND );
}
else
{
m_pCine->StartSequence( (CBaseMonster *)this, m_pCine->m_iszPlay, TRUE );
if( m_fSequenceFinished )
ClearSchedule();
pev->framerate = 1.0;
//ALERT( at_aiconsole, "Script %s has begun for %s\n", STRING( m_pCine->m_iszPlay ), STRING( pev->classname ) );
}
m_scriptState = SCRIPT_PLAYING;
break;
} }
//LRC //LRC
case TASK_END_SCRIPT: case TASK_END_SCRIPT:

Loading…
Cancel
Save