X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fhavocbot%2Fhavocbot.qc;h=629009761fbcece18ce7d57a4f2094d6ef842eef;hb=541c234fd442f5857209128fc7a907e406f4be03;hp=0ecafaf1e87c7aa62fda4892d2c38ef300e05683;hpb=390d33b5f587dc807ae08ffe39adc1d762fc7f4c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index 0ecafaf1e..629009761 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -1,10 +1,20 @@ #include "havocbot.qh" -#include "role_onslaught.qc" -#include "role_keyhunt.qc" -#include "roles.qc" +#include "../../_all.qh" + +#include "../aim.qh" +#include "../bot.qh" +#include "../navigation.qh" +#include "../scripting.qh" +#include "../waypoints.qh" + +#include "../../../common/constants.qh" + +#include "../../../common/triggers/trigger/jumppads.qh" + +#include "../../../warpzonelib/common.qh" void havocbot_ai() -{ +{SELFPARAM(); if(self.draggedby) return; @@ -148,9 +158,6 @@ void havocbot_ai() // if the bot is not attacking, consider reloading weapons if (!(self.aistatus & AI_STATUS_ATTACKING)) { - float i; - entity e; - // we are currently holding a weapon that's not fully loaded, reload it if(skill >= 2) // bots can only reload the held weapon on purpose past this skill if(self.clip_load < self.clip_size) @@ -161,9 +168,9 @@ void havocbot_ai() if(skill >= 5) // bots can only look for unloaded weapons past this skill if(self.clip_load >= 0) // only if we're not reloading a weapon already { - for(i = WEP_FIRST; i <= WEP_LAST; ++i) + for (int i = WEP_FIRST; i <= WEP_LAST; ++i) { - e = get_weaponinfo(i); + entity e = get_weaponinfo(i); if ((self.weapons & WepSet_FromWeapon(i)) && (e.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[i] < e.reloading_ammo)) self.switchweapon = i; } @@ -172,7 +179,7 @@ void havocbot_ai() } void havocbot_keyboard_movement(vector destorg) -{ +{SELFPARAM(); vector keyboard; float blend, maxspeed; float sk; @@ -247,7 +254,7 @@ void havocbot_keyboard_movement(vector destorg) } void havocbot_bunnyhop(vector dir) -{ +{SELFPARAM(); float bunnyhopdistance; vector deviation; float maxspeed; @@ -390,7 +397,7 @@ void havocbot_bunnyhop(vector dir) } void havocbot_movetogoal() -{ +{SELFPARAM(); vector destorg; vector diff; vector dir; @@ -470,7 +477,7 @@ void havocbot_movetogoal() // Flying self.BUTTON_HOOK = true; - if(self.navigation_jetpack_point.z - PL_MAX_z + PL_MIN_z < self.origin.z) + if(self.navigation_jetpack_point.z - PL_MAX.z + PL_MIN.z < self.origin.z) { self.movement_x = dir * v_forward * maxspeed; self.movement_y = dir * v_right * maxspeed; @@ -530,7 +537,7 @@ void havocbot_movetogoal() threshold = maxspeed * 0.2; if(sxy < threshold) { - dprint("Warning: ", self.netname, " got stuck on a jumppad (velocity in xy is ", ftos(sxy), "), trying to get out of it now\n"); + LOG_TRACE("Warning: ", self.netname, " got stuck on a jumppad (velocity in xy is ", ftos(sxy), "), trying to get out of it now\n"); self.aistatus |= AI_STATUS_OUT_JUMPPAD; } return; @@ -593,7 +600,7 @@ void havocbot_movetogoal() else if(self.health>WEP_CVAR(devastator, damage)*0.5) { if(self.velocity.z < 0) - if(client_hasweapon(self, WEP_DEVASTATOR, true, false)) + if(client_hasweapon(self, WEP_DEVASTATOR.m_id, true, false)) { self.movement_x = maxspeed; @@ -607,7 +614,7 @@ void havocbot_movetogoal() return; } - self.switchweapon = WEP_DEVASTATOR; + self.switchweapon = WEP_DEVASTATOR.m_id; self.v_angle_x = 90; self.BUTTON_ATCK = true; self.rocketjumptime = time + WEP_CVAR(devastator, detonatedelay); @@ -781,7 +788,7 @@ void havocbot_movetogoal() if(tracebox_hits_trigger_hurt(dst_ahead, self.mins, self.maxs, trace_endpos)) { // Remove dangerous dynamic goals from stack - dprint("bot ", self.netname, " avoided the goal ", self.goalcurrent.classname, " ", etos(self.goalcurrent), " because it led to a dangerous path; goal stack cleared\n"); + LOG_TRACE("bot ", self.netname, " avoided the goal ", self.goalcurrent.classname, " ", etos(self.goalcurrent), " because it led to a dangerous path; goal stack cleared\n"); navigation_clearroute(); return; } @@ -847,9 +854,9 @@ void havocbot_movetogoal() } void havocbot_chooseenemy() -{ +{SELFPARAM(); entity head, best, head2; - float rating, bestrating, i, hf; + float rating, bestrating, hf; vector eye, v; if (autocvar_bot_nofire || IS_INDEPENDENT_PLAYER(self)) { @@ -901,10 +908,29 @@ void havocbot_chooseenemy() self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE; - for(i = 0; ; ++i) + bool scan_transparent = false; + bool scan_secondary_targets = false; + bool have_secondary_targets = false; + while(true) { - while (head) + scan_secondary_targets = false; + :scan_targets + for( ; head; head = head.chain) { + if(!scan_secondary_targets) + { + if(head.classname == "misc_breakablemodel") + { + have_secondary_targets = true; + continue; + } + } + else + { + if(head.classname != "misc_breakablemodel") + continue; + } + v = (head.absmin + head.absmax) * 0.5; rating = vlen(v - eye); if (rating= 30) { - dprint("Warning: can't walk to the personal waypoint located at ", vtos(self.havocbot_personal_waypoint.origin),"\n"); + LOG_TRACE("Warning: can't walk to the personal waypoint located at ", vtos(self.havocbot_personal_waypoint.origin),"\n"); self.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_LINKING; remove(self.havocbot_personal_waypoint); return CMD_STATUS_ERROR; } else - dprint(self.netname, " can't walk to its personal waypoint (after ", ftos(self.havocbot_personal_waypoint_failcounter), " failed attempts), trying later\n"); + LOG_TRACE(self.netname, " can't walk to its personal waypoint (after ", ftos(self.havocbot_personal_waypoint_failcounter), " failed attempts), trying later\n"); } } @@ -1155,7 +1192,7 @@ float havocbot_moveto(vector pos) if(self.aistatus & AI_STATUS_WAYPOINT_PERSONAL_REACHED) { // Step 5: Waypoint reached - dprint(self.netname, "'s personal waypoint reached\n"); + LOG_TRACE(self.netname, "'s personal waypoint reached\n"); remove(self.havocbot_personal_waypoint); self.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_REACHED; return CMD_STATUS_FINISHED; @@ -1170,7 +1207,7 @@ float havocbot_moveto(vector pos) // Wait until it is linked if(!self.havocbot_personal_waypoint.wplinked) { - dprint(self.netname, " waiting for personal waypoint to be linked\n"); + LOG_TRACE(self.netname, " waiting for personal waypoint to be linked\n"); return CMD_STATUS_EXECUTING; } @@ -1179,7 +1216,7 @@ float havocbot_moveto(vector pos) self.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_GOING; // Step 3: Route to waypoint - dprint(self.netname, " walking to its personal waypoint\n"); + LOG_TRACE(self.netname, " walking to its personal waypoint\n"); return CMD_STATUS_EXECUTING; } @@ -1188,7 +1225,7 @@ float havocbot_moveto(vector pos) wp = waypoint_spawnpersonal(pos); if(wp==world) { - dprint("Error: Can't spawn personal waypoint at ",vtos(pos),"\n"); + LOG_TRACE("Error: Can't spawn personal waypoint at ",vtos(pos),"\n"); return CMD_STATUS_ERROR; } @@ -1224,7 +1261,7 @@ float havocbot_resetgoal() } void havocbot_setupbot() -{ +{SELFPARAM(); self.bot_ai = havocbot_ai; self.cmd_moveto = havocbot_moveto; self.cmd_resetgoal = havocbot_resetgoal; @@ -1233,7 +1270,7 @@ void havocbot_setupbot() } vector havocbot_dodge() -{ +{SELFPARAM(); // LordHavoc: disabled because this is too expensive return '0 0 0'; #if 0