Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
add support for colored blood and gibs (#182)
Browse files Browse the repository at this point in the history
* add support for colored blood and gibs

Due to popular demand. 😉

* use P_SetTarget() instead of editing the target value directly

* introduce a new mobjflag instead of misusing the mobj->target pointer

* set flags more consistently

If MF_COLOREDBLOOD is set and none of (MF_TRANSLATION1|MF_TRANSLATION2)
this means green blood (Baron of Hell / Hell Knight) and if
MF_TRANSLATION1 is additionally set this means blue blood (Cacodaemon).

This allows for up to 4 different blood colors once MF_TRANSLATION2 is
also taken into account. Let's see what we come up with...

* add comments
  • Loading branch information
fabiangreffrath authored Feb 5, 2021
1 parent 2119b6f commit 051c4a5
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 3 deletions.
5 changes: 5 additions & 0 deletions prboom2/src/gl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2609,6 +2609,11 @@ void gld_ProjectSprite(mobj_t* thing, int lightlevel)
sprite.fogdensity = gld_CalcFogDensity(thing->subsector->sector, lightlevel, GLDIT_SPRITE);
}
sprite.cm = CR_LIMIT + (int)((thing->flags & MF_TRANSLATION) >> (MF_TRANSSHIFT));
// [FG] colored blood and gibs
if (thing->flags & MF_COLOREDBLOOD)
{
sprite.cm = (thing->flags & MF_TRANSLATION1) ? CR_BLUE2 : CR_GREEN;
}
sprite.gltexture = gld_RegisterPatch(lump, sprite.cm, true);
if (!sprite.gltexture)
goto unlock_patch;
Expand Down
4 changes: 4 additions & 0 deletions prboom2/src/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,8 @@ enum {

enem_dog_jumping,

enem_colored_blood,

enem_end
};

Expand Down Expand Up @@ -3069,6 +3071,8 @@ setup_menu_t enem_settings1[] = // Enemy Settings screen

{"Allow dogs to jump down",S_YESNO,m_null,E_X,E_Y+ enem_dog_jumping*8, {"dog_jumping"}},

{"Colored blood and gibs",S_YESNO,m_null,E_X,E_Y+ enem_colored_blood*8, {"colored_blood"}},

// Button for resetting to defaults
{0,S_RESET,m_null,X_BUTTON,Y_BUTTON},

Expand Down
3 changes: 3 additions & 0 deletions prboom2/src/m_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ default_t defaults[] =
def_bool, ss_enem, &dog_jumping},
/* End of MBF AI extras */

// [FG] colored blood and gibs
{"colored_blood",{(int*)&colored_blood}, {0}, 0, 1, def_bool, ss_none},

{"sts_always_red",{&sts_always_red},{1},0,1, // no color changes on status bar
def_bool,ss_stat},
{"sts_pct_always_gray",{&sts_pct_always_gray},{0},0,1, // 2/23/98 chg default
Expand Down
4 changes: 3 additions & 1 deletion prboom2/src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ dboolean PTR_ShootTraverse (intercept_t* in)
if (in->d.thing->flags & MF_NOBLOOD)
P_SpawnPuff (x,y,z);
else
P_SpawnBlood (x,y,z, la_damage);
P_SpawnBlood (x,y,z, la_damage, th);

if (la_damage)
P_DamageMobj (th, shootthing, shootthing, la_damage);
Expand Down Expand Up @@ -1971,6 +1971,7 @@ dboolean PIT_ChangeSector (mobj_t* thing)
}
thing->height = 0;
thing->radius = 0;
thing->flags |= P_ColoredBlood(thing);
return true; // keep checking
}

Expand Down Expand Up @@ -2008,6 +2009,7 @@ dboolean PIT_ChangeSector (mobj_t* thing)
mo = P_SpawnMobj (thing->x,
thing->y,
thing->z + thing->height/2, MT_BLOOD);
mo->flags |= P_ColoredBlood(thing);

/* killough 8/10/98: remove dependence on order of evaluation */
t = P_Random(pr_crush);
Expand Down
21 changes: 20 additions & 1 deletion prboom2/src/p_mobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
#include "g_overflow.h"
#include "e6y.h"//e6y

// [FG] colored blood and gibs
dboolean colored_blood;

//
// P_SetMobjState
// Returns true if the mobj is still present.
Expand Down Expand Up @@ -1495,10 +1498,25 @@ void P_SpawnPuff(fixed_t x,fixed_t y,fixed_t z)
}


// [FG] colored blood and gibs
uint_64_t P_ColoredBlood (mobj_t* bleeder)
{
if (colored_blood)
{
// Barons of Hell and Hell Knights bleed green blood
if (bleeder->type == MT_BRUISER || bleeder->type == MT_KNIGHT)
return MF_COLOREDBLOOD;
// Cacodemons bleed blue blood
else if (bleeder->type == MT_HEAD)
return MF_COLOREDBLOOD | MF_TRANSLATION1;
}
return 0;
}

//
// P_SpawnBlood
//
void P_SpawnBlood(fixed_t x,fixed_t y,fixed_t z,int damage)
void P_SpawnBlood(fixed_t x,fixed_t y,fixed_t z,int damage, mobj_t* bleeder)
{
mobj_t* th;
// killough 5/5/98: remove dependence on order of evaluation:
Expand All @@ -1507,6 +1525,7 @@ void P_SpawnBlood(fixed_t x,fixed_t y,fixed_t z,int damage)
th = P_SpawnMobj(x,y,z, MT_BLOOD);
th->momz = FRACUNIT*2;
th->tics -= P_Random(pr_spawnblood)&3;
th->flags |= P_ColoredBlood(bleeder);

if (th->tics < 1)
th->tics = 1;
Expand Down
8 changes: 7 additions & 1 deletion prboom2/src/p_mobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@
#define MF_NOTARGET LONGLONG(0x0000010000000000)
// fly mode is active
#define MF_FLY LONGLONG(0x0000020000000000)
// [FG] colored blood and gibs
#define MF_COLOREDBLOOD LONGLONG(0x0000040000000000)

#define ALIVE(thing) ((thing->health > 0) && ((thing->flags & (MF_COUNTKILL | MF_CORPSE | MF_RESSURECTED)) == MF_COUNTKILL))

Expand Down Expand Up @@ -404,14 +406,18 @@ typedef struct mobj_s
extern int iquehead;
extern int iquetail;

// [FG] colored blood and gibs
extern dboolean colored_blood;

mobj_t* P_SubstNullMobj (mobj_t* th);
void P_RespawnSpecials(void);
mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type);
void P_RemoveMobj(mobj_t *th);
dboolean P_SetMobjState(mobj_t *mobj, statenum_t state);
void P_MobjThinker(mobj_t *mobj);
void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z);
void P_SpawnBlood(fixed_t x, fixed_t y, fixed_t z, int damage);
uint_64_t P_ColoredBlood (mobj_t* bleeder);
void P_SpawnBlood(fixed_t x, fixed_t y, fixed_t z, int damage, mobj_t* bleeder);
mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type);
void P_SpawnPlayerMissile(mobj_t *source, mobjtype_t type);
dboolean P_IsDoomnumAllowed(int doomnum);
Expand Down
8 changes: 8 additions & 0 deletions prboom2/src/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,14 @@ static void R_DrawVisSprite(vissprite_t *vis)

if (!dcvars.colormap) // NULL colormap = shadow draw
colfunc = R_GetDrawColumnFunc(RDC_PIPELINE_FUZZ, filter, filterz); // killough 3/14/98
else
// [FG] colored blood and gibs
if (vis->mobjflags & MF_COLOREDBLOOD)
{
colfunc = R_GetDrawColumnFunc(RDC_PIPELINE_TRANSLATED, filter, filterz);
dcvars.translation = (vis->mobjflags & MF_TRANSLATION1) ?
colrngs[CR_BLUE2] : colrngs[CR_GREEN];
}
else
if (vis->mobjflags & MF_TRANSLATION)
{
Expand Down

0 comments on commit 051c4a5

Please sign in to comment.