Skip to content

Commit

Permalink
Rewrite soulstone reaction handling
Browse files Browse the repository at this point in the history
  • Loading branch information
out-of-phaze committed Jan 3, 2025
1 parent 1e23635 commit 7d36dae
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 50 deletions.
6 changes: 2 additions & 4 deletions code/modules/reagents/reactions/_reaction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

return 1

/decl/chemical_reaction/proc/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/proc/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
var/atom/location = holder.get_reaction_loc(chemical_reaction_flags)
if(thermal_product && location && ATOM_SHOULD_TEMPERATURE_ENQUEUE(location))
ADJUST_ATOM_TEMPERATURE(location, location.temperature + (location.get_thermal_mass_coefficient() * thermal_product))
Expand All @@ -61,8 +61,6 @@
if(reaction_volume > A)
reaction_volume = A

var/alt_reaction_indicator = get_alternate_reaction_indicator(holder)

for(var/reactant in required_reagents)
holder.remove_reagent(reactant, reaction_volume * required_reagents[reactant], safety = 1)

Expand All @@ -71,7 +69,7 @@
if(result)
holder.add_reagent(result, amt_produced, data, safety = 1)

on_reaction(holder, amt_produced, alt_reaction_indicator, data)
on_reaction(holder, amt_produced, data)

//called after processing reactions, if they occurred
/decl/chemical_reaction/proc/post_reaction(var/datum/reagents/holder)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/reactions/reaction_compounds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
required_reagents = list(/decl/material/liquid/capsaicin = 2)
result = list(/decl/material/liquid/capsaicin/condensed = 1)

/decl/chemical_reaction/compound/condensed_capsaicin/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/compound/condensed_capsaicin/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
. = ..()
holder?.add_reagent(/decl/material/liquid/water, created_volume)

Expand Down
16 changes: 8 additions & 8 deletions code/modules/reagents/reactions/reaction_grenade_reaction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
required_reagents = list(/decl/material/liquid/water = 1, /decl/material/solid/potassium = 1)
mix_message = "The solution bubbles vigorously!"

/decl/chemical_reaction/grenade_reaction/explosion_potassium/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/grenade_reaction/explosion_potassium/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/atom/location = holder.get_reaction_loc(chemical_reaction_flags)
if(location)
Expand All @@ -32,7 +32,7 @@
result_amount = null
mix_message = "The solution bubbles vigorously!"

/decl/chemical_reaction/grenade_reaction/flash_powder/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/grenade_reaction/flash_powder/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/turf/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(location)
Expand All @@ -58,7 +58,7 @@
mix_message = "The solution bubbles vigorously!"
maximum_temperature = T100C

/decl/chemical_reaction/grenade_reaction/emp_pulse/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/grenade_reaction/emp_pulse/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/turf/location = holder.get_reaction_loc(chemical_reaction_flags)
if(location)
Expand All @@ -79,7 +79,7 @@
reaction_sound = 'sound/items/Welder.ogg'
mix_message = "The solution suddenly ignites!"

/decl/chemical_reaction/grenade_reaction/flash_fire/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/grenade_reaction/flash_fire/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/turf/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(istype(location))
Expand All @@ -93,7 +93,7 @@
result_amount = 0.4
mix_message = "The solution bubbles vigorously!"

/decl/chemical_reaction/grenade_reaction/chemsmoke/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/grenade_reaction/chemsmoke/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(location)
Expand All @@ -112,7 +112,7 @@
result_amount = 2
mix_message = "The solution bubbles vigorously!"

/decl/chemical_reaction/grenade_reaction/foam/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/grenade_reaction/foam/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/turf/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(location)
Expand All @@ -129,7 +129,7 @@
result_amount = 5
mix_message = "The solution foams up violently!"

/decl/chemical_reaction/grenade_reaction/metalfoam/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/grenade_reaction/metalfoam/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/atom/location = holder.get_reaction_loc(chemical_reaction_flags)
if(location)
Expand All @@ -151,7 +151,7 @@
result_amount = 5
mix_message = "The solution bubbles vigorously!"

/decl/chemical_reaction/grenade_reaction/ironfoam/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/grenade_reaction/ironfoam/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/turf/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(location)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/reactions/reaction_herbal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
result_amount = 2
minimum_temperature = 100 CELSIUS

/decl/chemical_reaction/drug/herbal/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/drug/herbal/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
. = ..()
// Add plant matter to represent the herbs that the medicine has been leached out of.
holder?.add_reagent(/decl/material/solid/organic/plantmatter, created_volume)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/reactions/reaction_other.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
return ..()
return 0

/decl/chemical_reaction/soap_key/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/soap_key/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
var/obj/item/soap/S = holder.get_reaction_loc(chemical_reaction_flags)
if(istype(S) && S.key_data)
new /obj/item/key/temporary(get_turf(S), /decl/material/liquid/cleaner, S.key_data, strength)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/reactions/reaction_recipe_food.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
abstract_type = /decl/chemical_reaction/recipe/food
var/obj_result

/decl/chemical_reaction/recipe/food/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/recipe/food/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(obj_result && isturf(location))
Expand Down
14 changes: 7 additions & 7 deletions code/modules/reagents/reactions/reaction_synthesis.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
)
. = ..()

/decl/chemical_reaction/synthesis/fiberglass/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/synthesis/fiberglass/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(location)
Expand Down Expand Up @@ -47,7 +47,7 @@
if(rtype != /decl/material/liquid/crystal_agent && REAGENT_VOLUME(holder, rtype) >= REAGENT_UNITS_PER_MATERIAL_SHEET)
return TRUE

/decl/chemical_reaction/synthesis/crystalization/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/synthesis/crystalization/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
var/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(location)
var/list/removing_reagents = list()
Expand Down Expand Up @@ -81,7 +81,7 @@
continue
return TRUE

/decl/chemical_reaction/synthesis/aerogel/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/synthesis/aerogel/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
var/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(location)
var/list/removing_reagents = list()
Expand All @@ -100,7 +100,7 @@
required_reagents = list(/decl/material/liquid/acid = 1, /decl/material/liquid/plasticide = 2)
mix_message = "The solution solidifies into a grey-white mass."

/decl/chemical_reaction/synthesis/plastication/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/synthesis/plastication/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(location)
Expand All @@ -115,7 +115,7 @@
result_amount = 3
mix_message = "The solution hardens and begins to crystallize."

/decl/chemical_reaction/synthesis/resin_pack/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/synthesis/resin_pack/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/turf/T = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(!istype(T))
Expand All @@ -136,7 +136,7 @@
mix_message = "The solution thickens and solidifies."
minimum_temperature = 100 CELSIUS

/decl/chemical_reaction/synthesis/soap/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/synthesis/soap/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/turf/T = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(!istype(T))
Expand Down Expand Up @@ -167,7 +167,7 @@
minimum_temperature = 100 CELSIUS
var/chipboard_type = /decl/material/solid/organic/wood/chipboard

/decl/chemical_reaction/synthesis/chipboard/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
/decl/chemical_reaction/synthesis/chipboard/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
..()
var/turf/T = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(!istype(T))
Expand Down
27 changes: 0 additions & 27 deletions mods/content/psionics/datum/chems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,3 @@
..()
var/datum/ability_handler/psionics/psi = M.get_ability_handler(/datum/ability_handler/psionics)
psi?.check_latency_trigger(30, "a [name] overdose")

/decl/chemical_reaction/synthesis/nullglass
name = "Soulstone"
result = null
required_reagents = list(/decl/material/liquid/blood = 15, /decl/material/liquid/crystal_agent = 1)
result_amount = 1

#ifdef GAMEMODE_PACK_CULT
/decl/chemical_reaction/synthesis/nullglass/get_alternate_reaction_indicator(var/datum/reagents/holder)
var/list/blood_data = REAGENT_DATA(holder, /decl/material/liquid/blood)
var/weakref/donor_ref = LAZYACCESS(blood_data, DATA_BLOOD_DONOR)
var/mob/living/donor = donor_ref?.resolve()
. = istype(donor) && !!donor.get_ability_handler(/datum/ability_handler/psionics)
#endif

/decl/chemical_reaction/synthesis/nullglass/on_reaction(datum/reagents/holder, created_volume, reaction_flags, list/reaction_data)
var/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
if(reaction_flags)
#ifdef GAMEMODE_PACK_CULT
for(var/i = 1, i <= created_volume, i++)
new /obj/item/soulstone(location)
#else
CRASH("Nullglass alternate reaction triggered in [holder.my_atom] without cult modpack loaded!")
#endif
else
for(var/i = 1, i <= created_volume*2, i++)
new /obj/item/shard(location, /decl/material/solid/gemstone/crystal)
27 changes: 27 additions & 0 deletions mods/gamemodes/cult/mobs/constructs/soulstone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,33 @@
full = f
update_icon()

// Soulstone synthesis recipe.
/decl/chemical_reaction/synthesis/soulstone
name = "Soulstone"
result = null
required_reagents = list(/decl/material/liquid/blood = 15, /decl/material/liquid/crystal_agent = 1)
result_amount = 1
hidden_from_codex = TRUE // This shouldn't show up in search. Maybe it should be linked in a 'guide to cult' or something?

/decl/chemical_reaction/synthesis/soulstone/send_data(datum/reagents/holder, reaction_limit)
return REAGENT_DATA(holder, /decl/material/liquid/blood) // allow on_reaction to get donor data

/// Whether or not the reaction should produce a soulstone or a normal crystal.
/// The donor mob parameter may either be /mob/living or null.
/decl/chemical_reaction/synthesis/soulstone/proc/donor_is_magic(mob/living/donor)
return FALSE // By default, no one is magic! This is for modpacks to override.

/decl/chemical_reaction/synthesis/soulstone/on_reaction(datum/reagents/holder, created_volume, list/reaction_data)
var/location = get_turf(holder.get_reaction_loc(chemical_reaction_flags))
var/weakref/donor_ref = LAZYACCESS(reaction_data, DATA_BLOOD_DONOR)
if(donor_is_magic(donor_ref?.resolve()))
for(var/i = 1, i <= created_volume, i++)
new /obj/item/soulstone(location)
else // waste it and produce useless crystal shards
for(var/i = 1, i <= created_volume*2, i++)
new /obj/item/shard(location, /decl/material/solid/gemstone/crystal)

// Construct shells. These accept soulstones.
/obj/structure/constructshell
name = "empty shell"
icon = 'icons/obj/structures/construct.dmi'
Expand Down
4 changes: 4 additions & 0 deletions mods/~compatibility/patches/psionics/cult_psi.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Make psion blood usable for soulstone synthesis.
/decl/chemical_reaction/synthesis/soulstone/donor_is_magic(mob/living/donor)
return ..() || !!donor?.get_ability_handler(/datum/ability_handler/psionics)

// Make soulstones interact with psionics.
/obj/item/soulstone/disrupts_psionics()
. = !full ? src : FALSE
Expand Down

0 comments on commit 7d36dae

Please sign in to comment.