]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: reset aim when bots respawn
authorterencehill <piuntn@gmail.com>
Thu, 22 Nov 2018 17:14:02 +0000 (18:14 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 22 Nov 2018 17:14:02 +0000 (18:14 +0100)
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/aim.qc
qcsrc/server/bot/default/aim.qh
qcsrc/server/client.qc

index 11e0707e989e3ab5e344825b1cdc742103678e81..4a0ede4e2acebe76a385a172403c9ad1caba9c2e 100644 (file)
@@ -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);
index f30c5e58ea4dacaa878f2911d2debdd68ec8cc3b..ae133b4ed0382f2c77ff0be9b0e3a27b60fa09d1 100644 (file)
@@ -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;
index 1eb71bc7ff58fee1cdaa2eecdf81003495eb5d91..2a3145176258a6aa523efd3c95a252c8251ba897 100644 (file)
@@ -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);
index 01c8222e62de1597fb561a31590f8bcb164e9b04..8ccd64b1e1eadbd29ef50c44b5503e3b8e78c2c3 100644 (file)
@@ -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';