For Tripmine looks the code :
PHP Code:
void CTripmineGrenade :: BeamBreakThink( void )
{
BOOL bBlowup = 0;
TraceResult tr;
// HACKHACK Set simple box using this really nice global!
gpGlobals->trace_flags = FTRACE_SIMPLEBOX;
UTIL_TraceLine( pev->origin, m_vecEnd, dont_ignore_monsters, ENT( pev ), &tr );
// ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength );
// respawn detect.
if ( !m_pBeam )
{
MakeBeam( );
if ( tr.pHit )
m_hOwner = CBaseEntity::Instance( tr.pHit ); // reset owner too
}
if (fabs( m_flBeamLength - tr.flFraction ) > 0.001)
{
bBlowup = 1;
}
else
{
if (m_hOwner == NULL)
bBlowup = 1;
else if (m_posOwner != m_hOwner->pev->origin)
bBlowup = 1;
else if (m_angleOwner != m_hOwner->pev->angles)
bBlowup = 1;
}
if (bBlowup)
{
// a bit of a hack, but all CGrenade code passes pev->owner along to make sure the proper player gets credit for the kill
// so we have to restore pev->owner from pRealOwner, because an entity's tracelines don't strike it's pev->owner which meant
// that a player couldn't trigger his own tripmine. Now that the mine is exploding, it's safe the restore the owner so the
// CGrenade code knows who the explosive really belongs to.
pev->owner = m_pRealOwner;
pev->health = 0;
Killed( VARS( pev->owner ), GIB_NORMAL );
return;
}
pev->nextthink = gpGlobals->time + 0.1;
}
PHP Code:
if (m_hOwner == NULL)
bBlowup = 1;
else if (m_posOwner != m_hOwner->pev->origin)
bBlowup = 1;
else if (m_angleOwner != m_hOwner->pev->angles)
bBlowup = 1;
it will explode if m_hOwner is null, or if m_posOwner/m_angleOwner is different.
For m_hOwner, get_pdata_ent() should work.
__________________