More or less Im using it as an advanced replacement for Visible () , or Fisible () in my Frikbot code, but have not implimented it yet completely. It does seem to more or less work in cases where the target is completely not
visible. I had noticed that on DM2 For example, Frikbot would fire at you if you were partialy visible through one of the slotted horizontal bars forming the map near the Rocket Lanucher area and wall buttons. Apparently
it could see the target but the aim was never hitting using the Shotgun. I dont know if it was because of the bots skill, so I set out trying to get a better calculation for its aim. I suppose from here we could actually reference all 16 points
as .vectors then aim at either an individual offset or do another calc based on the groups that are hit.
Also, it might have some uses calculating a possible headshot?
Code: Select all
float(entity from, entity seen) CantSee =
{
local float score;
local vector start;
if (self.ishuman == 1)
makevectors (from.v_angle);
else
makevectors2 (from.angles);
score = 100;
start = realorigin(from) + from.view_ofs + v_forward*18;
// Bottom corners
traceline (start, (seen.absmin), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (seen.absmax - '0 0 56'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (seen.absmax - '0 32 56'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (seen.absmax - '0 -32 0'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
// Bottom sides
traceline (start, (realorigin(seen) + '0 -16 -22'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (realorigin(seen) + '0 16 -22'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (realorigin(seen) + '16 0 -22'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (realorigin(seen) + '-16 0 -22'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
// Top corners
traceline (start, (seen.absmin + '0 0 56'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (seen.absmax), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (seen.absmax - '0 32 0'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (seen.absmin - '0 -32 -56'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
// Top sides
traceline (start, (realorigin(seen) + '0 -16 32'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (realorigin(seen) + '0 16 32'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (realorigin(seen) + '16 0 32'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
traceline (start, (realorigin(seen) + '-16 0 32'), FALSE, seen);
if (trace_fraction < 1)
score = score - 6.25;
// Skip this one for now
/*
// bottom center
traceline (self.origin + self.view_ofs, (here), FALSE, self);
if (trace_fraction < 1)
score = score + 1;
*/
//if (score == 16) return 1;
return score;
};