Bot AI: keep the jump button pressed for a short while, useful with ramp jumps
authorterencehill <piuntn@gmail.com>
Sun, 16 Feb 2020 22:28:31 +0000 (23:28 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 16 Feb 2020 22:28:31 +0000 (23:28 +0100)
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/bot.qh
qcsrc/server/bot/default/havocbot/havocbot.qc

index f367adab32c538c455a1a12ea8216897de1d2781..ffe2e72b42c98c212b6cb696ba47d04d613e7161 100644 (file)
@@ -104,7 +104,8 @@ void bot_think(entity this)
 
        // clear buttons
        PHYS_INPUT_BUTTON_ATCK(this) = false;
-       PHYS_INPUT_BUTTON_JUMP(this) = false;
+       // keep jump button pressed for a short while, useful with ramp jumps
+       PHYS_INPUT_BUTTON_JUMP(this) = (!IS_DEAD(this) && time < this.bot_jump_time + 0.2);
        PHYS_INPUT_BUTTON_ATCK2(this) = false;
        PHYS_INPUT_BUTTON_ZOOM(this) = false;
        PHYS_INPUT_BUTTON_CROUCH(this) = false;
index 2cc20e0d34d4b7e080fabae33738a7ce3ef3218f..88dba449d5fe245d9a63b05c019f9c1ffd1009ec 100644 (file)
@@ -65,6 +65,7 @@ entity bot_list;
 .bool bot_pickup_respawning;
 .float bot_canfire;
 .float bot_strategytime;
+.float bot_jump_time;
 
 .float bot_forced_team;
 .float bot_config_loaded;
index 86b8be7c6dcb917ea320066da47713388afffa2b..a31ee34ae3c48e081619f0cd27b4e7f31899388a 100644 (file)
@@ -245,6 +245,7 @@ void havocbot_bunnyhop(entity this, vector dir)
        if (can_run)
        {
                PHYS_INPUT_BUTTON_JUMP(this) = true;
+               this.bot_jump_time = time;
                this.aistatus |= AI_STATUS_RUNNING;
        }
        else
@@ -649,8 +650,6 @@ void havocbot_movetogoal(entity this)
                        dir.z = 1;
                else if(this.velocity.z >= 0 && !(this.waterlevel == WATERLEVEL_WETFEET && this.watertype == CONTENT_WATER))
                        PHYS_INPUT_BUTTON_JUMP(this) = true;
-               else
-                       PHYS_INPUT_BUTTON_JUMP(this) = false;
                makevectors(this.v_angle.y * '0 1 0');
                vector v = dir * maxspeed;
                CS(this).movement.x = v * v_forward;
@@ -884,7 +883,6 @@ void havocbot_movetogoal(entity this)
                                }
                                else
                                {
-                                       PHYS_INPUT_BUTTON_JUMP(this) = false;
                                        if (destorg.z > this.origin.z)
                                                dir = flatdir;
                                }
@@ -928,6 +926,7 @@ void havocbot_movetogoal(entity this)
                                )
                                {
                                        PHYS_INPUT_BUTTON_JUMP(this) = true;
+                                       this.bot_jump_time = time;
                                        // avoid changing route while bot is jumping a gap
                                        navigation_goalrating_timeout_extend_if_needed(this, 1.5);
                                }
@@ -1005,13 +1004,19 @@ void havocbot_movetogoal(entity this)
                                                vector jump_height = (IS_ONGROUND(this)) ? stepheightvec + jumpheight_vec : jumpstepheightvec;
                                                tracebox(this.origin + jump_height, this.mins, this.maxs, actual_destorg + jump_height, false, this);
                                                if (trace_fraction > s)
+                                               {
                                                        PHYS_INPUT_BUTTON_JUMP(this) = true;
+                                                       this.bot_jump_time = time;
+                                               }
                                                else
                                                {
                                                        jump_height = stepheightvec + jumpheight_vec / 2;
                                                        tracebox(this.origin + jump_height, this.mins, this.maxs, actual_destorg + jump_height, false, this);
                                                        if (trace_fraction > s)
+                                                       {
                                                                PHYS_INPUT_BUTTON_JUMP(this) = true;
+                                                               this.bot_jump_time = time;
+                                                       }
                                                }
                                        }
                                }