Browse Source

Another try to make shockroach dropping closer to original behavior

opforfixed
Roman Chistokhodov 5 years ago
parent
commit
37ef63e6d1
  1. 23
      dlls/gearbox/shockroach.cpp
  2. 2
      dlls/gearbox/shockroach.h
  3. 28
      dlls/gearbox/strooper.cpp

23
dlls/gearbox/shockroach.cpp

@ -76,10 +76,12 @@ void CShockRoach::Spawn()
Precache(); Precache();
SET_MODEL(ENT(pev), "models/w_shock_rifle.mdl"); SET_MODEL(ENT(pev), "models/w_shock_rifle.mdl");
UTIL_SetOrigin(pev, pev->origin);
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP; pev->movetype = MOVETYPE_FLY;
m_bloodColor = BLOOD_COLOR_GREEN; m_bloodColor = BLOOD_COLOR_GREEN;
pev->effects = 0; pev->effects = 0;
pev->health = gSkillData.sroachHealth; pev->health = gSkillData.sroachHealth;
pev->view_ofs = Vector(0, 0, 20);// position of the eyes relative to monster's origin. pev->view_ofs = Vector(0, 0, 20);// position of the eyes relative to monster's origin.
@ -148,22 +150,25 @@ void CShockRoach::LeapTouch(CBaseEntity *pOther)
//========================================================= //=========================================================
// PrescheduleThink // PrescheduleThink
//========================================================= //=========================================================
void CShockRoach::PrescheduleThink(void) void CShockRoach::MonsterThink(void)
{
float lifeTime = (gpGlobals->time - m_flBirthTime);
if (lifeTime >= 0.2)
{ {
// explode when ready pev->movetype = MOVETYPE_STEP;
if (!m_fRoachSolid && m_flBirthTime + 0.2 >= gpGlobals->time) { }
if (!m_fRoachSolid && lifeTime >= 2.0 ) {
m_fRoachSolid = TRUE; m_fRoachSolid = TRUE;
UTIL_SetSize(pev, Vector(-12, -12, 0), Vector(12, 12, 24)); UTIL_SetSize(pev, Vector(-12, -12, 0), Vector(12, 12, 4));
} }
// explode when ready if (lifeTime >= gSkillData.sroachLifespan)
if (gpGlobals->time >= m_flBirthTime + gSkillData.sroachLifespan)
{ {
pev->health = -1; pev->health = -1;
Killed(pev, 0); Killed(pev, 0);
return; return;
} }
CHeadCrab::PrescheduleThink(); CHeadCrab::MonsterThink();
} }
//========================================================= //=========================================================
@ -218,6 +223,8 @@ void CShockRoach::StartTask(Task_t *pTask)
int CShockRoach::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) int CShockRoach::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType )
{ {
if ( gpGlobals->time - m_flBirthTime < 2.0 )
flDamage = 0.0;
// Skip headcrab's TakeDamage to avoid unwanted immunity to acid. // Skip headcrab's TakeDamage to avoid unwanted immunity to acid.
return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType );
} }

2
dlls/gearbox/shockroach.h

@ -29,7 +29,7 @@ public:
void DeathSound(void); void DeathSound(void);
void IdleSound(void); void IdleSound(void);
void AlertSound(void); void AlertSound(void);
void PrescheduleThink(void); void MonsterThink(void);
void StartTask(Task_t* pTask); void StartTask(Task_t* pTask);
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType );

28
dlls/gearbox/strooper.cpp

@ -134,7 +134,7 @@ public:
void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType);
virtual int SizeForGrapple() { return GRAPPLE_LARGE; } virtual int SizeForGrapple() { return GRAPPLE_LARGE; }
void DropShockRoach(); void DropShockRoach(bool gibbed);
int Save(CSave &save); int Save(CSave &save);
int Restore(CRestore &restore); int Restore(CRestore &restore);
@ -212,7 +212,7 @@ void CStrooper::GibMonster(void)
{ {
if (GetBodygroup(GUN_GROUP) != GUN_NONE) if (GetBodygroup(GUN_GROUP) != GUN_NONE)
{ {
DropShockRoach(); DropShockRoach(true);
} }
EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "common/bodysplat.wav", 1, ATTN_NORM ); EMIT_SOUND( ENT( pev ), CHAN_WEAPON, "common/bodysplat.wav", 1, ATTN_NORM );
@ -299,7 +299,7 @@ void CStrooper::HandleAnimEvent(MonsterEvent_t *pEvent)
{ {
if (GetBodygroup(GUN_GROUP) != GUN_NONE) if (GetBodygroup(GUN_GROUP) != GUN_NONE)
{ {
DropShockRoach(); DropShockRoach(false);
} }
} }
break; break;
@ -586,7 +586,7 @@ void CStrooper::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDi
CSquadMonster::TraceAttack(pevAttacker, flDamage, vecDir, ptr, bitsDamageType); CSquadMonster::TraceAttack(pevAttacker, flDamage, vecDir, ptr, bitsDamageType);
} }
void CStrooper::DropShockRoach() void CStrooper::DropShockRoach(bool gibbed)
{ {
Vector vecGunPos; Vector vecGunPos;
Vector vecGunAngles; Vector vecGunAngles;
@ -594,19 +594,37 @@ void CStrooper::DropShockRoach()
GetAttachment(0, vecGunPos, vecGunAngles); GetAttachment(0, vecGunPos, vecGunAngles);
SetBodygroup(GUN_GROUP, GUN_NONE); SetBodygroup(GUN_GROUP, GUN_NONE);
Vector vecDropAngles = vecGunAngles; Vector vecDropAngles;
// Remove any pitch. // Remove any pitch.
vecDropAngles.x = 0; vecDropAngles.x = 0;
vecDropAngles.y = vecGunAngles.y;
vecDropAngles.z = 0; vecDropAngles.z = 0;
Vector vecPos = pev->origin; Vector vecPos = pev->origin;
if (gibbed)
vecPos.z += 32; vecPos.z += 32;
else
vecPos.z += 48;
// now spawn a shockroach. // now spawn a shockroach.
CBaseEntity* roach = CBaseEntity::Create( "monster_shockroach", vecPos, vecDropAngles ); CBaseEntity* roach = CBaseEntity::Create( "monster_shockroach", vecPos, vecDropAngles );
if (roach)
{
if (ShouldFadeOnDeath()) if (ShouldFadeOnDeath())
roach->pev->spawnflags |= SF_MONSTER_FADECORPSE; roach->pev->spawnflags |= SF_MONSTER_FADECORPSE;
if (gibbed)
{
roach->pev->velocity = Vector(RANDOM_FLOAT(-100.0f, 100.0f), RANDOM_FLOAT(-100.0f, 100.0f), RANDOM_FLOAT(200.0f, 300.0f));
roach->pev->avelocity = Vector(0, RANDOM_FLOAT(200.0f, 300.0f), 0);
}
else
{
roach->pev->velocity = Vector(RANDOM_FLOAT(-20.0f, 20.0f) , RANDOM_FLOAT(-20.0f, 20.0f), RANDOM_FLOAT(20.0f, 30.0f));
roach->pev->avelocity = Vector(0, RANDOM_FLOAT(20.0f, 40.0f), 0);
}
}
} }

Loading…
Cancel
Save