BotLib: break func_breakable entities within their path.
This commit is contained in:
parent
1bf829920f
commit
b37afb1362
3 changed files with 28 additions and 1 deletions
|
@ -64,6 +64,8 @@ class bot:player
|
|||
float m_flEnemyDist;
|
||||
weapontype_t m_wtWeaponType;
|
||||
vector m_vecLastPOI;
|
||||
float m_flForceWeaponAttack;
|
||||
vector m_vecForceWeaponAttackPos;
|
||||
|
||||
void(void) bot;
|
||||
|
||||
|
@ -88,6 +90,7 @@ class bot:player
|
|||
virtual void(entity) SetEnemy;
|
||||
virtual float(void) GetRunSpeed;
|
||||
virtual float(void) GetWalkSpeed;
|
||||
nonvirtual void ForceWeaponAttack(vector, float);
|
||||
|
||||
virtual void(string) SetName;
|
||||
};
|
||||
|
|
|
@ -353,7 +353,8 @@ bot::RunAI(void)
|
|||
if (enemyvisible) {
|
||||
WeaponAttack();
|
||||
}
|
||||
}
|
||||
} else if (m_flForceWeaponAttack > time)
|
||||
WeaponAttack();
|
||||
|
||||
BrainThink(enemyvisible, enemydistant);
|
||||
CheckRoute();
|
||||
|
@ -382,6 +383,10 @@ bot::RunAI(void)
|
|||
aimpos = m_eTarget.origin;
|
||||
}
|
||||
|
||||
/* force bot to fire at a position if desired */
|
||||
if (m_flForceWeaponAttack > time)
|
||||
aimpos = m_vecForceWeaponAttackPos;
|
||||
|
||||
/* aim ahead if aimpos is somehow invalid */
|
||||
if (aimpos == [0,0,0]) {
|
||||
makevectors(angles);
|
||||
|
@ -470,6 +475,15 @@ bot::RunAI(void)
|
|||
RouteClear();
|
||||
}
|
||||
|
||||
/* if there's a breakable in the way... */
|
||||
traceline(origin, aimpos, MOVE_NORMAL, this);
|
||||
|
||||
/* Hackish: If there's a func_breakable in the way... */
|
||||
if (trace_ent.classname == "func_breakable") {
|
||||
NSEntity traceEnt = (NSEntity)trace_ent;
|
||||
ForceWeaponAttack(traceEnt.WorldSpaceCenter(), 1.0f);
|
||||
}
|
||||
|
||||
/* now we'll set the movevalues relative to the input_angle */
|
||||
if ((m_iCurNode >= 0 && Route_GetNodeFlags(&m_pRoute[m_iCurNode]) & LF_WALK) || shouldwalk)
|
||||
vecDirection = normalize(aimpos - origin) * GetWalkSpeed();
|
||||
|
|
|
@ -88,6 +88,9 @@ bot::WeaponAttack(void)
|
|||
should_attack = 1;
|
||||
}
|
||||
|
||||
if (m_flForceWeaponAttack > time)
|
||||
should_attack = 1;
|
||||
|
||||
if (should_attack && m_flAttackTime < time) {
|
||||
if (!m_iAttackMode) {
|
||||
input_buttons |= INPUT_BUTTON0;
|
||||
|
@ -121,6 +124,13 @@ bot::WeaponAttack(void)
|
|||
m_iAttackMode = 0;
|
||||
}
|
||||
|
||||
void
|
||||
bot::ForceWeaponAttack(vector attackPos, float attackTime)
|
||||
{
|
||||
m_vecForceWeaponAttackPos = attackPos;
|
||||
m_flForceWeaponAttack = attackTime + time;
|
||||
}
|
||||
|
||||
var float g_botalert_timer;
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue