X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fbot.qc;h=c033daeecebead6955d18eabdddb2ae2b108e7a9;hb=70b84d37e2cf1d5336c327cb43593024de2a2c6c;hp=e42a50f6d4a9ccb8abad44d3b3db2511a13a06a6;hpb=b2fa86504c5f79fb70897d94a4a3c88333f96407;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc index e42a50f6d..c033daeec 100644 --- a/qcsrc/server/bot/bot.qc +++ b/qcsrc/server/bot/bot.qc @@ -31,31 +31,26 @@ #include "../../csqcmodellib/sv_model.qh" -#include "../../dpdefs/dpextensions.qh" -#include "../../dpdefs/progsdefs.qh" - #include "../../warpzonelib/common.qh" #include "../../warpzonelib/util_server.qh" entity bot_spawn() -{ - entity oldself, bot; - bot = spawnclient(); +{SELFPARAM(); + entity bot = spawnclient(); if (bot) { currentbots = currentbots + 1; - oldself = self; - self = bot; + setself(bot); bot_setnameandstuff(); ClientConnect(); PutClientInServer(); - self = oldself; + setself(this); } return bot; } void bot_think() -{ +{SELFPARAM(); if (self.bot_nextthink > time) return; @@ -133,7 +128,7 @@ void bot_think() } void bot_setnameandstuff() -{ +{SELFPARAM(); string readfile, s; float file, tokens, prio; entity p; @@ -156,7 +151,7 @@ void bot_setnameandstuff() if(file < 0) { - print(strcat("Error: Can not open the bot configuration file '",autocvar_bot_config_file,"'\n")); + LOG_INFO(strcat("Error: Can not open the bot configuration file '",autocvar_bot_config_file,"'\n")); readfile = ""; } else @@ -302,42 +297,42 @@ void bot_custom_weapon_priority_setup() tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_far)," "); int c = 0; - for(i=0; i < tokens && c < WEP_COUNT; ++i){ + for(i=0; i < tokens && c < Weapons_COUNT; ++i){ w = stof(argv(i)); if ( w >= WEP_FIRST && w <= WEP_LAST) { bot_weapons_far[c] = w; ++c; } } - if(c < WEP_COUNT) + if(c < Weapons_COUNT) bot_weapons_far[c] = -1; // Parse mid distance weapon priorities tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_mid)," "); c = 0; - for(i=0; i < tokens && c < WEP_COUNT; ++i){ + for(i=0; i < tokens && c < Weapons_COUNT; ++i){ w = stof(argv(i)); if ( w >= WEP_FIRST && w <= WEP_LAST) { bot_weapons_mid[c] = w; ++c; } } - if(c < WEP_COUNT) + if(c < Weapons_COUNT) bot_weapons_mid[c] = -1; // Parse close distance weapon priorities tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_close)," "); c = 0; - for(i=0; i < tokens && i < WEP_COUNT; ++i){ + for(i=0; i < tokens && i < Weapons_COUNT; ++i){ w = stof(argv(i)); if ( w >= WEP_FIRST && w <= WEP_LAST) { bot_weapons_close[c] = w; ++c; } } - if(c < WEP_COUNT) + if(c < Weapons_COUNT) bot_weapons_close[c] = -1; bot_custom_weapon = true; @@ -383,13 +378,13 @@ void bot_relinkplayerlist() } e = e.chain; } - dprint(strcat("relink: ", ftos(currentbots), " bots seen.\n")); + LOG_TRACE(strcat("relink: ", ftos(currentbots), " bots seen.\n")); bot_strategytoken = bot_list; bot_strategytoken_taken = true; } void bot_clientdisconnect() -{ +{SELFPARAM(); if (!IS_BOT_CLIENT(self)) return; bot_clearqueue(self); @@ -412,7 +407,7 @@ void bot_clientdisconnect() } void bot_clientconnect() -{ +{SELFPARAM(); if (!IS_BOT_CLIENT(self)) return; self.bot_preferredcolors = self.clientcolors; @@ -524,18 +519,18 @@ void autoskill(float factor) bestbot = max(bestbot, head.totalfrags - head.totalfrags_lastcheck); } - dprint("autoskill: best player got ", ftos(bestplayer), ", "); - dprint("best bot got ", ftos(bestbot), "; "); + LOG_TRACE("autoskill: best player got ", ftos(bestplayer), ", "); + LOG_TRACE("best bot got ", ftos(bestbot), "; "); if(bestbot < 0 || bestplayer < 0) { - dprint("not doing anything\n"); + LOG_TRACE("not doing anything\n"); // don't return, let it reset all counters below } else if(bestbot <= bestplayer * factor - 2) { if(autocvar_skill < 17) { - dprint("2 frags difference, increasing skill\n"); + LOG_TRACE("2 frags difference, increasing skill\n"); cvar_set("skill", ftos(autocvar_skill + 1)); bprint("^2SKILL UP!^7 Now at level ", ftos(autocvar_skill), "\n"); } @@ -544,14 +539,14 @@ void autoskill(float factor) { if(autocvar_skill > 0) { - dprint("2 frags difference, decreasing skill\n"); + LOG_TRACE("2 frags difference, decreasing skill\n"); cvar_set("skill", ftos(autocvar_skill - 1)); bprint("^1SKILL DOWN!^7 Now at level ", ftos(autocvar_skill), "\n"); } } else { - dprint("not doing anything\n"); + LOG_TRACE("not doing anything\n"); return; // don't reset counters, wait for them to accumulate }