Skip to content

Commit

Permalink
Fixes addictive reagents (#867)
Browse files Browse the repository at this point in the history
* ipcs immune

* fix addiction points

* nicotine back up to 18/u

* rescale alcohol

* buff alcohol

* tweaks
  • Loading branch information
Kapu1178 authored Mar 5, 2024
1 parent ee272a1 commit 1fd5097
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 24 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_NOCRITDAMAGE "no_crit"
/// Cannot experience Shock (pain version, not electrical)
#define TRAIT_NO_PAINSHOCK "no_painshock"
/// Does not get addicted
#define TRAIT_NO_ADDICTION "no_addiction"

// Stops the mob from slipping on water, or banana peels, or pretty much anything that doesn't have [GALOSHES_DONT_HELP] set
#define TRAIT_NO_SLIP_WATER "NO_SLIP_WATER"
Expand Down
5 changes: 3 additions & 2 deletions code/_onclick/hud/alert.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@
alerts[category] = thealert
if(client && hud_used)
hud_used.reorganize_alerts()
thealert.transform = matrix(32, 6, MATRIX_TRANSLATE)
animate(thealert, transform = matrix(), time = 2.5, easing = CUBIC_EASING)

thealert.transform = matrix(32, 0, MATRIX_TRANSLATE)
animate(thealert, transform = matrix(), time = 1 SECONDS, easing = ELASTIC_EASING)

if(thealert.timeout)
addtimer(CALLBACK(src, PROC_REF(alert_timeout), thealert, category), thealert.timeout)
Expand Down
18 changes: 18 additions & 0 deletions code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -153,24 +153,40 @@
var/mob/living/old_current = current
if(current)
current.transfer_observers_to(new_character) //transfer anyone observing the old character to the new one

set_current(new_character) //associate ourself with our new body
QDEL_NULL(antag_hud)

new_character.mind = src //and associate our new body with ourself

antag_hud = new_character.add_alt_appearance(/datum/atom_hud/alternate_appearance/basic/antagonist_hud, "combo_hud", src)

for(var/a in antag_datums) //Makes sure all antag datums effects are applied in the new body
var/datum/antagonist/A = a
A.on_body_transfer(old_current, current)

if(iscarbon(new_character))
var/mob/living/carbon/C = new_character
C.last_mind = src

transfer_martial_arts(new_character)

// If the new mob is immune to addictions, cure them all.
if(HAS_TRAIT(new_character, TRAIT_NO_ADDICTION))
for(var/addiction_type in subtypesof(/datum/addiction))
remove_addiction_points(addiction_type, MAX_ADDICTION_POINTS)

RegisterSignal(new_character, COMSIG_LIVING_DEATH, PROC_REF(set_death_time))

if(active || force_key_move)
new_character.key = key //now transfer the key to link the client to our new body

if(new_character.client)
LAZYCLEARLIST(new_character.client.recent_examines)
new_character.client.init_verbs() // re-initialize character specific verbs

current.update_atom_languages()

SEND_SIGNAL(src, COMSIG_MIND_TRANSFERRED, old_current)
SEND_SIGNAL(current, COMSIG_MOB_MIND_TRANSFERRED_INTO)

Expand Down Expand Up @@ -849,6 +865,8 @@

///Adds addiction points to the specified addiction
/datum/mind/proc/add_addiction_points(type, amount)
if(current && HAS_TRAIT(current, TRAIT_NO_ADDICTION))
return
LAZYSET(addiction_points, type, min(LAZYACCESS(addiction_points, type) + amount, MAX_ADDICTION_POINTS))
var/datum/addiction/affected_addiction = SSaddiction.all_addictions[type]
return affected_addiction.on_gain_addiction_points(src)
Expand Down
5 changes: 2 additions & 3 deletions code/datums/status_effects/debuffs/drunk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,13 @@
// Over 81, we will gain constant toxloss
if(drunk_value >= 81)
owner.adjustToxLoss(1)
if(owner.stat != CONSCIOUS && prob(5))
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)
owner.adjustToxLoss(1)
owner.adjustOrganLoss(ORGAN_SLOT_BRAIN, 0.4)
if(owner.stat != CONSCIOUS && prob(20))
if(owner.stat == CONSCIOUS && prob(20))
// Don't put us in a deep sleep if the shuttle's here. QoL, mainly.
if(SSshuttle.emergency.mode == SHUTTLE_DOCKED && is_station_level(owner.z))
to_chat(owner, span_warning("You're so tired... but you can't miss that shuttle..."))
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/human/species_types/ipc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
TRAIT_NO_PAINSHOCK,
TRAIT_NOSOFTCRIT,
TRAIT_LIMBATTACHMENT,
TRAIT_NO_ADDICTION,
)
inherent_biotypes = MOB_ROBOTIC|MOB_HUMANOID

Expand Down
12 changes: 12 additions & 0 deletions code/modules/mob/living/carbon/init_signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
RegisterSignal(src, SIGNAL_ADDTRAIT(TRAIT_SOFT_CRITICAL_CONDITION), PROC_REF(on_softcrit_gain))
RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_SOFT_CRITICAL_CONDITION), PROC_REF(on_softcrit_loss))

RegisterSignal(src, SIGNAL_ADDTRAIT(TRAIT_NO_ADDICTION), PROC_REF(on_noaddiction_trait_gain))

/**
* On gain of TRAIT_NOBREATH
*
Expand Down Expand Up @@ -42,6 +44,16 @@

reagents.end_metabolization(keep_liverless = TRUE)

/**
* On gain of TRAIT_NO_ADDICTION
*
* This will remove all addictions.
*/
/mob/living/carbon/proc/on_noaddiction_trait_gain(datum/source)
SIGNAL_HANDLER
for(var/addiction_type in subtypesof(/datum/addiction))
mind?.remove_addiction_points(addiction_type, MAX_ADDICTION_POINTS)

/mob/living/carbon/proc/on_softcrit_gain(datum/source)
SIGNAL_HANDLER

Expand Down
5 changes: 1 addition & 4 deletions code/modules/reagents/chemistry/holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,10 @@
need_mob_update += reagent.overdose_start(owner)
log_game("[key_name(owner)] has started overdosing on [reagent.name] at [reagent.volume] units.")

for(var/addiction in reagent.addiction_types)
owner.mind?.add_addiction_points(addiction, reagent.addiction_types[addiction] * 0.2)

if(reagent.overdosed)
need_mob_update += reagent.overdose_process(owner)

need_mob_update += reagent.on_mob_life(owner, metabolism_class)
need_mob_update += reagent.on_mob_life(owner, metabolism_class, can_overdose)
return need_mob_update

/// Signals that metabolization has stopped, triggering the end of trait-based effects
Expand Down
6 changes: 5 additions & 1 deletion code/modules/reagents/chemistry/reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ GLOBAL_LIST_INIT(name2reagent, build_name2reagent())
return

/// Called from [/datum/reagents/proc/metabolize]
/datum/reagent/proc/on_mob_life(mob/living/carbon/M, location)
/datum/reagent/proc/on_mob_life(mob/living/carbon/M, location, do_addiction)
SHOULD_NOT_OVERRIDE(TRUE)
SHOULD_NOT_SLEEP(TRUE)

Expand All @@ -135,6 +135,10 @@ GLOBAL_LIST_INIT(name2reagent, build_name2reagent())
removed *= M.metabolism_efficiency
removed = min(removed, volume)

if(do_addiction && length(addiction_types))
for(var/addiction in addiction_types)
M.mind?.add_addiction_points(addiction, addiction_types[addiction] * removed)

//adjust effective amounts - removed, dose, and max_dose - for mob size
var/effective = removed
if(!(chemical_flags & REAGENT_IGNORE_MOB_SIZE) && location != CHEM_TOUCH)
Expand Down
23 changes: 10 additions & 13 deletions code/modules/reagents/chemistry/reagents/alcohol_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,21 @@ All effects don't start immediately, but rather get worse over time; the rate is
C.adjust_nutrition(nutriment_factor * removed)

APPLY_CHEM_EFFECT(C, CE_ALCOHOL, 1)
var/effective_dose = volume * (1 + volume/60) //drinking a LOT will make you go down faster
var/effective_dose = boozepwr * (1 + volume/60) //drinking a LOT will make you go down faster

if(effective_dose >= boozepwr / 20) // Early warning
C.set_timed_status_effect(2 SECONDS, /datum/status_effect/dizziness, only_if_higher = TRUE)
if(effective_dose >= 50)
APPLY_CHEM_EFFECT(C, CE_PAINKILLER, 900/boozepwr)

if(effective_dose >= boozepwr / 13) // Slurring
APPLY_CHEM_EFFECT(C, CE_PAINKILLER, 150/boozepwr)
if(effective_dose >= 75)
APPLY_CHEM_EFFECT(C, CE_PAINKILLER, 900/boozepwr)

if(effective_dose >= boozepwr / 6.5) // Confusion - walking in random directions
APPLY_CHEM_EFFECT(C, CE_PAINKILLER, 150/boozepwr)
if(effective_dose >= 100)
APPLY_CHEM_EFFECT(C, CE_PAINKILLER, 900/boozepwr)

if(effective_dose >= boozepwr / 3.25) // Blurry vision
APPLY_CHEM_EFFECT(C, CE_PAINKILLER, 150/boozepwr)
if(effective_dose >= 125)
APPLY_CHEM_EFFECT(C, CE_PAINKILLER, 900/boozepwr)

if(effective_dose >= boozepwr / 1.75) // Drowsyness - periodically falling asleep
APPLY_CHEM_EFFECT(C, CE_PAINKILLER, 150/boozepwr)

if(effective_dose >= boozepwr) // Toxic dose
if(effective_dose >= 150)
APPLY_CHEM_EFFECT(C, CE_ALCOHOL_TOXIC, toxicity)

if(druggy)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/chemistry/reagents/drug_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
overdose_threshold = 30
metabolization_rate = 0.01

addiction_types = list(/datum/addiction/nicotine = 12)
addiction_types = list(/datum/addiction/nicotine = 18)

//Nicotine is used as a pesticide IRL.
/datum/reagent/drug/nicotine/on_hydroponics_apply(obj/item/seeds/myseed, datum/reagents/chems, obj/machinery/hydroponics/mytray, mob/user)
Expand Down

0 comments on commit 1fd5097

Please sign in to comment.