float bot_aim(float shotspeed, float shotspeedupward, float maxshottime, float applygravity)
{
- local float f, r;
+ local float f, r, hf, distanceratio;
local vector v;
/*
eprint(self);
dprint(", ", ftos(applygravity));
dprint(");\n");
*/
+
+ hf = self.dphitcontentsmask;
+ self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
+
shotspeed *= g_weaponspeedfactor;
shotspeedupward *= g_weaponspeedfactor;
if (!shotspeed)
shotorg = self.origin + self.view_ofs;
shotdir = v_forward;
v = bot_shotlead(self.bot_aimtargorigin, self.bot_aimtargvelocity, shotspeed, self.bot_aimlatency);
- local float distanceratio;
- distanceratio =sqrt(bound(0,skill,10000))*0.3*(vlen(v-shotorg)-100)/autocvar_bot_ai_aimskill_firetolerance_distdegrees;
+ distanceratio = sqrt(bound(0,skill,10000))*0.3*(vlen(v-shotorg)-100)/autocvar_bot_ai_aimskill_firetolerance_distdegrees;
distanceratio = bound(0,distanceratio,1);
r = (autocvar_bot_ai_aimskill_firetolerance_maxdegrees-autocvar_bot_ai_aimskill_firetolerance_mindegrees)
* (1-distanceratio) + autocvar_bot_ai_aimskill_firetolerance_mindegrees;
if (applygravity && self.bot_aimtarg)
{
if (!findtrajectorywithleading(shotorg, '0 0 0', '0 0 0', self.bot_aimtarg, shotspeed, shotspeedupward, maxshottime, 0, self))
+ {
+ self.dphitcontentsmask = hf;
return FALSE;
+ }
+
f = bot_aimdir(findtrajectory_velocity - shotspeedupward * '0 0 1', r);
}
else
if (trace_fraction < 1)
if (trace_ent != self.enemy)
if (!bot_shouldattack(trace_ent))
+ {
+ self.dphitcontentsmask = hf;
return FALSE;
+ }
}
//if (r > maxshottime * shotspeed)
// return FALSE;
+ self.dphitcontentsmask = hf;
return TRUE;
};
void havocbot_chooseenemy()
{
local entity head, best, head2;
- local float rating, bestrating, i, f;
+ local float rating, bestrating, i, hf;
local vector eye, v;
if (autocvar_bot_nofire || IS_INDEPENDENT_PLAYER(self))
{
bestrating = 100000000;
head = head2 = findchainfloat(bot_attack, TRUE);
+ // Backup hit flags
+ hf = self.dphitcontentsmask;
+
// Search for enemies, if no enemy can be seen directly try to look through transparent objects
+
+ self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
+
for(;;)
{
while (head)
break;
// Set flags to see through transparent objects
- f = self.dphitcontentsmask;
- self.dphitcontentsmask = DPCONTENTS_OPAQUE;
+ self.dphitcontentsmask |= DPCONTENTS_OPAQUE;
head = head2;
++i;
}
- // Restore hit flags if needed
- if(i)
- self.dphitcontentsmask = f;
+ // Restore hit flags
+ self.dphitcontentsmask = hf;
self.enemy = best;
self.havocbot_stickenemy = TRUE;