Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reagent & Addiction tweaks and/or fixes #399

Merged
merged 6 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2904,6 +2904,7 @@
#include "code\modules\reagents\addiction\alcohol.dm"
#include "code\modules\reagents\addiction\gottheit.dm"
#include "code\modules\reagents\addiction\hallucinogens.dm"
#include "code\modules\reagents\addiction\nicotine.dm"
#include "code\modules\reagents\addiction\opiate.dm"
#include "code\modules\reagents\addiction\psionics.dm"
#include "code\modules\reagents\Chemistry-Reagents\Chemistry-Reagents-Core.dm"
Expand Down
15 changes: 9 additions & 6 deletions code/__defines/chemistry.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@
#define HANDLE_REACTIONS(_reagents) SSchemistry.active_holders[_reagents] = TRUE
#define UNQUEUE_REACTIONS(_reagents) SSchemistry.active_holders -= _reagents

#define ANTIDEPRESSANT_MESSAGE_DELAY 5 MINUTES

/// Minimum requirement for addiction buzz to be met
#define MIN_ADDICTION_REAGENT_AMOUNT 2
#define MAX_ADDICTION_POINTS 1000
/// Maximum amount of addiction points for any addiction type
#define MAX_ADDICTION_POINTS 2000

/// Addiction start/ends
#define WITHDRAWAL_STAGE1_START_CYCLE 20
#define WITHDRAWAL_STAGE1_END_CYCLE 80
#define WITHDRAWAL_STAGE2_START_CYCLE 81
#define WITHDRAWAL_STAGE2_END_CYCLE 140
#define WITHDRAWAL_STAGE3_START_CYCLE 141
#define WITHDRAWAL_STAGE1_START_CYCLE 50
#define WITHDRAWAL_STAGE1_END_CYCLE 120
#define WITHDRAWAL_STAGE2_START_CYCLE 121
#define WITHDRAWAL_STAGE2_END_CYCLE 200
#define WITHDRAWAL_STAGE3_START_CYCLE 201
3 changes: 3 additions & 0 deletions code/_global_vars/lists/objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ GLOBAL_DATUM_INIT(universe, /datum/universal_state, new)
GLOBAL_LIST_INIT(full_alphabet, list("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"))

GLOBAL_LIST_EMPTY(meteor_list)

/// List of all /datum/reagent datums indexed by reagent path. Used by chemistry stuff
GLOBAL_LIST(chemical_reagents_list)
2 changes: 1 addition & 1 deletion code/modules/clothing/masks/chewable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ obj/item/clothing/mask/chewable/Destroy()
type_butt = /obj/item/trash/cigbutt/spitgum
/obj/item/clothing/mask/chewable/tobacco/nico/New()
..()
reagents.add_reagent(/datum/reagent/medicine/fluff/nicotine, 2)
reagents.add_reagent(/datum/reagent/nicotine, 2)
color = reagents.get_color()

/obj/item/clothing/mask/chewable/candy
Expand Down
2 changes: 1 addition & 1 deletion code/modules/hydroponics/seed_datums.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@
name = "puretobacco"
seed_name = "succulent tobacco"
display_name = "succulent tobacco leaves"
chems = list(/datum/reagent/medicine/fluff/nicotine = list(1,10))
chems = list(/datum/reagent/nicotine = list(1,10))

/datum/seed/tobacco/puretobacco/New()
..()
Expand Down
26 changes: 26 additions & 0 deletions code/modules/reagents/Chemistry-Holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ GLOBAL_DATUM_INIT(temp_reagents_holder, /obj, new)
if(!istype(my_atom))
CRASH("Invalid reagents holder: [log_info_line(my_atom)]")
..()
if(!GLOB.chemical_reagents_list)
build_chemical_reagent_list()
src.my_atom = my_atom
src.maximum_volume = maximum_volume

Expand Down Expand Up @@ -488,3 +490,27 @@ GLOBAL_DATUM_INIT(temp_reagents_holder, /obj, new)
else
reagents = new/datum/reagents(max_vol, src)
return reagents

// Helper procs
//Chemical Reagents - Initialises all /datum/reagent into a list indexed by reagent id
/proc/build_chemical_reagent_list()
if(GLOB.chemical_reagents_list)
return

var/paths = subtypesof(/datum/reagent)
GLOB.chemical_reagents_list = list()

var/datum/reagents/anti_runtime = new(20000, GLOB.temp_reagents_holder) // Self-explanatory name
for(var/path in paths)
var/datum/reagent/D = new path(anti_runtime)
if(!D.name) // Those are usually master/parent types of other stuff
qdel(D)
continue
GLOB.chemical_reagents_list[path] = D
qdel(anti_runtime)

/proc/get_chem_id(chem_name)
for(var/X in GLOB.chemical_reagents_list)
var/datum/reagent/R = GLOB.chemical_reagents_list[X]
if(ckey(chem_name) == ckey(lowertext(R.name)))
return X
8 changes: 4 additions & 4 deletions code/modules/reagents/Chemistry-Reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

var/should_admin_log = FALSE

/// Assoc list with key type of addiction this reagent feeds, and value amount of addiction points added per unit of reagent metabolzied (which means * REM every life())
/// Assoc list with key type of addiction this reagent feeds, and value amount of addiction points added per unit of reagent metabolzied (which means * removed every life())
var/list/addiction_types = null

/datum/reagent/New(var/datum/reagents/holder)
Expand Down Expand Up @@ -101,9 +101,6 @@
if(volume > overdose_threshold)
overdose(M, alien)

for(var/addiction in addiction_types)
M.AddAddictionPoints(addiction, addiction_types[addiction] * REM)

//determine the metabolism rate
var/removed = metabolism
if(ingest_met && (location == CHEM_INGEST))
Expand All @@ -112,6 +109,9 @@
removed = touch_met
removed = M.get_adjusted_metabolism(removed)

for(var/addiction in addiction_types)
M.AddAddictionPoints(addiction, addiction_types[addiction] * removed)

//adjust effective amounts - removed, dose, and max_dose - for mob size
var/effective = removed
if(!(flags & IGNORE_MOB_SIZE) && location != CHEM_TOUCH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
value = DISPENSER_REAGENT_VALUE

/datum/reagent/ethanol/New()
addiction_types = list(/datum/addiction/alcohol = max(0.5, 15 / strength)) // Higher strength is somehow weaker, go figure
addiction_types = list(/datum/addiction/alcohol = max(0.5, 50 / strength)) // Higher strength is somehow weaker, go figure
return ..()

/datum/reagent/ethanol/touch_mob(var/mob/living/L, var/amount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,20 +728,24 @@
reagent_state = LIQUID
color = COLOR_YELLOW
value = 50
addiction_types = list(/datum/addiction/gottheit = 200) // Near instant addiction
metabolism = 0.1
addiction_types = list(/datum/addiction/gottheit = 600) // Near instant addiction

/datum/reagent/gottheit/affect_blood(mob/living/carbon/M, alien, removed)
/datum/reagent/gottheit/affect_blood(mob/living/carbon/human/M, alien, removed)
if(alien == IS_DIONA)
return

// Heal all conventional damage types
M.adjustCloneLoss(-40 * removed)
M.adjustOxyLoss(-10 * removed)
M.heal_organ_damage(40 * removed, 40 * removed)
M.adjustToxLoss(-40 * removed)
M.adjustOxyLoss(-40 * removed)
M.heal_organ_damage(80 * removed, 80 * removed)
M.adjustToxLoss(-80 * removed)

// Restore blood
M.regenerate_blood(8 * removed)

// Some useful chem effects, including painkilling
M.add_chemical_effect(CE_PAINKILLER, 200)
M.add_chemical_effect(CE_PAINKILLER, 400)
M.add_chemical_effect(CE_SPEEDBOOST, 1)

// Reduce bad effects
Expand All @@ -760,6 +764,8 @@
if(ishuman(M))
var/mob/living/carbon/human/H = M
for(var/obj/item/organ/internal/I in H.internal_organs)
if((I.status & ORGAN_DEAD) && prob(25))
I.revive()
if(!BP_IS_ROBOTIC(I))
I.heal_damage(20 * removed)
for(var/obj/item/organ/external/E in H.organs)
Expand All @@ -772,7 +778,7 @@
if(E.status & ORGAN_BROKEN)
E.status &= ~ORGAN_BROKEN
if(E.status & ORGAN_DEAD)
E.status &= ~ORGAN_DEAD
E.revive()

// Remove all diseases
for(var/datum/disease/D in M.diseases)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#define ANTIDEPRESSANT_MESSAGE_DELAY 5 MINUTES

// Reagents in this file should have little to no mechanical effect, and instead be focused on roleplay!

/datum/reagent/medicine/fluff
Expand Down Expand Up @@ -86,34 +84,6 @@
M.add_chemical_effect(CE_ANTIVIRAL, 1)



// We classify nicotine and tobacco as a medicine for ease of coding, and because we can't simulate lung cancer after several years of use.
/datum/reagent/medicine/fluff/nicotine
name = "Nicotine"
description = "A sickly yellow liquid sourced from tobacco leaves. Stimulates and relaxes the mind and body."
taste_description = "peppery bitterness"
color = "#efebaa"
overdose = REAGENTS_OVERDOSE / 6
data = 0
value = 2

/datum/reagent/medicine/fluff/nicotine/affect_blood(mob/living/carbon/M, alien, removed)
if (alien == IS_DIONA)
return
if (prob(volume * 20))
M.add_chemical_effect(CE_PULSE, 1)
if (volume <= 0.02 && M.chem_doses[type] >= 0.05 && world.time > data + ANTIDEPRESSANT_MESSAGE_DELAY * 0.3)
data = world.time
to_chat(M, SPAN_WARNING("You feel antsy, your concentration wavers..."))
else
if (world.time > data + ANTIDEPRESSANT_MESSAGE_DELAY * 0.3)
data = world.time
to_chat(M, SPAN_NOTICE("You feel invigorated and calm."))

/datum/reagent/medicine/fluff/nicotine/overdose(mob/living/carbon/M, alien)
..()
M.add_chemical_effect(CE_PULSE, 2)

/datum/reagent/medicine/fluff/tobacco
name = "Tobacco"
description = "Cut and processed tobacco leaves."
Expand All @@ -130,7 +100,7 @@

/datum/reagent/medicine/fluff/tobacco/affect_blood(mob/living/carbon/M, alien, removed)
..()
M.reagents.add_reagent(/datum/reagent/medicine/fluff/nicotine, nicotine_ratio)
M.reagents.add_reagent(/datum/reagent/nicotine, nicotine_ratio)

/datum/reagent/medicine/fluff/tobacco/fine
name = "Fine Tobacco"
Expand Down Expand Up @@ -171,5 +141,3 @@
if (world.time > data + ANTIDEPRESSANT_MESSAGE_DELAY * 0.35)
data = world.time
to_chat(M, SPAN_NOTICE("You feel faintly sore in the throat."))

#undef ANTIDEPRESSANT_MESSAGE_DELAY
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,65 @@
if(istype(R, /datum/reagent/ethanol))
M.chem_doses[R.type] = max(M.chem_doses[R.type] - removed * 5, 0)
// Helps with alcohol addiction slightly
M.RemoveAddictionPoints(/datum/addiction/alcohol, removed * 3)
M.RemoveAddictionPoints(/datum/addiction/alcohol, removed * 5)

/datum/reagent/medicine/naltrexone
name = "Naltrexone"
description = "A medication primarily used to manage alcohol, opioid and other minor drug addictions. Should not be taken in cases of liver damage."
reagent_state = LIQUID
color = "#f0e962"
value = 3.1
/// List of addiction type paths and amount of points it will remove from them per unit
var/list/affected_addictions = list(
/datum/addiction/alcohol = 3,
/datum/addiction/opiate = 3,
/datum/addiction/hallucinogens = 3,
)

/datum/reagent/medicine/naltrexone/affect_blood(mob/living/carbon/M, alien, removed)
if(alien == IS_DIONA)
return

// Side effects
if(prob(15))
M.dizziness = clamp(M.dizziness + 15, M.dizziness, 50)
if(prob(15))
M.confused = clamp(M.confused + 15, M.confused, 50)
// With liver damage, it will worsen it
var/obj/item/organ/internal/liver/L = M.internal_organs_by_name[BP_LIVER]
if(istype(L) && L.damage >= 5)
L.take_general_damage(min(2, L.damage * 0.1))
// At small doses, acts as minor painkiller
if(volume <= 5)
M.add_chemical_effect(CE_PAINKILLER, 10)
// Helps with various addictions
for(var/addiction_type in affected_addictions)
M.RemoveAddictionPoints(addiction_type, removed * affected_addictions[addiction_type])

/datum/reagent/medicine/varenicline
name = "Varenicline"
description = "A medication used for smoking cessation and for the treatment of blurry vision."
reagent_state = LIQUID
color = "#c0e1ed"
value = 3.1

/datum/reagent/medicine/varenicline/affect_blood(mob/living/carbon/M, alien, removed)
if(alien == IS_DIONA)
return

// Side effects
if(prob(15))
M.druggy = clamp(M.druggy + 15, M.druggy, 50)
if(prob(1) && ishuman(M))
var/mob/living/carbon/human/H = M
H.vomit()
// Fluff messages
if(prob(3))
to_chat(M, SPAN_WARNING("Your head hurts!"))
// Slightly helps fix blurry vision
M.eye_blurry = max(M.eye_blurry - 2, 0)
// Helps with nicotine addiction
M.RemoveAddictionPoints(/datum/addiction/nicotine, removed * 5)

/datum/reagent/medicine/imidazoline
name = "Imidazoline"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/datum/reagent/medicine/painkiller/New()
if(is_opiate)
addiction_types = list(/datum/addiction/opiate = max(0.5, 0.025 * target_painkiller_strength))
addiction_types = list(/datum/addiction/opiate = max(0.5, 0.15 * target_painkiller_strength))
return ..()

/datum/reagent/medicine/painkiller/affect_blood(mob/living/carbon/M, alien, removed)
Expand Down
Loading
Loading