Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into mech-clamp-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SapphicOverload committed Feb 23, 2024
2 parents b8a2419 + ea38b6a commit 3a44727
Show file tree
Hide file tree
Showing 37 changed files with 558 additions and 76 deletions.
22 changes: 22 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,25 @@

/// Possible value of [/atom/movable/buckle_lying]. If set to a different (positive-or-zero) value than this, the buckling thing will force a lying angle on the buckled.
#define NO_BUCKLE_LYING -1

/// Squashing will not occur if the mob is not lying down (bodyposition is LYING_DOWN)
#define SQUASHED_SHOULD_BE_DOWN (1<<0)
/// If present, outright gibs the squashed mob instead of just dealing damage
#define SQUASHED_SHOULD_BE_GIBBED (1<<1)
/// If squashing always passes if the mob is dead
#define SQUASHED_ALWAYS_IF_DEAD (1<<2)
/// Don't squash our mob if its not located in a turf
#define SQUASHED_DONT_SQUASH_IN_CONTENTS (1<<3)

// Bitflags for mob dismemberment and gibbing
/// Mobs will drop a brain
#define DROP_BRAIN (1<<0)
/// Mobs will drop organs
#define DROP_ORGANS (1<<1)
/// Mobs will drop bodyparts (arms, legs, etc.)
#define DROP_BODYPARTS (1<<2)
/// Mobs will drop items
#define DROP_ITEMS (1<<3)

/// Mobs will drop everything
#define DROP_ALL_REMAINS (DROP_BRAIN | DROP_ORGANS | DROP_BODYPARTS | DROP_ITEMS)
2 changes: 2 additions & 0 deletions code/__DEFINES/status_effects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@

#define STATUS_EFFECT_EXPOSED /datum/status_effect/exposed //increases incoming damage

#define STATUS_EFFECT_EXPOSED_HARPOONED /datum/status_effect/exposed/harpooned //increases incoming damage when hit by a gasharpoon

#define STATUS_EFFECT_TAMING /datum/status_effect/taming //tames the target after enough tame stacks

#define STATUS_EFFECT_NECROPOLIS_CURSE /datum/status_effect/necropolis_curse
Expand Down
3 changes: 2 additions & 1 deletion code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@
#define INIT_ORDER_PATH -50
#define INIT_ORDER_DISCORD -60
#define INIT_ORDER_EXPLOSIONS -69
#define INIT_ORDER_STATPANELS -98
#define INIT_ORDER_STATPANELS -97
#define INIT_ORDER_INIT_PROFILER -98 //Near the end, logs the costs of initialize
#define INIT_ORDER_DEMO -99 // To avoid a bunch of changes related to initialization being written, do this last
#define INIT_ORDER_CHAT -100 //Should be last to ensure chat remains smooth during init.

Expand Down
4 changes: 2 additions & 2 deletions code/controllers/master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
var/newdrift = ((REALTIMEOFDAY - init_timeofday) - (world.time - init_time)) / world.tick_lag
tickdrift = max(0, MC_AVERAGE_FAST(tickdrift, newdrift))
var/starting_tick_usage = TICK_USAGE

if(newdrift - olddrift >= CONFIG_GET(number/drift_dump_threshold))
//Yog: profile dumping was throttling lower performance computers, so we're going to have it disabled by default but you can enable it via config flags
if(newdrift - olddrift >= CONFIG_GET(number/drift_dump_threshold) && CONFIG_GET(flag/auto_profile))
AttemptProfileDump(CONFIG_GET(number/drift_profile_delay))
olddrift = newdrift

Expand Down
28 changes: 28 additions & 0 deletions code/controllers/subsystem/init_profiler.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#define INIT_PROFILE_NAME "init_profiler.json"

///Subsystem exists so we can separately log init time costs from the costs of general operation
///Hopefully this makes sorting out what causes problems when easier
SUBSYSTEM_DEF(init_profiler)
name = "Init Profiler"
init_order = INIT_ORDER_INIT_PROFILER
init_stage = INITSTAGE_MAX
flags = SS_NO_FIRE

/datum/controller/subsystem/init_profiler/Initialize()
if(CONFIG_GET(flag/auto_profile))
write_init_profile()
return SS_INIT_SUCCESS

/datum/controller/subsystem/init_profiler/proc/write_init_profile()
var/current_profile_data = world.Profile(PROFILE_REFRESH, format = "json")
CHECK_TICK

if(!length(current_profile_data)) //Would be nice to have explicit proc to check this
stack_trace("Warning, profiling stopped manually before dump.")
var/prof_file = file("[GLOB.log_directory]/[INIT_PROFILE_NAME]")
if(fexists(prof_file))
fdel(prof_file)
WRITE_FILE(prof_file, current_profile_data)
world.Profile(PROFILE_CLEAR) //Now that we're written this data out, dump it. We don't want it getting mixed up with our current round data

#undef INIT_PROFILE_NAME
19 changes: 10 additions & 9 deletions code/controllers/subsystem/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,9 @@ SUBSYSTEM_DEF(job)
/datum/controller/subsystem/job/proc/irish_override()
var/datum/map_template/template = SSmapping.station_room_templates["Bar Irish"]

for(var/obj/effect/landmark/stationroom/box/bar/B in GLOB.bar_landmarks)
for(var/obj/effect/landmark/stationroom/box/bar/B in GLOB.landmarks_list)
template.load(B.loc, centered = FALSE)

qdel(B)

/datum/controller/subsystem/job/proc/random_chapel_init()
try
Expand Down Expand Up @@ -664,9 +664,9 @@ SUBSYSTEM_DEF(job)
log_game("WARNING: CHAPEL RECOVERY FAILED! THERE WILL BE NO CHAPEL FOR THIS ROUND!")
return

for(var/obj/effect/landmark/stationroom/box/chapel/B in GLOB.chapel_landmarks)
for(var/obj/effect/landmark/stationroom/box/chapel/B in GLOB.landmarks_list)
template.load(B.loc, centered = FALSE)

qdel(B)
catch(var/exception/e)
message_admins("RUNTIME IN RANDOM_CHAPEL_INIT")
spawn_chapel()
Expand All @@ -681,9 +681,9 @@ SUBSYSTEM_DEF(job)
if(isnull(template))
message_admins("UNABLE TO SPAWN CHAPEL")

for(var/obj/effect/landmark/stationroom/box/chapel/B in GLOB.chapel_landmarks)
for(var/obj/effect/landmark/stationroom/box/chapel/B in GLOB.landmarks_list)
template.load(B.loc, centered = FALSE)

qdel(B)

/datum/controller/subsystem/job/proc/random_clerk_init()
try
Expand Down Expand Up @@ -728,9 +728,9 @@ SUBSYSTEM_DEF(job)
log_game("WARNING: CLERK RECOVERY FAILED! THERE WILL BE NO CLERK SHOP FOR THIS ROUND!")
return

for(var/obj/effect/landmark/stationroom/box/clerk/B in GLOB.clerk_office_landmarks)
for(var/obj/effect/landmark/stationroom/box/clerk/B in GLOB.landmarks_list)
template.load(B.loc, centered = FALSE)

qdel(B)
catch(var/exception/e)
message_admins("RUNTIME IN RANDOM_CLERK_INIT")
spawn_clerk()
Expand All @@ -745,8 +745,9 @@ SUBSYSTEM_DEF(job)
if(isnull(template))
message_admins("UNABLE TO SPAWN CLERK")

for(var/obj/effect/landmark/stationroom/box/clerk/B in GLOB.clerk_office_landmarks)
for(var/obj/effect/landmark/stationroom/box/clerk/B in GLOB.landmarks_list)
template.load(B.loc, centered = FALSE)
qdel(B)

/datum/controller/subsystem/job/proc/handle_auto_deadmin_roles(client/C, rank)
if(!C?.holder)
Expand Down
11 changes: 10 additions & 1 deletion code/datums/components/squeak.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@
var/last_use = 0
var/use_delay = 20

///what we set connect_loc to if parent is an item
var/static/list/item_connections = list(
COMSIG_ATOM_ENTERED = PROC_REF(play_squeak_crossed),
)

/datum/component/squeak/Initialize(custom_sounds, volume_override, chance_override, step_delay_override, use_delay_override)
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignals(parent, list(COMSIG_ATOM_ENTERED, COMSIG_ATOM_BLOB_ACT, COMSIG_ATOM_HULK_ATTACK, COMSIG_PARENT_ATTACKBY), PROC_REF(play_squeak))
if(ismovable(parent))
RegisterSignals(parent, list(COMSIG_MOVABLE_BUMP, COMSIG_MOVABLE_IMPACT, COMSIG_PROJECTILE_BEFORE_FIRE), PROC_REF(play_squeak))
RegisterSignal(parent, COMSIG_MOVABLE_CROSSED, PROC_REF(play_squeak_crossed))
AddComponent(/datum/component/connect_loc_behalf, parent, item_connections)
RegisterSignal(parent, COMSIG_MOVABLE_DISPOSING, PROC_REF(disposing_react))
if(isitem(parent))
RegisterSignals(parent, list(COMSIG_ITEM_ATTACK, COMSIG_ITEM_ATTACK_OBJ, COMSIG_ITEM_HIT_REACT), PROC_REF(play_squeak))
Expand All @@ -41,6 +46,10 @@
if(isnum(use_delay_override))
use_delay = use_delay_override

/datum/component/squeak/UnregisterFromParent()
. = ..()
qdel(GetComponent(/datum/component/connect_loc_behalf))

/datum/component/squeak/proc/play_squeak()
if(prob(squeak_chance))
if(!override_squeak_sounds)
Expand Down
81 changes: 81 additions & 0 deletions code/datums/components/squishable.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
///This component allows something to be when crossed, for example for cockroaches.
/datum/component/squashable
///Chance on crossed to be squashed
var/squash_chance = 50
///How much brute is applied when mob is squashed
var/squash_damage = 1
///Squash flags, for extra checks etcetera.
var/squash_flags = NONE
///Special callback to call on squash instead, for things like hauberoach
var/datum/callback/on_squash_callback
///signal list given to connect_loc
var/static/list/loc_connections = list(
COMSIG_ATOM_ENTERED = PROC_REF(on_entered),
)


/datum/component/squashable/Initialize(squash_chance, squash_damage, squash_flags, squash_callback)
. = ..()
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
if(squash_chance)
src.squash_chance = squash_chance
if(squash_damage)
src.squash_damage = squash_damage
if(squash_flags)
src.squash_flags = squash_flags
if(!src.on_squash_callback && squash_callback)
on_squash_callback = CALLBACK(parent, squash_callback)

AddComponent(/datum/component/connect_loc_behalf, parent, loc_connections)

/datum/component/squashable/Destroy(force)
on_squash_callback = null
return ..()

///Handles the squashing of the mob
/datum/component/squashable/proc/on_entered(turf/source_turf, atom/movable/crossing_movable)
// SIGNAL_HANDLER -- dont uncomment this

if(parent == crossing_movable)
return

var/mob/living/parent_as_living = parent
if((squash_flags & SQUASHED_DONT_SQUASH_IN_CONTENTS) && !isturf(parent_as_living.loc))
return

if((squash_flags & SQUASHED_SHOULD_BE_DOWN) && parent_as_living.body_position != LYING_DOWN)
return

var/should_squash = ((squash_flags & SQUASHED_ALWAYS_IF_DEAD) && parent_as_living.stat == DEAD) || prob(squash_chance)

if(should_squash && on_squash_callback)
if(on_squash_callback.Invoke(parent_as_living, crossing_movable))
return //Everything worked, we're done!
if(isliving(crossing_movable))
var/mob/living/crossing_mob = crossing_movable
if(crossing_mob.mob_size > MOB_SIZE_SMALL && !(crossing_mob.movement_type & MOVETYPES_NOT_TOUCHING_GROUND))
if(HAS_TRAIT(crossing_mob, TRAIT_PACIFISM))
crossing_mob.visible_message(span_notice("[crossing_mob] carefully steps over [parent_as_living]."), span_notice("You carefully step over [parent_as_living] to avoid hurting it."))
return
if(should_squash)
crossing_mob.visible_message(span_notice("[crossing_mob] squashed [parent_as_living]."), span_notice("You squashed [parent_as_living]."))
Squish(parent_as_living)
else
parent_as_living.visible_message(span_notice("[parent_as_living] avoids getting crushed."))
else if(isstructure(crossing_movable))
if(should_squash)
crossing_movable.visible_message(span_notice("[parent_as_living] is crushed under [crossing_movable]."))
Squish(parent_as_living)
else
parent_as_living.visible_message(span_notice("[parent_as_living] avoids getting crushed."))

/datum/component/squashable/proc/Squish(mob/living/target)
if(squash_flags & SQUASHED_SHOULD_BE_GIBBED)
target.gib(DROP_ALL_REMAINS)
else
target.adjustBruteLoss(squash_damage)

/datum/component/squashable/UnregisterFromParent()
. = ..()
qdel(GetComponent(/datum/component/connect_loc_behalf))
39 changes: 39 additions & 0 deletions code/datums/status_effects/debuffs/debuffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,45 @@
for(var/i in S.damage_coeff)
S.damage_coeff[i] /= power

/datum/status_effect/exposed/harpooned
id = "harpooned"
duration = 2 SECONDS
///damage multiplier
power = 1.3

/datum/status_effect/exposed/harpooned/on_apply()
. = ..()
if(.)
owner.add_filter("exposed", 2, list("type" = "outline", "color" = COLOR_RED, "size" = 1))

if(ishuman(owner))
var/mob/living/carbon/human/H = owner
H.physiology.brute_mod *= power
H.physiology.burn_mod *= power
H.physiology.tox_mod *= power
H.physiology.oxy_mod *= power
H.physiology.clone_mod *= power
H.physiology.stamina_mod *= power
else if(isanimal(owner))
var/mob/living/simple_animal/S = owner
for(var/i in S.damage_coeff)
S.damage_coeff[i] *= power

/datum/status_effect/exposed/harpooned/on_remove()
owner.remove_filter("exposed")
if(ishuman(owner))
var/mob/living/carbon/human/H = owner
H.physiology.brute_mod /= power
H.physiology.burn_mod /= power
H.physiology.tox_mod /= power
H.physiology.oxy_mod /= power
H.physiology.clone_mod /= power
H.physiology.stamina_mod /= power
else if(isanimal(owner))
var/mob/living/simple_animal/S = owner
for(var/i in S.damage_coeff)
S.damage_coeff[i] /= power

/datum/status_effect/knuckled
id = "knuckle_wound"
duration = 10 SECONDS
Expand Down
Loading

0 comments on commit 3a44727

Please sign in to comment.