Skip to content

Commit

Permalink
Rahhhhhh
Browse files Browse the repository at this point in the history
  • Loading branch information
XeonMations committed Nov 27, 2024
1 parent 6bdabd1 commit 67ef2c2
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 116 deletions.
7 changes: 7 additions & 0 deletions code/__DEFINES/atmospherics/atmos_piping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
#define TANK_MAX_RELEASE_PRESSURE (ONE_ATMOSPHERE*3)
#define TANK_MIN_RELEASE_PRESSURE 0
#define TANK_DEFAULT_RELEASE_PRESSURE 16
/// Denotes that our tank is overpressurized simply from gas merging.
#define TANK_MERGE_OVERPRESSURE "tank_overpressure"
// Indices for the reaction_results returned by explosion_information()
/// Reactions that have happened in the tank.
#define TANK_RESULTS_REACTION 1
/// Additional information of the tank.
#define TANK_RESULTS_MISC 2

//MULTIPIPES
//IF YOU EVER CHANGE THESE CHANGE SPRITES TO MATCH.
Expand Down
8 changes: 8 additions & 0 deletions code/__DEFINES/dcs/signals/signals_datum/signals_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
/// Called on the merger after finishing a refresh: (list/leaving_members, list/joining_members)
#define COMSIG_MERGER_REFRESH_COMPLETE "comsig_merger_refresh_complete"

// Gas mixture signals
/// From /datum/gas_mixture/proc/merge: ()
#define COMSIG_GASMIX_MERGED "comsig_gasmix_merged"
/// From /datum/gas_mixture/proc/remove: ()
#define COMSIG_GASMIX_REMOVED "comsig_gasmix_removed"
/// From /datum/gas_mixture/proc/react: ()
#define COMSIG_GASMIX_REACTED "comsig_gasmix_reacted"

/// Sent when the amount of materials in material_container changes
#define COMSIG_MATERIAL_CONTAINER_CHANGED "material_container_changed"

Expand Down
49 changes: 16 additions & 33 deletions code/__HELPERS/atmospherics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,38 @@

/** A simple rudimentary gasmix to information list converter. Can be used for UIs.
* Args:
* * gasmix: [/datum/gas_mixture]
* * name: String used to name the list, optional.
* - gasmix: [/datum/gas_mixture]
* - name: String used to name the list, optional.
* Returns: A list parsed_gasmixes with the following structure:
* - parsed_gasmixes Value: Assoc List Desc: The thing we return
* -- Key: name Value: String Desc: Gasmix Name
* -- Key: temperature Value: Number Desc: Temperature in kelvins
* -- Key: volume Value: Number Desc: Volume in liters
* -- Key: pressure Value: Number Desc: Pressure in kPa
* -- Key: ref Value: String Desc: The reference for the instantiated gasmix.
* -- Key: gases Value: Numbered list Desc: List of gasses in our gasmix
* --- Key: 1 Value: String Desc: gas id var from the gas
* --- Key: 2 Value: String Desc: Human readable gas name.
* --- Key: 3 Value: Number Desc: Mol amount of the gas.
* -- Key: gases Value: Numbered list Desc: Assoc list of reactions that occur inside.
* --- Key: 1 Value: String Desc: reaction id var from the gas.
* --- Key: 2 Value: String Desc: Human readable reaction name.
* --- Key: 3 Value: Number Desc: The number associated with the reaction.
* - parsed_gasmixes - Assoc List
* -- Key: name Value: String Desc: Gasmix Name
* -- Key: temperature Value: Number Desc: Temperature in kelvins
* -- Key: volume Value: Number Desc: Volume in liters
* -- Key: pressure Value: Number Desc: Pressure in kPa
* -- Key: ref Value: Text Desc: The reference for the instantiated gasmix.
* -- Key: gases Value: Assoc list Desc: List of gasses in our gasmix
* --- Key: gas_name Value: Gas Mole Desc: Gas Name - Gas Amount pair
* Returned list should always be filled with keys even if value are nulls.
*/
/proc/gas_mixture_parser(datum/gas_mixture/gasmix, name)
. = list(
"gases" = list(),
"reactions" = list(),
"name" = format_text(name),
"name" = name,
"total_moles" = null,
"temperature" = null,
"volume"= null,
"pressure"= null,
"reference" = null,
)
"ref" = null,
)
if(!gasmix)
return
for(var/gas_path in gasmix.gases)
.["gases"] += list(list(
gasmix.gases[gas_path][GAS_META][META_GAS_ID],
gasmix.gases[gas_path][GAS_META][META_GAS_NAME],
gasmix.gases[gas_path][MOLES],
))
for(var/datum/gas_reaction/reaction_result as anything in gasmix.reaction_results)
.["reactions"] += list(list(
initial(reaction_result.id),
initial(reaction_result.name),
gasmix.reaction_results[reaction_result],
))
for(var/gas_id in gasmix.gases)
.["gases"][gasmix.gases[gas_id][GAS_META][META_GAS_NAME]] = gasmix.gases[gas_id][MOLES]
.["total_moles"] = gasmix.total_moles()
.["temperature"] = gasmix.temperature
.["volume"] = gasmix.volume
.["pressure"] = gasmix.return_pressure()
.["reference"] = REF(gasmix)
.["ref"] = REF(gasmix)

/proc/extract_id_tags(list/objects)
var/list/tags = list()
Expand Down
4 changes: 4 additions & 0 deletions code/controllers/subsystem/air.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ SUBSYSTEM_DEF(air)
var/list/turf/active_super_conductivity = list()
var/list/turf/open/high_pressure_delta = list()
var/list/atom_process = list()
/// Reactions which will contribute to a hotspot's size.
var/list/hotspot_reactions

/// A cache of objects that perisists between processing runs when resumed == TRUE. Dangerous, qdel'd objects not cleared from this may cause runtimes on processing.
var/list/currentrun = list()
Expand Down Expand Up @@ -96,6 +98,8 @@ SUBSYSTEM_DEF(air)
/datum/controller/subsystem/air/Initialize(timeofday)
map_loading = FALSE
gas_reactions = init_gas_reactions()
hotspot_reactions = init_hotspot_reactions()

setup_allturfs()
setup_atmos_machinery()
setup_pipenets()
Expand Down
7 changes: 5 additions & 2 deletions code/controllers/subsystem/explosion.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ SUBSYSTEM_DEF(explosions)
var/list/med_mov_atom = list()
var/list/high_mov_atom = list()

var/list/explosions = list()
// Track how many explosions have happened.
var/explosion_index = 0

var/currentpart = SSEXPLOSIONS_TURFS

Expand Down Expand Up @@ -449,7 +450,9 @@ SUBSYSTEM_DEF(explosions)
if(GLOB.Debug2)
log_world("## DEBUG: Explosion([x0],[y0],[z0])(d[devastation_range],h[heavy_impact_range],l[light_impact_range]): Took [took] seconds.")

SEND_GLOBAL_SIGNAL(COMSIG_GLOB_EXPLOSION, epicenter, devastation_range, heavy_impact_range, light_impact_range, took, orig_dev_range, orig_heavy_range, orig_light_range)
explosion_index += 1

SEND_GLOBAL_SIGNAL(COMSIG_GLOB_EXPLOSION, epicenter, devastation_range, heavy_impact_range, light_impact_range, took, orig_dev_range, orig_heavy_range, orig_light_range, explosion_index)

#undef CREAK_DELAY
#undef DEVASTATION_PROB
Expand Down
5 changes: 4 additions & 1 deletion code/game/machinery/computer/arcade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ GLOBAL_LIST_INIT(arcade_prize_pool, list(
var/gameover = FALSE
var/blocked = FALSE //Player cannot attack/heal while set
var/turtle = 0
///unique to the emag mode, acts as a time limit where the player dies when it reaches 0.
var/bomb_cooldown = 19

/obj/machinery/computer/arcade/battle/Reset()
var/name_action
Expand Down Expand Up @@ -277,7 +279,8 @@ GLOBAL_LIST_INIT(arcade_prize_pool, list(
playsound(loc, 'sound/arcade/win.ogg', 50, 1, extrarange = -3, falloff_exponent = 10)

if(obj_flags & EMAGGED)
new /obj/effect/spawner/newbomb/timer(loc)
bomb_cooldown = initial(bomb_cooldown)
new /obj/effect/spawner/newbomb/plasma(loc, /obj/item/assembly/timer)
new /obj/item/clothing/head/collectable/petehat(loc)
message_admins("[ADMIN_LOOKUPFLW(usr)] has outbombed Cuban Pete and been awarded a bomb.")
log_game("[key_name(usr)] has outbombed Cuban Pete and been awarded a bomb.")
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doppler_array.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ CREATION_TEST_IGNORE_SUBTYPES(/obj/item/paper/record_printout)
playsound(src, 'sound/items/screwdriver2.ogg', 50, 1)

/obj/machinery/doppler_array/proc/sense_explosion(datum/source,turf/epicenter,devastation_range,heavy_impact_range,light_impact_range,
took,orig_dev_range,orig_heavy_range,orig_light_range)
took,orig_dev_range,orig_heavy_range,orig_light_range,explosion_index)
SIGNAL_HANDLER

if(machine_stat & NOPOWER)
Expand Down
199 changes: 155 additions & 44 deletions code/game/objects/effects/spawners/bombspawner.dm
Original file line number Diff line number Diff line change
@@ -1,66 +1,177 @@
#define CELSIUS_TO_KELVIN(T_K) ((T_K) + T0C)

#define OPTIMAL_TEMP_K_PLA_BURN_SCALE(PRESSURE_P,PRESSURE_O,TEMP_O) (((PRESSURE_P) * GLOB.meta_gas_info[/datum/gas/plasma][META_GAS_SPECIFIC_HEAT]) / (((PRESSURE_P) * GLOB.meta_gas_info[/datum/gas/plasma][META_GAS_SPECIFIC_HEAT] + (PRESSURE_O) * GLOB.meta_gas_info[/datum/gas/oxygen][META_GAS_SPECIFIC_HEAT]) / PLASMA_UPPER_TEMPERATURE - (PRESSURE_O) * GLOB.meta_gas_info[/datum/gas/oxygen][META_GAS_SPECIFIC_HEAT] / CELSIUS_TO_KELVIN(TEMP_O)))
#define OPTIMAL_TEMP_K_PLA_BURN_RATIO(PRESSURE_P,PRESSURE_O,TEMP_O) (CELSIUS_TO_KELVIN(TEMP_O) * PLASMA_OXYGEN_FULLBURN * (PRESSURE_P) / (PRESSURE_O))

/**
* Spawns a TTV.
*
*/
/obj/effect/spawner/newbomb
name = "bomb"
icon = 'icons/hud/screen_gen.dmi'
icon_state = "x"
var/temp_p = 1500
var/temp_o = 1000 // tank temperatures
var/pressure_p = 10 * ONE_ATMOSPHERE
var/pressure_o = 10 * ONE_ATMOSPHERE //tank pressures
var/assembly_type
/* Gasmixes for tank_one and tank_two of the ttv respectively.
* Populated on /obj/effect/spawner/newbomb/Initialize, depopulated right after by the children procs.
*/
var/datum/gas_mixture/first_gasmix
var/datum/gas_mixture/second_gasmix

/**
* The part of code that actually spawns the bomb. Always call the parent's initialize first for subtypes of these.
*
* Arguments:
* * assembly - An assembly typepath to add to the ttv.
*/
/obj/effect/spawner/newbomb/Initialize(mapload, assembly = null)
. = ..()
var/obj/item/transfer_valve/ttv = new(loc)
ttv.tank_one = new /obj/item/tank/internals/plasma (ttv)
ttv.tank_two = new /obj/item/tank/internals/oxygen (ttv)
first_gasmix = ttv.tank_one.return_air()
second_gasmix = ttv.tank_two.return_air()
first_gasmix.remove_ratio(1)
second_gasmix.remove_ratio(1)
if(ispath(assembly, /obj/item/assembly))
var/obj/item/assembly/newassembly = new assembly (ttv)
ttv.attached_device = newassembly
newassembly.on_attach()
newassembly.holder = ttv
ttv.update_appearance()
return INITIALIZE_HINT_QDEL


/obj/effect/spawner/newbomb/proc/calculate_pressure(datum/gas_mixture/gasmix, pressure)
return pressure * gasmix.volume/(R_IDEAL_GAS_EQUATION*gasmix.temperature)

/obj/effect/spawner/newbomb/plasma

/obj/effect/spawner/newbomb/plasma/Initialize(mapload)
. = ..()
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = 1413
second_gasmix.temperature = 141.3
first_gasmix.assert_gas(/datum/gas/plasma)
second_gasmix.assert_gas(/datum/gas/oxygen)
first_gasmix.gases[/datum/gas/plasma][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)

/obj/effect/spawner/newbomb/tritium

/obj/effect/spawner/newbomb/tritium/Initialize(mapload, obj/item/assembly)
. = ..()
if(!first_gasmix || !second_gasmix)
return

first_gasmix.temperature = 8000
second_gasmix.temperature = 43

first_gasmix.assert_gas(/datum/gas/plasma)
second_gasmix.assert_gas(/datum/gas/oxygen)
second_gasmix.assert_gas(/datum/gas/tritium)

/obj/effect/spawner/newbomb/Initialize(mapload)
first_gasmix.gases[/datum/gas/plasma][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = 0.67 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = 0.33 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)

/obj/effect/spawner/newbomb/isolated_tritium

/obj/effect/spawner/newbomb/isolated_tritium/Initialize(mapload)
. = ..()
var/obj/item/transfer_valve/V = new(src.loc)
var/obj/item/tank/internals/plasma/plasma_tank = new(V)
var/obj/item/tank/internals/oxygen/oxygen_tank = new(V)
if(!first_gasmix || !second_gasmix)
return

var/datum/gas_mixture/plasma_mix = plasma_tank.return_air()
var/datum/gas_mixture/oxygen_mix = oxygen_tank.return_air()
first_gasmix.temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1
second_gasmix.temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1

SET_MOLES(/datum/gas/plasma, plasma_mix, pressure_p*plasma_mix.volume/(R_IDEAL_GAS_EQUATION*CELSIUS_TO_KELVIN(temp_p)))
plasma_mix.temperature = CELSIUS_TO_KELVIN(temp_p)
first_gasmix.assert_gas(/datum/gas/hypernoblium)
first_gasmix.assert_gas(/datum/gas/tritium)
second_gasmix.assert_gas(/datum/gas/oxygen)

SET_MOLES(/datum/gas/oxygen, oxygen_mix, pressure_o*oxygen_mix.volume/(R_IDEAL_GAS_EQUATION*CELSIUS_TO_KELVIN(temp_o)))
oxygen_mix.temperature = CELSIUS_TO_KELVIN(temp_o)
first_gasmix.gases[/datum/gas/hypernoblium][MOLES] = REACTION_OPPRESSION_THRESHOLD - 0.01
first_gasmix.gases[/datum/gas/tritium][MOLES] = 0.5 * calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE-1)

V.tank_one = plasma_tank
V.tank_two = oxygen_tank
plasma_tank.master = V
oxygen_tank.master = V
/obj/effect/spawner/newbomb/noblium

/obj/effect/spawner/newbomb/noblium/Initialize(mapload)
. = ..()
if(!first_gasmix || !second_gasmix)
return

if(assembly_type)
var/obj/item/assembly/A = new assembly_type(V)
V.attached_device = A
A.holder = V
first_gasmix.temperature = 2.7
second_gasmix.temperature = 2.7

V.update_icon()
first_gasmix.assert_gas(/datum/gas/nitrogen)
second_gasmix.assert_gas(/datum/gas/tritium)

/obj/effect/spawner/newbomb/timer/syndicate/Initialize(mapload)
temp_p = (OPTIMAL_TEMP_K_PLA_BURN_SCALE(pressure_p, pressure_o, temp_o)/2 + OPTIMAL_TEMP_K_PLA_BURN_RATIO(pressure_p, pressure_o, temp_o)/2) - T0C
first_gasmix.gases[/datum/gas/nitrogen][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)

/obj/effect/spawner/newbomb/pressure

/obj/effect/spawner/newbomb/pressure/Initialize(mapload)
. = ..()
if(!first_gasmix || !second_gasmix)
return/obj/effect/spawner/newbomb/tritium

/obj/effect/spawner/newbomb/timer
assembly_type = /obj/item/assembly/timer
/obj/effect/spawner/newbomb/tritium/Initialize(mapload, obj/item/assembly)
. = ..()
if(!first_gasmix || !second_gasmix)
return

/obj/effect/spawner/newbomb/timer/syndicate
pressure_o = TANK_LEAK_PRESSURE - 1
temp_o = 20
first_gasmix.temperature = 8000
second_gasmix.temperature = 43

pressure_p = TANK_LEAK_PRESSURE - 1
first_gasmix.assert_gas(/datum/gas/plasma)
second_gasmix.assert_gas(/datum/gas/oxygen)
second_gasmix.assert_gas(/datum/gas/tritium)

/obj/effect/spawner/newbomb/proximity
assembly_type = /obj/item/assembly/prox_sensor
first_gasmix.gases[/datum/gas/plasma][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = 0.67 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = 0.33 * calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)

/obj/effect/spawner/newbomb/radio
assembly_type = /obj/item/assembly/signaler
/obj/effect/spawner/newbomb/isolated_tritium

/obj/effect/spawner/newbomb/isolated_tritium/Initialize(mapload)
. = ..()
if(!first_gasmix || !second_gasmix)
return

first_gasmix.temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1
second_gasmix.temperature = FIRE_MINIMUM_TEMPERATURE_TO_EXIST + 1

first_gasmix.assert_gas(/datum/gas/hypernoblium)
first_gasmix.assert_gas(/datum/gas/tritium)
second_gasmix.assert_gas(/datum/gas/oxygen)

first_gasmix.gases[/datum/gas/hypernoblium][MOLES] = REACTION_OPPRESSION_THRESHOLD - 0.01
first_gasmix.gases[/datum/gas/tritium][MOLES] = 0.5 * calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/oxygen][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE-1)

/obj/effect/spawner/newbomb/noblium

/obj/effect/spawner/newbomb/noblium/Initialize(mapload)
. = ..()
if(!first_gasmix || !second_gasmix)
return

first_gasmix.temperature = 2.7
second_gasmix.temperature = 2.7

first_gasmix.assert_gas(/datum/gas/nitrogen)
second_gasmix.assert_gas(/datum/gas/tritium)

first_gasmix.gases[/datum/gas/nitrogen][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)

/obj/effect/spawner/newbomb/pressure

/obj/effect/spawner/newbomb/pressure/Initialize(mapload)
. = ..()
if(!first_gasmix || !second_gasmix)
return
first_gasmix.temperature = 20000
second_gasmix.temperature = 2.7

#undef CELSIUS_TO_KELVIN
first_gasmix.assert_gas(/datum/gas/hypernoblium)
second_gasmix.assert_gas(/datum/gas/tritium)

#undef OPTIMAL_TEMP_K_PLA_BURN_SCALE
#undef OPTIMAL_TEMP_K_PLA_BURN_RATIO
first_gasmix.gases[/datum/gas/hypernoblium][MOLES] = calculate_pressure(first_gasmix, TANK_LEAK_PRESSURE - 1)
second_gasmix.gases[/datum/gas/tritium][MOLES] = calculate_pressure(second_gasmix, TANK_LEAK_PRESSURE - 1)
Loading

0 comments on commit 67ef2c2

Please sign in to comment.