Skip to content

Commit

Permalink
HacX: Attempt to mimic the personal forcefield's blue view filter
Browse files Browse the repository at this point in the history
This is about as close as we're going to get without significant
work on the renderer.
  • Loading branch information
danij-deng committed Feb 6, 2012
1 parent 4b9f790 commit 50c1e4e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 35 deletions.
5 changes: 5 additions & 0 deletions doomsday/plugins/jdoom/include/p_local.h
Expand Up @@ -47,6 +47,11 @@
#define NUMREDPALS (8)
#define NUMBONUSPALS (4)

// For HacX's invulnerablity blue palette shift.
/// @note These do not correspond to real palette indices.
#define STARTINVULPALS (14)
#define NUMINVULPALS (4)

#define FLOATSPEED (4)

#define DELTAMUL (6.324555320) // Used when calculating ticcmd_t.lookdirdelta
Expand Down
107 changes: 72 additions & 35 deletions doomsday/plugins/jdoom/src/d_refresh.c
Expand Up @@ -73,10 +73,14 @@ float quitDarkenOpacity = 0;
static void rendSpecialFilter(int player, const RectRaw* region)
{
player_t* plr = players + player;
const int filter = plr->powers[PT_INVULNERABILITY];
float max = 30, str, r, g, b;
int filter;
assert(region);

// In HacX a simple blue shift is used instead.
if(gameMode == doom2_hacx) return;

filter = plr->powers[PT_INVULNERABILITY];
if(!filter) return;

if(filter < max)
Expand Down Expand Up @@ -113,7 +117,18 @@ boolean R_ViewFilterColor(float rgba[4], int filter)
rgba[CR] = 1;
rgba[CG] = 0;
rgba[CB] = 0;
rgba[CA] = (deathmatch? 1.0f : cfg.filterStrength) * filter / 9.f;
rgba[CA] = (deathmatch? 1.0f : cfg.filterStrength) * (filter+1) / (float)NUMREDPALS;
return true;
}

if(gameMode == doom2_hacx &&
filter >= STARTINVULPALS && filter < STARTINVULPALS + NUMINVULPALS)
{
// Blue.
rgba[CR] = .16f;
rgba[CG] = .16f;
rgba[CB] = .92f;
rgba[CA] = cfg.filterStrength * .98f * (filter - STARTINVULPALS + 1) / (float)NUMINVULPALS;
return true;
}

Expand All @@ -127,15 +142,15 @@ boolean R_ViewFilterColor(float rgba[4], int filter)
rgba[CR] = .5f;
rgba[CG] = .5f;
rgba[CB] = .5f;
rgba[CA] = cfg.filterStrength * (filter - STARTBONUSPALS + 1) / 16.f;
rgba[CA] = cfg.filterStrength * .25f * (filter - STARTBONUSPALS + 1) / (float)NUMBONUSPALS;
}
else
{
// Gold.
rgba[CR] = 1;
rgba[CG] = .8f;
rgba[CB] = .5f;
rgba[CA] = cfg.filterStrength * (filter - STARTBONUSPALS + 1) / 16.f;
rgba[CA] = cfg.filterStrength * .25f * (filter - STARTBONUSPALS + 1) / (float)NUMBONUSPALS;
}
return true;
}
Expand All @@ -161,7 +176,7 @@ void R_UpdateViewFilter(int player)
#define RADIATIONPAL (13) /// Radiation suit, green shift.

player_t* plr = players + player;
int palette = 0, cnt;
int palette = 0;

if(player < 0 || player >= MAXPLAYERS)
{
Expand All @@ -174,44 +189,66 @@ void R_UpdateViewFilter(int player)
// Not currently present?
if(!plr->plr->inGame) return;

cnt = plr->damageCount;

if(plr->powers[PT_STRENGTH])
if(gameMode == doom2_hacx && plr->powers[PT_INVULNERABILITY])
{
// Slowly fade the berzerk out.
int bzc = 12 - (plr->powers[PT_STRENGTH] >> 6);
cnt = MAX_OF(cnt, bzc);
}
// A blue shift is used in HacX.
const int max = 10;
const int cnt = plr->powers[PT_INVULNERABILITY];

if(cnt < max)
palette = .5f + (NUMINVULPALS-1) * ((float)cnt / max);
else if(cnt < 4 * 32 && !(cnt & 8))
palette = .5f + (NUMINVULPALS-1) * .7f;
else if(cnt > INVULNTICS - max)
palette = .5f + (NUMINVULPALS-1) * ((float)(INVULNTICS - cnt) / max);
else
palette = NUMINVULPALS-1; // Full shift.

if(cnt)
if(palette >= NUMINVULPALS)
palette = NUMINVULPALS - 1;
palette += STARTINVULPALS;
}
else
{
// In Chex Quest the green palette shift is used instead (perhaps to
// suggest the player is being covered in goo?).
if(gameMode == doom_chex)
int cnt = plr->damageCount;

if(plr->powers[PT_STRENGTH])
{
palette = RADIATIONPAL;
// Slowly fade the berzerk out.
int bzc = 12 - (plr->powers[PT_STRENGTH] >> 6);
cnt = MAX_OF(cnt, bzc);
}
else
{
palette = (cnt + 7) >> 3;
if(palette >= NUMREDPALS)
palette = NUMREDPALS - 1;

palette += STARTREDPALS;
if(cnt)
{
// In Chex Quest the green palette shift is used instead (perhaps to
// suggest the player is being covered in goo?).
if(gameMode == doom_chex)
{
palette = RADIATIONPAL;
}
else
{
palette = (cnt + 7) >> 3;
if(palette >= NUMREDPALS)
palette = NUMREDPALS - 1;

palette += STARTREDPALS;
}
}
}
else if(plr->bonusCount)
{
palette = (plr->bonusCount + 7) >> 3;
if(palette >= NUMBONUSPALS)
palette = NUMBONUSPALS - 1;
else if(plr->bonusCount)
{
palette = (plr->bonusCount + 7) >> 3;
if(palette >= NUMBONUSPALS)
palette = NUMBONUSPALS - 1;

palette += STARTBONUSPALS;
}
else if(plr->powers[PT_IRONFEET] > 4 * 32 ||
plr->powers[PT_IRONFEET] & 8)
{
palette = RADIATIONPAL;
palette += STARTBONUSPALS;
}
else if(plr->powers[PT_IRONFEET] > 4 * 32 ||
plr->powers[PT_IRONFEET] & 8)
{
palette = RADIATIONPAL;
}
}

// $democam
Expand Down

0 comments on commit 50c1e4e

Please sign in to comment.