Skip to content

Commit

Permalink
Smooth the alcohol impairment curve because a bottle of vodka should …
Browse files Browse the repository at this point in the history
…last more than 5 minutes (#1793)

* alcohol processing changes

* add temporary message about TM

* stop light drinker from making you insta-sick

* modularize it

* fix lints

* proc documentation

* switch fix

* remove TM Only warning
  • Loading branch information
lessthnthree authored and StealsThePRs committed Apr 18, 2024
1 parent 108a4cd commit 821cccc
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 21 deletions.
2 changes: 1 addition & 1 deletion code/__DEFINES/reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
#define GOLDSCHLAGER_GOLD_RATIO (GOLDSCHLAGER_GOLD/(GOLDSCHLAGER_VODKA+GOLDSCHLAGER_GOLD))

/// The rate at which alcohol affects the drinker
#define ALCOHOL_RATE 0.005
#define ALCOHOL_RATE 0.0025 // NOVA EDIT CHANGE - ALCOHOL_PROCESSING - Original: 0.005

#define BLASTOFF_DANCE_MOVE_CHANCE_PER_UNIT 3
#define BLASTOFF_DANCE_MOVES_PER_SUPER_MOVE 3
Expand Down
10 changes: 6 additions & 4 deletions code/datums/mood.dm
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@
if(MOOD_LEVEL_HAPPY4)
msg += "[span_boldnicegreen("I love life!")]\n"
*/
//NOVA EDIT CHANGE BEGIN - ALEXITHYMIA
//NOVA EDIT CHANGE BEGIN - ALEXITHYMIA / ALCOHOL_PROCESSING
if(!HAS_TRAIT(user, TRAIT_MOOD_NOEXAMINE))
switch(mood_level)
if(MOOD_LEVEL_SAD4)
Expand All @@ -410,10 +410,12 @@
msg += "[span_boldnicegreen("I love life!")]\n"
else
msg += "[span_notice("No clue.")]\n"
//NOVA EDIT CHANGE END

msg += "[span_notice("Moodlets:")]\n"//All moodlets
//if(mood_events.len) //ORIGINAL
if(mood_events.len && !HAS_TRAIT(user, TRAIT_MOOD_NOEXAMINE)) //NOVA EDIT CHANGE - ALEXITHYMIA
msg += get_alcohol_processing(user)
msg += get_drunk_mood(user)
if(mood_events.len && !HAS_TRAIT(user, TRAIT_MOOD_NOEXAMINE)) //ORIGINAL: if(mood_events.len)
//NOVA EDIT CHANGE END
for(var/category in mood_events)
var/datum/mood_event/event = mood_events[category]
switch(event.mood_change)
Expand Down
26 changes: 13 additions & 13 deletions code/datums/status_effects/debuffs/drunk.dm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// NOVA EDIT CHANGE BEGIN (#21546 DRUNK EFFECTS)
// NOVA EDIT CHANGE BEGIN - ALCOHOL_PROCESSING
// Defines for the ballmer peak.
#define BALLMER_PEAK_LOW_END 25.8 // Original 12.9
#define BALLMER_PEAK_HIGH_END 27.6 // Original 13.8
#define BALLMER_PEAK_WINDOWS_ME 37 // Original 26

/// The threshld which determine if someone is tipsy vs drunk
#define TIPSY_THRESHOLD 21 // Original 6
// NOVA EDIT CHANGE END (#21546 DRUNK EFFECTS)
#define TIPSY_THRESHOLD 23.4 // Original 6
// NOVA EDIT CHANGE END - ALCOHOL_PROCESSING

/**
* The drunk status effect.
Expand All @@ -23,7 +23,7 @@
/datum/status_effect/inebriated/on_creation(mob/living/new_owner, drunk_value = 0)
. = ..()
set_drunk_value(drunk_value)

/datum/status_effect/inebriated/get_examine_text()
// Dead people don't look drunk
if(owner.stat == DEAD || HAS_TRAIT(owner, TRAIT_FAKEDEATH))
Expand Down Expand Up @@ -71,7 +71,7 @@
// Every tick, the drunk value decrases by
// 4% the current drunk_value + 0.01
// (until it reaches 0 and terminates)
set_drunk_value(drunk_value - (0.0075 + drunk_value * 0.0075)) // NOVA EDIT CHANGE - Alcohol Tolerance - Original: set_drunk_value(drunk_value - (0.01 + drunk_value * 0.04)
set_drunk_value(drunk_value - (drunk_value * 0.0015)) // NOVA EDIT CHANGE - ALCOHOL_PROCESSING - Original: set_drunk_value(drunk_value - (0.01 + drunk_value * 0.04)
if(QDELETED(src))
return

Expand Down Expand Up @@ -146,7 +146,7 @@
if(drunk_value > BALLMER_PEAK_WINDOWS_ME) // by this point you're into windows ME territory
owner.say(pick_list_replacements(VISTA_FILE, "ballmer_windows_me_msg"), forced = "ballmer")

// NOVA EDIT CHANGE BEGIN (#21546 DRUNK EFFECTS)
// NOVA EDIT CHANGE BEGIN - ALCOHOL_PROCESSING
/* ORIGINAL
// Drunk slurring scales in intensity based on how drunk we are -at 16 you will likely not even notice it,
// but when we start to scale up you definitely will
Expand Down Expand Up @@ -181,44 +181,44 @@
owner.adjust_jitter(-6 SECONDS)

// Over 41, we have a 10% chance to gain confusion and occasionally slur words, scaling with drunk_value
if(drunk_value >= 41)
if(drunk_value >= 43.4)
if(prob(clamp(drunk_value - 8, 0, 100)))
owner.adjust_timed_status_effect(4 SECONDS, /datum/status_effect/speech/slurring/drunk, max_duration = 20 SECONDS)
if(prob(10))
owner.adjust_confusion(4 SECONDS)

// Over 61, we start to get blurred vision
if(drunk_value >= 61)
if(drunk_value >= 63.4)
owner.set_dizzy_if_lower(45 SECONDS)
if(prob(15))
owner.adjust_eye_blur_up_to(4 SECONDS, 20 SECONDS)

// Over 71, we will constantly have blurry eyes, we might vomit
if(drunk_value >= 71)
if(drunk_value >= 73.4)
owner.set_eye_blur_if_lower(20 SECONDS)
if(prob(3))
owner.adjust_confusion(15 SECONDS)
if(iscarbon(owner))
var/mob/living/carbon/carbon_owner = owner
carbon_owner.vomit() // Vomiting clears toxloss - consider this a blessing
// NOVA EDIT CHANGE END (#21546 DRUNK EFFECTS)

// Over 81, we will gain constant toxloss
if(drunk_value >= 81)
if(drunk_value >= 83.4)
owner.adjustToxLoss(1)
if(owner.stat == CONSCIOUS && prob(5))
to_chat(owner, span_warning("Maybe you should lie down for a bit..."))

// Over 91, we gain even more toxloss, brain damage, and have a chance of dropping into a long sleep
if(drunk_value >= 91)
if(drunk_value >= 93.4)
owner.adjustToxLoss(1)
owner.adjustOrganLoss(ORGAN_SLOT_BRAIN, 0.4)
if(owner.stat == CONSCIOUS)
attempt_to_blackout()

// And finally, over 100 - let's be honest, you shouldn't be alive by now.
if(drunk_value >= 101)
if(drunk_value >= 103.4)
owner.adjustToxLoss(2)
// NOVA EDIT CHANGE END - ALCOHOL_PROCESSING

/datum/status_effect/inebriated/drunk/proc/attempt_to_blackout()
/* NOVA EDIT REMOVAL - Blackout drunk begone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
if(HAS_TRAIT(drinker, TRAIT_ALCOHOL_TOLERANCE)) // we're an accomplished drinker
booze_power *= 0.7
if(HAS_TRAIT(drinker, TRAIT_LIGHT_DRINKER))
booze_power *= 2
booze_power *= 1.33 // NOVA EDIT CHANGE - ALCOHOL_PROCESSING - Original: booze_power *= 2

// water will dilute alcohol effects
var/total_water_volume = 0
Expand All @@ -73,12 +73,12 @@
booze_power *= (total_alcohol_volume / combined_dilute_volume)

// Volume, power, and server alcohol rate effect how quickly one gets drunk
drinker.adjust_drunk_effect(sqrt(volume) * booze_power * ALCOHOL_RATE * REM * seconds_per_tick * 0.25) // NOVA EDIT CHANGE - Alcohol Tolerance - Original: (sqrt(volume) * booze_power * ALCOHOL_RATE * REM * seconds_per_tick)
drinker.adjust_drunk_effect(booze_power * ALCOHOL_RATE * REM * seconds_per_tick) // NOVA EDIT CHANGE - ALCOHOL_PROCESSING - Original: (sqrt(volume) * booze_power * ALCOHOL_RATE * REM * seconds_per_tick)
if(boozepwr > 0)
var/obj/item/organ/internal/liver/liver = drinker.get_organ_slot(ORGAN_SLOT_LIVER)
var/heavy_drinker_multiplier = (HAS_TRAIT(drinker, TRAIT_HEAVY_DRINKER) ? 0.5 : 1)
if (istype(liver))
if(liver.apply_organ_damage(((max(sqrt(volume) * (boozepwr ** ALCOHOL_EXPONENT) * liver.alcohol_tolerance * heavy_drinker_multiplier * seconds_per_tick, 0))/300))) // NOVA EDIT CHANGE - Alcohol Tolerance - Original: if((((max(sqrt(volume) * (boozepwr ** ALCOHOL_EXPONENT) * liver.alcohol_tolerance * heavy_drinker_multiplier * seconds_per_tick, 0))/150)))
if(liver.apply_organ_damage(((max(sqrt(volume) * (boozepwr ** ALCOHOL_EXPONENT) * liver.alcohol_tolerance * heavy_drinker_multiplier * seconds_per_tick, 0))/300))) // NOVA EDIT CHANGE - ALCOHOL_PROCESSING - Original: if((((max(sqrt(volume) * (boozepwr ** ALCOHOL_EXPONENT) * liver.alcohol_tolerance * heavy_drinker_multiplier * seconds_per_tick, 0))/150)))
return UPDATE_MOB_HEALTH

/datum/reagent/consumable/ethanol/expose_obj(obj/exposed_obj, reac_volume)
Expand Down
53 changes: 53 additions & 0 deletions modular_nova/modules/alcohol_processing/code/alcohol_processing.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#define BAC_STAGE_1_ACTIVE 0.01
#define BAC_STAGE_2_WARN 0.05
#define BAC_STAGE_2_ACTIVE 0.07
#define BAC_STAGE_3_WARN 0.11
#define BAC_STAGE_3_ACTIVE 0.13
#define BAC_STAGE_4_WARN 0.17
#define BAC_STAGE_4_ACTIVE 0.19
#define BAC_STAGE_5_WARN 0.23

/datum/reagent/consumable/ethanol
metabolization_rate = 0.3 * REAGENTS_METABOLISM

/atom/movable/screen/alert/status_effect/drunk
desc = "All that alcohol you've been drinking is impairing your speech, \
motor skills, and mental cognition. Make sure to act like it. \
Check your current drunkenness level using your mood status."

/// Adds a moodlet entry based on if the mob currently has alcohol processing in their system.
/datum/mood/proc/get_alcohol_processing(mob/user)
if(user.reagents.reagent_list.len)
for(var/datum/reagent/consumable/ethanol/booze in user.reagents.reagent_list)
return span_notice("I'm still processing that alcohol I drank...\n")

/// Adds a moodlet entry based on the current blood alcohol content of the mob.
/datum/mood/proc/get_drunk_mood(mob/user)
var/mob/living/target = user
var/blood_alcohol_content = target.get_blood_alcohol_content()
switch(blood_alcohol_content)
if(BAC_STAGE_1_ACTIVE to BAC_STAGE_2_WARN)
return span_notice("Had a drink, time to relax!\n")
if(BAC_STAGE_2_WARN to BAC_STAGE_2_ACTIVE)
return span_nicegreen("Now I'm starting to feel that drink.\n")
if(BAC_STAGE_2_ACTIVE to BAC_STAGE_3_WARN)
return span_nicegreen("A bit tipsy, this feels good!\n")
if(BAC_STAGE_3_WARN to BAC_STAGE_3_ACTIVE)
return span_nicegreen("Those drinks are really starting to hit!\n")
if(BAC_STAGE_3_ACTIVE to BAC_STAGE_4_WARN)
return span_nicegreen("I can't remember how many I've had, but I feel great!\n")
if(BAC_STAGE_4_WARN to BAC_STAGE_4_ACTIVE)
return span_warning("I think I've had too much to drink... I should probably stop... drink some water...\n")
if(BAC_STAGE_4_ACTIVE to BAC_STAGE_5_WARN)
return span_bolddanger("I'm not feeling so hot...\n")
if(BAC_STAGE_5_WARN to INFINITY)
return span_bolddanger("Is there a doctor around? I really don't feel good...\n")

#undef BAC_STAGE_1_ACTIVE
#undef BAC_STAGE_2_WARN
#undef BAC_STAGE_2_ACTIVE
#undef BAC_STAGE_3_WARN
#undef BAC_STAGE_3_ACTIVE
#undef BAC_STAGE_4_WARN
#undef BAC_STAGE_4_ACTIVE
#undef BAC_STAGE_5_WARN
23 changes: 23 additions & 0 deletions modular_nova/modules/alcohol_processing/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Title: Alcohol Processing

MODULE ID: ALCOHOL_PROCESSING

### Description:

Adjusts the rate of alcohol processing, its effects, and thresholds. Drinks last longer with a smoother up and down for more predictable roleplay drinking.

### TG Proc Changes:
- EDIT: code/datums/mood.dm > /datum/mood/proc/print_mood(mob/user)
- EDIT: code/datums/status_effects/debuffs/drunk.dm > /datum/status_effect/inebriated/drunk/on_tick_effects(), /datum/status_effect/inebriated/tick()
- EDIT: code/modules/reagents/chemistry/reagents/drinks/alcohol_reagents.dm > /datum/reagent/consumable/ethanol/on_mob_life()

### Master file additions

- N/A

### Included files that are not contained in this module:

- N/A

### Credits:
LT3
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6747,6 +6747,7 @@
#include "modular_nova\modules\aesthetics\windows\code\windows.dm"
#include "modular_nova\modules\airlock_override\code\airlock_override.dm"
#include "modular_nova\modules\akula\code\wetsuit.dm"
#include "modular_nova\modules\alcohol_processing\code\alcohol_processing.dm"
#include "modular_nova\modules\alerts\code\alert_sound_to_playing.dm"
#include "modular_nova\modules\alerts\code\config.dm"
#include "modular_nova\modules\alerts\code\default_announcer.dm"
Expand Down

0 comments on commit 821cccc

Please sign in to comment.