I haven't tested it, but I think this is a good clue:
if (!cr.CritterIsNpc)
{
max_range = TraceWall(cx, cy, ox, oy, map, max_range); // in case wall is blocking
return dist <= max_range; // behind a wall
}
return true; // max pe range handled before
From check_look.cpp, which handles whether critters are visible or not. But I think it might depend on the AI usage as well - if you use CRITTER_EVENT_SHOW_CRITTER_# events, then that will "detect through walls" I think.