mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-02-09 05:24:17 +00:00
Fix prop owner, fix bouncing without damage on nearest targets
This commit is contained in:
parent
e444f097c2
commit
f5426c5d21
@ -539,7 +539,7 @@ void CGravGun::Pull(CBaseEntity* ent)
|
|||||||
if(ent->pev->velocity.Length() > 500 )
|
if(ent->pev->velocity.Length() > 500 )
|
||||||
ent->pev->velocity = diff.Normalize() * 500;
|
ent->pev->velocity = diff.Normalize() * 500;
|
||||||
|
|
||||||
pev->velocity.z += 10;
|
ent->pev->velocity.z += 20;
|
||||||
if( diff.Length() < 150 )
|
if( diff.Length() < 150 )
|
||||||
{
|
{
|
||||||
m_iStage = 1;
|
m_iStage = 1;
|
||||||
@ -554,7 +554,7 @@ void CGravGun::Pull(CBaseEntity* ent)
|
|||||||
ent->pev->velocity = diff.Normalize()*(55000.0* 1.0/diff.Length());
|
ent->pev->velocity = diff.Normalize()*(55000.0* 1.0/diff.Length());
|
||||||
if(ent->pev->velocity.Length() > 900 )
|
if(ent->pev->velocity.Length() > 900 )
|
||||||
ent->pev->velocity = diff.Normalize() * 900;
|
ent->pev->velocity = diff.Normalize() * 900;
|
||||||
pev->velocity.z += 15;
|
ent->pev->velocity.z += 15;
|
||||||
ALERT( at_notice, "vel %f\n", ent->pev->velocity.Length() );
|
ALERT( at_notice, "vel %f\n", ent->pev->velocity.Length() );
|
||||||
}
|
}
|
||||||
//ent->pev->velocity = ent->pev->velocity + m_pPlayer->pev->velocity;
|
//ent->pev->velocity = ent->pev->velocity + m_pPlayer->pev->velocity;
|
||||||
|
@ -94,17 +94,23 @@ public:
|
|||||||
virtual void BounceSound(void);
|
virtual void BounceSound(void);
|
||||||
virtual int BloodColor(void) { return DONT_BLEED; }
|
virtual int BloodColor(void) { return DONT_BLEED; }
|
||||||
virtual void Killed(entvars_t *pevAttacker, int iGib);
|
virtual void Killed(entvars_t *pevAttacker, int iGib);
|
||||||
|
|
||||||
virtual float TouchGravGun( CBaseEntity *attacker, int stage )
|
virtual float TouchGravGun( CBaseEntity *attacker, int stage )
|
||||||
{
|
{
|
||||||
float speed = 2500;
|
float speed = 2500;
|
||||||
|
|
||||||
if( pev->deadflag )
|
if( pev->deadflag )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pev->movetype = MOVETYPE_BOUNCE;
|
pev->movetype = MOVETYPE_BOUNCE;
|
||||||
if(stage)
|
|
||||||
|
if( stage )
|
||||||
{
|
{
|
||||||
pev->nextthink = gpGlobals->time + m_flRespawnTime;
|
pev->nextthink = gpGlobals->time + m_flRespawnTime;
|
||||||
SetThink( &CProp::RespawnThink );
|
SetThink( &CProp::RespawnThink );
|
||||||
|
m_flLastGravgun = gpGlobals->time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( stage == 2 )
|
if( stage == 2 )
|
||||||
{
|
{
|
||||||
UTIL_MakeVectors( attacker->pev->v_angle + attacker->pev->punchangle);
|
UTIL_MakeVectors( attacker->pev->v_angle + attacker->pev->punchangle);
|
||||||
@ -119,28 +125,39 @@ 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( stage == 3 )
|
if( stage == 3 )
|
||||||
{
|
{
|
||||||
pev->avelocity.y = pev->avelocity.y*1.5 + RANDOM_FLOAT(100, -100);
|
pev->avelocity.y = pev->avelocity.y*1.5 + RANDOM_FLOAT(100, -100);
|
||||||
pev->avelocity.x = pev->avelocity.x*1.5 + RANDOM_FLOAT(100, -100);
|
pev->avelocity.x = pev->avelocity.x*1.5 + RANDOM_FLOAT(100, -100);
|
||||||
|
m_flLastGravgun = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !m_attacker || m_attacker == this )
|
if( !m_attacker || m_attacker == this )
|
||||||
{
|
{
|
||||||
m_owner2 = attacker;
|
m_owner2 = attacker;
|
||||||
m_attacker = attacker;
|
m_attacker = attacker;
|
||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
if( !m_owner2 && m_attacker && ( pev->velocity.Length() < 400) )
|
|
||||||
|
if( !m_owner2 && m_attacker && ( pev->velocity.Length() < 200) )
|
||||||
|
{
|
||||||
m_attacker = attacker;
|
m_attacker = attacker;
|
||||||
return speed;
|
return speed;
|
||||||
if( ( stage == 2 ) && ( m_attacker == attacker ) )
|
}
|
||||||
|
|
||||||
|
if( stage != 2 && ( pev->velocity.Length() == 0 ) )
|
||||||
|
return speed;
|
||||||
|
|
||||||
|
if( m_attacker == attacker )
|
||||||
{
|
{
|
||||||
m_owner2 = attacker;
|
m_owner2 = attacker;
|
||||||
|
|
||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckRotate();
|
void CheckRotate();
|
||||||
void EXPORT RespawnThink();
|
void EXPORT RespawnThink();
|
||||||
void EXPORT AngleThink();
|
void EXPORT AngleThink();
|
||||||
@ -179,10 +196,15 @@ public:
|
|||||||
Vector spawnOrigin;
|
Vector spawnOrigin;
|
||||||
Vector spawnAngles;
|
Vector spawnAngles;
|
||||||
|
|
||||||
|
// multiplayer
|
||||||
EHANDLE m_owner2;
|
EHANDLE m_owner2;
|
||||||
EHANDLE m_attacker;
|
EHANDLE m_attacker;
|
||||||
|
|
||||||
|
// hand throw
|
||||||
float m_flNextAttack;
|
float m_flNextAttack;
|
||||||
float m_flRespawnTime;
|
float m_flRespawnTime;
|
||||||
|
|
||||||
|
// shape change
|
||||||
PropShape m_shape;
|
PropShape m_shape;
|
||||||
PropShape m_oldshape;
|
PropShape m_oldshape;
|
||||||
EHANDLE m_pHolstered;
|
EHANDLE m_pHolstered;
|
||||||
@ -196,6 +218,7 @@ public:
|
|||||||
int m_iaCustomAnglesZ[10];
|
int m_iaCustomAnglesZ[10];
|
||||||
float m_flTouchTimer;
|
float m_flTouchTimer;
|
||||||
int m_iTouchCounter;
|
int m_iTouchCounter;
|
||||||
|
float m_flLastGravgun;
|
||||||
};
|
};
|
||||||
LINK_ENTITY_TO_CLASS(prop, CProp);
|
LINK_ENTITY_TO_CLASS(prop, CProp);
|
||||||
|
|
||||||
@ -848,6 +871,12 @@ void CProp::BounceTouch(CBaseEntity *pOther)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pev->movetype = MOVETYPE_BOUNCE;
|
pev->movetype = MOVETYPE_BOUNCE;
|
||||||
|
if( gpGlobals->time - m_flLastGravgun < 0.1 )
|
||||||
|
{
|
||||||
|
//pev->nextthink = gpGlobals->time + 0.1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( gpGlobals->time - m_flTouchTimer < 1 && m_iTouchCounter > 100 )
|
if( gpGlobals->time - m_flTouchTimer < 1 && m_iTouchCounter > 100 )
|
||||||
{
|
{
|
||||||
if( pOther->pev->solid == SOLID_BBOX || pOther->pev->solid == SOLID_SLIDEBOX )
|
if( pOther->pev->solid == SOLID_BBOX || pOther->pev->solid == SOLID_SLIDEBOX )
|
||||||
@ -1059,9 +1088,14 @@ void CProp::RespawnThink()
|
|||||||
|
|
||||||
void CProp::AngleThink()
|
void CProp::AngleThink()
|
||||||
{
|
{
|
||||||
|
if( gpGlobals->time - m_flLastGravgun < 0.1 )
|
||||||
|
{
|
||||||
|
pev->nextthink = gpGlobals->time + 0.1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
pev->nextthink = gpGlobals->time + m_flRespawnTime;
|
pev->nextthink = gpGlobals->time + m_flRespawnTime;
|
||||||
SetThink( &CProp::RespawnThink);
|
SetThink( &CProp::RespawnThink);
|
||||||
if (!(pev->flags & FL_ONGROUND || fabs(pev->velocity.z) < 40))
|
if( pev->flags & FL_ONGROUND || fabs(pev->velocity.z) < 40 )
|
||||||
{
|
{
|
||||||
m_owner2 = m_attacker = 0;
|
m_owner2 = m_attacker = 0;
|
||||||
return;
|
return;
|
||||||
@ -1172,8 +1206,8 @@ int CProp::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flD
|
|||||||
{
|
{
|
||||||
Vector r = (pevInflictor->origin - pev->origin);
|
Vector r = (pevInflictor->origin - pev->origin);
|
||||||
if ( (!m_attacker
|
if ( (!m_attacker
|
||||||
|| (pev->velocity.Length() < 700)) && ((CBaseEntity*)GET_PRIVATE(ENT(pevAttacker)))
|
|| (pev->velocity.Length() < 400)) && ((CBaseEntity*)GET_PRIVATE(ENT(pevAttacker)))
|
||||||
&& ((CBaseEntity*)GET_PRIVATE(ENT(pevAttacker)))->IsPlayer())
|
&& ((CBaseEntity*)GET_PRIVATE(ENT(pevAttacker)))->IsPlayer() && gpGlobals->time - m_flLastGravgun > 0.1 )
|
||||||
m_attacker.Set(ENT(pevAttacker));
|
m_attacker.Set(ENT(pevAttacker));
|
||||||
DeployThink();
|
DeployThink();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user