Fix little bugs and respawn

This commit is contained in:
mittorn 2016-03-27 03:56:54 +06:00
parent 4ef7b10268
commit 089928c629
6 changed files with 75 additions and 50 deletions

View File

@ -726,6 +726,20 @@ void CGib :: BounceGibTouch ( CBaseEntity *pOther )
} }
else 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 ) 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. 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; TraceResult tr;
SetThink( &SUB_Remove ); SetThink( &SUB_Remove );
pev->nextthink = gpGlobals->time + 10; pev->nextthink = gpGlobals->time + 100;
if ( !FClassnameIs( pOther->pev, "worldspawn" ) ) 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)); UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0));
pev->nextthink = gpGlobals->time + 4; pev->nextthink = gpGlobals->time + 4;
m_lifeTime = 25; m_lifeTime = 250;
SetThink( &WaitTillLand ); SetThink( &WaitTillLand );
SetTouch( &BounceGibTouch ); SetTouch( &BounceGibTouch );
@ -1225,11 +1239,11 @@ BOOL CBaseEntity :: FVisible ( CBaseEntity *pEntity )
Vector vecLookerOrigin; Vector vecLookerOrigin;
Vector vecTargetOrigin; Vector vecTargetOrigin;
if(!pEntity) if(!pEntity)
return FALSE; return FALSE;
if(!pEntity->pev) if(!pEntity->pev)
return FALSE; return FALSE;
if (FBitSet( pEntity->pev->flags, FL_NOTARGET )) if (FBitSet( pEntity->pev->flags, FL_NOTARGET ))
return FALSE; return FALSE;

View File

@ -92,7 +92,6 @@ void CItem::Spawn( void )
pev->movetype = MOVETYPE_TOSS; pev->movetype = MOVETYPE_TOSS;
pev->solid = SOLID_TRIGGER; pev->solid = SOLID_TRIGGER;
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
m_SpawnPoint = Vector( 0, 0, 0 );
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
SetTouch( &ItemTouch); SetTouch( &ItemTouch);
@ -102,6 +101,7 @@ void CItem::Spawn( void )
UTIL_Remove( this ); UTIL_Remove( this );
return; return;
} }
m_SpawnPoint = pev->origin;
} }
extern int gEvilImpulse101; extern int gEvilImpulse101;

View File

@ -157,6 +157,8 @@ public:
virtual float TouchGravGun( CBaseEntity *attacker, int stage ) virtual float TouchGravGun( CBaseEntity *attacker, int stage )
{ {
pev->nextthink = gpGlobals->time + m_lifeTime;
if( stage ) pev->owner = attacker->edict();
return 700; return 700;
} }

View File

@ -118,13 +118,13 @@ public:
pev->avelocity.y = UTIL_AngleDiff(atarget.y, pev->angles.y) * 10; pev->avelocity.y = UTIL_AngleDiff(atarget.y, pev->angles.y) * 10;
pev->avelocity.z = UTIL_AngleDiff(atarget.z, pev->angles.z) * 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_owner2 = attacker;
m_attacker = attacker; m_attacker = attacker;
return speed; return speed;
} }
if( m_attacker && ( pev->velocity.Length() < 600) ) if( !m_owner2 && m_attacker && ( pev->velocity.Length() < 400) )
m_attacker = attacker; m_attacker = attacker;
return speed; return speed;
if( ( stage == 2 ) && ( m_attacker == attacker ) ) if( ( stage == 2 ) && ( m_attacker == attacker ) )
@ -805,7 +805,10 @@ void CProp::DeployThink( void )
void CProp::BounceTouch(CBaseEntity *pOther) void CProp::BounceTouch(CBaseEntity *pOther)
{ {
if( pev->health <= 0 ) if( pev->health <= 0 )
{
DieThink();
return; return;
}
//ALERT( at_console, "BounceTouch: %f %f %f\n", pev->angles.x, pev->angles.y, pev->angles.z ); //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 // only do damage if we're moving fairly fast
DeployThink(); DeployThink();

View File

@ -535,6 +535,25 @@ void CBasePlayerItem::Materialize( void )
SetThink( NULL ); 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, // AttemptToMaterialize - the item is trying to rematerialize,
@ -1068,7 +1087,7 @@ void CBasePlayerAmmo::Spawn( void )
pev->solid = SOLID_TRIGGER; pev->solid = SOLID_TRIGGER;
UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16));
UTIL_SetOrigin( pev, pev->origin ); UTIL_SetOrigin( pev, pev->origin );
m_SpawnPoint = Vector( 0, 0, 0 ); m_SpawnPoint = pev->origin;
SetTouch( &DefaultTouch ); SetTouch( &DefaultTouch );
} }
@ -1085,7 +1104,25 @@ CBaseEntity* CBasePlayerAmmo::Respawn( void )
return this; 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 ) void CBasePlayerAmmo::Materialize( void )
{ {
if ( pev->effects & EF_NODRAW ) if ( pev->effects & EF_NODRAW )
@ -1095,10 +1132,11 @@ void CBasePlayerAmmo::Materialize( void )
pev->effects &= ~EF_NODRAW; pev->effects &= ~EF_NODRAW;
pev->effects |= EF_MUZZLEFLASH; 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. UTIL_SetOrigin( pev, m_SpawnPoint );// link into world.
else DROP_TO_FLOOR(edict());
UTIL_SetOrigin( pev, m_SpawnPoint = pev->origin ); //else
// UTIL_SetOrigin( pev, m_SpawnPoint = pev->origin );
SetTouch( &DefaultTouch ); SetTouch( &DefaultTouch );
} }

View File

@ -54,7 +54,7 @@ public:
virtual float TouchGravGun( CBaseEntity *attacker, int stage ) virtual float TouchGravGun( CBaseEntity *attacker, int stage )
{ {
pev->owner = attacker->edict(); 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. 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_iIdPrimary; // Unique Id for primary ammo
// int m_iIdSecondary; // Unique Id for secondary ammo // int m_iIdSecondary; // Unique Id for secondary ammo
Vector m_SpawnPoint; Vector m_SpawnPoint;
virtual float TouchGravGun( CBaseEntity *attacker, int stage) 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;
}
}; };
@ -388,23 +372,7 @@ public:
CBaseEntity* Respawn( void ); CBaseEntity* Respawn( void );
void EXPORT Materialize( void ); void EXPORT Materialize( void );
virtual float TouchGravGun( CBaseEntity *attacker, int stage) 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;
}
Vector m_SpawnPoint; Vector m_SpawnPoint;
}; };