This bug affects ALL the HL bots (no matter if it's CS related or not)
In order to make one's bot see through glass, the bot coder usually uses an overloaded TraceLine() call with the "ignore_glass" parameter. It looks like this:
UTIL_TraceLine (vecStart, vecEnd, ignore_monsters,
ignore_glass, pEdict, &tr);
However
THIS DOES NOT ALWAYS WORK. There are several ways to create glass-like effects with entities when building a map, but all of them have something in common: the created entity must have the "kRenderTransTexture" as "render mode" and a render amount between 0 and 255 (0 being totally transparent, and 255 totally opaque). However SOME MAPPERS ALSO MAKE THEIR GLASS ENTITIES WEAR THE FL_WORLDBRUSH FLAG, THUS ASSIMILATING THEIR ENTITY WITH THE WORLD. This is especially true for non-breakable glasses like those you can see in the Counter-Strike map cs_siege, for example.
The problem with this is that UTIL_TraceLine with the ignore_glass flag doesn't pass anymore through world brushes !
In order to allow our TraceLine to pass, we must then clear the transparent entity of its FL_WORLDBRUSH flag.
Since this flag is set when the entity is spawned, we must clear it AFTER the actual engine function Spawn() is called. Non-metamod (hook DLL) bots can do this in DispatchSpawn, right AFTER "g_engfuncs.pfnSpawn" is called.
However, metamod bots must hook on one metamod API more, and use one function from the
GetEntityAPI2_Post interface. The appropriate code for metamod bots will then look like this:
Code:
int Spawn_Post (edict_t *pent)
{
// solves the bots unable to see through certain types of glass bug.
// MAPPERS: NEVER ALLOW A TRANSPARENT ENTITY TO WEAR THE FL_WORLDBRUSH FLAG !!!
// is this a transparent entity ?
if (pent->v.rendermode == kRenderTransTexture)
pent->v.flags &= ~FL_WORLDBRUSH; // then clear the FL_WORLDBRUSH flag
RETURN_META_VALUE (MRES_IGNORED, 0);
}
Note that you
MUST declare Spawn_Post in the GetEntityAPI2_Post interface and you
MUST notify metamod that you are using this new API,
IN ADDITION to the GetEntityAPI2 one (you usually do this when defining gMetaFunctionTable).