Added idle and alert schedule selection to npc_shadow_walker

This commit is contained in:
1upD 2018-09-27 12:02:59 -04:00
parent 06a40e6dc0
commit bcaa781ad9

View File

@ -83,7 +83,9 @@ public:
int SelectFailSchedule(int failedSchedule, int failedTask, AI_TaskFailureCode_t taskFailCode); int SelectFailSchedule(int failedSchedule, int failedTask, AI_TaskFailureCode_t taskFailCode);
int SelectScheduleRetrieveItem(); int SelectScheduleRetrieveItem();
int SelectSchedule(); int SelectSchedule();
int SelectIdleSchedule();
int SelectAlertSchedule();
int SelectCombatSchedule();
DECLARE_DATADESC(); DECLARE_DATADESC();
// This is a dummy field. In order to provide save/restore // This is a dummy field. In order to provide save/restore
@ -94,7 +96,6 @@ public:
bool m_bHasWeapon; bool m_bHasWeapon;
DEFINE_CUSTOM_AI; DEFINE_CUSTOM_AI;
}; };
@ -230,36 +231,99 @@ int CNPC_ShadowWalker::SelectScheduleRetrieveItem()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int CNPC_ShadowWalker::SelectSchedule() int CNPC_ShadowWalker::SelectSchedule()
{ {
int schedule;
// Top priority - If there is a weapon available, grab it! // Top priority - If there is a weapon available, grab it!
int schedule = SelectScheduleRetrieveItem(); //schedule = SelectScheduleRetrieveItem();
if (schedule != SCHED_NONE) //if (schedule != SCHED_NONE)
return schedule; // return schedule;
// Can I see the enemy? // Can I see the enemy?
if (HasCondition(COND_SEE_ENEMY) && HasCondition(COND_ENEMY_FACING_ME)) //if (HasCondition(COND_SEE_ENEMY) && HasCondition(COND_ENEMY_FACING_ME))
//{
// // Enemy can't see me
// if (!HasCondition(COND_HAVE_ENEMY_LOS)) {
// return SCHED_CHASE_ENEMY;
// }
//
// return SCHED_RUN_FROM_ENEMY;
//}
switch (m_NPCState)
{ {
// Enemy can't see me case NPC_STATE_IDLE:
if (!HasCondition(COND_HAVE_ENEMY_LOS)) { AssertMsgOnce(GetEnemy() == NULL, "NPC has enemy but is not in combat state?");
return SCHED_CHASE_ENEMY; return SelectIdleSchedule();
case NPC_STATE_ALERT:
AssertMsgOnce(GetEnemy() == NULL, "NPC has enemy but is not in combat state?");
return SelectAlertSchedule();
//case NPC_STATE_COMBAT:
//return SelectCombatSchedule();
default:
return BaseClass::SelectSchedule();
}
} }
return SCHED_RUN_FROM_ENEMY; //-----------------------------------------------------------------------------
// Idle schedule selection
//-----------------------------------------------------------------------------
int CNPC_ShadowWalker::SelectIdleSchedule()
{
int nSched = SelectFlinchSchedule();
if (nSched != SCHED_NONE)
return nSched;
if (HasCondition(COND_HEAR_DANGER) ||
HasCondition(COND_HEAR_COMBAT) ||
HasCondition(COND_HEAR_WORLD) ||
HasCondition(COND_HEAR_BULLET_IMPACT) ||
HasCondition(COND_HEAR_PLAYER))
{
// Investigate sound source
return SCHED_INVESTIGATE_SOUND;
} }
schedule = BaseClass::SelectSchedule(); // no valid route! Wander instead
if (schedule != SCHED_NONE) if (GetNavigator()->GetGoalType() == GOALTYPE_NONE)
return schedule; return SCHED_IDLE_WANDER;
// I musn't run away! I musn't run away! // valid route. Get moving
// If BaseNPC chooses to run from enemy, take cover instead return SCHED_IDLE_WALK;
if (schedule == SCHED_RUN_FROM_ENEMY &&!HasCondition(COND_NO_WEAPON)) {
return SCHED_TAKE_COVER_FROM_ENEMY;
} }
return SCHED_IDLE_STAND; //-----------------------------------------------------------------------------
// Alert schedule selection
// Copied from baseNPC
//-----------------------------------------------------------------------------
int CNPC_ShadowWalker::SelectAlertSchedule()
{
// Per default base NPC, check flinch schedule first
int nSched = SelectFlinchSchedule();
if (nSched != SCHED_NONE)
return nSched;
// Scan around for new enemies
if (HasCondition(COND_ENEMY_DEAD) && SelectWeightedSequence(ACT_VICTORY_DANCE) != ACTIVITY_NOT_AVAILABLE)
return SCHED_ALERT_SCAN;
if (HasCondition(COND_HEAR_DANGER) ||
HasCondition(COND_HEAR_PLAYER) ||
HasCondition(COND_HEAR_WORLD) ||
HasCondition(COND_HEAR_BULLET_IMPACT) ||
HasCondition(COND_HEAR_COMBAT))
{
// Investigate sound source
return SCHED_INVESTIGATE_SOUND;
} }
// no valid route! Wander instead
if (GetNavigator()->GetGoalType() == GOALTYPE_NONE)
return SCHED_IDLE_WANDER;
// valid route. Get moving
return SCHED_ALERT_WALK;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: // Purpose: