Thanks again PM. Now this may be nice...
Code:
if (m_iAimFlags < AIM_LASTENEMY)
{
// check if we're going through a door...
UTIL_TraceLine(pev->origin, m_vecDestOrigin, ignore_monsters, edict(), &tr);
if (tr.flFraction < 1.0 && !FNullEnt(tr.pHit))
{
if (FClassnameIs(tr.pHit, "func_door") ||
FClassnameIs(tr.pHit, "func_door_rotating"))
{
// Always face the door when going through it
m_iAimFlags |= AIM_ENTITY;
// PMB: don't use the origin of the door
m_vecEntity = m_vecDestOrigin;
// If the door is near enough...
if (Length2(VecBModelOrigin(tr.pHit) - pev->origin) < 2500)
{
m_flNoCollTime = gpGlobals->time + 0.5; // don't consider being stuck
if (RANDOM_LONG(1, 100) < 50)
pev->buttons |= IN_USE; // Also 'use' the door randomly
}
}
}
}