ammo_hud 
Procs | |
| get_hud | Resolves the ammo HUD screen object for a given holder or item. |
|---|---|
| on_dropped | Handles disabling the ammo HUD when the item is dropped. |
| on_equipped | Handles enabling the ammo HUD when the item is equipped. |
| on_hands_swap | Updates the ammo HUD when the mob swaps active hands. |
| should_update | Determines whether the given item should currently update the ammo HUD. |
| update_ballistic | Updates the ammo HUD for ballistic firearms. |
| update_energy | Updates the ammo HUD for energy-based firearms. |
| update_hud | Dispatches an ammo HUD update based on the item's type. |
| update_welder | Updates the ammo HUD for welding tools. |
Proc Details
get_hud
Resolves the ammo HUD screen object for a given holder or item.
Attempts to locate the human mob currently responsible for displaying the ammo HUD, either via an explicitly provided holder or by checking the item's current location.
Will return null if no valid human HUD exists or if the mob has not initialized their HUD yet.
Arguments:
- holder - Optional mob currently holding the item.
- parent_item - Item whose location may contain a valid mob holder.
Returns:
- /atom/movable/screen/ammo_counter if available, otherwise null.
on_dropped
Handles disabling the ammo HUD when the item is dropped.
Removes the HUD-displaying trait from the dropped item and disables the ammo HUD if no other held items are currently displaying it.
Also unregisters the hand-swap signal from the dropper to prevent stale callbacks after the item leaves their hands.
Signal handler for COMSIG_ITEM_DROPPED.
Arguments:
- source - The item being dropped.
- dropper - The mob dropping the item.
on_equipped
Handles enabling the ammo HUD when the item is equipped.
Ensures the equipper is a human and is actively holding the item. If a valid ammo HUD is available, it is enabled and the item is marked as displaying an ammo HUD via a trait.
Also registers a hand-swap signal when both hands are holding HUD-capable items to ensure the display reflects the active hand.
Signal handler for COMSIG_ITEM_EQUIPPED.
Arguments:
- source - The item being equipped.
- equipper - The mob equipping the item.
- slot - Inventory slot the item was equipped into.
on_hands_swap
Updates the ammo HUD when the mob swaps active hands.
Ensures the newly active held item is eligible for ammo HUD display before refreshing the HUD contents to reflect the active hand.
Signal handler for COMSIG_MOB_SWAP_HANDS.
Arguments:
- source - The mob swapping hands.
- swapped_to - The current active hand item that we swapped to.
- swapped_from - The previous, now inactive hand item that we swapped from.
should_update
Determines whether the given item should currently update the ammo HUD.
Prevents inactive-hand items from updating the HUD while another actively held item is already responsible for displaying ammo data.
This avoids conflicting updates when both hands contain HUD-capable items.
Arguments:
- to_update - The item requesting a HUD update.
Returns:
- TRUE if the item may update the HUD.
- FALSE if the update should be suppressed.
update_ballistic
Updates the ammo HUD for ballistic firearms.
Displays remaining ammunition using digit overlays and handles special states such as missing magazines or empty weapons.
Signal handler for COMSIG_UPDATE_AMMO_HUD and COMSIG_GUN_CHAMBER_PROCESSED.
Arguments:
- to_update - The ballistic firearm being evaluated.
- hud - Optional ammo HUD screen object to update.
update_energy
Updates the ammo HUD for energy-based firearms.
Displays current battery percentage and per-shot energy cost using maptext overlays, with color-coded thresholds for low power states.
Signal handler for COMSIG_UPDATE_AMMO_HUD and COMSIG_GUN_CHAMBER_PROCESSED.
Arguments:
- to_update - The energy firearm being evaluated.
- hud - Optional ammo HUD screen object to update.
update_hud
Dispatches an ammo HUD update based on the item's type.
Routes the update call to the appropriate handler for ballistic guns, energy guns, or welding tools.
Arguments:
- source - The item whose ammo display should be updated.
- hud - Optional ammo HUD screen object to update.
update_welder
Updates the ammo HUD for welding tools.
Displays remaining fuel amount and welding state using digit overlays. Handles empty fuel tanks and active flame indication.
Signal handler for COMSIG_UPDATE_AMMO_HUD.
Arguments:
- to_update - The welding tool being evaluated.
- hud - Optional ammo HUD screen object to update.