]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/default/havocbot/havocbot.qc
Merge branch 'master' into terencehill/bot_waypoints
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / havocbot / havocbot.qc
index e9b9cdf41ea9f836e0806accca989dd58341b4ec..9f6da64eb26abe234e4142e221f24ecd8d47a98c 100644 (file)
@@ -288,7 +288,7 @@ void havocbot_bunnyhop(entity this, vector dir)
                return;
        }
 
-       if(this.waterlevel > WATERLEVEL_WETFEET)
+       if(this.waterlevel > WATERLEVEL_WETFEET || IS_DUCKED(this))
        {
                this.aistatus &= ~AI_STATUS_RUNNING;
                return;
@@ -479,6 +479,11 @@ void havocbot_movetogoal(entity this)
        CS(this).movement = '0 0 0';
        maxspeed = autocvar_sv_maxspeed;
 
+       if (this.goalcurrent.wpflags & WAYPOINTFLAG_CROUCH)
+               PHYS_INPUT_BUTTON_CROUCH(this) = true;
+       else
+               PHYS_INPUT_BUTTON_CROUCH(this) = false;
+
        PHYS_INPUT_BUTTON_JETPACK(this) = false;
        // Jetpack navigation
        if(this.navigation_jetpack_goal)
@@ -1055,7 +1060,17 @@ void havocbot_movetogoal(entity this)
                        LABEL(jumpobstacle_check);
                        dir = flatdir = normalize(actual_destorg - this.origin);
 
-                       if (turning || fabs(deviation.y) < 50) // don't even try to jump if deviation is too high
+                       bool jump_forbidden = false;
+                       if (!turning && fabs(deviation.y) > 50)
+                               jump_forbidden = true;
+                       else if (IS_DUCKED(this))
+                       {
+                               tracebox(this.origin, PL_MIN_CONST, PL_MAX_CONST, this.origin, false, this);
+                               if (trace_startsolid)
+                                       jump_forbidden = true;
+                       }
+
+                       if (!jump_forbidden)
                        {
                                tracebox(this.origin, this.mins, this.maxs, actual_destorg, false, this);
                                if (trace_fraction < 1 && trace_plane_normal.z < 0.7)
@@ -1284,9 +1299,15 @@ void havocbot_movetogoal(entity this)
        if(skill+this.bot_moveskill >= autocvar_bot_ai_bunnyhop_skilloffset)
                havocbot_bunnyhop(this, dir);
 
-       if ((dir * v_up) >= autocvar_sv_jumpvelocity*0.5 && (IS_ONGROUND(this))) PHYS_INPUT_BUTTON_JUMP(this) = true;
-       if (((dodge * v_up) > 0) && random()*frametime >= 0.2*bound(0,(10-skill-this.bot_dodgeskill)*0.1,1)) PHYS_INPUT_BUTTON_JUMP(this) = true;
-       if (((dodge * v_up) < 0) && random()*frametime >= 0.5*bound(0,(10-skill-this.bot_dodgeskill)*0.1,1)) this.havocbot_ducktime=time+0.3/bound(0.1,skill+this.bot_dodgeskill,10);
+       if (dir * v_up >= autocvar_sv_jumpvelocity * 0.5 && IS_ONGROUND(this))
+               PHYS_INPUT_BUTTON_JUMP(this) = true;
+       if (dodge)
+       {
+               if (dodge * v_up > 0 && random() * frametime >= 0.2 * bound(0, (10 - skill - this.bot_dodgeskill) * 0.1, 1))
+                       PHYS_INPUT_BUTTON_JUMP(this) = true;
+               if (dodge * v_up < 0 && random() * frametime >= 0.5 * bound(0, (10 - skill - this.bot_dodgeskill) * 0.1, 1))
+                       this.havocbot_ducktime = time + 0.3 / bound(0.1, skill + this.bot_dodgeskill, 10);
+       }
 }
 
 entity havocbot_gettarget(entity this, bool secondary)