Browse Source

Opfor fixes (#242)

* Update displacer. Play displacer sounds in player entity

* Detach player from a rope when they get teleported with displacer

* Make snarks enemies to shock troopers

* Don't explicitly set Touch as touch function for displacer ball

* Fix possible null pointer reference is desert eagle
opforfixed
Roman Chistokhodov 3 years ago committed by GitHub
parent
commit
a32bec7904
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      dlls/gearbox/displacer.cpp
  2. 2
      dlls/gearbox/displacerball.h
  3. 5
      dlls/gearbox/eagle.cpp
  4. 2
      dlls/monsters.cpp
  5. 53
      dlls/player.cpp
  6. 2
      dlls/player.h

36
dlls/gearbox/displacer.cpp

@ -56,7 +56,6 @@ void CDisplacerBall::Spawn(void)
pev->frame = 0; pev->frame = 0;
pev->scale = 0.75; pev->scale = 0.75;
SetTouch( &CDisplacerBall::Touch );
SetThink( &CDisplacerBall::FlyThink ); SetThink( &CDisplacerBall::FlyThink );
pev->nextthink = gpGlobals->time + 0.2; pev->nextthink = gpGlobals->time + 0.2;
UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0));
@ -154,9 +153,7 @@ void CDisplacerBall::SelfCreate(entvars_t *pevOwner,Vector vecStart)
void CDisplacerBall::Touch(CBaseEntity *pOther) void CDisplacerBall::Touch(CBaseEntity *pOther)
{ {
// Do not collide with the owner. pev->velocity = g_vecZero;
if (ENT(pOther->pev) == pev->owner || (ENT(pOther->pev) == VARS(pev->owner)->owner))
return;
TraceResult tr; TraceResult tr;
Vector vecSpot; Vector vecSpot;
@ -164,11 +161,7 @@ void CDisplacerBall::Touch(CBaseEntity *pOther)
pev->enemy = pOther->edict(); pev->enemy = pOther->edict();
CBaseEntity *pTarget = NULL; CBaseEntity *pTarget = NULL;
if (!pOther->pev->takedamage) EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/displacer_impact.wav", 0.9f, ATTN_NORM);
{
EMIT_SOUND_DYN(ENT(pev), CHAN_WEAPON, "weapons/displacer_impact.wav", 1, ATTN_NORM, 0, 100);
UTIL_MuzzleLight( pOther->pev->origin, 160.0f, 255, 180, 96, 1.0f, 100.0f );
}
if( ( g_pGameRules->IsMultiplayer() && !g_pGameRules->IsCoOp() ) && pOther->IsPlayer() ) if( ( g_pGameRules->IsMultiplayer() && !g_pGameRules->IsCoOp() ) && pOther->IsPlayer() )
{ {
@ -219,7 +212,7 @@ void CDisplacerBall::Circle( void )
WRITE_COORD(pev->origin.z); WRITE_COORD(pev->origin.z);
WRITE_COORD(pev->origin.x); WRITE_COORD(pev->origin.x);
WRITE_COORD(pev->origin.y); WRITE_COORD(pev->origin.y);
WRITE_COORD(pev->origin.z + 800); // reach damage radius over .2 seconds WRITE_COORD(pev->origin.z + 800.0f); // reach damage radius over .2 seconds
WRITE_SHORT(iRingSprite); WRITE_SHORT(iRingSprite);
WRITE_BYTE(0); // startframe WRITE_BYTE(0); // startframe
WRITE_BYTE(0); // framerate WRITE_BYTE(0); // framerate
@ -237,8 +230,6 @@ void CDisplacerBall::Circle( void )
void CDisplacerBall::KillThink( void ) void CDisplacerBall::KillThink( void )
{ {
if( pRemoveEnt )
UTIL_Remove( pRemoveEnt );
SetThink( &CDisplacerBall::ExplodeThink ); SetThink( &CDisplacerBall::ExplodeThink );
pev->nextthink = gpGlobals->time + 0.2f; pev->nextthink = gpGlobals->time + 0.2f;
} }
@ -335,7 +326,7 @@ BOOL CDisplacer::PlayEmptySound(void)
{ {
if (m_iPlayEmptySound) if (m_iPlayEmptySound)
{ {
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "buttons/button11.wav", 1, ATTN_NORM); EMIT_SOUND(m_pPlayer->edict(), CHAN_WEAPON, "buttons/button11.wav", 0.9f, ATTN_NORM);
m_iPlayEmptySound = 0; m_iPlayEmptySound = 0;
return 0; return 0;
} }
@ -395,7 +386,7 @@ void CDisplacer::Precache(void)
//========================================================= //=========================================================
BOOL CDisplacer::Deploy() BOOL CDisplacer::Deploy()
{ {
return DefaultDeploy("models/v_displacer.mdl", "models/p_displacer.mdl", DISPLACER_DRAW, "displacer", UseDecrement()); return DefaultDeploy("models/v_displacer.mdl", "models/p_displacer.mdl", DISPLACER_DRAW, "egon", UseDecrement());
} }
//========================================================= //=========================================================
@ -421,7 +412,7 @@ void CDisplacer::SecondaryAttack(void)
if (m_fFireOnEmpty || !CanFireDisplacer(DISPLACER_SECONDARY_USAGE)) if (m_fFireOnEmpty || !CanFireDisplacer(DISPLACER_SECONDARY_USAGE))
{ {
PlayEmptySound(); PlayEmptySound();
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3f; m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f;
return; return;
} }
@ -443,7 +434,7 @@ void CDisplacer::PrimaryAttack()
if ( m_fFireOnEmpty || !CanFireDisplacer(DISPLACER_PRIMARY_USAGE)) if ( m_fFireOnEmpty || !CanFireDisplacer(DISPLACER_PRIMARY_USAGE))
{ {
PlayEmptySound(); PlayEmptySound();
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3f; m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f;
return; return;
} }
m_iFireMode = FIREMODE_FORWARD; m_iFireMode = FIREMODE_FORWARD;
@ -490,10 +481,10 @@ void CDisplacer::ClearSpin( void )
switch (m_iFireMode) switch (m_iFireMode)
{ {
case FIREMODE_FORWARD: case FIREMODE_FORWARD:
STOP_SOUND(ENT(pev), CHAN_WEAPON, "weapons/displacer_spin.wav"); STOP_SOUND(m_pPlayer->edict(), CHAN_WEAPON, "weapons/displacer_spin.wav");
break; break;
case FIREMODE_BACKWARD: case FIREMODE_BACKWARD:
STOP_SOUND(ENT(pev), CHAN_WEAPON, "weapons/displacer_spin2.wav"); STOP_SOUND(m_pPlayer->edict(), CHAN_WEAPON, "weapons/displacer_spin2.wav");
break; break;
} }
} }
@ -509,12 +500,12 @@ void CDisplacer::SpinUp( void )
if( m_iFireMode == FIREMODE_FORWARD ) if( m_iFireMode == FIREMODE_FORWARD )
{ {
EMIT_SOUND( edict(), CHAN_WEAPON, "weapons/displacer_spin.wav", 1, ATTN_NORM ); EMIT_SOUND( m_pPlayer->edict(), CHAN_WEAPON, "weapons/displacer_spin.wav", 1, ATTN_NORM );
SetThink (&CDisplacer::Displace); SetThink (&CDisplacer::Displace);
} }
else else
{ {
EMIT_SOUND( edict(), CHAN_WEAPON, "weapons/displacer_spin2.wav", 1, ATTN_NORM ); EMIT_SOUND( m_pPlayer->edict(), CHAN_WEAPON, "weapons/displacer_spin2.wav", 1, ATTN_NORM );
SetThink (&CDisplacer::Teleport); SetThink (&CDisplacer::Teleport);
} }
pev->nextthink = gpGlobals->time + 0.9; pev->nextthink = gpGlobals->time + 0.9;
@ -583,6 +574,9 @@ void CDisplacer::Teleport( void )
if( pTarget && /*HACK*/( tmp != Vector( 0, 0, 0 )/*HACK*/ ) ) if( pTarget && /*HACK*/( tmp != Vector( 0, 0, 0 )/*HACK*/ ) )
{ {
if( (m_pPlayer->m_afPhysicsFlags & PFLAG_ONROPE) )
m_pPlayer->LetGoRope();
// UTIL_ScreenFade( m_pPlayer, Vector( 0, 200, 0 ), 0.5, 0.5, 255, FFADE_IN ); // UTIL_ScreenFade( m_pPlayer, Vector( 0, 200, 0 ), 0.5, 0.5, 255, FFADE_IN );
m_flTimeWeaponIdle = UTIL_WeaponTimeBase(); m_flTimeWeaponIdle = UTIL_WeaponTimeBase();
@ -619,7 +613,7 @@ void CDisplacer::Teleport( void )
} }
else else
{ {
EMIT_SOUND( edict(), CHAN_BODY, "buttons/button11.wav", 1, ATTN_NORM ); EMIT_SOUND( m_pPlayer->edict(), CHAN_WEAPON, "buttons/button11.wav", 0.9f, ATTN_NORM );
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 3.0; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 3.0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.9; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.9;
} }

2
dlls/gearbox/displacerball.h

@ -28,7 +28,5 @@ public:
void ArmBeam( int iSide ); void ArmBeam( int iSide );
int m_iBeams; int m_iBeams;
CBaseEntity *pRemoveEnt;
}; };
#endif #endif

5
dlls/gearbox/eagle.cpp

@ -91,11 +91,13 @@ void CEagle::Holster( int skiplocal /* = 0 */ )
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
SendWeaponAnim( DEAGLE_HOLSTER ); SendWeaponAnim( DEAGLE_HOLSTER );
#if !CLIENT_DLL
if (m_pEagleLaser) if (m_pEagleLaser)
{ {
m_pEagleLaser->Killed( NULL, GIB_NEVER ); m_pEagleLaser->Killed( NULL, GIB_NEVER );
m_pEagleLaser = NULL; m_pEagleLaser = NULL;
} }
#endif
} }
void CEagle::SecondaryAttack() void CEagle::SecondaryAttack()
@ -167,7 +169,8 @@ void CEagle::PrimaryAttack()
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_EAGLE, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_EAGLE, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase()+ 0.5; m_flNextPrimaryAttack = UTIL_WeaponTimeBase()+ 0.5;
#if !CLIENT_DLL #if !CLIENT_DLL
m_pEagleLaser->Suspend( 0.6 ); if (m_pEagleLaser)
m_pEagleLaser->Suspend( 0.6f );
#endif #endif
} }
else else

2
dlls/monsters.cpp

@ -2200,7 +2200,7 @@ int CBaseMonster::IRelationship( CBaseEntity *pTarget )
/*INSECT*/ { R_FR ,R_FR ,R_FR ,R_FR ,R_F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R_DL ,R_NO ,R_NO, R_NO, R_AL, R_AL, R_AL, R_DL},
/*XSHOCK*/ { R_NO ,R_DL ,R_HT ,R_DL ,R_HT ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_DL, R_NO, R_NO, R_AL, R_AL, R_HT}, /*XSHOCK*/ { R_NO ,R_DL ,R_HT ,R_DL ,R_HT ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_NO ,R_DL, R_NO, R_NO, R_AL, R_AL, R_HT},
/*PLRALLYMIL*/ { R_NO ,R_DL ,R_AL ,R_DL ,R_DL ,R_HT ,R_DL ,R_DL ,R_DL ,R_DL ,R_NO ,R_DL, R_NO, R_NO, R_DL, R_HT, R_AL} /*PLRALLYMIL*/ { R_NO ,R_DL ,R_AL ,R_DL ,R_DL ,R_HT ,R_DL ,R_DL ,R_DL ,R_DL ,R_NO ,R_DL, R_NO, R_NO, R_DL, R_HT, R_AL}

53
dlls/player.cpp

@ -1931,13 +1931,7 @@ void CBasePlayer::PreThink( void )
if( !m_pRope->MoveDown( flDelta ) ) if( !m_pRope->MoveDown( flDelta ) )
{ {
//Let go of the rope, detach. - Solokiller //Let go of the rope, detach. - Solokiller
pev->movetype = MOVETYPE_WALK; LetGoRope();
pev->solid = SOLID_SLIDEBOX;
m_afPhysicsFlags &= ~PFLAG_ONROPE;
m_pRope->DetachObject();
m_pRope = NULL;
m_bIsClimbing = false;
} }
} }
else else
@ -1954,12 +1948,7 @@ void CBasePlayer::PreThink( void )
else if( !m_pRope->MoveDown( flDelta ) ) else if( !m_pRope->MoveDown( flDelta ) )
{ {
//Let go of the rope, detach. - Solokiller //Let go of the rope, detach. - Solokiller
pev->movetype = MOVETYPE_WALK; LetGoRope();
pev->solid = SOLID_SLIDEBOX;
m_afPhysicsFlags &= ~PFLAG_ONROPE;
m_pRope->DetachObject();
m_pRope = NULL;
m_bIsClimbing = false;
} }
} }
} }
@ -1992,23 +1981,18 @@ void CBasePlayer::PreThink( void )
if( m_afButtonPressed & IN_JUMP ) if( m_afButtonPressed & IN_JUMP )
{ {
//We've jumped off the rope, give us some momentum - Solokiller //We've jumped off the rope, give us some momentum - Solokiller
pev->movetype = MOVETYPE_WALK; CRope* rope = m_pRope;
pev->solid = SOLID_SLIDEBOX; LetGoRope();
this->m_afPhysicsFlags &= ~PFLAG_ONROPE;
Vector vecDir = gpGlobals->v_up * 165.0 + gpGlobals->v_forward * 150.0; Vector vecDir = gpGlobals->v_up * 165.0 + gpGlobals->v_forward * 150.0;
Vector vecVelocity = m_pRope->GetAttachedObjectsVelocity() * 2; Vector vecVelocity = rope->GetAttachedObjectsVelocity() * 2;
vecVelocity = vecVelocity.Normalize(); vecVelocity = vecVelocity.Normalize();
vecVelocity = vecVelocity * 200; vecVelocity = vecVelocity * 200;
pev->velocity = vecVelocity + vecDir; pev->velocity = vecVelocity + vecDir;
m_pRope->DetachObject();
m_pRope = NULL;
m_bIsClimbing = false;
} }
return; return;
} }
@ -2096,6 +2080,21 @@ void CBasePlayer::PreThink( void )
pev->velocity = g_vecZero; pev->velocity = g_vecZero;
} }
} }
void CBasePlayer::LetGoRope()
{
//Let go of the rope, detach. - Solokiller
pev->movetype = MOVETYPE_WALK;
pev->solid = SOLID_SLIDEBOX;
m_afPhysicsFlags &= ~PFLAG_ONROPE;
if (m_pRope)
{
m_pRope->DetachObject();
m_pRope = NULL;
}
m_bIsClimbing = false;
}
/* Time based Damage works as follows: /* Time based Damage works as follows:
1) There are several types of timebased damage: 1) There are several types of timebased damage:
@ -4355,17 +4354,7 @@ BOOL CBasePlayer::FBecomeProne( void )
if( (m_afPhysicsFlags & PFLAG_ONROPE) ) if( (m_afPhysicsFlags & PFLAG_ONROPE) )
{ {
pev->movetype = MOVETYPE_WALK; LetGoRope();
pev->solid = SOLID_SLIDEBOX;
this->m_afPhysicsFlags &= ~PFLAG_ONROPE;
if (m_pRope)
{
m_pRope->DetachObject();
m_pRope = NULL;
}
m_bIsClimbing = false;
} }
return TRUE; return TRUE;

2
dlls/player.h

@ -403,6 +403,8 @@ public:
} }
CRope* GetRope() { return m_pRope; } CRope* GetRope() { return m_pRope; }
void LetGoRope();
}; };
#define AUTOAIM_2DEGREES 0.0348994967025 #define AUTOAIM_2DEGREES 0.0348994967025

Loading…
Cancel
Save