]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/aim.qc
server: pass compilation units test
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / aim.qc
index c889a2f9aaf8a540af01cacd2ee588f83c9ae99a..7202547fc0b8491a72619f510e89a7be2dedf3f8 100644 (file)
@@ -1,9 +1,13 @@
 #include "aim.qh"
-#include "../_all.qh"
 
 #include "bot.qh"
 
-#include "../mutators/mutators_include.qh"
+#include <common/physics/player.qh>
+#include <common/state.qh>
+
+#include "../weapons/weaponsystem.qh"
+
+#include "../mutators/all.qh"
 
 // traces multiple trajectories to find one that will impact the target
 // 'end' vector is the place it aims for,
@@ -18,7 +22,7 @@ float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, f
        if (targ.solid < SOLID_BBOX) // SOLID_NOT and SOLID_TRIGGER
                return false; // could never hit it
        if (!tracetossent)
-               tracetossent = spawn();
+               tracetossent = new(tracetossent);
        tracetossent.owner = ignore;
        setsize(tracetossent, m1, m2);
        savesolid = targ.solid;
@@ -37,10 +41,10 @@ float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, f
        }
 
        if (!tracetossfaketarget)
-               tracetossfaketarget = spawn();
+               tracetossfaketarget = new(tracetossfaketarget);
        tracetossfaketarget.solid = savesolid;
        tracetossfaketarget.movetype = targ.movetype;
-       setmodel(tracetossfaketarget, targ.model); // no low precision
+       _setmodel(tracetossfaketarget, targ.model); // no low precision
        tracetossfaketarget.model = targ.model;
        tracetossfaketarget.modelindex = targ.modelindex;
        setsize(tracetossfaketarget, targ.mins, targ.maxs);
@@ -86,7 +90,7 @@ float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, f
 }
 
 void lag_update()
-{
+{SELFPARAM();
        if (self.lag1_time) if (time > self.lag1_time) {self.lag_func(self.lag1_time, self.lag1_float1, self.lag1_float2, self.lag1_entity1, self.lag1_vec1, self.lag1_vec2, self.lag1_vec3, self.lag1_vec4);self.lag1_time = 0;}
        if (self.lag2_time) if (time > self.lag2_time) {self.lag_func(self.lag2_time, self.lag2_float1, self.lag2_float2, self.lag2_entity1, self.lag2_vec1, self.lag2_vec2, self.lag2_vec3, self.lag2_vec4);self.lag2_time = 0;}
        if (self.lag3_time) if (time > self.lag3_time) {self.lag_func(self.lag3_time, self.lag3_float1, self.lag3_float2, self.lag3_entity1, self.lag3_vec1, self.lag3_vec2, self.lag3_vec3, self.lag3_vec4);self.lag3_time = 0;}
@@ -95,7 +99,7 @@ void lag_update()
 }
 
 float lag_additem(float t, float f1, float f2, entity e1, vector v1, vector v2, vector v3, vector v4)
-{
+{SELFPARAM();
        if (self.lag1_time == 0) {self.lag1_time = t;self.lag1_float1 = f1;self.lag1_float2 = f2;self.lag1_entity1 = e1;self.lag1_vec1 = v1;self.lag1_vec2 = v2;self.lag1_vec3 = v3;self.lag1_vec4 = v4;return true;}
        if (self.lag2_time == 0) {self.lag2_time = t;self.lag2_float1 = f1;self.lag2_float2 = f2;self.lag2_entity1 = e1;self.lag2_vec1 = v1;self.lag2_vec2 = v2;self.lag2_vec3 = v3;self.lag2_vec4 = v4;return true;}
        if (self.lag3_time == 0) {self.lag3_time = t;self.lag3_float1 = f1;self.lag3_float2 = f2;self.lag3_entity1 = e1;self.lag3_vec1 = v1;self.lag3_vec2 = v2;self.lag3_vec3 = v3;self.lag3_vec4 = v4;return true;}
@@ -106,7 +110,7 @@ float lag_additem(float t, float f1, float f2, entity e1, vector v1, vector v2,
 }
 
 float bot_shouldattack(entity e)
-{
+{SELFPARAM();
        if (e.team == self.team)
        {
                if (e == self)
@@ -116,15 +120,9 @@ float bot_shouldattack(entity e)
                        return false;
        }
 
-       if(e.frozen)
+       if(STAT(FROZEN, e))
                return false;
 
-       // If neither player has ball then don't attack unless the ball is on the
-       // ground.
-       if (g_keepaway)
-               if (!e.ballcarried && !self.ballcarried && ka_ball.owner)
-                       return false;
-
        if(teamplay)
        {
                if(e.team==0)
@@ -136,22 +134,21 @@ float bot_shouldattack(entity e)
 
        if (!e.takedamage)
                return false;
-       if (e.deadflag)
+       if (IS_DEAD(e))
                return false;
-       if (e.BUTTON_CHAT)
+       if (PHYS_INPUT_BUTTON_CHAT(e))
                return false;
        if(e.flags & FL_NOTARGET)
                return false;
 
-       checkentity = e;
-       if(MUTATOR_CALLHOOK(BotShouldAttack))
+       if(MUTATOR_CALLHOOK(BotShouldAttack, e))
                return false;
 
        return true;
 }
 
 void bot_lagfunc(float t, float f1, float f2, entity e1, vector v1, vector v2, vector v3, vector v4)
-{
+{SELFPARAM();
        if(self.flags & FL_INWATER)
        {
                self.bot_aimtarg = world;
@@ -174,7 +171,7 @@ void bot_lagfunc(float t, float f1, float f2, entity e1, vector v1, vector v2, v
 }
 
 float bot_aimdir(vector v, float maxfiredeviation)
-{
+{SELFPARAM();
        float dist, delta_t, blend;
        vector desiredang, diffang;
 
@@ -309,7 +306,7 @@ float bot_aimdir(vector v, float maxfiredeviation)
        // note the maxfiredeviation is in degrees so this has to convert to radians first
        //if ((normalize(v) * shotdir) >= cos(maxfiredeviation * (3.14159265358979323846 / 180)))
        if ((normalize(v) * shotdir) >= cos(maxfiredeviation * (3.14159265358979323846 / 180)))
-       if (vlen(trace_endpos-shotorg) < 500+500*bound(0, skill+self.bot_aggresskill, 10) || random()*random()>bound(0,(skill+self.bot_aggresskill)*0.05,1))
+       if(vdist(trace_endpos-shotorg, <, 500 + 500 * bound(0, skill + self.bot_aggresskill, 10)) || random()*random()>bound(0,(skill+self.bot_aggresskill)*0.05,1))
                self.bot_firetimer = time + bound(0.1, 0.5-(skill+self.bot_aggresskill)*0.05, 0.5);
        //traceline(shotorg,shotorg+shotdir*1000,false,world);
        //dprint(ftos(maxfiredeviation),"\n");
@@ -325,7 +322,7 @@ vector bot_shotlead(vector targorigin, vector targvelocity, float shotspeed, flo
 }
 
 float bot_aim(float shotspeed, float shotspeedupward, float maxshottime, float applygravity)
-{
+{SELFPARAM();
        float f, r, hf, distanceratio;
        vector v;
        /*
@@ -344,12 +341,12 @@ float bot_aim(float shotspeed, float shotspeedupward, float maxshottime, float a
        shotspeedupward *= W_WeaponSpeedFactor();
        if (!shotspeed)
        {
-               dprint("bot_aim: WARNING: weapon ", WEP_NAME(self.weapon), " shotspeed is zero!\n");
+               LOG_TRACE("bot_aim: WARNING: weapon ", PS(self).m_weapon.m_name, " shotspeed is zero!\n");
                shotspeed = 1000000;
        }
        if (!maxshottime)
        {
-               dprint("bot_aim: WARNING: weapon ", WEP_NAME(self.weapon), " maxshottime is zero!\n");
+               LOG_TRACE("bot_aim: WARNING: weapon ", PS(self).m_weapon.m_name, " maxshottime is zero!\n");
                maxshottime = 1;
        }
        makevectors(self.v_angle);