mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-16 08:10:32 +02:00
50 lines
1014 B
C++
50 lines
1014 B
C++
// BotAI_Battle_Attacked.cpp
|
|
//
|
|
|
|
#pragma hdrstop
|
|
#include "precompiled.h"
|
|
#include "../Game_local.h"
|
|
|
|
/*
|
|
==================
|
|
rvmBot::state_Attacked
|
|
==================
|
|
*/
|
|
stateResult_t rvmBot::state_Attacked(stateParms_t* parms) {
|
|
// respawn if dead.
|
|
if (BotIsDead(&bs))
|
|
{
|
|
stateThread.SetState("state_Respawn");
|
|
return SRESULT_DONE_FRAME;
|
|
}
|
|
|
|
if (gameLocal.SysScriptTime() > bs.aggressiveAttackTime || bs.weaponnum == 0) {
|
|
stateThread.SetState("state_Retreat");
|
|
return SRESULT_DONE;
|
|
}
|
|
|
|
// Ensure the target is a player.
|
|
idPlayer *entinfo = gameLocal.entities[bs.enemy]->Cast<idPlayer>();
|
|
if (!entinfo)
|
|
{
|
|
stateThread.SetState("state_SeekLTG");
|
|
return SRESULT_DONE_FRAME;
|
|
}
|
|
|
|
// If our enemy is dead, search for another LTG.
|
|
if (EntityIsDead(entinfo))
|
|
{
|
|
stateThread.SetState("state_SeekLTG");
|
|
return SRESULT_DONE_FRAME;
|
|
}
|
|
|
|
bs.currentGoal.origin = bs.lastenemyorigin;
|
|
|
|
//aim at the enemy
|
|
BotAimAtEnemy(&bs);
|
|
|
|
//attack the enemy if possible
|
|
BotCheckAttack(&bs);
|
|
|
|
return SRESULT_WAIT;
|
|
} |