X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fbot.qc;h=3b2af5d92c41141ed4f08cab410c20d6324b6abb;hp=40b769ddd3fb4a78f3b156995a2cf53153800869;hb=21307f327df5609b82d90496c1c6156d636d1c8d;hpb=ee32da5f4dafee5883369c759fe8ed042114bda5 diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc index 40b769ddd..3b2af5d92 100644 --- a/qcsrc/server/bot/bot.qc +++ b/qcsrc/server/bot/bot.qc @@ -1,34 +1,57 @@ #include "bot.qh" + #include "aim.qh" #include "navigation.qh" +#include "scripting.qh" #include "waypoints.qh" -#include "aim.qc" -#include "navigation.qc" -#include "waypoints.qc" -#include "scripting.qc" +#include "havocbot/havocbot.qh" +#include "havocbot/scripting.qh" + +#include "../teamplay.qh" + +#include "../antilag.qh" +#include "../autocvars.qh" +#include "../campaign.qh" +#include "../cl_client.qh" +#include "../constants.qh" +#include "../defs.qh" +#include "../race.qh" +#include "../t_items.qh" + +#include "../mutators/mutators_include.qh" + +#include "../weapons/accuracy.qh" + +#include "../../common/constants.qh" +#include "../../common/mapinfo.qh" +#include "../../common/teams.qh" +#include "../../common/util.qh" + +#include "../../common/weapons/all.qh" -#include "havocbot/havocbot.qc" +#include "../../lib/csqcmodel/sv_model.qh" + +#include "../../lib/warpzone/common.qh" +#include "../../lib/warpzone/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; @@ -53,7 +76,7 @@ void bot_think() { self.v_angle = self.angles; self.v_angle_z = 0; - self.fixangle = FALSE; + self.fixangle = false; } self.dmg_take = 0; @@ -106,7 +129,7 @@ void bot_think() } void bot_setnameandstuff() -{ +{SELFPARAM(); string readfile, s; float file, tokens, prio; entity p; @@ -129,7 +152,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 @@ -201,7 +224,7 @@ void bot_setnameandstuff() READSKILL(bot_thinkskill, 1, 0.5); // think skill READSKILL(bot_aiskill, 2, 0); // "ai" skill - self.bot_config_loaded = TRUE; + self.bot_config_loaded = true; // this is really only a default, JoinBestTeam is called later setcolor(self, stof(bot_shirt) * 16 + stof(bot_pants)); @@ -241,9 +264,9 @@ void bot_setnameandstuff() void bot_custom_weapon_priority_setup() { - float tokens, i, c, w; + float tokens, i, w; - bot_custom_weapon = FALSE; + bot_custom_weapon = false; if( autocvar_bot_ai_custom_weapon_priority_far == "" || autocvar_bot_ai_custom_weapon_priority_mid == "" || @@ -274,46 +297,46 @@ void bot_custom_weapon_priority_setup() // Parse far distance weapon priorities tokens = tokenizebyseparator(W_NumberWeaponOrder(autocvar_bot_ai_custom_weapon_priority_far)," "); - c = 0; - for(i=0; i < tokens && c < WEP_COUNT; ++i){ + int c = 0; + 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; + bot_custom_weapon = true; } void bot_endgame() @@ -356,13 +379,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; + bot_strategytoken_taken = true; } void bot_clientdisconnect() -{ +{SELFPARAM(); if (!IS_BOT_CLIENT(self)) return; bot_clearqueue(self); @@ -385,13 +408,13 @@ void bot_clientdisconnect() } void bot_clientconnect() -{ +{SELFPARAM(); if (!IS_BOT_CLIENT(self)) return; self.bot_preferredcolors = self.clientcolors; self.bot_nextthink = time - random(); self.lag_func = bot_lagfunc; - self.isbot = TRUE; + self.isbot = true; self.createdtime = self.bot_nextthink; if(!self.bot_config_loaded) // This is needed so team overrider doesn't break between matches @@ -406,7 +429,7 @@ void bot_clientconnect() else if(self.bot_forced_team==4) self.team = NUM_TEAM_4; else - JoinBestTeam(self, FALSE, TRUE); + JoinBestTeam(self, false, true); havocbot_setupbot(); } @@ -417,7 +440,7 @@ void bot_removefromlargestteam() entity best, head; CheckAllowedTeams(world); GetTeamCounts(world); - head = findchainfloat(isbot, TRUE); + head = findchainfloat(isbot, true); if (!head) return; best = head; @@ -463,7 +486,7 @@ void bot_removenewest() return; } - head = findchainfloat(isbot, TRUE); + head = findchainfloat(isbot, true); if (!head) return; best = head; @@ -497,18 +520,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"); } @@ -517,14 +540,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 } @@ -560,7 +583,7 @@ float bot_fixcount() // minplayers+bot_number, or remove all bots if no one is playing // But don't remove bots immediately on level change, as the real players // usually haven't rejoined yet - bots_would_leave = FALSE; + bots_would_leave = false; if (teamplay && autocvar_bot_vs_human && (c3==-1 && c4==-1)) bots = min(ceil(fabs(autocvar_bot_vs_human) * activerealplayers), maxclients - realplayers); else if ((realplayers || autocvar_bot_join_empty || (currentbots > 0 && time < 5))) @@ -575,7 +598,7 @@ float bot_fixcount() bots = min(max(minbots, minplayers - activerealplayers), maxclients - realplayers); if(bots > minbots) - bots_would_leave = TRUE; + bots_would_leave = true; } else { @@ -592,14 +615,14 @@ float bot_fixcount() if (bot_spawn() == world) { bprint("Can not add bot, server full.\n"); - return FALSE; + return false; } } while (currentbots > bots) bot_removenewest(); } - return TRUE; + return true; } void bot_serverframe() @@ -654,7 +677,7 @@ void bot_serverframe() } else { - botframe_spawnedwaypoints = TRUE; + botframe_spawnedwaypoints = true; waypoint_loadall(); if(!waypoint_load_links()) waypoint_schedulerelinkall(); @@ -667,7 +690,7 @@ void bot_serverframe() // frame, which causes choppy framerates) if (bot_strategytoken_taken) { - bot_strategytoken_taken = FALSE; + bot_strategytoken_taken = false; if (bot_strategytoken) bot_strategytoken = bot_strategytoken.nextbot; if (!bot_strategytoken)