diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index 255fc386..4f89b584 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -771,3 +771,39 @@ CBaseEntity *CBaseEntity::Create( const char *szName, const Vector &vecOrigin, c DispatchSpawn( pEntity->edict() ); return pEntity; } + +//modif de Roy, we need to solve firing in Gaz non-virtual conundrum +BOOL CBaseEntity::IsInGaz ( void ) +{ + if( !IsPlayer()) return FALSE; //Quit immediately. This will always be true. CBaseEntity doesn't have an IsPlayer returning TRUE at all. + //Oh, but... CBasePlayer has! + //However, when combat.cpp calls this function, it calls this version, not the players, since the base function + //is for CBaseEntity, it simply asks it if it's the player (which is true in that case). Since it gets called without an actual pointer, it + //doesn't know which function to fire and does this one, not the player's (which inherits and overrides this function). + //So, if this one gets called in this context, IsPlayer is going to return TRUE, and then this fires up. + + Vector vecPlayer = Center (); + + CBaseEntity *pFind = NULL; + edict_t *pTrigger = NULL; + pTrigger = FIND_ENTITY_BY_CLASSNAME( NULL, "trigger_gaz" ); + + while ( !FNullEnt ( pTrigger ) ) + { + pFind = CBaseEntity::Instance ( pTrigger ); + + + if ( vecPlayer.x > pFind->pev->absmin.x && vecPlayer.x < pFind->pev->absmax.x && + vecPlayer.y > pFind->pev->absmin.y && vecPlayer.y < pFind->pev->absmax.y && + vecPlayer.z > pFind->pev->absmin.z && vecPlayer.z < pFind->pev->absmax.z ) // Player est ds le trigger + { + return TRUE; + } + else + { + pTrigger = FIND_ENTITY_BY_CLASSNAME( pTrigger, "trigger_gaz" ); + } + + } + return FALSE; +} \ No newline at end of file diff --git a/dlls/cbase.h b/dlls/cbase.h index 7bc4a332..30f59ace 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -334,7 +334,7 @@ public: virtual BOOL FVisible( const Vector &vecOrigin ); //modif de Julien - BOOL IsInGaz ( void ) { return FALSE; }; //Must NOT be virtual, causes "unimplemented symbol" error in game. + BOOL IsInGaz ( void ); //Must NOT be virtual, causes "unimplemented symbol" error in game. BOOL m_bFireInGaz;