Skip to content

Commit

Permalink
add bot endgame chat
Browse files Browse the repository at this point in the history
  • Loading branch information
jkivilin committed Dec 3, 2011
1 parent 691b8ea commit d4d193a
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 4 deletions.
7 changes: 6 additions & 1 deletion addons/jk_botti/jk_botti.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
# "say" command to send a bot_whine message after being killed.
# Allowed values are 0 - 100. The default value is 10.
#
# bot_endgame_percent <value> - sets the percent of time bot will use the
# "say" command to send a bot_chat after end of game.
# Allowed values are 0 - 100. The default value is 40.
#
# bot_chat_tag_percent <value> - sets the percent of time bots will remove
# clan tags from player names. The default value is 80.
#
Expand Down Expand Up @@ -143,6 +147,7 @@ team_balancetype 1
bot_chat_percent 10
bot_taunt_percent 20
bot_whine_percent 10
bot_endgame_percent 40

bot_chat_tag_percent 80
bot_chat_drop_percent 10
Expand All @@ -166,4 +171,4 @@ addbot "" "" 5
# Note that above addbots will be used by min/max code until
# all addbot-bots are in use. After this code will generate
# new bots with default settings.
botskill 3
botskill 3
11 changes: 11 additions & 0 deletions addons/jk_botti/jk_botti_chat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,14 @@ argh! dropped pepsi on kboard
!doh
!DOH!!
%n .. leet as usual :P

[bot_endgame]
!I win!
!gg
!gg
!gg
!GG
!GG
!GG
losers hahaha
hahaha
5 changes: 5 additions & 0 deletions addons/jk_botti/jk_botti_readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ Credits:
--------------------
2. What's new
--------------------
1.41:
* Add bot endgame chatting.
* New setting 'bot_endgame_percent', see jk_botti.cfg
* New section [bot_endgame] in jk_botti_chat.txt

1.40:
* Add support for Opposing Force Deathmatch.
* Tuned skill 1 bot to be more leet, skill 2 is now about same as old skill 1.
Expand Down
10 changes: 10 additions & 0 deletions bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern int bot_add_level_tag;
extern int bot_chat_percent;
extern int bot_taunt_percent;
extern int bot_whine_percent;
extern int bot_endgame_percent;
extern int bot_logo_percent;
extern int bot_chat_tag_percent;
extern int bot_chat_drop_percent;
Expand Down Expand Up @@ -729,6 +730,7 @@ void BotCreate( const char *skin, const char *name, int skill, int top_color, in
pBot.chat_percent = bot_chat_percent;
pBot.taunt_percent = bot_taunt_percent;
pBot.whine_percent = bot_whine_percent;
pBot.endgame_percent = bot_endgame_percent;
pBot.chat_tag_percent = bot_chat_tag_percent;
pBot.chat_drop_percent = bot_chat_drop_percent;
pBot.chat_swap_percent = bot_chat_swap_percent;
Expand All @@ -745,6 +747,7 @@ void BotCreate( const char *skin, const char *name, int skill, int top_color, in
pBot.f_bot_say = 0.0;
pBot.bot_say_msg[0] = 0;
pBot.f_bot_chat_time = gpGlobals->time;
pBot.b_bot_endgame = FALSE;

// use system wide timer for connection times
// bot will stay 30-160 minutes
Expand Down Expand Up @@ -2082,6 +2085,13 @@ void BotThink( bot_t &pBot )
// in intermission.. don't do anything, freeze bot
if(g_in_intermission)
{
// endgame chat..
if(!pBot.b_bot_endgame)
{
pBot.b_bot_endgame = TRUE;
BotChatEndGame(pBot);
}

BotRunPlayerMove(pBot, pEdict->v.v_angle, 0, 0, 0, 0, 0, (byte)pBot.msecval);
return;
}
Expand Down
2 changes: 2 additions & 0 deletions bot.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ typedef struct
int chat_percent;
int taunt_percent;
int whine_percent;
int endgame_percent;
int chat_tag_percent;
int chat_drop_percent;
int chat_swap_percent;
Expand Down Expand Up @@ -242,6 +243,7 @@ typedef struct
float f_bot_say;
char bot_say_msg[256];
float f_bot_chat_time;
qboolean b_bot_endgame;

float f_duck_time;

Expand Down
92 changes: 89 additions & 3 deletions bot_chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ char *tag2[NUM_TAGS]={
int bot_chat_count;
int bot_taunt_count;
int bot_whine_count;
int bot_endgame_count;

bot_chat_t bot_chat[MAX_BOT_CHAT];
bot_chat_t bot_taunt[MAX_BOT_CHAT];
bot_chat_t bot_whine[MAX_BOT_CHAT];
bot_chat_t bot_endgame[MAX_BOT_CHAT];

int recent_bot_chat[5];
int recent_bot_taunt[5];
int recent_bot_whine[5];
int recent_bot_endgame[5];

int player_count;
char player_names[32][33]; // 32 players max, 32 chars + null
Expand Down Expand Up @@ -254,6 +257,64 @@ void BotChatTalk(bot_t &pBot)
}


// endgame say
void BotChatEndGame(bot_t &pBot)
{
char chat_text[81];
char chat_name[64];
const char *bot_name;

edict_t *pEdict = pBot.pEdict;

if ((bot_endgame_count > 0) && RANDOM_LONG2(1,100) <= pBot.endgame_percent)
{
int endgame_index;
qboolean used;
int i, recent_count;

// set chat flag and time to chat...
pBot.b_bot_say = TRUE;
pBot.f_bot_say = gpGlobals->time + RANDOM_FLOAT2(0.4, 3.0);

recent_count = 0;

while (recent_count < 5)
{
endgame_index = RANDOM_LONG2(0, bot_endgame_count-1);

used = FALSE;

for (i=0; i < 5; i++)
{
if (recent_bot_endgame[i] == endgame_index)
used = TRUE;
}

if (used)
recent_count++;
else
break;
}

for (i=4; i > 0; i--)
recent_bot_endgame[i] = recent_bot_endgame[i-1];

recent_bot_endgame[0] = endgame_index;

if (bot_endgame[endgame_index].can_modify)
BotChatText(bot_endgame[endgame_index].text, chat_text, sizeof(chat_text));
else
safe_strcopy(chat_text, sizeof(chat_text), bot_endgame[endgame_index].text);

safe_strcopy(chat_name, sizeof(chat_name), STRING(pBot.pEdict->v.netname));

bot_name = STRING(pEdict->v.netname);

BotChatFillInName(pBot.bot_say_msg, sizeof(pBot.bot_say_msg), chat_text, chat_name, bot_name);
}
}


//
void LoadBotChat(void)
{
Expand All @@ -267,12 +328,14 @@ void LoadBotChat(void)
bot_chat_count = 0;
bot_taunt_count = 0;
bot_whine_count = 0;
bot_endgame_count = 0;

for (i=0; i < 5; i++)
{
recent_bot_chat[i] = -1;
recent_bot_taunt[i] = -1;
recent_bot_whine[i] = -1;
recent_bot_endgame[i] = -1;
}

UTIL_BuildFileName_N(filename, sizeof(filename), "addons/jk_botti/jk_botti_chat.txt", NULL);
Expand Down Expand Up @@ -320,8 +383,14 @@ void LoadBotChat(void)
section = 2;
continue;
}

if (strcmp(buffer, "[bot_endgame]") == 0)
{
section = 3;
continue;
}

if ((length > 0) && (section == 0) && // bot chat
if ((length > 0) && !(buffer[0] == '!' && length==1) && (section == 0) && // bot chat
(bot_chat_count < MAX_BOT_CHAT))
{
if (buffer[0] == '!')
Expand All @@ -338,7 +407,7 @@ void LoadBotChat(void)
bot_chat_count++;
}

if ((length > 0) && (section == 1) && // bot taunt
if ((length > 0) && !(buffer[0] == '!' && length==1) && (section == 1) && // bot taunt
(bot_taunt_count < MAX_BOT_CHAT))
{
if (buffer[0] == '!')
Expand All @@ -355,7 +424,7 @@ void LoadBotChat(void)
bot_taunt_count++;
}

if ((length > 0) && (section == 2) && // bot whine
if ((length > 0) && !(buffer[0] == '!' && length==1) && (section == 2) && // bot whine
(bot_whine_count < MAX_BOT_CHAT))
{
if (buffer[0] == '!')
Expand All @@ -371,6 +440,23 @@ void LoadBotChat(void)

bot_whine_count++;
}

if ((length > 0) && !(buffer[0] == '!' && length==1) && (section == 3) && // bot endgame
(bot_endgame_count < MAX_BOT_CHAT))
{
if (buffer[0] == '!')
{
safe_strcopy(bot_endgame[bot_endgame_count].text, sizeof(bot_endgame[bot_endgame_count].text), &buffer[1]);
bot_endgame[bot_endgame_count].can_modify = FALSE;
}
else
{
safe_strcopy(bot_endgame[bot_endgame_count].text, sizeof(bot_endgame[bot_endgame_count].text), buffer);
bot_endgame[bot_endgame_count].can_modify = TRUE;
}

bot_endgame_count++;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions bot_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void BotDoRandomJumpingAndDuckingAndLongJumping(bot_t &pBot, float moved_distanc
void BotChatTaunt(bot_t &pBot, edict_t *victim_edict);
void BotChatWhine(bot_t &pBot);
void BotChatTalk(bot_t &pBot);
void BotChatEndGame(bot_t &pBot);

float BotChangePitch( bot_t &pBot, float speed );
float BotChangeYaw( bot_t &pBot, float speed );
Expand Down
18 changes: 18 additions & 0 deletions commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ extern int bot_add_level_tag;
extern int bot_chat_percent;
extern int bot_taunt_percent;
extern int bot_whine_percent;
extern int bot_endgame_percent;
extern int bot_logo_percent;
extern int bot_chat_tag_percent;
extern int bot_chat_drop_percent;
Expand Down Expand Up @@ -476,6 +477,23 @@ qboolean ProcessCommand(const int cmdtype, const printfunc_t printfunc, void * a

return TRUE;
}
else if (FStrEq(pcmd, "bot_endgame_percent"))
{
if ((arg1 != NULL) && (*arg1 != 0))
{
int temp = atoi(arg1);

if ((temp < 0) || (temp > 100))
printfunc(PRINTFUNC_INFO, arg, "invalid bot_endgame_percent value!\n");
else
bot_endgame_percent = temp;
}

safevoid_snprintf(msg, sizeof(msg), "bot_endgame_percent is %d\n", bot_endgame_percent);
printfunc(PRINTFUNC_INFO, arg, msg);

return TRUE;
}
else if (FStrEq(pcmd, "bot_chat_tag_percent"))
{
if ((arg1 != NULL) && (*arg1 != 0))
Expand Down
1 change: 1 addition & 0 deletions dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ int bot_add_level_tag = 0; // use [lvl%d] for bots (where %d is skill level of
int bot_chat_percent = 10; // percent of time to chat
int bot_taunt_percent = 20; // percent of time to taunt after kill
int bot_whine_percent = 10; // percent of time to whine after death
int bot_endgame_percent = 40; // percent of time to chat after endgame
int bot_logo_percent = 40; // percent of time to spray logo after kill

int bot_chat_tag_percent = 80; // percent of the time to drop clan tag
Expand Down

0 comments on commit d4d193a

Please sign in to comment.