Skip to content

Commit

Permalink
NUGHUD Health icon
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlaux committed Nov 1, 2023
1 parent 67e31e4 commit 17c451e
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 26 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
## New Features

- **NUGHUD:**
- Ammo icon;
- Ammo and Health icons;
- Toggle to apply patch offsets.
- **_Direct Vertical Aiming_ for melee attacks**
- **_Disable Melee Snapping_ setting**

## Changes

- **NUGHUD:**
- Let Ammo and Armor icons fall back to vanilla sprites;
- Made Patches and Ammo and Armor icons alignable horizontally and vertically;
- Let Ammo, Health and Armor icons fall back to vanilla sprites;
- Made Patches and icons alignable horizontally and vertically;
- Disabled Armor icon by default.
- **Implemented Teleporter Zoom for multiplayer respawning**
- **MDK Fist attacks now prioritize enemies over friends**
Expand Down
7 changes: 7 additions & 0 deletions docs/nughud.lmp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ nughud_health_y 171
nughud_health_wide -1
nughud_health_align 1

; Health icon
nughud_healthicon_x -1
nughud_healthicon_y 0
nughud_healthicon_wide 0
nughud_healthicon_align -1
nughud_healthicon_vlign 1

; Arms numbers

nughud_arms1_x -1
Expand Down
51 changes: 28 additions & 23 deletions docs/nughud.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,30 @@ The following types of widgets support special behavior:

The following widgets are available:

| Widget(s) | Disableable | Alignable | Description |
| :----------------: | :---------: | :-------: | :---------- |
| `nughud_ammo` | Yes | Yes | Ammo count for the currently-equipped weapon |
| `nughud_ammoicon` | Yes | Yes | Ammo icon, which changes depending on ammo type of current weapon |
| `nughud_health` | Yes | Yes | Health count |
| `nughud_arms#` | Yes | No | Arms (weapon) number, where # is a number between `1` and `9` (inclusive) |
| `nughud_frags` | Yes | Yes | Frags count, only shown during Deathmatch games |
| `nughud_face` | Yes | No | Face (Mugshot) |
| `nughud_armor` | Yes | Yes | Armor count |
| `nughud_armoricon` | Yes | Yes | Armor icon, which changes depending on current armor type |
| `nughud_key#` | Yes | No | Key display, where # is a number between `0` and `2` (in order: Blue Key; Yellow Key; Red Key) |
| `nughud_ammo#` | Yes | Yes | Ammo count for each type, where # is a number between `0` and `3` (in order: Bullets; Shells; Cells; Rockets) |
| `nughud_maxammo#` | Yes | Yes | Same as the above, but for Max Ammo |
| `nughud_time` | No | Yes | Time display, only shown if enabled by the user |
| `nughud_sts` | No | Yes | Stats (Kills/Items/Secrets) display, only shown if enabled by the user |
| `nughud_title` | No | Yes | Level Name display, only shown on the Automap |
| `nughud_powers` | No | Yes | Powerup Timers, only shown if enabled by the user |
| `nughud_coord` | No | Yes | Coordinates display, only shown if enabled by the user |
| `nughud_fps` | No | Yes | FPS display, only shown when the FPS cheat is activated |
| `nughud_message` | No | Yes | Message display |
| `nughud_secret` | No | Yes | Secret Message display |

**The _Ammo_ and _Armor icons_ can also be aligned vertically** by means of the `_vlign` property, with the following possible values:
| Widget(s) | Disableable | Alignable | Description |
| :-----------------: | :---------: | :-------: | :---------- |
| `nughud_ammo` | Yes | Yes | Ammo count for the currently-equipped weapon |
| `nughud_ammoicon` | Yes | Yes | Ammo icon, which changes depending on ammo type of current weapon |
| `nughud_health` | Yes | Yes | Health count |
| `nughud_healthicon` | Yes | Yes | Health icon, which changes depending on whether the player has Berserk |
| `nughud_arms#` | Yes | No | Arms (weapon) number, where # is a number between `1` and `9` (inclusive) |
| `nughud_frags` | Yes | Yes | Frags count, only shown during Deathmatch games |
| `nughud_face` | Yes | No | Face (Mugshot) |
| `nughud_armor` | Yes | Yes | Armor count |
| `nughud_armoricon` | Yes | Yes | Armor icon, which changes depending on current armor type |
| `nughud_key#` | Yes | No | Key display, where # is a number between `0` and `2` (in order: Blue Key; Yellow Key; Red Key) |
| `nughud_ammo#` | Yes | Yes | Ammo count for each type, where # is a number between `0` and `3` (in order: Bullets; Shells; Cells; Rockets) |
| `nughud_maxammo#` | Yes | Yes | Same as the above, but for Max Ammo |
| `nughud_time` | No | Yes | Time display, only shown if enabled by the user |
| `nughud_sts` | No | Yes | Stats (Kills/Items/Secrets) display, only shown if enabled by the user |
| `nughud_title` | No | Yes | Level Name display, only shown on the Automap |
| `nughud_powers` | No | Yes | Powerup Timers, only shown if enabled by the user |
| `nughud_coord` | No | Yes | Coordinates display, only shown if enabled by the user |
| `nughud_fps` | No | Yes | FPS display, only shown when the FPS cheat is activated |
| `nughud_message` | No | Yes | Message display |
| `nughud_secret` | No | Yes | Secret Message display |

**The _Ammo_, _Health_ and _Armor icons_ can also be aligned vertically** by means of the `_vlign` property, with the following possible values:
- ` 1` for top alignment;
- ` 0` for center alignment;
- `-1` for bottom alignment.
Expand Down Expand Up @@ -144,6 +145,10 @@ Ammo graphics, used for the Ammo icon widget:
- NHAMMO# - Graphic, where # is a number between 0 and 3 (in order: Bullets; Shells; Cells; Rockets)
Health graphics, used for the Health icon widget:
- NHEALTH# - Graphic, where # is a number between 0 and 1 (respectively, no Berserk and Berserk)
Armor graphics, used for the Armor icon widget:
- NHARMOR# - Graphic, where # is a number between 0 and 2 (in order: no Armor; Green Armor; Blue Armor)
Expand Down
1 change: 1 addition & 0 deletions src/m_nughud.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ default_t nughud_defaults[] = {
WIDGET3( "nughud_ammoicon", nughud.ammoicon, -1, 0, 0, -1, 1 ),
TOGGLE( "nughud_ammoicon_big",nughud.ammoicon_big, 0 ),
WIDGET2( "nughud_health", nughud.health, ST_HEALTHX, ST_HEALTHY, -1, 1 ),
WIDGET3( "nughud_healthicon", nughud.healthicon, -1, 0, 0, -1, 1 ),
WIDGET( "nughud_arms1", nughud.arms[0], -1, 0, 0 ),
WIDGET( "nughud_arms2", nughud.arms[1], 111, 172, -1 ),
WIDGET( "nughud_arms3", nughud.arms[2], 119, 172, -1 ),
Expand Down
1 change: 1 addition & 0 deletions src/m_nughud.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ typedef struct nughud_s {
nughud_vlignable_t ammoicon;
boolean ammoicon_big;
nughud_alignable_t health;
nughud_vlignable_t healthicon;
nughud_widget_t arms[9];
nughud_alignable_t frags;
nughud_widget_t face;
Expand Down
43 changes: 43 additions & 0 deletions src/st_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ static patch_t *nhwpnum[9][2]; // NHW0NUM# and NHW1NUM#, from 1 to 9
static patch_t *nhkeys[NUMCARDS+3]; // NHKEYS
static patch_t *nhbersrk; // NHBERSRK
static patch_t *nhammo[4]; // NHAMMO#, from 0 to 3
static patch_t *nhealth[2]; // NHEALTH#, from 0 to 1
static patch_t *nharmor[3]; // NHARMOR#, from 0 to 2
static patch_t *nhinfnty; // NHINFNTY

Expand Down Expand Up @@ -964,6 +965,34 @@ void ST_drawWidgets(void)
if (patch) { NughudDrawPatch(&nughud.ammoicon, patch, no_offsets); }
}

if (nughud.healthicon.x > -1)
{
patch_t *patch;
int lump;
boolean no_offsets = false;

if (nhealth[0])
{ patch = nhealth[plyr->powers[pw_strength] ? 1 : 0]; }
else {
char namebuf[32];

no_offsets = true;

switch (plyr->powers[pw_strength] ? 1 : 0)
{
case 0: sprintf(namebuf, "MEDIA0"); break;
case 1: sprintf(namebuf, "PSTRA0"); break;
}

if ((lump = (W_CheckNumForName)(namebuf, ns_sprites)) >= 0)
{ patch = (patch_t *) W_CacheLumpNum(lump, PU_STATIC); }
else
{ patch = NULL; }
}

if (patch) { NughudDrawPatch(&nughud.healthicon, patch, no_offsets); }
}

if (nughud.armoricon.x > -1)
{
patch_t *patch;
Expand Down Expand Up @@ -1447,6 +1476,20 @@ void ST_loadGraphics(void)
}
}

// Health icons -------------------

// Load NHEALTH0 to NHEALTH1 if available
for (i = 0; i < 2; i++) {
sprintf(namebuf, "NHEALTH%d", i);

if ((lump = (W_CheckNumForName)(namebuf, ns_global)) >= 0)
{ nhealth[i] = (patch_t *) W_CacheLumpNum(lump, PU_STATIC); }
else {
nhealth[0] = NULL;
break;
}
}

// Armor icons --------------------

// Load NHARMOR0 to NHARMOR2 if available
Expand Down

0 comments on commit 17c451e

Please sign in to comment.