Skip to content

Commit

Permalink
bot_developer extended with specific outputs (reporting, chat disabli…
Browse files Browse the repository at this point in the history
…ng, obstacle testing) (#183)
  • Loading branch information
NeonKnightOA authored Mar 13, 2024
1 parent e12d8d2 commit a714685
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 145 deletions.
24 changes: 12 additions & 12 deletions code/game/ai_chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ int BotChat_EnterGame(bot_state_t *bs) {
char name[32];
float rnd;

if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
//don't chat in teamplay
if (G_IsATeamGametype(gametype)) return qfalse;
Expand Down Expand Up @@ -414,7 +414,7 @@ int BotChat_ExitGame(bot_state_t *bs) {
char name[32];
float rnd;

if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
//don't chat in teamplay
if (G_IsATeamGametype(gametype)) return qfalse;
Expand Down Expand Up @@ -447,7 +447,7 @@ int BotChat_StartLevel(bot_state_t *bs) {
char name[32];
float rnd;

if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (BotIsObserver(bs)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
//don't chat in teamplay
Expand Down Expand Up @@ -479,7 +479,7 @@ int BotChat_EndLevel(bot_state_t *bs) {
char name[32];
float rnd;

if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (BotIsObserver(bs)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
// teamplay
Expand Down Expand Up @@ -539,7 +539,7 @@ int BotChat_Death(bot_state_t *bs) {
char name[32];
float rnd;

if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_DEATH, 0, 1);
// don't chat in tournament mode
Expand Down Expand Up @@ -638,7 +638,7 @@ int BotChat_Kill(bot_state_t *bs) {
char name[32];
float rnd;

if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_KILL, 0, 1);
// don't chat in tournament mode
Expand Down Expand Up @@ -700,7 +700,7 @@ int BotChat_EnemySuicide(bot_state_t *bs) {
char name[32];
float rnd;

if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
if (BotNumActivePlayers() <= 1) return qfalse;
//
Expand Down Expand Up @@ -735,7 +735,7 @@ int BotChat_HitTalking(bot_state_t *bs) {
int lasthurt_client;
float rnd;

if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
if (BotNumActivePlayers() <= 1) return qfalse;
lasthurt_client = g_entities[bs->client].client->lasthurt_client;
Expand Down Expand Up @@ -781,7 +781,7 @@ int BotChat_HitNoDeath(bot_state_t *bs) {
//
if (lasthurt_client < 0 || lasthurt_client >= MAX_CLIENTS) return qfalse;
//
if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
if (BotNumActivePlayers() <= 1) return qfalse;
rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_HITNODEATH, 0, 1);
Expand Down Expand Up @@ -819,7 +819,7 @@ int BotChat_HitNoKill(bot_state_t *bs) {
float rnd;
aas_entityinfo_t entinfo;

if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
if (BotNumActivePlayers() <= 1) return qfalse;
rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_HITNOKILL, 0, 1);
Expand Down Expand Up @@ -856,7 +856,7 @@ int BotChat_Random(bot_state_t *bs) {
float rnd;
char name[32];

if (bot_nochat.integer) return qfalse;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return qfalse;
if (BotIsObserver(bs)) return qfalse;
if (bs->lastchat_time > FloatTime() - TIME_BETWEENCHATTING) return qfalse;
// don't chat in tournament mode
Expand Down Expand Up @@ -925,7 +925,7 @@ void BotChatTest(bot_state_t *bs) {
char *weap;
int num, i;

if (bot_nochat.integer) return;
if (bot_nochat.integer || (bot_developer.integer & BOTDEV_DISABLECHAT)) return;

num = trap_BotNumInitialChats(bs->cs, "game_enter");
for (i = 0; i < num; i++)
Expand Down
84 changes: 43 additions & 41 deletions code/game/ai_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

int notleader[MAX_CLIENTS];

#ifdef DEBUG
/*
==================
BotPrintTeamGoal
Expand All @@ -68,6 +67,10 @@ void BotPrintTeamGoal(bot_state_t *bs) {
char netname[MAX_NETNAME];
float t;

// Exit if not in the adequate devmode for bots.
if (!(bot_developer.integer & BOTDEV_REPORTACTIONS)) {
return;
}
ClientName(bs->client, netname, sizeof(netname));
t = bs->teamgoal_time - FloatTime();
switch(bs->ltgtype) {
Expand Down Expand Up @@ -159,7 +162,6 @@ void BotPrintTeamGoal(bot_state_t *bs) {
}
}
}
#endif //DEBUG

/*
==================
Expand Down Expand Up @@ -655,9 +657,9 @@ void BotMatch_HelpAccompany(bot_state_t *bs, bot_match_t *match) {
// remember last ordered task
BotRememberLastOrderedTask(bs);
}
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -715,9 +717,9 @@ void BotMatch_DefendKeyArea(bot_state_t *bs, bot_match_t *match) {
BotSetTeamStatus(bs);
// remember last ordered task
BotRememberLastOrderedTask(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -764,9 +766,9 @@ void BotMatch_TakeA(bot_state_t *bs, bot_match_t *match) {
BotSetTeamStatus(bs);
// remember last ordered task
BotRememberLastOrderedTask(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -855,9 +857,9 @@ void BotMatch_HoldDOMPoint(bot_state_t *bs, bot_match_t *match) {
BotSetTeamStatus(bs);
// remember last ordered task
BotRememberLastOrderedTask(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -895,9 +897,9 @@ void BotMatch_GetItem(bot_state_t *bs, bot_match_t *match) {
bs->teamgoal_time = FloatTime() + TEAM_GETITEM_TIME;
//
BotSetTeamStatus(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -987,9 +989,9 @@ void BotMatch_Camp(bot_state_t *bs, bot_match_t *match) {
BotSetTeamStatus(bs);
// remember last ordered task
BotRememberLastOrderedTask(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -1026,9 +1028,9 @@ void BotMatch_Patrol(bot_state_t *bs, bot_match_t *match) {
BotSetTeamStatus(bs);
// remember last ordered task
BotRememberLastOrderedTask(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -1080,9 +1082,9 @@ void BotMatch_GetFlag(bot_state_t *bs, bot_match_t *match) {
BotSetTeamStatus(bs);
// remember last ordered task
BotRememberLastOrderedTask(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -1136,9 +1138,9 @@ void BotMatch_AttackEnemyBase(bot_state_t *bs, bot_match_t *match) {
BotSetTeamStatus(bs);
// remember last ordered task
BotRememberLastOrderedTask(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -1178,9 +1180,9 @@ void BotMatch_Harvest(bot_state_t *bs, bot_match_t *match) {
BotSetTeamStatus(bs);
// remember last ordered task
BotRememberLastOrderedTask(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -1222,9 +1224,9 @@ void BotMatch_RushBase(bot_state_t *bs, bot_match_t *match) {
bs->rushbaseaway_time = 0;
//
BotSetTeamStatus(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -1308,9 +1310,9 @@ void BotMatch_ReturnFlag(bot_state_t *bs, bot_match_t *match) {
bs->rushbaseaway_time = 0;
//
BotSetTeamStatus(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down Expand Up @@ -1933,9 +1935,9 @@ void BotMatch_Kill(bot_state_t *bs, bot_match_t *match) {
bs->teamgoal_time = FloatTime() + TEAM_KILL_SOMEONE;
//
BotSetTeamStatus(bs);
#ifdef DEBUG
BotPrintTeamGoal(bs);
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotPrintTeamGoal(bs);
}
}

/*
Expand Down
42 changes: 20 additions & 22 deletions code/game/ai_dmnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ void BotRecordNodeSwitch(bot_state_t *bs, char *node, char *str, char *s) {

ClientName(bs->client, netname, sizeof(netname));
Com_sprintf(nodeswitch[numnodeswitches], 144, "%s at %2.1f entered %s: %s from %s\n", netname, FloatTime(), node, str, s);
#ifdef DEBUG
if (0) {
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotAI_Print(PRT_MESSAGE, "%s", nodeswitch[numnodeswitches]);
}
#endif //DEBUG
numnodeswitches++;
}

Expand Down Expand Up @@ -161,9 +159,9 @@ int BotGoForAir(bot_state_t *bs, int tfl, bot_goal_t *ltg, float range) {
//if the bot needs air
if (bs->lastair_time < FloatTime() - 6) {
//
#ifdef DEBUG
//BotAI_Print(PRT_MESSAGE, "going for air\n");
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotAI_Print(PRT_MESSAGE, "going for air\n");
}
//if we can find an air goal
if (BotGetAirGoal(bs, &goal)) {
trap_BotPushGoal(bs->gs, &goal);
Expand Down Expand Up @@ -307,11 +305,11 @@ int BotGetItemLongTermGoal(bot_state_t *bs, int tfl, bot_goal_t *goal) {
}
else {//the bot gets sorta stuck with all the avoid timings, shouldn't happen though
//
#ifdef DEBUG
char netname[128];
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
char netname[128];

BotAI_Print(PRT_MESSAGE, "%s: no valid ltg (probably stuck)\n", ClientName(bs->client, netname, sizeof(netname)));
#endif
BotAI_Print(PRT_MESSAGE, "%s: no valid ltg (probably stuck)\n", ClientName(bs->client, netname, sizeof(netname)));
}
//trap_BotDumpAvoidGoals(bs->gs);
//reset the avoid goals and the avoid reach
trap_BotResetAvoidGoals(bs->gs);
Expand Down Expand Up @@ -1596,9 +1594,9 @@ int AINode_Seek_ActivateEntity(bot_state_t *bs) {
BotEntityInfo(goal->entitynum, &entinfo);
// if the entity the bot shoots at moved
if (!VectorCompare(bs->activatestack->origin, entinfo.origin)) {
#ifdef DEBUG
BotAI_Print(PRT_MESSAGE, "hit shootable button or trigger\n");
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotAI_Print(PRT_MESSAGE, "hit shootable button or trigger\n");
}
bs->activatestack->time = 0;
}
// if the activate goal has been activated or the bot takes too long
Expand All @@ -1623,9 +1621,9 @@ int AINode_Seek_ActivateEntity(bot_state_t *bs) {
else if (!bs->activatestack->shoot) {
//if the bot touches the current goal
if (trap_BotTouchingGoal(bs->origin, goal)) {
#ifdef DEBUG
BotAI_Print(PRT_MESSAGE, "touched button or trigger\n");
#endif //DEBUG
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotAI_Print(PRT_MESSAGE, "touched button or trigger\n");
}
bs->activatestack->time = 0;
}
}
Expand Down Expand Up @@ -2093,9 +2091,9 @@ int AINode_Battle_Fight(bot_state_t *bs) {
}
//if there is another better enemy
if (BotFindEnemy(bs, bs->enemy)) {
#ifdef DEBUG
BotAI_Print(PRT_MESSAGE, "found new better enemy\n");
#endif
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotAI_Print(PRT_MESSAGE, "found new better enemy\n");
}
}
//if no enemy
if (bs->enemy < 0) {
Expand Down Expand Up @@ -2418,9 +2416,9 @@ int AINode_Battle_Retreat(bot_state_t *bs) {
}
//if there is another better enemy
if (BotFindEnemy(bs, bs->enemy)) {
#ifdef DEBUG
BotAI_Print(PRT_MESSAGE, "found new better enemy\n");
#endif
if (bot_developer.integer & BOTDEV_REPORTACTIONS) {
BotAI_Print(PRT_MESSAGE, "found new better enemy\n");
}
}
//
bs->tfl = TFL_DEFAULT;
Expand Down
Loading

0 comments on commit a714685

Please sign in to comment.