]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/havocbot/havocbot.qc
Merge branch 'master' into Mario/weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / havocbot / havocbot.qc
index 2aa6038d82fb21e640f84a7970cf18b1e2ae930c..2ce9706a2ff40cdcb67557a2d1d6979a9d4e5dd3 100644 (file)
@@ -20,7 +20,7 @@ void havocbot_ai()
                }
                else
                {
-                       if not(self.jumppadcount)
+                       if (!self.jumppadcount)
                                self.havocbot_role();
                }
 
@@ -28,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;
@@ -88,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(!WEPSET_EMPTY_E(self))
+               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;
@@ -113,7 +113,7 @@ void havocbot_ai()
        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;
@@ -122,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);
@@ -146,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;
@@ -164,7 +164,7 @@ void havocbot_ai()
                        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                        {
                                e = get_weaponinfo(i);
-                               if (WEPSET_CONTAINS_EW(self, i) && (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] < e.reloading_ammo))
                                        self.switchweapon = i;
                        }
                }
@@ -253,9 +253,6 @@ 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;
@@ -267,7 +264,7 @@ void havocbot_bunnyhop(vector dir)
 
        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;
@@ -276,7 +273,7 @@ void havocbot_bunnyhop(vector dir)
 
        if(self.waterlevel > WATERLEVEL_WETFEET)
        {
-               self.aistatus &~= AI_STATUS_RUNNING;
+               self.aistatus &= ~AI_STATUS_RUNNING;
                return;
        }
 
@@ -319,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)
                                        {
@@ -342,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;
                                        }
@@ -366,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)<maxspeed)
                        self.BUTTON_JUMP = FALSE;
@@ -425,7 +422,7 @@ void havocbot_movetogoal()
                }
 
                // Take off
-               if not(self.aistatus & AI_STATUS_JETPACK_FLYING)
+               if (!(self.aistatus & AI_STATUS_JETPACK_FLYING))
                {
                        // Brake almost completely so it can get a good direction
                        if(vlen(self.velocity)>10)
@@ -458,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;
                }
@@ -517,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
@@ -545,11 +542,11 @@ void havocbot_movetogoal()
                }
        }
        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 // WEAPONTODO: move this to bot think!
+       // If there is a trigger_hurt right below try to use the jetpack or make a rocketjump
        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 ))
@@ -701,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
@@ -725,10 +722,10 @@ void havocbot_movetogoal()
                        vector dst_ahead, dst_down;
                        makevectors(self.v_angle_y * '0 1 0');
                        dst_ahead = self.origin + self.view_ofs + (self.velocity * 0.4) + (v_forward * 32 * 3);
-                       dst_down = dst_ahead + '0 0 -1500';
+                       dst_down = dst_ahead - '0 0 1500';
 
                        // Look ahead
-                       traceline(self.origin + self.view_ofs , dst_ahead, TRUE, world);
+                       traceline(self.origin + self.view_ofs, dst_ahead, TRUE, world);
 
                        // Check head-banging against walls
                        if(vlen(self.origin + self.view_ofs - trace_endpos) < 25 && !(self.aistatus & AI_STATUS_OUT_WATER))
@@ -759,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);
@@ -926,7 +923,7 @@ void havocbot_chooseenemy()
 
                // I want to do a second scan if no enemy was found or I don't have weapons
                // TODO: Perform the scan when using the rifle (requires changes on the rifle code)
-               if(best || !WEPSET_EMPTY_E(self)) // || self.weapon == WEP_RIFLE
+               if(best || self.weapons) // || self.weapon == WEP_RIFLE
                        break;
                if(i)
                        break;
@@ -959,7 +956,7 @@ float havocbot_chooseweapon_checkreload(float new_weapon)
                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)
@@ -974,7 +971,7 @@ void havocbot_chooseweapon()
        float i;
 
        // ;)
-       if(WEPSET_EQ_AW(g_weaponarena_weapons, WEP_TUBA))
+       if(g_weaponarena_weapons == WEPSET_TUBA)
        {
                self.switchweapon = WEP_TUBA;
                return;
@@ -985,7 +982,7 @@ void havocbot_chooseweapon()
        {
                // If no weapon was chosen get the first available weapon
                if(self.weapon==0)
-               for(i=WEP_LASER + 1; i < WEP_COUNT ; ++i)
+               for(i=WEP_BLASTER + 1; i < WEP_COUNT ; ++i) // Samual: This seems strange compared to other weapon loops...
                {
                        if(client_hasweapon(self, i, TRUE, FALSE))
                        {
@@ -1114,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;
                }
 
@@ -1135,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;
                                }
@@ -1160,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;
                }
 
@@ -1178,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