From: terencehill Date: Fri, 21 Dec 2018 18:17:08 +0000 (+0100) Subject: Fix #2177 "Bot code causes division by zero" X-Git-Tag: xonotic-v0.8.5~1681 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=703394e150e49224c2d8e3f7a733f43cbbf080c7;p=xonotic%2Fxonotic-data.pk3dir.git Fix #2177 "Bot code causes division by zero" --- diff --git a/qcsrc/server/bot/default/aim.qc b/qcsrc/server/bot/default/aim.qc index 7af3fab05..1f570eaf5 100644 --- a/qcsrc/server/bot/default/aim.qc +++ b/qcsrc/server/bot/default/aim.qc @@ -170,14 +170,15 @@ void bot_lagfunc(entity this, float t, float f1, float f2, entity e1, vector v1, this.bot_canfire = 1; } +// this function should be called after bot_aim so the aim is reset the next frame void bot_aim_reset(entity this) { + this.bot_mouseaim = this.v_angle; + this.bot_olddesiredang = this.v_angle; this.bot_aimdir_executed = true; this.bot_badaimtime = 0; this.bot_aimthinktime = time; this.bot_prevaimtime = time; - this.bot_mouseaim = this.v_angle; - this.bot_olddesiredang = this.v_angle; this.bot_1st_order_aimfilter = '0 0 0'; this.bot_2nd_order_aimfilter = '0 0 0'; this.bot_3th_order_aimfilter = '0 0 0'; @@ -198,6 +199,10 @@ void bot_aimdir(entity this, vector v, float maxfiredeviation) this.v_angle_y = this.v_angle.y - floor(this.v_angle.y / 360) * 360; this.v_angle_z = 0; + // make work bot_aim_reset even if called before this function + if (this.bot_prevaimtime == time) + return; + // invalid aim dir (can happen when bot overlaps target) if(!v) return;