Bot: buying fix (thanks CYBERDEViL)

This commit is contained in:
Marco Cawthorne 2024-01-03 14:14:32 -08:00
parent 5b2c2df919
commit cb9f360dd4
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
1 changed files with 13 additions and 0 deletions

View File

@ -29,6 +29,14 @@ class csbot:bot
virtual void(void) CreateObjective;
virtual void(void) PostFrame;
virtual void(void) WeaponThink;
/* Workaround:
* gflags is not yet set when CSBot_BuyStart_Shop() or CreateObjective()
* are called, so we back it up on PostFrame() and use that instead.
* Known issues it solves:
* - Check if the bot is in a Bomb Zone (gflags & GF_BOMBZONE)
* - Check if the bot is in a Buy Zone (gflags & GF_BUYZONE) */
int m_gflagsBackup;
};
void
@ -170,6 +178,7 @@ void
csbot::PostFrame(void)
{
team = infokeyf(this, "*team");
m_gflagsBackup = gflags;
};
void
@ -196,6 +205,7 @@ csbot::csbot(void)
bot::bot();
targetname = "_csbot_";
team = infokeyf(this, "*team");
m_gflagsBackup = 0;
}
void
@ -243,6 +253,9 @@ CSBot_BuyStart_Shop(void)
pl.team = infokeyf(pl, "*team");
/* Workaround */
pl.gflags = ((csbot)pl).m_gflagsBackup;
count = 0;
while (done != 1) {
int r = floor(random(1,17));