Skip to content

Commit c035207

Browse files
committed
Handle obituaries for crushed monsters better
1 parent 060183c commit c035207

File tree

10 files changed

+81
-82
lines changed

10 files changed

+81
-82
lines changed

src/c_cmds.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4097,7 +4097,7 @@ static void killfunc2(char *cmd, char *parms)
40974097
thing->flags2 |= MF2_MASSACRE;
40984098
massacre = true;
40994099

4100-
P_DamageMobj(thing, viewplayer->mo, viewplayer->mo, thing->health, false, false);
4100+
P_DamageMobj(thing, viewplayer->mo, viewplayer->mo, thing->health, false, false, false);
41014101
massacre = false;
41024102
kills++;
41034103
}
@@ -4367,7 +4367,7 @@ static void killfunc2(char *cmd, char *parms)
43674367
{
43684368
killcmdmobj->flags2 |= MF2_MASSACRE;
43694369
massacre = true;
4370-
P_DamageMobj(killcmdmobj, viewplayer->mo, viewplayer->mo, killcmdmobj->health, false, false);
4370+
P_DamageMobj(killcmdmobj, viewplayer->mo, viewplayer->mo, killcmdmobj->health, false, false, false);
43714371
massacre = false;
43724372

43734373
if (isdefaultplayername())
@@ -4414,13 +4414,13 @@ static void killfunc2(char *cmd, char *parms)
44144414
{
44154415
thing->flags2 |= MF2_MASSACRE;
44164416
massacre = true;
4417-
P_DamageMobj(thing, viewplayer->mo, viewplayer->mo, thing->health, false, false);
4417+
P_DamageMobj(thing, viewplayer->mo, viewplayer->mo, thing->health, false, false, false);
44184418
massacre = false;
44194419
kills++;
44204420
}
44214421
else if (type == MT_BARREL)
44224422
{
4423-
P_DamageMobj(thing, viewplayer->mo, viewplayer->mo, thing->health, false, false);
4423+
P_DamageMobj(thing, viewplayer->mo, viewplayer->mo, thing->health, false, false, false);
44244424
kills++;
44254425
}
44264426
else if (thing->flags & MF_SPECIAL)
@@ -9220,7 +9220,7 @@ static void takefunc2(char *cmd, char *parms)
92209220
if (viewplayer->health > initial_health)
92219221
{
92229222
healthcvar = true;
9223-
P_DamageMobj(viewplayer->mo, viewplayer->mo, viewplayer->mo, viewplayer->health - initial_health, false, false);
9223+
P_DamageMobj(viewplayer->mo, viewplayer->mo, viewplayer->mo, viewplayer->health - initial_health, false, false, false);
92249224
healthcvar = false;
92259225
result = true;
92269226
}
@@ -9280,7 +9280,7 @@ static void takefunc2(char *cmd, char *parms)
92809280
{
92819281
healthcvar = true;
92829282
P_DamageMobj(viewplayer->mo, viewplayer->mo, viewplayer->mo,
9283-
viewplayer->health - !!(viewplayer->cheats & CF_BUDDHA), false, false);
9283+
viewplayer->health - !!(viewplayer->cheats & CF_BUDDHA), false, false, false);
92849284
healthcvar = false;
92859285

92869286
if (isdefaultplayername())

src/c_obituary.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,19 @@ void C_BuildObituaryString(const int index)
357357
return;
358358
}
359359
}
360+
else if (obituary->crushed)
361+
{
362+
char targetname[128];
363+
364+
C_BuildThingName(targetname, sizeof(targetname), target,
365+
obituary->targetfriendly, obituary->targetcorpse, obituary->targetname, "");
366+
367+
targetname[0] = (char)toupper(targetname[0]);
368+
369+
M_snprintf(buffer, buffersize, "%s was crushed to death.", targetname);
370+
buffer[0] = (char)toupper(buffer[0]);
371+
return;
372+
}
360373
}
361374

362375
static bool C_SameObituary(const obituaryinfo_t *a, const obituaryinfo_t *b)
@@ -381,32 +394,31 @@ static bool C_SameObituary(const obituaryinfo_t *a, const obituaryinfo_t *b)
381394
}
382395

383396
void C_WriteObituary(mobj_t *target, mobj_t *inflicter, mobj_t *source,
384-
const bool gibbed, const bool telefragged)
397+
const bool gibbed, const bool telefragged, const bool crushed)
385398
{
386399
const int i = MAX(0, numconsolestrings - 1);
387400
obituaryinfo_t obituary = { 0 };
388401

389402
if (target)
390403
{
391-
const bool isplayer = !!target->player;
392404
const int flags = target->flags;
393405

394406
obituary.target = target->type;
395-
obituary.targetisplayer = isplayer;
407+
obituary.targetisplayer = !!target->player;
396408
obituary.targetfriendly = !!(flags & MF_FRIEND);
397409
obituary.targetcorpse = !!(flags & MF_CORPSE);
398410

399411
if (*target->name)
400412
M_StringCopy(obituary.targetname, target->name, sizeof(obituary.targetname));
401413

402-
if (!source && isplayer && target->player->mo == target)
414+
if (!source)
403415
{
404-
const sector_t *sector = viewplayer->mo->subsector->sector;
405-
406-
if (sector->ceilingdata && sector->ceilingheight - sector->floorheight < VIEWHEIGHT)
416+
if (crushed)
407417
obituary.crushed = true;
408418
else
409419
{
420+
const sector_t *sector = target->subsector->sector;
421+
410422
obituary.terraintype = sector->terraintype;
411423
obituary.floorpic = sector->floorpic;
412424
}

src/c_obituary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ typedef struct
6666

6767
void C_BuildObituaryString(const int index);
6868
void C_WriteObituary(mobj_t *target, mobj_t *inflicter, mobj_t *source, const bool gibbed,
69-
const bool telefragged);
69+
const bool telefragged, const bool crushed);

src/p_enemy.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ void A_TroopAttack(mobj_t *actor, player_t *player, pspdef_t *psp)
11741174
const int damage = ((M_Random() & 7) + 1) * 3;
11751175

11761176
S_StartSound(actor, sfx_claw);
1177-
P_DamageMobj(target, actor, actor, damage, true, false);
1177+
P_DamageMobj(target, actor, actor, damage, true, false, false);
11781178
P_SpawnBloodOnMelee(target, damage);
11791179
return;
11801180
}
@@ -1199,7 +1199,7 @@ void A_SargAttack(mobj_t *actor, player_t *player, pspdef_t *psp)
11991199
{
12001200
const int damage = (M_Random() % 10 + 1) * 4;
12011201

1202-
P_DamageMobj(target, actor, actor, damage, true, false);
1202+
P_DamageMobj(target, actor, actor, damage, true, false, false);
12031203
P_SpawnBloodOnMelee(target, damage);
12041204
}
12051205
}
@@ -1217,7 +1217,7 @@ void A_HeadAttack(mobj_t *actor, player_t *player, pspdef_t *psp)
12171217
{
12181218
const int damage = (M_Random() % 6 + 1) * 10;
12191219

1220-
P_DamageMobj(target, actor, actor, damage, true, false);
1220+
P_DamageMobj(target, actor, actor, damage, true, false, false);
12211221
P_SpawnBloodOnMelee(target, damage);
12221222

12231223
return;
@@ -1262,7 +1262,7 @@ void A_BruisAttack(mobj_t *actor, player_t *player, pspdef_t *psp)
12621262
const int damage = ((M_Random() & 7) + 1) * 10;
12631263

12641264
S_StartSound(actor, sfx_claw);
1265-
P_DamageMobj(target, actor, actor, damage, true, false);
1265+
P_DamageMobj(target, actor, actor, damage, true, false, false);
12661266
P_SpawnBloodOnMelee(target, damage);
12671267

12681268
return;
@@ -1381,7 +1381,7 @@ void A_SkelFist(mobj_t *actor, player_t *player, pspdef_t *psp)
13811381
const int damage = (M_Random() % 10 + 1) * 6;
13821382

13831383
S_StartSound(actor, sfx_skepch);
1384-
P_DamageMobj(target, actor, actor, damage, true, false);
1384+
P_DamageMobj(target, actor, actor, damage, true, false, false);
13851385
P_SpawnBloodOnMelee(target, damage);
13861386
}
13871387
}
@@ -1678,7 +1678,7 @@ void A_VileAttack(mobj_t *actor, player_t *player, pspdef_t *psp)
16781678
return;
16791679

16801680
S_StartSound(actor, sfx_barexp);
1681-
P_DamageMobj(target, actor, actor, 20, true, false);
1681+
P_DamageMobj(target, actor, actor, 20, true, false, false);
16821682

16831683
// [BH] don't apply upward momentum from vile attack to player when no clipping mode on
16841684
if (!target->player || !(target->flags & MF_NOCLIP))
@@ -1816,7 +1816,7 @@ void A_BetaSkullAttack(mobj_t *actor, player_t *player, pspdef_t *psp)
18161816

18171817
S_StartSound(actor, actor->info->attacksound);
18181818
A_FaceTarget(actor, NULL, NULL);
1819-
P_DamageMobj(target, actor, actor, ((M_Random() & 7) + 1) * actor->info->damage, true, false);
1819+
P_DamageMobj(target, actor, actor, ((M_Random() & 7) + 1) * actor->info->damage, true, false, false);
18201820
}
18211821

18221822
void A_Stop(mobj_t *actor, player_t *player, pspdef_t *psp)
@@ -1865,7 +1865,7 @@ static void A_PainShootSkull(mobj_t *actor, angle_t angle)
18651865
// kill it immediately
18661866
massacre = true; // [BH] set this to avoid obituary
18671867
newmobj->flags &= ~MF_COUNTKILL;
1868-
P_DamageMobj(newmobj, actor, actor, 10000, true, false);
1868+
P_DamageMobj(newmobj, actor, actor, 10000, true, false, false);
18691869
massacre = false;
18701870

18711871
return;
@@ -2408,7 +2408,7 @@ void A_KeenDie(mobj_t *actor, player_t *player, pspdef_t *psp)
24082408
// killough 11/98: kill an object
24092409
void A_Die(mobj_t *actor, player_t *player, pspdef_t *psp)
24102410
{
2411-
P_DamageMobj(actor, NULL, NULL, actor->health, false, false);
2411+
P_DamageMobj(actor, NULL, NULL, actor->health, false, false, false);
24122412
}
24132413

24142414
//
@@ -2510,7 +2510,7 @@ void A_Scratch(mobj_t *actor, player_t *player, pspdef_t *psp)
25102510
if (state->misc2)
25112511
S_StartSound(actor, state->misc2);
25122512

2513-
P_DamageMobj(target, actor, actor, state->misc1, true, false);
2513+
P_DamageMobj(target, actor, actor, state->misc1, true, false, false);
25142514
P_SpawnBloodOnMelee(target, state->misc1);
25152515
}
25162516
}
@@ -2745,7 +2745,8 @@ void A_MonsterMeleeAttack(mobj_t *actor, player_t *player, pspdef_t *psp)
27452745

27462746
S_StartSound(actor, actor->state->args[2]);
27472747

2748-
P_DamageMobj(target, actor, actor, (M_Random() % actor->state->args[1] + 1) * actor->state->args[0], true, false);
2748+
P_DamageMobj(target, actor, actor, (M_Random() % actor->state->args[1] + 1) * actor->state->args[0],
2749+
true, false, false);
27492750
}
27502751

27512752
//

src/p_inter.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ static void P_SpawnGibBlood(mobj_t *target)
15841584
//
15851585
// P_KillMobj
15861586
//
1587-
void P_KillMobj(mobj_t *target, mobj_t *inflicter, mobj_t *source, const bool telefragged)
1587+
void P_KillMobj(mobj_t *target, mobj_t *inflicter, mobj_t *source, const bool telefragged, const bool crushed)
15881588
{
15891589
bool gibbed;
15901590
const mobjtype_t type = target->type;
@@ -1710,7 +1710,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflicter, mobj_t *source, const bool te
17101710
target->flags2 |= MF2_EXPLODING;
17111711

17121712
if (!hacx && !massacre)
1713-
C_WriteObituary(target, inflicter, source, gibbed, telefragged);
1713+
C_WriteObituary(target, inflicter, source, gibbed, telefragged, crushed);
17141714

17151715
target->flags |= (MF_CORPSE | MF_DROPOFF);
17161716

@@ -1766,7 +1766,8 @@ static bool P_InfightingImmune(const mobj_t *target, const mobj_t *source)
17661766
// Source can be NULL for slime, barrel explosions
17671767
// and other environmental stuff.
17681768
//
1769-
void P_DamageMobj(mobj_t *target, mobj_t *inflicter, mobj_t *source, int damage, const bool adjust, const bool telefragged)
1769+
void P_DamageMobj(mobj_t *target, mobj_t *inflicter, mobj_t *source, int damage,
1770+
const bool adjust, const bool telefragged, const bool crushed)
17701771
{
17711772
player_t *splayer = NULL;
17721773
player_t *tplayer;
@@ -1966,7 +1967,7 @@ void P_DamageMobj(mobj_t *target, mobj_t *inflicter, mobj_t *source, int damage,
19661967
tplayer->negativehealth = HUD_NUMBER_MIN;
19671968

19681969
tplayer->damagecount = 100;
1969-
P_KillMobj(target, inflicter, source, telefragged);
1970+
P_KillMobj(target, inflicter, source, telefragged, crushed);
19701971
}
19711972
else
19721973
{
@@ -2002,7 +2003,7 @@ void P_DamageMobj(mobj_t *target, mobj_t *inflicter, mobj_t *source, int damage,
20022003
&& damage >= 10 && info->gibhealth < 0 && P_CheckMeleeRange(target))
20032004
target->health = info->gibhealth - 1;
20042005

2005-
P_KillMobj(target, inflicter, source, telefragged);
2006+
P_KillMobj(target, inflicter, source, telefragged, crushed);
20062007
return;
20072008
}
20082009

src/p_local.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ extern int blockmapyneg;
323323
bool P_TouchSpecialThing(mobj_t *special, const mobj_t *toucher, const bool message, const bool stat);
324324
bool P_TakeSpecialThing(const mobjtype_t type);
325325

326-
void P_DamageMobj(mobj_t *target, mobj_t *inflicter, mobj_t *source, int damage, const bool adjust, const bool telefragged);
326+
void P_DamageMobj(mobj_t *target, mobj_t *inflicter, mobj_t *source, int damage,
327+
const bool adjust, const bool telefragged, const bool crushed);
327328

328329
void P_ResurrectMobj(mobj_t *target);
329330

src/p_map.c

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static bool PIT_StompThing(mobj_t *thing)
120120
if (!telefrag) // killough 08/09/98: make consistent across all levels
121121
return false;
122122

123-
P_DamageMobj(thing, NULL, tmthing, 10000, true, true); // Stomp!
123+
P_DamageMobj(thing, NULL, tmthing, 10000, true, true, false); // Stomp!
124124

125125
return true;
126126
}
@@ -479,19 +479,19 @@ static bool PIT_CheckThing(mobj_t *thing)
479479
// If a solid object of a different type comes in contact with a touchy
480480
// thing, and the touchy thing is not the sole one moving relative to fixed
481481
// surroundings such as walls, then the touchy thing dies immediately.
482-
if ((flags & MF_TOUCHY) // touchy object
483-
&& (tmflags & MF_SOLID) // solid object touches it
484-
&& thing->health > 0 // touchy object is alive
485-
&& ((thing->flags2 & MF2_ARMED) // Thing is an armed mine
486-
|| sentient(thing)) // ...or a sentient thing
487-
&& (type != tmtype // only different species
488-
|| type == MT_PLAYER) // ...or different players
489-
&& thing->z + thing->height >= tmthing->z // touches vertically
482+
if ((flags & MF_TOUCHY) // touchy object
483+
&& (tmflags & MF_SOLID) // solid object touches it
484+
&& thing->health > 0 // touchy object is alive
485+
&& ((thing->flags2 & MF2_ARMED) // Thing is an armed mine
486+
|| sentient(thing)) // ...or a sentient thing
487+
&& (type != tmtype // only different species
488+
|| type == MT_PLAYER) // ...or different players
489+
&& thing->z + thing->height >= tmthing->z // touches vertically
490490
&& tmthing->z + tmthing->height >= thing->z
491-
&& ((type ^ MT_PAIN) | (tmtype ^ MT_SKULL)) // PEs and lost souls are considered same
492-
&& ((type ^ MT_SKULL) | (tmtype ^ MT_PAIN))) // (but Barons and Knights are intentionally not)
491+
&& ((type ^ MT_PAIN) | (tmtype ^ MT_SKULL)) // PEs and lost souls are considered same
492+
&& ((type ^ MT_SKULL) | (tmtype ^ MT_PAIN))) // (but Barons and Knights are intentionally not)
493493
{
494-
P_DamageMobj(thing, NULL, NULL, thing->health, true, false); // kill object
494+
P_DamageMobj(thing, NULL, NULL, thing->health, true, false, false); // kill object
495495
return true;
496496
}
497497

@@ -517,7 +517,7 @@ static bool PIT_CheckThing(mobj_t *thing)
517517
// check for skulls slamming into things
518518
if ((tmflags & MF_SKULLFLY) && ((flags & MF_SOLID) || infiniteheight || compat_nopassover))
519519
{
520-
P_DamageMobj(thing, tmthing, tmthing, ((M_Random() & 7) + 1) * tmthing->info->damage, true, false);
520+
P_DamageMobj(thing, tmthing, tmthing, ((M_Random() & 7) + 1) * tmthing->info->damage, true, false, false);
521521

522522
tmthing->flags &= ~MF_SKULLFLY;
523523
tmthing->momx = 0;
@@ -595,7 +595,7 @@ static bool PIT_CheckThing(mobj_t *thing)
595595
if (tmthing->info->ripsound)
596596
S_StartSound(tmthing, tmthing->info->ripsound);
597597

598-
P_DamageMobj(thing, tmthing, tmthing->target, damage, true, false);
598+
P_DamageMobj(thing, tmthing, tmthing->target, damage, true, false, false);
599599
numspechit = 0;
600600

601601
if (tmtype == MT_RIPPER)
@@ -608,7 +608,8 @@ static bool PIT_CheckThing(mobj_t *thing)
608608
}
609609

610610
// damage/explode
611-
P_DamageMobj(thing, tmthing, tmthing->target, ((M_Random() & 7) + 1) * tmthing->info->damage, true, false);
611+
P_DamageMobj(thing, tmthing, tmthing->target, ((M_Random() & 7) + 1) * tmthing->info->damage,
612+
true, false, false);
612613

613614
if (type != MT_BARREL && type != MT_LAMP)
614615
{
@@ -1818,7 +1819,7 @@ static bool PTR_ShootTraverse(intercept_t *in)
18181819
if (la_damage)
18191820
{
18201821
successfulshot = true;
1821-
P_DamageMobj(th, shootthing, shootthing, la_damage, true, false);
1822+
P_DamageMobj(th, shootthing, shootthing, la_damage, true, false, false);
18221823
}
18231824

18241825
// don't go any farther
@@ -2066,7 +2067,7 @@ bool PIT_RadiusAttack(mobj_t *thing)
20662067
(bombdamage * (bombdistance - dist) / bombdistance) + 1);
20672068

20682069
// must be in direct path
2069-
P_DamageMobj(thing, bombspot, bombsource, damage, true, false);
2070+
P_DamageMobj(thing, bombspot, bombsource, damage, true, false, false);
20702071

20712072
// [BH] count number of times player's rockets hit a monster
20722073
if (bombspot->type == MT_ROCKET && type != MT_BARREL && type != MT_LAMP && !(thing->flags & MF_CORPSE))
@@ -2212,7 +2213,7 @@ static void PIT_ChangeSector(mobj_t *thing)
22122213
// killough 11/98: kill touchy things immediately
22132214
if ((flags & MF_TOUCHY) && ((flags2 & MF2_ARMED) || sentient(thing)))
22142215
{
2215-
P_DamageMobj(thing, NULL, NULL, thing->health, true, false); // kill object
2216+
P_DamageMobj(thing, NULL, NULL, thing->health, true, false, false); // kill object
22162217
return;
22172218
}
22182219

@@ -2259,24 +2260,7 @@ static void PIT_ChangeSector(mobj_t *thing)
22592260
}
22602261
}
22612262

2262-
P_DamageMobj(thing, NULL, NULL, 10, true, false);
2263-
2264-
if (thing->health <= 0 && !thing->player && type != MT_BARREL && obituaries)
2265-
{
2266-
char name[128];
2267-
2268-
if (*thing->name)
2269-
M_StringCopy(name, thing->name, sizeof(name));
2270-
else
2271-
M_snprintf(name, sizeof(name), "%s %s%s",
2272-
((flags & MF_FRIEND) && type > MT_NULL && type < NUMMOBJTYPES && monstercount[type] == 1 ? "the" :
2273-
(isvowel(thing->info->name1[0]) && !(flags & MF_FRIEND) ? "an" : "a")),
2274-
((flags & MF_FRIEND) ? "friendly " : ""),
2275-
(*thing->info->name1 ? thing->info->name1 : "monster"));
2276-
2277-
name[0] = toupper(name[0]);
2278-
C_PlayerMessage("%s was crushed to death.", name);
2279-
}
2263+
P_DamageMobj(thing, NULL, NULL, 10, true, false, true);
22802264
}
22812265
}
22822266

0 commit comments

Comments
 (0)