X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fhavocbot%2Fhavocbot.qc;h=18e4341718e67e698e12c76045a8d035418e8af8;hb=0ee74987765518ffed584a790f90607c3f3f8e71;hp=9b7198cef821f83efb36eeabae7e4923ae502989;hpb=fb61c977ddeed686ef587fd54e40f55a4bdc2322;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index 9b7198cef..fb79a3318 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -1,10 +1,6 @@ #include "havocbot.qh" -#include "role_ctf.qc" #include "role_onslaught.qc" #include "role_keyhunt.qc" -#include "role_freezetag.qc" -#include "role_keepaway.qc" -#include "role_assault.qc" #include "roles.qc" void havocbot_ai() @@ -24,7 +20,7 @@ void havocbot_ai() } else { - if not(self.jumppadcount) + if (!self.jumppadcount) self.havocbot_role(); } @@ -32,7 +28,7 @@ void havocbot_ai() // if we don't have a goal and we're under water look for a waypoint near the "shore" and push it if(self.deadflag != DEAD_NO) if(self.goalcurrent==world) - if(self.waterlevel==WATERLEVEL_SWIMMING || self.aistatus & AI_STATUS_OUT_WATER) + if(self.waterlevel==WATERLEVEL_SWIMMING || (self.aistatus & AI_STATUS_OUT_WATER)) { // Look for the closest waypoint out of water entity newgoal, head; @@ -92,11 +88,11 @@ void havocbot_ai() if (self.bot_aimtarg) { self.aistatus |= AI_STATUS_ATTACKING; - self.aistatus &~= AI_STATUS_ROAMING; + self.aistatus &= ~AI_STATUS_ROAMING; if(self.weapons) { - weapon_action(self.weapon, WR_AIM); + WEP_ACTION(self.weapon, WR_AIM); if (autocvar_bot_nofire || IS_INDEPENDENT_PLAYER(self)) { self.BUTTON_ATCK = FALSE; @@ -110,14 +106,14 @@ void havocbot_ai() } else { - if(self.bot_aimtarg.classname=="player") + if(IS_PLAYER(self.bot_aimtarg)) bot_aimdir(self.bot_aimtarg.origin + self.bot_aimtarg.view_ofs - self.origin - self.view_ofs , -1); } } else if (self.goalcurrent) { self.aistatus |= AI_STATUS_ROAMING; - self.aistatus &~= AI_STATUS_ATTACKING; + self.aistatus &= ~AI_STATUS_ATTACKING; vector now,v,next;//,heading; float aimdistance,skillblend,distanceblend,blend; @@ -126,7 +122,7 @@ void havocbot_ai() //heading = self.velocity; //dprint(self.goalstack01.classname,etos(self.goalstack01),"\n"); if( - self.goalstack01 != self && self.goalstack01 != world && self.aistatus & AI_STATUS_RUNNING == 0 && + self.goalstack01 != self && self.goalstack01 != world && ((self.aistatus & AI_STATUS_RUNNING) == 0) && !(self.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT) ) next = ((self.goalstack01.absmin + self.goalstack01.absmax) * 0.5) - (self.origin + self.view_ofs); @@ -150,7 +146,7 @@ void havocbot_ai() havocbot_movetogoal(); // if the bot is not attacking, consider reloading weapons - if not(self.aistatus & AI_STATUS_ATTACKING) + if (!(self.aistatus & AI_STATUS_ATTACKING)) { float i; entity e; @@ -168,7 +164,7 @@ void havocbot_ai() for(i = WEP_FIRST; i <= WEP_LAST; ++i) { e = get_weaponinfo(i); - if ((e.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[i] < cvar(strcat("g_balance_", e.netname, "_reload_ammo")))) + if ((self.weapons & WepSet_FromWeapon(i)) && (e.spawnflags & WEP_FLAG_RELOADABLE) && (self.weapon_load[i] < cvar(strcat("g_balance_", e.netname, "_reload_ammo")))) self.switchweapon = i; } } @@ -257,21 +253,18 @@ void havocbot_bunnyhop(vector dir) float maxspeed; vector gco, gno; - if(autocvar_g_midair) - return; - // Don't jump when attacking if(self.aistatus & AI_STATUS_ATTACKING) return; - if(self.goalcurrent.classname == "player") + if(IS_PLAYER(self.goalcurrent)) return; maxspeed = autocvar_sv_maxspeed; if(self.aistatus & AI_STATUS_DANGER_AHEAD) { - self.aistatus &~= AI_STATUS_RUNNING; + self.aistatus &= ~AI_STATUS_RUNNING; self.BUTTON_JUMP = FALSE; self.bot_canruntogoal = 0; self.bot_timelastseengoal = 0; @@ -280,7 +273,7 @@ void havocbot_bunnyhop(vector dir) if(self.waterlevel > WATERLEVEL_WETFEET) { - self.aistatus &~= AI_STATUS_RUNNING; + self.aistatus &= ~AI_STATUS_RUNNING; return; } @@ -323,7 +316,7 @@ void havocbot_bunnyhop(vector dir) if(self.aistatus & AI_STATUS_ROAMING) if(self.goalcurrent.classname=="waypoint") - if not(self.goalcurrent.wpflags & WAYPOINTFLAG_PERSONAL) + if (!(self.goalcurrent.wpflags & WAYPOINTFLAG_PERSONAL)) if(fabs(gco_z - self.origin_z) < self.maxs_z - self.mins_z) if(self.goalstack01!=world) { @@ -346,7 +339,7 @@ void havocbot_bunnyhop(vector dir) if(checkdistance) { - self.aistatus &~= AI_STATUS_RUNNING; + self.aistatus &= ~AI_STATUS_RUNNING; if(bunnyhopdistance > autocvar_bot_ai_bunnyhop_stopdistance) self.BUTTON_JUMP = TRUE; } @@ -370,7 +363,7 @@ void havocbot_bunnyhop(vector dir) #if 0 // Release jump button if(!cvar("sv_pogostick")) - if(self.flags & FL_ONGROUND == 0) + if((self.flags & FL_ONGROUND) == 0) { if(self.velocity_z < 0 || vlen(self.velocity)10) @@ -462,15 +455,15 @@ void havocbot_movetogoal() } // Switch to normal mode self.navigation_jetpack_goal = world; - self.aistatus &~= AI_STATUS_JETPACK_LANDING; - self.aistatus &~= AI_STATUS_JETPACK_FLYING; + self.aistatus &= ~AI_STATUS_JETPACK_LANDING; + self.aistatus &= ~AI_STATUS_JETPACK_FLYING; return; } } else if(checkpvs(self.origin,self.goalcurrent)) { // If I can see the goal switch to landing code - self.aistatus &~= AI_STATUS_JETPACK_FLYING; + self.aistatus &= ~AI_STATUS_JETPACK_FLYING; self.aistatus |= AI_STATUS_JETPACK_LANDING; return; } @@ -493,8 +486,8 @@ void havocbot_movetogoal() { if(fabs(self.velocity_z)<50) { - entity head, newgoal; - float distance, bestdistance; + entity head, newgoal = world; + float distance, bestdistance = 0; for (head = findchain(classname, "waypoint"); head; head = head.chain) { @@ -521,7 +514,7 @@ void havocbot_movetogoal() self.ignoregoaltime = time + autocvar_bot_ai_ignoregoal_timeout; navigation_clearroute(); navigation_routetogoal(newgoal, self.origin); - self.aistatus &~= AI_STATUS_OUT_JUMPPAD; + self.aistatus &= ~AI_STATUS_OUT_JUMPPAD; } } else @@ -544,16 +537,16 @@ void havocbot_movetogoal() } // Don't chase players while using a jump pad - if(self.goalcurrent.classname=="player" || self.goalstack01.classname=="player") + if(IS_PLAYER(self.goalcurrent) || IS_PLAYER(self.goalstack01)) return; } } else if(self.aistatus & AI_STATUS_OUT_JUMPPAD) - self.aistatus &~= AI_STATUS_OUT_JUMPPAD; + self.aistatus &= ~AI_STATUS_OUT_JUMPPAD; - // If there is a trigger_hurt right below try to use the jetpack or make a rocketjump + // If there is a trigger_hurt right below try to use the jetpack or make a rocketjump // WEAPONTODO: move this to bot think! if(skill>6) - if not(self.flags & FL_ONGROUND) + if (!(self.flags & FL_ONGROUND)) { tracebox(self.origin, self.mins, self.maxs, self.origin + '0 0 -65536', MOVE_NOMONSTERS, self); if(tracebox_hits_trigger_hurt(self.origin, self.mins, self.maxs, trace_endpos )) @@ -597,10 +590,10 @@ void havocbot_movetogoal() return; } - else if(self.health>autocvar_g_balance_rocketlauncher_damage*0.5) + else if(self.health>WEP_CVAR(devastator, damage)*0.5) { if(self.velocity_z < 0) - if(client_hasweapon(self, WEP_ROCKET_LAUNCHER, TRUE, FALSE)) + if(client_hasweapon(self, WEP_DEVASTATOR, TRUE, FALSE)) { self.movement_x = maxspeed; @@ -614,10 +607,10 @@ void havocbot_movetogoal() return; } - self.switchweapon = WEP_ROCKET_LAUNCHER; + self.switchweapon = WEP_DEVASTATOR; self.v_angle_x = 90; self.BUTTON_ATCK = TRUE; - self.rocketjumptime = time + autocvar_g_balance_rocketlauncher_detonatedelay; + self.rocketjumptime = time + WEP_CVAR(devastator, detonatedelay); return; } } @@ -705,7 +698,7 @@ void havocbot_movetogoal() else { if(self.aistatus & AI_STATUS_OUT_WATER) - self.aistatus &~= AI_STATUS_OUT_WATER; + self.aistatus &= ~AI_STATUS_OUT_WATER; // jump if going toward an obstacle that doesn't look like stairs we // can walk up directly @@ -763,10 +756,10 @@ void havocbot_movetogoal() // Check for water/slime/lava and dangerous edges // (only when the bot is on the ground or jumping intentionally) - self.aistatus &~= AI_STATUS_DANGER_AHEAD; + self.aistatus &= ~AI_STATUS_DANGER_AHEAD; if(trace_fraction == 1 && self.jumppadcount == 0 && !self.goalcurrent.wphardwired ) - if(self.flags & FL_ONGROUND || self.aistatus & AI_STATUS_RUNNING || self.BUTTON_JUMP == TRUE) + if((self.flags & FL_ONGROUND) || (self.aistatus & AI_STATUS_RUNNING) || self.BUTTON_JUMP == TRUE) { // Look downwards traceline(dst_ahead , dst_down, TRUE, world); @@ -809,7 +802,7 @@ void havocbot_movetogoal() dodge = dodge * bound(0,0.5+(skill+self.bot_dodgeskill)*0.1,1); evadelava = evadelava * bound(1,3-(skill+self.bot_dodgeskill),3); //Noobs fear lava a lot and take more distance from it traceline(self.origin, ( ( self.enemy.absmin + self.enemy.absmax ) * 0.5 ), TRUE, world); - if(trace_ent.classname == "player") + if(IS_PLAYER(trace_ent)) dir = dir * bound(0,(skill+self.bot_dodgeskill)/7,1); dir = normalize(dir + dodge + evadeobstacle + evadelava); @@ -908,7 +901,7 @@ void havocbot_chooseenemy() self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE; - for(;;) + for(i = 0; ; ++i) { while (head) { @@ -939,7 +932,6 @@ void havocbot_chooseenemy() self.dphitcontentsmask |= DPCONTENTS_OPAQUE; head = head2; - ++i; } // Restore hit flags @@ -960,11 +952,11 @@ float havocbot_chooseweapon_checkreload(float new_weapon) // if this weapon is scheduled for reloading, don't switch to it during combat if (self.weapon_load[new_weapon] < 0) { - float i, other_weapon_available; + float i, other_weapon_available = FALSE; for(i = WEP_FIRST; i <= WEP_LAST; ++i) { // if we are out of ammo for all other weapons, it's an emergency to switch to anything else - if (weapon_action(i, WR_CHECKAMMO1) + weapon_action(i, WR_CHECKAMMO2)) + if (WEP_ACTION(i, WR_CHECKAMMO1) + WEP_ACTION(i, WR_CHECKAMMO2)) other_weapon_available = TRUE; } if(other_weapon_available) @@ -979,7 +971,7 @@ void havocbot_chooseweapon() float i; // ;) - if(g_weaponarena == WEPBIT_TUBA) + if(g_weaponarena_weapons == WEPSET_TUBA) { self.switchweapon = WEP_TUBA; return; @@ -1119,7 +1111,7 @@ float havocbot_moveto(vector pos) if(self.havocbot_personal_waypoint==world) { dprint("Error: ", self.netname, " trying to walk to a non existent personal waypoint\n"); - self.aistatus &~= AI_STATUS_WAYPOINT_PERSONAL_GOING; + self.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_GOING; return CMD_STATUS_ERROR; } @@ -1140,7 +1132,7 @@ float havocbot_moveto(vector pos) if(self.havocbot_personal_waypoint_failcounter >= 30) { dprint("Warning: can't walk to the personal waypoint located at ", vtos(self.havocbot_personal_waypoint.origin),"\n"); - self.aistatus &~= AI_STATUS_WAYPOINT_PERSONAL_LINKING; + self.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_LINKING; remove(self.havocbot_personal_waypoint); return CMD_STATUS_ERROR; } @@ -1165,7 +1157,7 @@ float havocbot_moveto(vector pos) // Step 5: Waypoint reached dprint(self.netname, "'s personal waypoint reached\n"); remove(self.havocbot_personal_waypoint); - self.aistatus &~= AI_STATUS_WAYPOINT_PERSONAL_REACHED; + self.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_REACHED; return CMD_STATUS_FINISHED; } @@ -1183,7 +1175,7 @@ float havocbot_moveto(vector pos) } self.havocbot_personal_waypoint_searchtime = time; // so we set the route next frame - self.aistatus &~= AI_STATUS_WAYPOINT_PERSONAL_LINKING; + self.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_LINKING; self.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_GOING; // Step 3: Route to waypoint