Skip to content

Instantly share code, notes, and snippets.

@fabiangreffrath
Last active January 28, 2021 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiangreffrath/cb052b960bd14197d192bcab11bcfcba to your computer and use it in GitHub Desktop.
Save fabiangreffrath/cb052b960bd14197d192bcab11bcfcba to your computer and use it in GitHub Desktop.
diff --git a/prboom2/src/gl_main.c b/prboom2/src/gl_main.c
index a5911d46..beceba2c 100644
--- a/prboom2/src/gl_main.c
+++ b/prboom2/src/gl_main.c
@@ -2609,6 +2609,13 @@ 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));
+ if ((thing->type == MT_BLOOD || thing->state - states == S_GIBS) && thing->target)
+ {
+ if (thing->target->type == MT_HEAD)
+ sprite.cm = CR_BLUE2;
+ else if (thing->target->type == MT_BRUISER || thing->target->type == MT_KNIGHT)
+ sprite.cm = CR_GREEN;
+ }
sprite.gltexture = gld_RegisterPatch(lump, sprite.cm, true);
if (!sprite.gltexture)
goto unlock_patch;
diff --git a/prboom2/src/p_map.c b/prboom2/src/p_map.c
index bbe3c34f..95a569b5 100644
--- a/prboom2/src/p_map.c
+++ b/prboom2/src/p_map.c
@@ -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);
@@ -1971,6 +1971,7 @@ dboolean PIT_ChangeSector (mobj_t* thing)
}
thing->height = 0;
thing->radius = 0;
+ thing->target = thing;
return true; // keep checking
}
@@ -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->target = thing;
/* killough 8/10/98: remove dependence on order of evaluation */
t = P_Random(pr_crush);
diff --git a/prboom2/src/p_mobj.c b/prboom2/src/p_mobj.c
index d0fc68c5..608b4f70 100644
--- a/prboom2/src/p_mobj.c
+++ b/prboom2/src/p_mobj.c
@@ -1498,7 +1498,7 @@ void P_SpawnPuff(fixed_t x,fixed_t y,fixed_t z)
//
// 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* target)
{
mobj_t* th;
// killough 5/5/98: remove dependence on order of evaluation:
@@ -1507,6 +1507,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->target = target;
if (th->tics < 1)
th->tics = 1;
diff --git a/prboom2/src/p_mobj.h b/prboom2/src/p_mobj.h
index 84f63079..a0203682 100644
--- a/prboom2/src/p_mobj.h
+++ b/prboom2/src/p_mobj.h
@@ -411,7 +411,7 @@ 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);
+void P_SpawnBlood(fixed_t x, fixed_t y, fixed_t z, int damage, mobj_t* target);
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);
diff --git a/prboom2/src/r_draw.c b/prboom2/src/r_draw.c
index b3660427..984f58a6 100644
--- a/prboom2/src/r_draw.c
+++ b/prboom2/src/r_draw.c
@@ -734,6 +734,21 @@ void R_InitTranslationTables (void)
}
else // Keep all other colors as is.
translationtables[i]=translationtables[i+256]=translationtables[i+512]=i;
+
+ if (!netgame)
+ for (i = 0; i < 256; i++)
+ {
+ if (i == 44 || i == 45 || i == 47 || i == 67)
+ {
+ translationtables[i] = 207;
+ translationtables[i+256] = 127;
+ }
+ if (i >= 0xb0 && i <= 0xbf)
+ {
+ translationtables[i] = 200 + (i - 0xb0) / 2;
+ translationtables[i+256] = 114 + (i - 0xb0);
+ }
+ }
}
//
diff --git a/prboom2/src/r_things.c b/prboom2/src/r_things.c
index 5582c9d2..0f039d78 100644
--- a/prboom2/src/r_things.c
+++ b/prboom2/src/r_things.c
@@ -831,6 +831,14 @@ static void R_ProjectSprite (mobj_t* thing, int lightlevel)
index = MAXLIGHTSCALE - 1;
vis->colormap = spritelights[index];
}
+
+ if ((thing->type == MT_BLOOD || thing->state - states == S_GIBS) && thing->target)
+ {
+ if (thing->target->type == MT_HEAD)
+ vis->mobjflags |= 1<<MF_TRANSSHIFT;
+ else if (thing->target->type == MT_BRUISER || thing->target->type == MT_KNIGHT)
+ vis->mobjflags |= 2<<MF_TRANSSHIFT;
+ }
}
//
@coelckers
Copy link

Well, it's a hack. Is there any reason this can't be done right in a forward-thinking way?

@fabiangreffrath
Copy link
Author

First, because I am not sure if we want this at all in this port. Second, because we are currently missing a general drawing function for color translated columns. The one we have currently gets its translation table via vis->mobjflags & MF_TRANSLATION.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment