diff --git a/addons/jk_botti/jk_botti.cfg b/addons/jk_botti/jk_botti.cfg index 365b512..1e69469 100644 --- a/addons/jk_botti/jk_botti.cfg +++ b/addons/jk_botti/jk_botti.cfg @@ -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 - 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 - sets the percent of time bots will remove # clan tags from player names. The default value is 80. # @@ -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 @@ -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 \ No newline at end of file +botskill 3 diff --git a/addons/jk_botti/jk_botti_chat.txt b/addons/jk_botti/jk_botti_chat.txt index 543ef5d..3070286 100644 --- a/addons/jk_botti/jk_botti_chat.txt +++ b/addons/jk_botti/jk_botti_chat.txt @@ -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 diff --git a/addons/jk_botti/jk_botti_readme.txt b/addons/jk_botti/jk_botti_readme.txt index bb8caa7..b31b15f 100644 --- a/addons/jk_botti/jk_botti_readme.txt +++ b/addons/jk_botti/jk_botti_readme.txt @@ -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. diff --git a/bot.cpp b/bot.cpp index 630e4e3..b04a1dc 100644 --- a/bot.cpp +++ b/bot.cpp @@ -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; @@ -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; @@ -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 @@ -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; } diff --git a/bot.h b/bot.h index 6315757..fb0754c 100644 --- a/bot.h +++ b/bot.h @@ -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; @@ -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; diff --git a/bot_chat.cpp b/bot_chat.cpp index 38e0f52..cb0c476 100644 --- a/bot_chat.cpp +++ b/bot_chat.cpp @@ -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 @@ -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) { @@ -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); @@ -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] == '!') @@ -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] == '!') @@ -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] == '!') @@ -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++; + } } } diff --git a/bot_func.h b/bot_func.h index 0312c15..6ccda36 100644 --- a/bot_func.h +++ b/bot_func.h @@ -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 ); diff --git a/commands.cpp b/commands.cpp index bd8ad6d..0f0fd2a 100644 --- a/commands.cpp +++ b/commands.cpp @@ -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; @@ -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)) diff --git a/dll.cpp b/dll.cpp index bc7380e..e420278 100644 --- a/dll.cpp +++ b/dll.cpp @@ -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