Browse Source

HL:Invasion IsInGaz fix for trigger_gaz (weapons must not be able to shoot without triggering it)

invasion
Roy Shapiro 2 years ago
parent
commit
faa9ba8e2d
  1. 36
      dlls/cbase.cpp
  2. 2
      dlls/cbase.h

36
dlls/cbase.cpp

@ -771,3 +771,39 @@ CBaseEntity *CBaseEntity::Create( const char *szName, const Vector &vecOrigin, c
DispatchSpawn( pEntity->edict() ); DispatchSpawn( pEntity->edict() );
return pEntity; 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;
}

2
dlls/cbase.h

@ -334,7 +334,7 @@ public:
virtual BOOL FVisible( const Vector &vecOrigin ); virtual BOOL FVisible( const Vector &vecOrigin );
//modif de Julien //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; BOOL m_bFireInGaz;

Loading…
Cancel
Save