fix: commands execution order
This commit is contained in:
parent
64166213f6
commit
e22b0ffeea
4 changed files with 52 additions and 45 deletions
|
|
@ -533,6 +533,7 @@ private:
|
||||||
void donateC4ToHuman ();
|
void donateC4ToHuman ();
|
||||||
void clearAmmoInfo ();
|
void clearAmmoInfo ();
|
||||||
void handleChatterTaskChange (Task tid);
|
void handleChatterTaskChange (Task tid);
|
||||||
|
void executeChatterFrameEvents ();
|
||||||
|
|
||||||
void completeTask ();
|
void completeTask ();
|
||||||
void executeTasks ();
|
void executeTasks ();
|
||||||
|
|
|
||||||
|
|
@ -2455,6 +2455,49 @@ void Bot::handleChatterTaskChange (Task tid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bot::executeChatterFrameEvents () {
|
||||||
|
if (cv_radio_mode.as <int> () != 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// some stuff required by by chatter engine
|
||||||
|
if ((m_states & Sense::SeeingEnemy) && !game.isNullEntity (m_enemy)) {
|
||||||
|
int hasFriendNearby = numFriendsNear (pev->origin, 512.0f);
|
||||||
|
|
||||||
|
if (!hasFriendNearby && rg.chance (45) && (m_enemy->v.weapons & cr::bit (Weapon::C4))) {
|
||||||
|
pushChatterMessage (Chatter::SpotTheBomber);
|
||||||
|
}
|
||||||
|
else if (!hasFriendNearby && rg.chance (45) && m_team == Team::Terrorist && util.isPlayerVIP (m_enemy)) {
|
||||||
|
pushChatterMessage (Chatter::VIPSpotted);
|
||||||
|
}
|
||||||
|
else if (!hasFriendNearby
|
||||||
|
&& rg.chance (50)
|
||||||
|
&& game.getTeam (m_enemy) != m_team
|
||||||
|
&& isGroupOfEnemies (m_enemy->v.origin)) {
|
||||||
|
|
||||||
|
pushChatterMessage (Chatter::ScaredEmotion);
|
||||||
|
}
|
||||||
|
else if (!hasFriendNearby
|
||||||
|
&& rg.chance (40)
|
||||||
|
&& (m_enemy->v.weapons & kSniperWeaponMask)) {
|
||||||
|
|
||||||
|
pushChatterMessage (Chatter::SniperWarning);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if bot is trapped under shield yell for help !
|
||||||
|
if (getCurrentTaskId () == Task::Camp && hasShield () && isShieldDrawn () && hasFriendNearby >= 2) {
|
||||||
|
pushChatterMessage (Chatter::PinnedDown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if bomb planted warn players !
|
||||||
|
if (bots.hasBombSay (BombPlantedSay::Chatter) && bots.isBombPlanted () && m_team == Team::CT) {
|
||||||
|
pushChatterMessage (Chatter::GottaFindC4);
|
||||||
|
bots.clearBombSay (BombPlantedSay::Chatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Bot::checkRadioQueue () {
|
void Bot::checkRadioQueue () {
|
||||||
// this function handling radio and reacting to it
|
// this function handling radio and reacting to it
|
||||||
|
|
||||||
|
|
@ -3010,14 +3053,12 @@ void Bot::frame () {
|
||||||
if (m_thinkTimer.time < game.time ()) {
|
if (m_thinkTimer.time < game.time ()) {
|
||||||
m_thinkTimer.time = game.time () + m_thinkTimer.interval;
|
m_thinkTimer.time = game.time () + m_thinkTimer.interval;
|
||||||
|
|
||||||
upkeep ();
|
|
||||||
|
|
||||||
if (m_fullThinkTimer.time < game.time ()) {
|
if (m_fullThinkTimer.time < game.time ()) {
|
||||||
m_fullThinkTimer.time = game.time () + m_fullThinkTimer.interval;
|
m_fullThinkTimer.time = game.time () + m_fullThinkTimer.interval;
|
||||||
|
|
||||||
update ();
|
update ();
|
||||||
}
|
}
|
||||||
runMovement ();
|
upkeep ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_slowFrameTimestamp > game.time ()) {
|
if (m_slowFrameTimestamp > game.time ()) {
|
||||||
|
|
@ -3335,44 +3376,7 @@ void Bot::logic () {
|
||||||
else if (!game.isNullEntity (m_enemy)) {
|
else if (!game.isNullEntity (m_enemy)) {
|
||||||
trackEnemies ();
|
trackEnemies ();
|
||||||
}
|
}
|
||||||
|
executeChatterFrameEvents ();
|
||||||
// some stuff required by by chatter engine
|
|
||||||
if (cv_radio_mode.as <int> () == 2) {
|
|
||||||
if ((m_states & Sense::SeeingEnemy) && !game.isNullEntity (m_enemy)) {
|
|
||||||
int hasFriendNearby = numFriendsNear (pev->origin, 512.0f);
|
|
||||||
|
|
||||||
if (!hasFriendNearby && rg.chance (45) && (m_enemy->v.weapons & cr::bit (Weapon::C4))) {
|
|
||||||
pushChatterMessage (Chatter::SpotTheBomber);
|
|
||||||
}
|
|
||||||
else if (!hasFriendNearby && rg.chance (45) && m_team == Team::Terrorist && util.isPlayerVIP (m_enemy)) {
|
|
||||||
pushChatterMessage (Chatter::VIPSpotted);
|
|
||||||
}
|
|
||||||
else if (!hasFriendNearby
|
|
||||||
&& rg.chance (50)
|
|
||||||
&& game.getTeam (m_enemy) != m_team
|
|
||||||
&& isGroupOfEnemies (m_enemy->v.origin)) {
|
|
||||||
|
|
||||||
pushChatterMessage (Chatter::ScaredEmotion);
|
|
||||||
}
|
|
||||||
else if (!hasFriendNearby
|
|
||||||
&& rg.chance (40)
|
|
||||||
&& (m_enemy->v.weapons & kSniperWeaponMask)) {
|
|
||||||
|
|
||||||
pushChatterMessage (Chatter::SniperWarning);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if bot is trapped under shield yell for help !
|
|
||||||
if (getCurrentTaskId () == Task::Camp && hasShield () && isShieldDrawn () && hasFriendNearby >= 2) {
|
|
||||||
pushChatterMessage (Chatter::PinnedDown);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if bomb planted warn players !
|
|
||||||
if (bots.hasBombSay (BombPlantedSay::Chatter) && bots.isBombPlanted () && m_team == Team::CT) {
|
|
||||||
pushChatterMessage (Chatter::GottaFindC4);
|
|
||||||
bots.clearBombSay (BombPlantedSay::Chatter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_checkTerrain = true;
|
m_checkTerrain = true;
|
||||||
m_moveToGoal = true;
|
m_moveToGoal = true;
|
||||||
|
|
@ -3469,8 +3473,10 @@ void Bot::logic () {
|
||||||
|
|
||||||
void Bot::upkeep () {
|
void Bot::upkeep () {
|
||||||
setAimDirection ();
|
setAimDirection ();
|
||||||
updateLookAngles ();
|
|
||||||
doFireWeapons ();
|
doFireWeapons ();
|
||||||
|
|
||||||
|
updateLookAngles ();
|
||||||
|
runMovement ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::spawned () {
|
void Bot::spawned () {
|
||||||
|
|
|
||||||
|
|
@ -1564,8 +1564,8 @@ void Bot::attackMovement () {
|
||||||
m_strafeSetTime = strafeUpdateTime ();
|
m_strafeSetTime = strafeUpdateTime ();
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool wallOnRight = checkWallOnRight (96.0f);
|
const bool wallOnRight = checkWallOnRight (134.0f);
|
||||||
const bool wallOnLeft = checkWallOnLeft (96.0f);
|
const bool wallOnLeft = checkWallOnLeft (134.0f);
|
||||||
|
|
||||||
if (m_dodgeStrafeDir == Dodge::Left) {
|
if (m_dodgeStrafeDir == Dodge::Left) {
|
||||||
if (!wallOnLeft) {
|
if (!wallOnLeft) {
|
||||||
|
|
|
||||||
|
|
@ -1739,7 +1739,7 @@ void Bot::newRound () {
|
||||||
thinkInterval = 1.0f / 50.0f; // xash3d works acceptable at 50fps
|
thinkInterval = 1.0f / 50.0f; // xash3d works acceptable at 50fps
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto fullThinkInterval = 1.0f / 10.0f;
|
auto fullThinkInterval = 1.0f / (thinkFps * 0.5f);
|
||||||
|
|
||||||
// legacy games behaves strange, when this enabled, disable for xash3d as well if requested
|
// legacy games behaves strange, when this enabled, disable for xash3d as well if requested
|
||||||
if (bots.isFrameSkipDisabled ()) {
|
if (bots.isFrameSkipDisabled ()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue