+entity ka_ball;
// traces multiple trajectories to find one that will impact the target
// 'end' vector is the place it aims for,
// returns TRUE only if it hit targ (don't target non-solid entities)
float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, float shotspeed, float shotspeedupward, float maxtime, float shotdelay, entity ignore)
{
local float c, savesolid, shottime;
- local vector dir, end, v;
+ local vector dir, end, v, o;
if (shotspeed < 1)
return FALSE; // could cause division by zero if calculated
if (targ.solid < SOLID_BBOX) // SOLID_NOT and SOLID_TRIGGER
setsize(tracetossent, m1, m2);
savesolid = targ.solid;
targ.solid = SOLID_NOT;
- shottime = ((vlen(targ.origin - org) / shotspeed) + shotdelay);
- v = targ.velocity * shottime + targ.origin;
- tracebox(targ.origin, targ.mins, targ.maxs, v, FALSE, targ);
+ o = (targ.absmin + targ.absmax) * 0.5;
+ shottime = ((vlen(o - org) / shotspeed) + shotdelay);
+ v = targ.velocity * shottime + o;
+ tracebox(o, targ.mins, targ.maxs, v, FALSE, targ);
v = trace_endpos;
end = v + (targ.mins + targ.maxs) * 0.5;
if ((vlen(end - org) / shotspeed + 0.2) > maxtime)
{
if (e == self)
return FALSE;
- if (teams_matter)
+ if (teamplay)
if (e.team != 0)
return FALSE;
}
if(e.freezetag_frozen)
return FALSE;
- if(teams_matter)
+ // 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)
return FALSE;
{
f = bot_aimdir(v - shotorg, r);
//dprint("AIM: ");dprint(vtos(self.bot_aimtargorigin));dprint(" + ");dprint(vtos(self.bot_aimtargvelocity));dprint(" * ");dprint(ftos(self.bot_aimlatency + vlen(self.bot_aimtargorigin - shotorg) / shotspeed));dprint(" = ");dprint(vtos(v));dprint(" : aimdir = ");dprint(vtos(normalize(v - shotorg)));dprint(" : ");dprint(vtos(shotdir));dprint("\n");
- traceline(shotorg, shotorg + shotdir * 10000, FALSE, self);
- if (trace_ent.takedamage)
- if (trace_fraction < 1)
- if (!bot_shouldattack(trace_ent))
- return FALSE;
+ //traceline(shotorg, shotorg + shotdir * 10000, FALSE, self);
+ //if (trace_ent.takedamage)
+ //if (trace_fraction < 1)
+ //if (!bot_shouldattack(trace_ent))
+ // return FALSE;
traceline(shotorg, self.bot_aimtargorigin, FALSE, self);
if (trace_fraction < 1)
if (trace_ent != self.enemy)
if (!bot_shouldattack(trace_ent))
return FALSE;
}
- if (r > maxshottime * shotspeed)
- return FALSE;
- return f;
+
+ //if (r > maxshottime * shotspeed)
+ // return FALSE;
+ return TRUE;
};