BaseMonster: Went over various monsters to fix gibbing since that had

regressed with the way we do damage now.
Replaced all 'frame=' assignments with SetFrame calls so it gets networked.
This commit is contained in:
Marco Cawthorne 2020-04-28 17:49:32 +02:00
parent 2a6ff3babd
commit 5ce957bb20
28 changed files with 102 additions and 96 deletions

View file

@ -25,7 +25,8 @@ enum
MONSTER_IDLE,
MONSTER_WALK,
MONSTER_RUN,
MONSTER_DEAD
MONSTER_DEAD,
MONSTER_GIBBED,
};
enum
@ -354,8 +355,15 @@ CBaseMonster::Pain(int iHitBody)
void
CBaseMonster::Death(int iHitBody)
{
/* we were already dead before, so gib */
if (style == MONSTER_DEAD) {
Gib();
return;
}
m_iFlags = 0x0;
/* if we make more than 50 damage, gib immediately */
if (health < -50) {
Gib();
return;
@ -363,11 +371,13 @@ CBaseMonster::Death(int iHitBody)
/* make sure we're not causing any more obituaries */
flags &= ~FL_MONSTER;
m_iFlags = 0x0;
/* gibbing action */
style = MONSTER_DEAD;
SetSolid(SOLID_CORPSE);
SetMovetype(MOVETYPE_NONE);
SetSolid(SOLID_CORPSE);
health = 50 + health;
style = MONSTER_DEAD;
}
void

View file

@ -286,10 +286,8 @@ CSEv_AmmoBuyPrimary(void)
}
void
Ammo_AutoFill(float fWeapon)
Ammo_AutoFill(player pl)
{
player pl = (player)self;
if (autocvar_fcs_fillweapons == FALSE) {
return;
}

View file

@ -67,7 +67,7 @@ OP4CTFRules::PlayerDeath(player pl)
pl.think = PutClientInServer;
pl.nextthink = time + 4.0f;
sound(pl, CHAN_AUTO, "fvox/flatline.wav", 1.0, ATTN_NORM);
Sound_Play(pl, CHAN_AUTO, "player.die");
if (pl.health < -50) {
pl.health = 0;

View file

@ -370,7 +370,7 @@ void monster_scientist::Physics(void)
input_impulse = 0;
input_buttons = 0;
if (style != SCI_DEAD) {
if (style != MONSTER_DEAD) {
if (!(m_iFlags & SCIF_SEEN)) {
for (entity b = world; (b = find(b, ::classname, "player"));) {
/* Find players in a 256 unit radius */
@ -552,7 +552,10 @@ void monster_scientist::PlayerUse(void)
void monster_scientist::Pain(int iHitBody)
{
if (style == MONSTER_DEAD) {
return;
}
WarnOthers();
if (m_flPainTime > time) {
@ -574,6 +577,11 @@ void monster_scientist::Pain(int iHitBody)
void monster_scientist::Death(int iHitBody)
{
if (style == MONSTER_DEAD) {
Gib();
return;
}
int r;
r = floor(random(0,sci_snddie.length));
Speak(sci_snddie[r]);
@ -584,7 +592,6 @@ void monster_scientist::Death(int iHitBody)
nextthink = time + 10.0f;
m_eUser = world;
//customphysics = __NULL__;
m_iFlags = 0x0;
if (health < -50) {
@ -593,14 +600,13 @@ void monster_scientist::Death(int iHitBody)
}
flags &= ~FL_MONSTER;
movetype = MOVETYPE_NONE;
solid = SOLID_CORPSE;
//takedamage = DAMAGE_NO;
SetFrame(SCIA_DIE_SIMPLE + floor(random(0, 6)));
if (style != SCI_DEAD) {
SetFrame(SCIA_DIE_SIMPLE + floor(random(0, 6)));
style = SCI_DEAD;
}
/* corpse health */
SetMovetype(MOVETYPE_NONE);
SetSolid(SOLID_CORPSE);
health = 50 + health;
style = MONSTER_DEAD;
}
void monster_scientist::Hide(void)
@ -628,7 +634,7 @@ void monster_scientist::Respawn(void)
SetFrame(SCIA_IDLE1);
takedamage = DAMAGE_YES;
iBleeds = TRUE;
style = SCI_IDLE;
style = MONSTER_IDLE;
health = 50;
velocity = [0,0,0];
m_iFlags = 0x0;

View file

@ -72,7 +72,7 @@ monster_alien_controller::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_alien_controller.die");
frame = CON_FLINCH + floor(random(0, 2));
SetFrame(CON_FLINCH + floor(random(0, 2)));
m_flPainTime = time + 0.25f;
}
@ -81,7 +81,7 @@ monster_alien_controller::Death(int iHitBody)
{
/* if we're already dead (corpse) don't change animations */
if (style != MONSTER_DEAD) {
frame = CON_DIE;
SetFrame(CON_DIE);
Sound_Play(this, CHAN_VOICE, "monster_alien_controller.die");
}

View file

@ -85,7 +85,7 @@ monster_alien_grunt::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_alien_grunt.pain");
frame = AG_FLINCH + floor(random(0, 2));
SetFrame(AG_FLINCH + floor(random(0, 2)));
m_flPainTime = time + 0.25f;
}
@ -97,12 +97,12 @@ monster_alien_grunt::Death(int iHitBody)
/* headshots == different animation */
if (iHitBody == BODY_HEAD) {
if (random() < 0.5) {
frame = AG_DIEHS;
SetFrame(AG_DIEHS);
} else {
frame = AG_DIEFORWARD;
SetFrame(AG_DIEFORWARD);
}
} else {
frame = AG_DIE + floor(random(0, 2));
SetFrame(AG_DIE + floor(random(0, 2)));
}
Sound_Play(this, CHAN_VOICE, "monster_alien_grunt.die");
@ -132,7 +132,7 @@ void
monster_alien_grunt::Respawn(void)
{
CBaseMonster::Respawn();
frame = AG_IDLE;
SetFrame(AG_IDLE);
}
void

View file

@ -95,7 +95,7 @@ monster_alien_slave::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_alien_slave.pain");
frame = SLV_FLINCH + floor(random(0, 2));
SetFrame(SLV_FLINCH + floor(random(0, 2)));
m_flPainTime = time + 0.25f;
}
@ -107,12 +107,12 @@ monster_alien_slave::Death(int iHitBody)
/* headshots == different animation */
if (iHitBody == BODY_HEAD) {
if (random() < 0.5) {
frame = SLV_DIEHS;
SetFrame(SLV_DIEHS);
} else {
frame = SLV_DIEBACK;
SetFrame(SLV_DIEBACK);
}
} else {
frame = SLV_DIE + floor(random(0, 3));
SetFrame(SLV_DIE + floor(random(0, 3)));
}
Sound_Play(this, CHAN_VOICE, "monster_alien_slave.die");
@ -126,7 +126,7 @@ void
monster_alien_slave::Respawn(void)
{
CBaseNPC::Respawn();
frame = SLV_IDLE;
SetFrame(SLV_IDLE);
}
void

View file

@ -55,8 +55,7 @@ monster_barnacle::Death(int iHitBody)
{
/* if we're already dead (corpse) don't change animations */
if (style != MONSTER_DEAD) {
frame = BCL_DIE;
SetFrame(BCL_DIE);
Sound_Play(this, CHAN_VOICE, "monster_barnacle.die");
}
@ -68,7 +67,7 @@ void
monster_barnacle::Respawn(void)
{
CBaseMonster::Respawn();
frame = BCL_IDLE;
SetFrame(BCL_IDLE);
}
void monster_barnacle::monster_barnacle(void)

View file

@ -101,7 +101,7 @@ monster_barney::Pain(int iHitBody)
Sound_Speak(this, "monster_barney.pain");
frame = BA_FLINCH_LA + floor(random(0, 5));
SetFrame(BA_FLINCH_LA + floor(random(0, 5)));
m_iFlags |= MONSTER_FEAR;
m_flAnimTime = time + 0.25f;
}
@ -111,11 +111,9 @@ monster_barney::Death(int iHitBody)
{
WarnAllies();
Sound_Speak(this, "monster_barney.die");
if (style != MONSTER_DEAD) {
frame = 25 + floor(random(0, 6));
style = MONSTER_DEAD;
SetFrame(25 + floor(random(0, 6)));
Sound_Speak(this, "monster_barney.die");
}
/* now mark our state as 'dead' */

View file

@ -62,7 +62,7 @@ void monster_barney_dead::Respawn(void)
health = 0;
velocity = [0,0,0];
iBleeds = TRUE;
frame = 35 + m_iPose;
SetFrame(35 + m_iPose);
}
void monster_barney_dead::monster_barney_dead(void)

View file

@ -89,7 +89,7 @@ monster_bigmomma::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_bigmomma.pain");
frame = GON_FLINCH;
SetFrame(GON_FLINCH);
m_flAnimTime = time + 0.25f;
}
@ -98,7 +98,7 @@ monster_bigmomma::Death(int iHitBody)
{
/* if we're already dead (corpse) don't change animations */
if (style != MONSTER_DEAD) {
frame = GON_DIE;
SetFrame(GON_DIE);
Sound_Play(this, CHAN_VOICE, "monster_bigmomma.die");
}
@ -110,7 +110,7 @@ void
monster_bigmomma::Respawn(void)
{
CBaseMonster::Respawn();
frame = GON_IDLE;
SetFrame(GON_IDLE);
}
void monster_bigmomma::monster_bigmomma(void)

View file

@ -117,7 +117,7 @@ monster_bullchicken::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_bullchicken.pain");
frame = (random() < 0.5) ? BULL_FLINCH : BULL_FLINCH2;
SetFrame((random() < 0.5) ? BULL_FLINCH : BULL_FLINCH2);
m_flAnimTime = time + 0.25f;
}
@ -128,7 +128,7 @@ monster_bullchicken::Death(int iHitBody)
if (style != MONSTER_DEAD) {
/* two different animations */
frame = (random() < 0.5) ? BULL_DIE : BULL_DIE2;
SetFrame((random() < 0.5) ? BULL_DIE : BULL_DIE2);
Sound_Play(this, CHAN_VOICE, "monster_bullchicken.die");
}

View file

@ -91,7 +91,7 @@ monster_gargantua::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_gargantua.pain");
frame = (random() < 0.5) ? GARG_FLINCH : GARG_FLINCH2;
SetFrame((random() < 0.5) ? GARG_FLINCH : GARG_FLINCH2);
m_flAnimTime = time + 0.25f;
}
@ -100,9 +100,7 @@ monster_gargantua::Death(int iHitBody)
{
/* if we're already dead (corpse) don't change animations */
if (style != MONSTER_DEAD) {
frame = GARG_DIE;
SetFrame(GARG_DIE);
Sound_Play(this, CHAN_VOICE, "monster_gargantua.die");
}
@ -114,7 +112,7 @@ void
monster_gargantua::Respawn(void)
{
CBaseMonster::Respawn();
frame = GARG_IDLE;
SetFrame(GARG_IDLE);
/* takes damage from explosives only
* takedamage = DAMAGE_NO; */
iBleeds = FALSE;

View file

@ -72,7 +72,7 @@ void monster_gman::Respawn(void)
{
/* he can't die, he's the G-Man! */
CBaseMonster::Respawn();
frame = GMAN_IDLE;
SetFrame(GMAN_IDLE);
takedamage = DAMAGE_NO;
iBleeds = FALSE;
}

View file

@ -95,7 +95,7 @@ monster_headcrab::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_headcrab.pain");
frame = HC_FLINCH;
SetFrame(HC_FLINCH);
m_flAnimTime = time + 0.25f;
}
@ -104,8 +104,7 @@ monster_headcrab::Death(int iHitBody)
{
/* if we're already dead (corpse) don't change animations */
if (style != MONSTER_DEAD) {
frame = HC_DIE;
SetFrame(HC_DIE);
Sound_Play(this, CHAN_VOICE, "monster_headcrab.die");
}

View file

@ -62,7 +62,7 @@ void monster_hevsuit_dead::Respawn(void)
health = 0;
velocity = [0,0,0];
iBleeds = TRUE;
frame = 73 + m_iPose;
SetFrame(73 + m_iPose);
SendFlags |= NPC_BODY;
}

View file

@ -62,7 +62,7 @@ void monster_hgrunt_dead::Respawn(void)
health = 0;
velocity = [0,0,0];
iBleeds = TRUE;
frame = 44 + m_iPose;
SetFrame(44 + m_iPose);
SendFlags |= NPC_BODY;
}

View file

@ -83,7 +83,7 @@ monster_houndeye::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_houndeye.pain");
frame = HE_FLINCH + floor(random(0, 2));
SetFrame(HE_FLINCH + floor(random(0, 2)));
m_flAnimTime = time + 0.25f;
}
@ -92,7 +92,7 @@ monster_houndeye::Death(int iHitBody)
{
/* if we're already dead (corpse) don't change animations */
if (style != MONSTER_DEAD) {
frame = HE_DIE + floor(random(0, 4));
SetFrame(HE_DIE + floor(random(0, 4)));
Sound_Play(this, CHAN_VOICE, "monster_houndeye.die");
}
@ -121,7 +121,7 @@ void
monster_houndeye::Respawn(void)
{
CBaseMonster::Respawn();
frame = HE_IDLE;
SetFrame(HE_IDLE);
}
void

View file

@ -62,12 +62,12 @@ monster_human_assassin::Death(int iHitBody)
/* this animation may not have been used, but it looks cool */
if (iHitBody == BODY_HEAD) {
if (random() < 0.5) {
frame = HAS_DIERUN;
SetFrame(HAS_DIERUN);
} else {
frame = HAS_DIEBACK;
SetFrame(HAS_DIEBACK);
}
} else {
frame = HAS_DIE;
SetFrame(HAS_DIE);
}
}

View file

@ -183,7 +183,7 @@ monster_human_grunt::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_human_grunt.pain");
frame = GR_FLINCH;
SetFrame(GR_FLINCH);
m_flAnimTime = time + 0.25f;
}
@ -196,12 +196,12 @@ monster_human_grunt::Death(int iHitBody)
/* this animation may not have been used, but it looks cool */
if (iHitBody == BODY_HEAD) {
if (random() < 0.5) {
frame = GR_DIEHS;
SetFrame(GR_DIEHS);
} else {
frame = GR_DIEBACK;
SetFrame(GR_DIEBACK);
}
} else {
frame = GR_DIE;
SetFrame(GR_DIE);
}
}
@ -214,7 +214,7 @@ void
monster_human_grunt::Respawn(void)
{
CBaseMonster::Respawn();
frame = GR_IDLE;
SetFrame(GR_IDLE);
}

View file

@ -68,7 +68,7 @@ monster_ichthyosaur::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_ichthyosaur.pain");
frame = ICHY_FLINCH + floor(random(0, 2));
SetFrame(ICHY_FLINCH + floor(random(0, 2)));
m_flAnimTime = time + 0.25f;
}
@ -81,13 +81,13 @@ monster_ichthyosaur::Death(int iHitBody)
switch (r) {
case 1:
frame = ICHY_DIE2;
SetFrame(ICHY_DIE2);
break;
case 2:
frame = ICHY_DIE3;
SetFrame(ICHY_DIE3);
break;
default:
frame = ICHY_DIE1;
SetFrame(ICHY_DIE1);
break;
}
@ -118,7 +118,7 @@ void
monster_ichthyosaur::Respawn(void)
{
CBaseMonster::Respawn();
frame = ICHY_IDLE;
SetFrame(ICHY_IDLE);
}
void

View file

@ -48,7 +48,7 @@ class monster_leech:CBaseMonster
void
monster_leech::DeathEnd(void)
{
frame = LEECH_DIEEND;
SetFrame(LEECH_DIEEND);
}
void
@ -56,7 +56,7 @@ monster_leech::Death(int iHitBody)
{
/* if we're already dead (corpse) don't change animations */
if (style != MONSTER_DEAD) {
frame = LEECH_DIE;
SetFrame(LEECH_DIE);
think = DeathEnd;
nextthink = time + 1.0f;
}
@ -69,7 +69,7 @@ void
monster_leech::Respawn(void)
{
CBaseMonster::Respawn();
frame = LEECH_SWIM;
SetFrame(LEECH_SWIM);
}
void monster_leech::monster_leech(void)

View file

@ -91,7 +91,7 @@ monster_nihilanth::Pain(int iHitBody)
Sound_Play(this, CHAN_VOICE, "monster_nihilanth.pain");
frame = (random() < 0.5) ? NIL_FLINCH : NIL_FLINCH2;
SetFrame((random() < 0.5) ? NIL_FLINCH : NIL_FLINCH2);
m_flAnimTime = time + 0.25f;
}
@ -100,7 +100,7 @@ monster_nihilanth::Death(int iHitBody)
{
/* if we're already dead (corpse) don't change animations */
if (style != MONSTER_DEAD) {
frame = NIL_DIE;
SetFrame(NIL_DIE);
Sound_Play(this, CHAN_VOICE, "monster_nihilanth.die");
}
@ -112,7 +112,7 @@ void
monster_nihilanth::Respawn(void)
{
CBaseMonster::Respawn();
frame = NIL_IDLE;
SetFrame(NIL_IDLE);
}
void monster_nihilanth::monster_nihilanth(void)

View file

@ -136,11 +136,9 @@ monster_scientist::Death(int iHitBody)
{
WarnAllies();
Sound_Speak(this, "monster_scientist.die");
if (style != MONSTER_DEAD) {
frame = SCIA_DIE_SIMPLE + floor(random(0, 6));
style = MONSTER_DEAD;
SetFrame(SCIA_DIE_SIMPLE + floor(random(0, 6)));
Sound_Speak(this, "monster_scientist.die");
}
/* now mark our state as 'dead' */

View file

@ -77,25 +77,25 @@ void monster_scientist_dead::Respawn(void)
switch (m_iPose) {
case 1:
frame = DSCIA_LYING2;
SetFrame(DSCIA_LYING2);
break;
case 2:
frame = DSCIA_DEADSIT;
SetFrame(DSCIA_DEADSIT);
break;
case 3:
frame = DSCIA_DEADHANG;
SetFrame(DSCIA_DEADHANG);
break;
case 4:
frame = DSCIA_DEADTABLE1;
SetFrame(DSCIA_DEADTABLE1);
break;
case 5:
frame = DSCIA_DEADTABLE2;
SetFrame(DSCIA_DEADTABLE2);
break;
case 6:
frame = DSCIA_DEADTABLE3;
SetFrame(DSCIA_DEADTABLE3);
break;
default:
frame = DSCIA_LYING1;
SetFrame(DSCIA_LYING1);
}
}

View file

@ -47,7 +47,7 @@ monster_sentry::Death(int iHitBody)
{
/* if we're already dead (corpse) don't change animations */
if (style != MONSTER_DEAD) {
frame = SENT_DIE;
SetFrame(SENT_DIE);
Sound_Play(this, CHAN_VOICE, "monster_sentry.die");
}
@ -59,7 +59,7 @@ void
monster_sentry::Respawn(void)
{
CBaseMonster::Respawn();
frame = SENT_IDLE;
SetFrame(SENT_IDLE);
iBleeds = FALSE;
}

View file

@ -114,7 +114,7 @@ monster_tentacle::Respawn(void)
/* not entirely true, takes damage then retreats and reheals */
takedamage = DAMAGE_NO;
iBleeds = FALSE;
frame = TE_IDLE;
SetFrame(TE_IDLE);
}
void

View file

@ -96,7 +96,7 @@ monster_zombie::Pain(int iHitBody)
}
Sound_Play(this, CHAN_VOICE, "monster_zombie.pain");
frame = ZO_FLINCH + floor(random(0, 2));
SetFrame(ZO_FLINCH + floor(random(0, 2)));
m_flAnimTime = time + 0.25f;
}
@ -108,12 +108,12 @@ monster_zombie::Death(int iHitBody)
/* headshots == different animation */
if (iHitBody == BODY_HEAD) {
if (random() < 0.5) {
frame = ZO_DIEHS;
SetFrame(ZO_DIEHS);
} else {
frame = ZO_DIEHS2;
SetFrame(ZO_DIEHS2);
}
} else {
frame = ZO_DIE + floor(random(0, 3));
SetFrame(ZO_DIE + floor(random(0, 3)));
}
Sound_Play(this, CHAN_VOICE, "monster_zombie.pain");
@ -143,7 +143,7 @@ void
monster_zombie::Respawn(void)
{
CBaseMonster::Respawn();
frame = ZO_IDLE;
SetFrame(ZO_IDLE);
}
void