Files
Aurora.3/code/datums/components/skills/service/bartending_skill_component.dm
VMSolidus 31d2be267d Morale UI Indicators (#22468)
This PR extends the functionality of the Morale Component to also
provide a UI element. Which is dynamically controlled by the component.
Players can click on it to view their current morale modifiers, and what
percentage effect said modifiers are currently providing. Morale is not
actually new, the mechanic has been on the server for over a month now,
though the players had no way of knowing it was there unless they
closely follow along with the github history.

I have extensively tested this over the course of 6 hours of work, and
have attached video proof of said testing.


https://github.com/user-attachments/assets/c0d3ca3a-0a52-46e1-8e46-9d1e5ef46e4f

### Asset Licenses
The following assets that **have not** been created by myself are
included in this PR:

| Path | Original Author | License |
| icons/mob/screen/morale_ui.dmi |
https://github.com/BeeStation/NSV13/commit/b6b1e2bf2cc60455851317d8e82cca8716d9dac1
| CC-BY-SA-3.0 |
2026-05-21 15:01:06 +00:00

72 lines
2.3 KiB
Plaintext

/datum/component/skill/bartending
/datum/moodlet/bartender_drink
moodlet_descriptor = SPAN_GOOD("Consumed a skillfully prepared drink.")
initial_descriptor = SPAN_GOOD("You have gained a morale modifier from consuming a skillfully prepared drink.")
/datum/component/drink_moodlet_provider
/// The morale boosting value of the moodlet this drink will provide.
var/moodlet_value = 0
/// Whether the DrinkMoodletProvider is allowed to overwrite stronger moodlets with weaker moodlets.
var/overwrite_moodlet = FALSE
/// Original name of the drink before the component changed it.
var/initial_name
/datum/component/drink_moodlet_provider/Initialize(value = 5.0, overwrite = FALSE, drink_quality)
. = ..()
if (!parent)
return
moodlet_value = value
overwrite_moodlet = overwrite
RegisterSignal(parent, COMSIG_CONTAINER_DRANK, PROC_REF(handle_drank), override = TRUE)
if (!isatom(parent))
return
var/atom/owner = parent
initial_name = owner.name
switch (drink_quality)
if (-INFINITY to 5)
owner.name = "inferior " + initial_name
if (5 to 10)
owner.name = "cheap " + initial_name
if (10 to 15)
owner.name = "finely-mixed " + initial_name
if (15 to 20)
owner.name = "superior quality " + initial_name
if (20 to INFINITY)
owner.name = "masterful " + initial_name
/datum/component/drink_moodlet_provider/Destroy()
if (!parent)
return ..()
UnregisterSignal(parent, COMSIG_CONTAINER_DRANK)
if (initial_name && istype(parent, /atom))
parent:name = initial_name
return ..()
/datum/component/drink_moodlet_provider/proc/handle_drank(obj/item/reagent_containers/owner, mob/user)
SIGNAL_HANDLER
if (QDELING(src))
return
if (!owner.reagents.total_volume)
qdel(src)
// No return here because total volume can be empty at this step (if the person drank the last of a cup)
var/datum/component/morale/morale_comp = user.GetComponent(MORALE_COMPONENT)
if (!morale_comp)
return
if (!overwrite_moodlet && astype(morale_comp.moodlets[/datum/moodlet/bartender_drink], /datum/moodlet)?.get_morale_modifier() > moodlet_value)
// Return if they already have a better drink moodlet.
return
var/datum/moodlet/new_moodlet = morale_comp.load_moodlet(/datum/moodlet/bartender_drink, moodlet_value)
new_moodlet.refresh_moodlet() // Reset the duration when they drink it.