From: terencehill Date: Thu, 22 Nov 2018 17:14:02 +0000 (+0100) Subject: Bot AI: reset aim when bots respawn X-Git-Tag: xonotic-v0.8.5~1705^2~10 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=0e4f674ee0300e74cc11de82564e2a03710822cd Bot AI: reset aim when bots respawn --- diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 11e0707e98..4a0ede4e2a 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -55,6 +55,7 @@ float skill; .int wpflags; bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, float applygravity); +void bot_aim_reset(entity this); void bot_clientconnect(entity this); void bot_clientdisconnect(entity this); void bot_cmdhelp(string scmd); diff --git a/qcsrc/server/bot/default/aim.qc b/qcsrc/server/bot/default/aim.qc index f30c5e58ea..ae133b4ed0 100644 --- a/qcsrc/server/bot/default/aim.qc +++ b/qcsrc/server/bot/default/aim.qc @@ -170,6 +170,23 @@ void bot_lagfunc(entity this, float t, float f1, float f2, entity e1, vector v1, this.bot_canfire = 1; } +void bot_aim_reset(entity this) +{ + this.bot_aimdir_executed = true; + makevectors(this.v_angle); + this.bot_badaimtime = 0; + this.bot_aimthinktime = time; + this.bot_prevaimtime = time; + this.bot_mouseaim = v_forward; + this.bot_olddesiredang = v_forward; + this.bot_1st_order_aimfilter = '0 0 0'; + this.bot_2nd_order_aimfilter = '0 0 0'; + this.bot_3th_order_aimfilter = '0 0 0'; + this.bot_4th_order_aimfilter = '0 0 0'; + this.bot_5th_order_aimfilter = '0 0 0'; + this.bot_firetimer = 0; +} + void bot_aimdir(entity this, vector v, float maxfiredeviation) { float dist, delta_t, blend; diff --git a/qcsrc/server/bot/default/aim.qh b/qcsrc/server/bot/default/aim.qh index 1eb71bc7ff..2a31451762 100644 --- a/qcsrc/server/bot/default/aim.qh +++ b/qcsrc/server/bot/default/aim.qh @@ -93,6 +93,7 @@ void bot_lagfunc(entity this, float t, float f1, float f2, entity e1, vector v1, float bot_shouldattack(entity this, entity targ); void bot_aimdir(entity this, vector v, float maxfiredeviation); bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity); +void bot_aim_reset(entity this); float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, float shotspeed, float shotspeedupward, float maxtime, float shotdelay, entity ignore); vector bot_shotlead(vector targorigin, vector targvelocity, float shotspeed, float shotdelay); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 01c8222e62..8ccd64b1e1 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -622,7 +622,10 @@ void PutPlayerInServer(entity this) this.angles = spot.angles; this.angles_z = 0; // never spawn tilted even if the spot says to if (IS_BOT_CLIENT(this)) + { this.v_angle = this.angles; + bot_aim_reset(this); + } this.fixangle = true; // turn this way immediately this.oldvelocity = this.velocity = '0 0 0'; this.avelocity = '0 0 0';