From 81fc0c1b323e539e2c34dd9a49696919cc9bee33 Mon Sep 17 00:00:00 2001
From: Ghommie <42542238+Ghommie@users.noreply.github.com>
Date: Wed, 2 Oct 2019 00:37:02 +0200
Subject: [PATCH] more foolproofing.
---
code/__DEFINES/obj_flags.dm | 1 +
code/game/atoms.dm | 1 +
code/game/objects/structures/tables_racks.dm | 3 ++-
code/game/turfs/turf.dm | 13 ++++++++---
code/modules/recycling/disposal/bin.dm | 23 +++++++++++---------
5 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/code/__DEFINES/obj_flags.dm b/code/__DEFINES/obj_flags.dm
index 01d95d7ff9..8d6c0644cf 100644
--- a/code/__DEFINES/obj_flags.dm
+++ b/code/__DEFINES/obj_flags.dm
@@ -10,6 +10,7 @@
#define UNIQUE_RENAME (1<<6) // can you customize the description/name of the thing?
#define USES_TGUI (1<<7) //put on things that use tgui on ui_interact instead of custom/old UI.
#define FROZEN (1<<8)
+#define SHOVABLE_ONTO (1<<9) //called on turf.shove_act() to consider whether an object should have a niche effect (defined in their own shove_act()) when someone is pushed onto it, or do a sanity CanPass() check.
// If you add new ones, be sure to add them to /obj/Initialize as well for complete mapping support
diff --git a/code/game/atoms.dm b/code/game/atoms.dm
index 09f32c215d..8922ac60e1 100644
--- a/code/game/atoms.dm
+++ b/code/game/atoms.dm
@@ -235,6 +235,7 @@
SEND_SIGNAL(src, COMSIG_ATOM_BULLET_ACT, P, def_zone)
. = P.on_hit(src, 0, def_zone)
+//used on altdisarm() for special interactions between the shoved victim (target) and the src, with user being the one shoving the target on it.
/atom/proc/shove_act(mob/living/target, mob/living/user)
return FALSE
diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm
index 1f1d667648..b17d585385 100644
--- a/code/game/objects/structures/tables_racks.dm
+++ b/code/game/objects/structures/tables_racks.dm
@@ -21,6 +21,7 @@
anchored = TRUE
layer = TABLE_LAYER
climbable = TRUE
+ obj_flags = CAN_BE_HIT|SHOVABLE_ONTO
pass_flags = LETPASSTHROW //You can throw objects over this, despite it's density.")
var/frame = /obj/structure/table_frame
var/framestack = /obj/item/stack/rods
@@ -141,7 +142,7 @@
target.Knockdown(SHOVE_KNOCKDOWN_TABLE)
user.visible_message("[user.name] shoves [target.name] onto \the [src]!",
"You shove [target.name] onto \the [src]!", null, COMBAT_MESSAGE_RANGE)
- target.throw_at(src, 1, 1, null, FALSE) //1 speed throws with no spin are basically just forcemoves with a hard collision check
+ target.forceMove(src.loc)
log_combat(user, target, "shoved", "onto [src] (table)")
return TRUE
diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm
index 7f3f7fae40..5331e76ae0 100755
--- a/code/game/turfs/turf.dm
+++ b/code/game/turfs/turf.dm
@@ -382,10 +382,17 @@
if(ismob(A) || .)
A.ratvar_act()
-/turf/shove_act(mob/living/target, mob/living/user)
+//called on /datum/species/proc/altdisarm()
+/turf/shove_act(mob/living/target, mob/living/user, pre_act = FALSE)
+ var/list/possibilities
for(var/obj/O in contents)
- if(O.shove_act(target, user))
- return TRUE
+ if(CHECK_BITFIELD(O.obj_flags, SHOVABLE_ONTO))
+ LAZYADD(possibilities)
+ else if(!O.CanPass(target, src))
+ return FALSE
+ if(possibilities)
+ var/obj/O = pick(possibilities)
+ return O.shove_act(target, user)
return FALSE
/turf/proc/get_smooth_underlay_icon(mutable_appearance/underlay_appearance, turf/asking_turf, adjacency_dir)
diff --git a/code/modules/recycling/disposal/bin.dm b/code/modules/recycling/disposal/bin.dm
index 9798ecc948..24d7d0300b 100644
--- a/code/modules/recycling/disposal/bin.dm
+++ b/code/modules/recycling/disposal/bin.dm
@@ -141,16 +141,7 @@
if(!pushing)
to_chat(user, "[target] doesn't fit inside [src]!")
return FALSE
-
-/obj/machinery/disposal/bin/shove_act(mob/living/target, mob/living/user)
- if(can_stuff_mob_in(target, user, TRUE))
- target.Knockdown(SHOVE_KNOCKDOWN_SOLID)
- target.forceMove(src)
- user.visible_message("[user.name] shoves [target.name] into \the [src]!",
- "You shove [target.name] into \the [src]!", null, COMBAT_MESSAGE_RANGE)
- log_combat(user, target, "shoved", "into [src] (disposal bin)")
- return TRUE
- return FALSE
+ return TRUE
/obj/machinery/disposal/relaymove(mob/user)
attempt_escape(user)
@@ -280,6 +271,7 @@
desc = "A pneumatic waste disposal unit."
icon_state = "disposal"
var/datum/oracle_ui/themed/nano/ui
+ obj_flags = CAN_BE_HIT | USES_TGUI | SHOVABLE_ONTO
/obj/machinery/disposal/bin/Initialize(mapload, obj/structure/disposalconstruct/make_from)
. = ..()
@@ -375,6 +367,17 @@
else
return ..()
+/obj/machinery/disposal/bin/shove_act(mob/living/target, mob/living/user)
+ if(can_stuff_mob_in(target, user, TRUE))
+ target.Knockdown(SHOVE_KNOCKDOWN_SOLID)
+ target.forceMove(src)
+ user.visible_message("[user.name] shoves [target.name] into \the [src]!",
+ "You shove [target.name] into \the [src]!", null, COMBAT_MESSAGE_RANGE)
+ log_combat(user, target, "shoved", "into [src] (disposal bin)")
+ return TRUE
+ return FALSE
+
+
/obj/machinery/disposal/bin/flush()
..()
full_pressure = FALSE