From: terencehill Date: Sun, 16 Feb 2020 22:28:31 +0000 (+0100) Subject: Bot AI: keep the jump button pressed for a short while, useful with ramp jumps X-Git-Tag: xonotic-v0.8.5~1152 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6bb9df7b42baeb0ef01bbcd7fca7ec490c794ce3;p=xonotic%2Fxonotic-data.pk3dir.git Bot AI: keep the jump button pressed for a short while, useful with ramp jumps --- diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index f367adab3..ffe2e72b4 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -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; diff --git a/qcsrc/server/bot/default/bot.qh b/qcsrc/server/bot/default/bot.qh index 2cc20e0d3..88dba449d 100644 --- a/qcsrc/server/bot/default/bot.qh +++ b/qcsrc/server/bot/default/bot.qh @@ -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; diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 86b8be7c6..a31ee34ae 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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; + } } } }