From 089928c629c9ba5bbabad80251d65eaed5eb14ac Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 27 Mar 2016 03:56:54 +0600 Subject: [PATCH] Fix little bugs and respawn --- dlls/combat.cpp | 28 +++++++++++++++++++++------- dlls/items.cpp | 2 +- dlls/monsters.h | 2 ++ dlls/prop.cpp | 7 +++++-- dlls/weapons.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++----- dlls/weapons.h | 38 +++----------------------------------- 6 files changed, 75 insertions(+), 50 deletions(-) diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 2899d051..8343067b 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -726,6 +726,20 @@ void CGib :: BounceGibTouch ( CBaseEntity *pOther ) } else { + if ( pev->velocity.Length() > 300) + { + entvars_t *pevOwner = pev; + if( pev->owner) + pevOwner = &pev->owner->v; + if(pevOwner) + { + float dmg = 10 + pev->velocity.Length() / 50; + TraceResult tr = UTIL_GetGlobalTrace(); + ClearMultiDamage(); + pOther->TraceAttack(pevOwner, dmg, gpGlobals->v_forward, &tr, DMG_CLUB); + ApplyMultiDamage(pev, pevOwner); + } + } if ( g_Language != LANGUAGE_GERMAN && m_cBloodDecals > 0 && m_bloodColor != DONT_BLEED ) { vecSpot = pev->origin + Vector ( 0 , 0 , 8 );//move up a bit, and trace down. @@ -757,7 +771,7 @@ void CGib :: StickyGibTouch ( CBaseEntity *pOther ) TraceResult tr; SetThink( &SUB_Remove ); - pev->nextthink = gpGlobals->time + 10; + pev->nextthink = gpGlobals->time + 100; if ( !FClassnameIs( pOther->pev, "worldspawn" ) ) { @@ -796,7 +810,7 @@ void CGib :: Spawn( const char *szGibModel ) UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0)); pev->nextthink = gpGlobals->time + 4; - m_lifeTime = 25; + m_lifeTime = 250; SetThink( &WaitTillLand ); SetTouch( &BounceGibTouch ); @@ -1225,11 +1239,11 @@ BOOL CBaseEntity :: FVisible ( CBaseEntity *pEntity ) Vector vecLookerOrigin; Vector vecTargetOrigin; - if(!pEntity) - return FALSE; - if(!pEntity->pev) - return FALSE; - + if(!pEntity) + return FALSE; + if(!pEntity->pev) + return FALSE; + if (FBitSet( pEntity->pev->flags, FL_NOTARGET )) return FALSE; diff --git a/dlls/items.cpp b/dlls/items.cpp index 0b394a58..bcd3edce 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -92,7 +92,6 @@ void CItem::Spawn( void ) pev->movetype = MOVETYPE_TOSS; pev->solid = SOLID_TRIGGER; UTIL_SetOrigin( pev, pev->origin ); - m_SpawnPoint = Vector( 0, 0, 0 ); UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); SetTouch( &ItemTouch); @@ -102,6 +101,7 @@ void CItem::Spawn( void ) UTIL_Remove( this ); return; } + m_SpawnPoint = pev->origin; } extern int gEvilImpulse101; diff --git a/dlls/monsters.h b/dlls/monsters.h index 28e462e9..6152c39a 100644 --- a/dlls/monsters.h +++ b/dlls/monsters.h @@ -157,6 +157,8 @@ public: virtual float TouchGravGun( CBaseEntity *attacker, int stage ) { + pev->nextthink = gpGlobals->time + m_lifeTime; + if( stage ) pev->owner = attacker->edict(); return 700; } diff --git a/dlls/prop.cpp b/dlls/prop.cpp index 78181e85..9e32cadb 100644 --- a/dlls/prop.cpp +++ b/dlls/prop.cpp @@ -118,13 +118,13 @@ public: pev->avelocity.y = UTIL_AngleDiff(atarget.y, pev->angles.y) * 10; pev->avelocity.z = UTIL_AngleDiff(atarget.z, pev->angles.z) * 10; } - if( !m_attacker) + if( !m_attacker || m_attacker == this ) { m_owner2 = attacker; m_attacker = attacker; return speed; } - if( m_attacker && ( pev->velocity.Length() < 600) ) + if( !m_owner2 && m_attacker && ( pev->velocity.Length() < 400) ) m_attacker = attacker; return speed; if( ( stage == 2 ) && ( m_attacker == attacker ) ) @@ -805,7 +805,10 @@ void CProp::DeployThink( void ) void CProp::BounceTouch(CBaseEntity *pOther) { if( pev->health <= 0 ) + { + DieThink(); return; + } //ALERT( at_console, "BounceTouch: %f %f %f\n", pev->angles.x, pev->angles.y, pev->angles.z ); // only do damage if we're moving fairly fast DeployThink(); diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 67f3fad5..109d61b8 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -535,6 +535,25 @@ void CBasePlayerItem::Materialize( void ) SetThink( NULL ); } +float CBasePlayerItem::TouchGravGun( CBaseEntity *attacker, int stage ) + { + if( stage == 2 ) + { + if( (attacker->pev->origin - pev->origin ).Length() < 90 ) + Touch( attacker ); + } + if( pev->movetype == MOVETYPE_FOLLOW ) + return 0; + if( pev->movetype == MOVETYPE_NONE ) + return 0; + if( pev->effects & EF_NODRAW ) + return 0; + SetThink( &CBasePlayerItem::AttemptToMaterialize ); + pev->nextthink = gpGlobals->time + 60;; + //if( pev->mins == pev->maxs ) + //return 0; + return 200; + } //========================================================= // AttemptToMaterialize - the item is trying to rematerialize, @@ -1068,7 +1087,7 @@ void CBasePlayerAmmo::Spawn( void ) pev->solid = SOLID_TRIGGER; UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); UTIL_SetOrigin( pev, pev->origin ); - m_SpawnPoint = Vector( 0, 0, 0 ); + m_SpawnPoint = pev->origin; SetTouch( &DefaultTouch ); } @@ -1085,7 +1104,25 @@ CBaseEntity* CBasePlayerAmmo::Respawn( void ) return this; } - +float CBasePlayerAmmo::TouchGravGun( CBaseEntity *attacker, int stage) +{ + if( stage == 2 ) + { + if( (attacker->pev->origin - pev->origin ).Length() < 90 ) + Touch( attacker ); + } + if( pev->movetype == MOVETYPE_FOLLOW ) + return 0; + if( pev->movetype == MOVETYPE_NONE ) + return 0; + if( pev->effects & EF_NODRAW ) + return 0; + //if( pev->mins == pev->maxs ) + //return 0; + SetThink( &CBasePlayerAmmo::Materialize ); + pev->nextthink = g_pGameRules->FlAmmoRespawnTime( this ); + return 200; +} void CBasePlayerAmmo::Materialize( void ) { if ( pev->effects & EF_NODRAW ) @@ -1095,10 +1132,11 @@ void CBasePlayerAmmo::Materialize( void ) pev->effects &= ~EF_NODRAW; pev->effects |= EF_MUZZLEFLASH; } - if( m_SpawnPoint != Vector(0, 0, 0) ) + //if( m_SpawnPoint != Vector(0, 0, 0) ) UTIL_SetOrigin( pev, m_SpawnPoint );// link into world. - else - UTIL_SetOrigin( pev, m_SpawnPoint = pev->origin ); + DROP_TO_FLOOR(edict()); + //else + // UTIL_SetOrigin( pev, m_SpawnPoint = pev->origin ); SetTouch( &DefaultTouch ); } diff --git a/dlls/weapons.h b/dlls/weapons.h index f03bdab8..471af83f 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -54,7 +54,7 @@ public: virtual float TouchGravGun( CBaseEntity *attacker, int stage ) { pev->owner = attacker->edict(); - return 200; + return 1000; } BOOL m_fRegisteredSound;// whether or not this grenade has issued its DANGER sound to the world sound list yet. @@ -286,23 +286,7 @@ public: // int m_iIdPrimary; // Unique Id for primary ammo // int m_iIdSecondary; // Unique Id for secondary ammo Vector m_SpawnPoint; - virtual float TouchGravGun( CBaseEntity *attacker, int stage) - { - if( stage == 2 ) - { - if( (attacker->pev->origin - pev->origin ).Length() < 90 ) - Touch( attacker ); - } - if( pev->movetype == MOVETYPE_FOLLOW ) - return 0; - if( pev->movetype == MOVETYPE_NONE ) - return 0; - if( pev->effects & EF_NODRAW ) - return 0; - //if( pev->mins == pev->maxs ) - //return 0; - return 200; - } + virtual float TouchGravGun( CBaseEntity *attacker, int stage); }; @@ -388,23 +372,7 @@ public: CBaseEntity* Respawn( void ); void EXPORT Materialize( void ); - virtual float TouchGravGun( CBaseEntity *attacker, int stage) - { - if( stage == 2 ) - { - if( (attacker->pev->origin - pev->origin ).Length() < 90 ) - Touch( attacker ); - } - if( pev->movetype == MOVETYPE_FOLLOW ) - return 0; - if( pev->movetype == MOVETYPE_NONE ) - return 0; - if( pev->effects & EF_NODRAW ) - return 0; - //if( pev->mins == pev->maxs ) - //return 0; - return 200; - } + virtual float TouchGravGun( CBaseEntity *attacker, int stage); Vector m_SpawnPoint; };