Skip to content

Commit

Permalink
adds persistent sheet silos to mining (#6353)
Browse files Browse the repository at this point in the history
65% multiplier - 10 per sheet constant loss

requested by @TheObserver-sys and signed off by me

mining rework will make this more balanced but vorestation has it; i
think it's fine to throw mining/science a bone.

---------

Co-authored-by: silicons <[email protected]>
Co-authored-by: BlueWildrose <[email protected]>
  • Loading branch information
3 people committed Mar 23, 2024
1 parent 9adb5ce commit f825c9a
Show file tree
Hide file tree
Showing 31 changed files with 643 additions and 492 deletions.
2 changes: 2 additions & 0 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3340,6 +3340,8 @@
#include "code\modules\mining\vertibore.dm"
#include "code\modules\mining\drilling\drill.dm"
#include "code\modules\mining\drilling\scanner.dm"
#include "code\modules\mining\machinery\sheet_silo.dm"
#include "code\modules\mining\machinery\sheet_silo_loader.dm"
#include "code\modules\mining\ore_redemption_machine\construction.dm"
#include "code\modules\mining\ore_redemption_machine\engineering_points_vendor.dm"
#include "code\modules\mining\ore_redemption_machine\equipment_vendor.dm"
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/controllers/persistence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#define OBJ_HAS_PERSISTENCE_ENABLED(OBJ) (OBJ.persist_static_id || OBJ.persist_dynamic_id)
/// check if an /obj is eligible at all for mass persistence
#define OBJ_MASS_PERSIST_SANITY_CHECK(OBJ) (OBJ_HAS_PERSIST_ENABLED(OBJ) && !(OBJ.obj_persist_status & (OBJ_PERSIST_STATUS_NO_THANK_YOU)))
/// sentinel id; set this if you want something to persist but generate its own dynamic id
/// instead of setting one manually
#define PERSISTENCE_DYNAMIC_ID_AUTOSET "!autoset"

//* /obj - obj_persist_status *//

Expand All @@ -22,6 +25,8 @@
#define OBJ_PERSIST_STATUS_FIRST_GENERATION (1<<2)
/// do not persist
#define OBJ_PERSIST_STATUS_NO_THANK_YOU (1<<3)
/// do not show persistent status on examine
#define OBJ_PERSIST_STATUS_NO_EXAMINE (1<<4)

//* /obj - obj_persist_dynamic_status *//

Expand Down
13 changes: 13 additions & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

#define in_range(source, user) (get_dist(source, user) <= 1 && (get_step(source, 0)?:z) == (get_step(user, 0)?:z))

//* Datatypes *//

/**
* used to filter nans and non-numbers from player input
*/
#if DM_VERSION < 515
#define is_safe_number(N) (isnum(N) && (N == N))
#else
#define is_safe_number(N) (isnum(N) && !isnan(N))
#endif

//* Typepaths *//

#define isatom(A) (isloc(A))

#define isdatum(D) (istype(D, /datum))
Expand Down
4 changes: 4 additions & 0 deletions code/__DEFINES/materials/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
#define MATERIAL_FLAG_VULNERABLE_MOB_ARMOR (1<<0)
/// utterly immune to melting, thermite or otherwise
#define MATERIAL_FLAG_UNMELTABLE (1<<1)
/// too dangerous to persist
/// this is a somewhat awful flag so we'll keep it until we need to get rid of it
#define MATERIAL_FLAG_CONSIDERED_OVERPOWERED (1<<2)

DEFINE_BITFIELD(material_flags, list(
BITFIELD(MATERIAL_FLAG_VULNERABLE_MOB_ARMOR),
BITFIELD(MATERIAL_FLAG_UNMELTABLE),
BITFIELD(MATERIAL_FLAG_CONSIDERED_OVERPOWERED),
))

//* /datum/material material_constraints
Expand Down
16 changes: 8 additions & 8 deletions code/controllers/subsystem/persistence/modules/level_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@
"generation" = generation,
"object_id" = entity.obj_persist_static_id,
"level_id" = entity.obj_persist_static_bound_id || level_id,
"data" = entity.serialize(),
"data" = safe_json_encode(entity.serialize()),
),
)
if(OBJ_PERSIST_STATIC_MODE_MAP)
query = SSdbcore.NewQuery(
"INSERT INTO [format_table_name("persistence_static_mapl_objects")] (generation, object_id, map_id, data) \
"INSERT INTO [format_table_name("persistence_static_map_objects")] (generation, object_id, map_id, data) \
VALUES (:generation, :object_id, :map_id, :data) ON DUPLICATE KEY UPDATE \
data = VALUES(data)",
list(
"generation" = generation,
"object_id" = entity.obj_persist_static_id,
"map_id" = entity.obj_persist_static_bound_id || map_id,
"data" = entity.serialize(),
"data" = safe_json_encode(entity.serialize()),
),
)
if(OBJ_PERSIST_STATIC_MODE_GLOBAL)
Expand All @@ -50,7 +50,7 @@
list(
"generation" = generation,
"object_id" = entity.obj_persist_static_id,
"data" = entity.serialize(),
"data" = safe_json_encode(entity.serialize()),
),
)
else
Expand All @@ -77,7 +77,7 @@

for(var/obj/entity as anything in entities)
var/datum/db_query/query
if(entity.obj_persist_dynamic_id)
if(entity.obj_persist_dynamic_id != PERSISTENCE_DYNAMIC_ID_AUTOSET)
query = SSdbcore.NewQuery(
"INSERT INTO [format_table_name("persistence_dynamic_objects")] (id, generation, status, data, prototype_id, level_id, x, y) \
VALUES (:status, :data, :prototype, :level, :x, :y) ON DUPLICATE KEY UPDATE \
Expand All @@ -87,7 +87,7 @@
"id" = entity.obj_persist_dynamic_id,
"generation" = generation,
"status" = entity.obj_persist_dynamic_status,
"data" = entity.serialize(),
"data" = safe_json_encode(entity.serialize()),
"prototype" = "[entity.type]",
"level" = level_id,
"x" = entity.x,
Expand All @@ -101,7 +101,7 @@
VALUES (:status, :data, :prototype, :level, :x, :y)",
list(
"status" = entity.obj_persist_dynamic_status,
"data" = entity.serialize(),
"data" = safe_json_encode(entity.serialize()),
"prototype" = "[entity.type]",
"level" = level_id,
"x" = entity.x,
Expand Down Expand Up @@ -197,7 +197,7 @@
for(var/obj/entity as anything in entities)
var/datum/db_query/query
var/bind_id
switch(entity.obj_persist_dynamic_status)
switch(entity.obj_persist_static_mode)
if(OBJ_PERSIST_STATIC_MODE_GLOBAL)
query = SSdbcore.NewQuery(
"SELECT data FROM [format_table_name("persistence_static_global_objects")] \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
src.generation = generation
src.hours_since_saved = 0
src.rounds_since_saved = 0
src.round_id_saved = GLOB.round_id
src.round_id_saved = GLOB.round_number

SSdbcore.RunQuery(
"INSERT INTO [format_table_name("persistence_level_metadata")] (saved, saved_round_id, level_id, data, generation) \
Expand Down
11 changes: 11 additions & 0 deletions code/datums/datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@
SEND_SIGNAL(source, COMSIG_CD_RESET(index), S_TIMER_COOLDOWN_TIMELEFT(source, index))
TIMER_COOLDOWN_END(source, index)

//* Duplication *//

/**
* makes a clone of this datum
*
* @params
* * include_contents - include semantic contents; ergo 'what we are hosting' vs 'what we are'
*/
/datum/proc/clone(include_contents)
return new type

//* Serialization *//

/**
Expand Down
28 changes: 20 additions & 8 deletions code/game/atoms/atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@

//? Context
/// open context menus by mob
var/list/context_menus
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/list/context_menus

//? Economy
// todo: move all this to obj level, you aren't going to sell a fucking turf.
Expand Down Expand Up @@ -143,16 +144,24 @@
//? Materials
/// combined material trait flags
/// this list is at /atom level but are only used/implemented on /obj generically; anything else, e.g. walls, should implement manually for efficiency.
var/material_trait_flags = NONE
/// * this variable is a cache variable and is generated from the materials on an entity.
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/material_trait_flags = NONE
/// material traits on us, associated to metadata
/// this list is at /atom level but are only used/implemented on /obj generically; anything else, e.g. walls, should implement manually for efficiency.
var/list/datum/material_trait/material_traits
/// * this variable is a cache variable and is generated from the materials on an entity.
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/list/datum/material_trait/material_traits
/// material trait metadata when [material_traits] is a single trait. null otherwise.
var/material_traits_data
/// * this variable is a cache variable and is generated from the materials on an entity.
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/material_traits_data
/// 'stacks' of ticking
/// this synchronizes the system so removing one ticking material trait doesn't fully de-tick the entity
//! DO NOT FUCK WITH THIS UNLESS YOU KNOW WHAT YOU ARE DOING
var/material_ticking_counter = 0
/// * this variable is a cache variable and is generated from the materials on an entity.
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/material_ticking_counter = 0
/// material trait relative strength
/// applies to all traits globally as opposed to just one material parts,
/// because this is at /atom level.
Expand All @@ -170,13 +179,16 @@
/// sorted priority list of datums for handling shieldcalls with
/// we use this instead of signals so we can enforce priorities
/// this is horrifying.
var/list/datum/shieldcall/shieldcalls
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/list/datum/shieldcall/shieldcalls

//? Overlays
/// vis overlays managed by SSvis_overlays to automaticaly turn them like other overlays.
var/list/managed_vis_overlays
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/list/managed_vis_overlays
/// overlays managed by [update_overlays][/atom/proc/update_overlays] to prevent removing overlays that weren't added by the same proc. Single items are stored on their own, not in a list.
var/list/managed_overlays
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/list/managed_overlays

//? Layers
/// Base layer - defaults to layer.
Expand Down
50 changes: 38 additions & 12 deletions code/game/atoms/movable/movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,36 @@

//? Movement
/// Whatever we're pulling.
var/atom/movable/pulling
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/atom/movable/pulling
/// Who's currently pulling us
var/atom/movable/pulledby
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/atom/movable/pulledby
/// If false makes [CanPass][/atom/proc/CanPass] call [CanPassThrough][/atom/movable/proc/CanPassThrough] on this type instead of using default behaviour
var/generic_canpass = TRUE
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/generic_canpass = TRUE
/// Pass flags.
var/pass_flags = NONE
/// movement calls we're in
var/in_move = 0
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/in_move = 0
/// a direction, or null
var/moving_diagonally = NOT_IN_DIAG_STEP
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/moving_diagonally = NOT_IN_DIAG_STEP
/// attempt to resume grab after moving instead of before. This is what atom/movable is pulling us during move-from-pulling.
var/atom/movable/moving_from_pull
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/atom/movable/moving_from_pull
/// Direction of our last move.
var/last_move_dir = NONE
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/last_move_dir = NONE
/// Our default glide_size. Null to use global default.
var/default_glide_size
/// Movement types, see [code/__DEFINES/flags/movement.dm]
/// Do *not* manually edit this variable in most cases. Use the helpers in [code/game/atoms/atoms_movement.dm].
var/movement_type = MOVEMENT_GROUND
/// todo: is there a better way to do this? what if we want to force something to be a movement type on map editor?
/// * this variable is a cache variable generated from movement type traits.
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/movement_type = MOVEMENT_GROUND

//? Spacedrift
/// Which direction we're drifting
Expand All @@ -63,7 +73,8 @@

//? Perspectives
/// our default perspective - if none, a temporary one will be generated when a mob requires it
var/datum/perspective/self_perspective
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/datum/perspective/self_perspective

//? Buckling
/// do we support the buckling system - if not, none of the default interactions will work, but comsigs will still fire!
Expand All @@ -77,7 +88,8 @@
/// direction to set buckled mobs to. null to not do that.
var/buckle_dir
/// buckled mobs, associated to their semantic mode if necessary
var/list/mob/buckled_mobs
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/list/mob/buckled_mobs
/// restrained default unbuckle time (NOT TIME TO UN-RESTRAIN, this is time to UNBUCKLE from us)
var/buckle_restrained_resist_time = 2 MINUTES

Expand Down Expand Up @@ -134,9 +146,11 @@
/// Either FALSE, [EMISSIVE_BLOCK_GENERIC], or [EMISSIVE_BLOCK_UNIQUE]
var/blocks_emissive = FALSE
/// Internal holder for emissive blocker object, do not use directly use; use blocks_emissive
var/atom/movable/emissive_blocker/em_block
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/atom/movable/emissive_blocker/em_block
/// Internal holder for emissives. Definitely don't directly use, this is absolutely an insane Citadel Moment(tm).
var/atom/movable/emissive_render/em_render
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/atom/movable/emissive_render/em_render

//? Icon Scale
/// Used to scale icons up or down horizonally in update_transform().
Expand Down Expand Up @@ -433,6 +447,18 @@
/atom/movable/proc/is_avoiding_ground()
return ((movement_type & MOVEMENT_TYPES) != MOVEMENT_GROUND) || throwing

//* Duplication *//

/**
* makes a clone of this movable
*
* @params
* * location - where to clone us
* * include_contents - include semantic contents; ergo 'what we are hosting' vs 'what we are'
*/
/atom/movable/clone(atom/location, include_contents)
return ..(include_contents)

//? Perspectives
/**
* get perspective to use when shifting eye to us,
Expand Down
12 changes: 9 additions & 3 deletions code/game/objects/objs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,16 @@
var/obj_persist_static_mode = OBJ_PERSIST_STATIC_MODE_MAP
/// on static map/level bind mode, this is to determine which level/map we're bound to
/// once bound, even if we go to another level, we are treated as this level.
var/obj_persist_static_bound_id
/// binding is done during load.
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/obj_persist_static_bound_id
/// if set, we are currently dynamically persisting. this is our ID and must be unique for a given map level.
/// this id will not collide with static id.
var/obj_persist_dynamic_id
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/obj_persist_dynamic_id
/// dynamic persistence state flags
var/obj_persist_dynamic_status = NONE
/// * this variable is not visible and should not be edited in the map editor.
var/tmp/obj_persist_dynamic_status = NONE

//? Sounds
/// volume when breaking out using resist process
Expand Down Expand Up @@ -644,6 +648,8 @@
if(isnull(mat)) // 'none' option
continue
. += "Its [key] is made out of [mat.display_name]"
if((obj_persist_dynamic_id || obj_persist_static_id) && !(obj_persist_status & OBJ_PERSIST_STATUS_NO_EXAMINE))
. += SPAN_BOLDNOTICE("This entity is a persistent entity; it may be preserved into future rounds.")

/obj/proc/examine_integrity(mob/user)
. = list()
Expand Down
4 changes: 4 additions & 0 deletions code/modules/admin/verbs/debug/reestablish_db_connection.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
message_admins("Reloading client database data...")
for(var/client/C in GLOB.clients)
C.player?.load()
message_admins("Asserting round ID set...")
if(!isnum(text2num(GLOB.round_id)))
SSdbcore.SetRoundID()
message_admins("Round ID was not set and has now been re-set. Things might be weird this round.")
4 changes: 2 additions & 2 deletions code/modules/mining/machine_processing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/obj/machinery/mineral/processing_unit_console
name = "production machine console"
icon = 'icons/obj/machines/mining_machines_vr.dmi'
icon = 'icons/obj/machines/mining_machines.dmi'
icon_state = "console"
density = TRUE
anchored = TRUE
Expand Down Expand Up @@ -136,7 +136,7 @@

/obj/machinery/mineral/processing_unit
name = "material processor" //This isn't actually a goddamn furnace, we're in space and it's processing platinum and flammable phoron...
icon = 'icons/obj/machines/mining_machines_vr.dmi'
icon = 'icons/obj/machines/mining_machines.dmi'
icon_state = "furnace"
density = TRUE
anchored = TRUE
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mining/machine_stacking.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/obj/machinery/mineral/stacking_unit_console
name = "stacking machine console"
icon = 'icons/obj/machines/mining_machines_vr.dmi'
icon = 'icons/obj/machines/mining_machines.dmi'
icon_state = "console"
density = 1
anchored = 1
Expand Down Expand Up @@ -72,7 +72,7 @@

/obj/machinery/mineral/stacking_machine
name = "stacking machine"
icon = 'icons/obj/machines/mining_machines_vr.dmi'
icon = 'icons/obj/machines/mining_machines.dmi'
icon_state = "stacker"
density = 1
anchored = 1.0
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mining/machine_unloading.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/obj/machinery/mineral/unloading_machine
name = "unloading machine"
icon = 'icons/obj/machines/mining_machines_vr.dmi'
icon = 'icons/obj/machines/mining_machines.dmi'
icon_state = "unloader"
density = 1
anchored = 1.0
Expand Down
Loading

0 comments on commit f825c9a

Please sign in to comment.