View Single Post
KWo
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
Old 03-26-2007 , 10:01   Re: IsShootableThruObstacle
Reply With Quote #5

I just want to replace this function in podbot mm by something simpler and written more optimized:
Code:
bool IsShootableThruObstacle (edict_t *pEdict, Vector vecDest)
{
   // Returns if enemy can be shoot through some obstacle
   // TODO: After seeing the disassembled CS Routine it could be speedup and simplified a lot

   Vector vecSrc = GetGunPosition (pEdict);
   Vector vecDir = (vecDest - vecSrc).Normalize (); // 1 unit long
   Vector vecPoint;
   int iThickness = 0;
   int iHits = 0;

   edict_t *pentIgnore = pEdict;
   TraceResult tr;

   UTIL_TraceLine (vecSrc, vecDest, ignore_monsters, ignore_glass, pentIgnore, &tr);

   while ((tr.flFraction != 1.0) && (iHits < 3))
   {
      iHits++;
      iThickness++;
      vecPoint = tr.vecEndPos + vecDir;

      while ((POINT_CONTENTS (vecPoint) == CONTENTS_SOLID) && (iThickness < 98)) // KWo - 23.10.2006
      {
         vecPoint = vecPoint + vecDir;
         iThickness++;
      }

      UTIL_TraceLine (vecPoint, vecDest, ignore_monsters, ignore_glass, pentIgnore, &tr);
   }

   if ((iHits < 3) && (iThickness < 98)) // KWo - 23.10.2006
   {
      float f_distance = (vecDest - vecPoint).Length ();

      if (f_distance < 121.95) // KWo - 23.10.2006
         return (TRUE);
   }

   return (FALSE);
}
That "// TODO" comment it's original Count Floyd's comment, but I have no idea what he was thinking about, that's why I'm asking here the people they have better HL knowledge than me.
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 (AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
KWo is offline