From ed6d2c191ce9a54c9eae51572dfe90a00d902f32 Mon Sep 17 00:00:00 2001
From: Squalhardt <99915170+Oricana-16@users.noreply.github.com>
Date: Sat, 18 Feb 2023 16:42:26 -0500
Subject: [PATCH 1/7] Chain Component + vehicle tethering
---
beestation.dme | 1 +
code/modules/power/cable.dm | 30 +++++++
monkestation/code/datums/components/chain.dm | 89 ++++++++++++++++++++
3 files changed, 120 insertions(+)
create mode 100644 monkestation/code/datums/components/chain.dm
diff --git a/beestation.dme b/beestation.dme
index 9c0e244b937c7..b7ca356d20019 100644
--- a/beestation.dme
+++ b/beestation.dme
@@ -3719,6 +3719,7 @@
#include "monkestation\code\datums\votesounds.dm"
#include "monkestation\code\datums\announcers\duke_announcer.dm"
#include "monkestation\code\datums\brain_damage\mild.dm"
+#include "monkestation\code\datums\components\chain.dm"
#include "monkestation\code\datums\components\hot_ice.dm"
#include "monkestation\code\datums\components\pricetag.dm"
#include "monkestation\code\datums\components\strong_pull.dm"
diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm
index 911e2d2057c32..99b1913c30dc2 100644
--- a/code/modules/power/cable.dm
+++ b/code/modules/power/cable.dm
@@ -512,6 +512,10 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
full_w_class = WEIGHT_CLASS_SMALL
grind_results = list(/datum/reagent/copper = 2) //2 copper per cable in the coil
usesound = 'sound/items/deconstruct.ogg'
+ //MONKESTATION EDIT: The target when tethering two things together
+ var/atom/movable/tether_target
+ //MONKESTATION EDIT: A temporary tether before they attach the vehicle to the second thing
+ var/datum/component/chain/temp_tether
/obj/item/stack/cable_coil/cyborg
is_cyborg = 1
@@ -589,6 +593,32 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
amount += extra
update_icon()
+//MONKESTATION EDIT: Tethering people to vehicles
+/obj/item/stack/cable_coil/afterattack(atom/movable/target, mob/user)
+ if(!istype(target))
+ return ..()
+
+ if(!temp_tether)
+ tether_target = null
+
+ if(!tether_target)
+ if(istype(target, /obj/vehicle/ridden))
+ to_chat(user,"You tie one end of the cable around [target]")
+ tether_target = target
+ temp_tether = target.AddComponent(/datum/component/chain, user, 3)
+ return
+
+ user.visible_message("[user] begins tying the other end of the cable [target]","You begin tying the other end of the cable [target]")
+ if(do_after(user, 5 SECONDS, target=target))
+ target.AddComponent(/datum/component/chain, tether_target, 3)
+
+ use(1)
+
+ qdel(temp_tether)
+ temp_tether = null
+ tether_target = null
+
+
///////////////////////////////////////////////
diff --git a/monkestation/code/datums/components/chain.dm b/monkestation/code/datums/components/chain.dm
new file mode 100644
index 0000000000000..01a5c5336f0c7
--- /dev/null
+++ b/monkestation/code/datums/components/chain.dm
@@ -0,0 +1,89 @@
+
+/*
+This component attaches to things that'll follow another object
+Like connecting a person to a wheelchair so they get dragged behind it
+*/
+/datum/component/chain
+ //The thing the parent will follow
+ var/atom/movable/attachment_point
+
+ var/atom/movable/owner
+ var/max_dist
+
+ var/datum/beam/tether_beam
+
+/datum/component/chain/Initialize(target, max_dist=3)
+ if(!ismovableatom(parent) || !ismovableatom(target))
+ return COMPONENT_INCOMPATIBLE
+
+ owner = parent
+ attachment_point = target
+ src.max_dist = max_dist
+
+ tether_beam = owner.Beam(target, "usb_cable_beam", 'icons/obj/wiremod.dmi')
+
+ RegisterSignal(target, COMSIG_MOVABLE_PRE_MOVE, .proc/on_attachment_move)
+ RegisterSignal(owner, COMSIG_MOVABLE_PRE_MOVE, .proc/on_parent_move)
+ RegisterSignal(owner, COMSIG_ATOM_ATTACK_HAND, .proc/on_parent_touched)
+
+/datum/component/chain/Destroy(force, silent)
+ . = ..()
+ qdel(tether_beam)
+
+/datum/component/chain/proc/on_attachment_move(atom/movable/mover, newloc)
+ SIGNAL_HANDLER
+
+ if(!owner)
+ qdel(src)
+ return
+
+ if(owner.anchored)
+ return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
+
+ var/dist = get_dist(owner,newloc)
+ if(dist < max_dist)
+ return
+
+ owner.Move(get_step_towards(parent,mover))
+
+ if(isliving(owner))
+ var/mob/living/living_owner = owner
+ living_owner.Knockdown(1 SECONDS)
+
+ if(dist > max_dist)
+ owner.visible_message("The tether snaps!")
+ qdel(src)
+
+/datum/component/chain/proc/on_parent_move(atom/movable/mover, newloc)
+ SIGNAL_HANDLER
+
+ if(!attachment_point)
+ qdel(src)
+ return
+
+ if(attachment_point.anchored)
+ return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
+
+ var/dist = get_dist(attachment_point,newloc)
+ if(dist < max_dist)
+ return
+
+ if(dist >= max_dist)
+ var/mob/living/living_owner = owner
+ living_owner.Knockdown(1 SECONDS)
+ to_chat(owner,"You trip on the tether!")
+ return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
+
+/datum/component/chain/proc/on_parent_touched(datum/source, mob/user)
+ SIGNAL_HANDLER
+
+ INVOKE_ASYNC(src, .proc/untie_parent, user)
+
+/datum/component/chain/proc/untie_parent(mob/user)
+ if(user == owner)
+ user.visible_message("[user] begins untying the cable from \himself.","You begin untying the cable from yourself.")
+ else
+ user.visible_message("[user] begins untying the cable from [owner].","You begin untying the cable from [owner].")
+ if(do_mob(user, owner, 10 SECONDS))
+ qdel(src)
+
From 2c225dbfa3597f3d76e700a897f09d390876f23e Mon Sep 17 00:00:00 2001
From: Squalhardt <99915170+Oricana-16@users.noreply.github.com>
Date: Sat, 18 Feb 2023 17:09:45 -0500
Subject: [PATCH 2/7] fixes small logic errors
---
code/modules/power/cable.dm | 4 +--
monkestation/code/datums/components/chain.dm | 26 ++++++++++++++------
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm
index 99b1913c30dc2..9f899ea3709fc 100644
--- a/code/modules/power/cable.dm
+++ b/code/modules/power/cable.dm
@@ -609,11 +609,9 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
return
user.visible_message("[user] begins tying the other end of the cable [target]","You begin tying the other end of the cable [target]")
- if(do_after(user, 5 SECONDS, target=target))
+ if(do_after(user, 8 SECONDS, target=target))
target.AddComponent(/datum/component/chain, tether_target, 3)
-
use(1)
-
qdel(temp_tether)
temp_tether = null
tether_target = null
diff --git a/monkestation/code/datums/components/chain.dm b/monkestation/code/datums/components/chain.dm
index 01a5c5336f0c7..d2978fc93d4b6 100644
--- a/monkestation/code/datums/components/chain.dm
+++ b/monkestation/code/datums/components/chain.dm
@@ -25,6 +25,7 @@ Like connecting a person to a wheelchair so they get dragged behind it
RegisterSignal(target, COMSIG_MOVABLE_PRE_MOVE, .proc/on_attachment_move)
RegisterSignal(owner, COMSIG_MOVABLE_PRE_MOVE, .proc/on_parent_move)
RegisterSignal(owner, COMSIG_ATOM_ATTACK_HAND, .proc/on_parent_touched)
+ RegisterSignal(owner, COMSIG_ATOM_TOOL_ACT(TOOL_WIRECUTTER), .proc/on_parent_wirecutters)
/datum/component/chain/Destroy(force, silent)
. = ..()
@@ -37,13 +38,13 @@ Like connecting a person to a wheelchair so they get dragged behind it
qdel(src)
return
- if(owner.anchored)
- return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
-
var/dist = get_dist(owner,newloc)
if(dist < max_dist)
return
+ if(owner.anchored)
+ return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
+
owner.Move(get_step_towards(parent,mover))
if(isliving(owner))
@@ -61,14 +62,17 @@ Like connecting a person to a wheelchair so they get dragged behind it
qdel(src)
return
- if(attachment_point.anchored)
- return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
-
var/dist = get_dist(attachment_point,newloc)
if(dist < max_dist)
return
- if(dist >= max_dist)
+ if(attachment_point.anchored)
+ return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
+
+ if(dist > max_dist)
+ qdel(src)
+
+ if(dist == max_dist && isliving(owner))
var/mob/living/living_owner = owner
living_owner.Knockdown(1 SECONDS)
to_chat(owner,"You trip on the tether!")
@@ -87,3 +91,11 @@ Like connecting a person to a wheelchair so they get dragged behind it
if(do_mob(user, owner, 10 SECONDS))
qdel(src)
+/datum/component/chain/proc/on_parent_wirecutters(datum/source, mob/user)
+ SIGNAL_HANDLER
+
+ if(user == owner)
+ user.visible_message("[user] cuts \himself free.","You cut yourself free.")
+ else
+ user.visible_message("[user] cuts [owner] free.","[user] cuts you free] free.")
+ qdel(src)
From 3316d0f748f93dbe32900299281268c11ad72d3a Mon Sep 17 00:00:00 2001
From: Squalhardt <99915170+Oricana-16@users.noreply.github.com>
Date: Sun, 19 Feb 2023 12:37:10 -0500
Subject: [PATCH 3/7] Improves Logic
---
code/modules/power/cable.dm | 11 +++++++---
monkestation/code/datums/components/chain.dm | 23 +++++++++++++-------
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm
index 9f899ea3709fc..4874dc5f5b5fc 100644
--- a/code/modules/power/cable.dm
+++ b/code/modules/power/cable.dm
@@ -605,18 +605,23 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
if(istype(target, /obj/vehicle/ridden))
to_chat(user,"You tie one end of the cable around [target]")
tether_target = target
- temp_tether = target.AddComponent(/datum/component/chain, user, 3)
+ temp_tether = target.AddComponent(/datum/component/chain, user, 4)
return
user.visible_message("[user] begins tying the other end of the cable [target]","You begin tying the other end of the cable [target]")
if(do_after(user, 8 SECONDS, target=target))
- target.AddComponent(/datum/component/chain, tether_target, 3)
+ target.AddComponent(/datum/component/chain, tether_target, 4)
use(1)
qdel(temp_tether)
temp_tether = null
tether_target = null
-
+/obj/item/stack/cable_coil/dropped(mob/user)
+ . = ..()
+ if(temp_tether)
+ qdel(temp_tether)
+ temp_tether = null
+ tether_target = null
///////////////////////////////////////////////
diff --git a/monkestation/code/datums/components/chain.dm b/monkestation/code/datums/components/chain.dm
index d2978fc93d4b6..2d20d12e8bc81 100644
--- a/monkestation/code/datums/components/chain.dm
+++ b/monkestation/code/datums/components/chain.dm
@@ -9,16 +9,18 @@ Like connecting a person to a wheelchair so they get dragged behind it
var/atom/movable/owner
var/max_dist
+ var/equal_force
var/datum/beam/tether_beam
-/datum/component/chain/Initialize(target, max_dist=3)
+/datum/component/chain/Initialize(target, max_dist=3, equal_force = TRUE)
if(!ismovableatom(parent) || !ismovableatom(target))
return COMPONENT_INCOMPATIBLE
owner = parent
attachment_point = target
src.max_dist = max_dist
+ src.equal_force = equal_force
tether_beam = owner.Beam(target, "usb_cable_beam", 'icons/obj/wiremod.dmi')
@@ -42,10 +44,8 @@ Like connecting a person to a wheelchair so they get dragged behind it
if(dist < max_dist)
return
- if(owner.anchored)
- return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
-
- owner.Move(get_step_towards(parent,mover))
+ if(!owner.anchored)
+ owner.Move(get_step_towards(owner,mover))
if(isliving(owner))
var/mob/living/living_owner = owner
@@ -66,13 +66,19 @@ Like connecting a person to a wheelchair so they get dragged behind it
if(dist < max_dist)
return
+ if(dist > max_dist)
+ qdel(src)
+ return
+
if(attachment_point.anchored)
return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
- if(dist > max_dist)
- qdel(src)
+ attachment_point.Move(get_step_towards(attachment_point,mover))
- if(dist == max_dist && isliving(owner))
+ if(equal_force)
+ return
+
+ if(isliving(owner))
var/mob/living/living_owner = owner
living_owner.Knockdown(1 SECONDS)
to_chat(owner,"You trip on the tether!")
@@ -99,3 +105,4 @@ Like connecting a person to a wheelchair so they get dragged behind it
else
user.visible_message("[user] cuts [owner] free.","[user] cuts you free] free.")
qdel(src)
+ return COMPONENT_BLOCK_TOOL_ATTACK
From b90bb35a7cf2d448cf54ff43a2722324173deccb Mon Sep 17 00:00:00 2001
From: Squalhardt <99915170+Oricana-16@users.noreply.github.com>
Date: Sun, 19 Feb 2023 14:21:50 -0500
Subject: [PATCH 4/7] Tethering works on all vehicles (clown car :D )
---
code/modules/power/cable.dm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm
index 4874dc5f5b5fc..60b8d08ae7bef 100644
--- a/code/modules/power/cable.dm
+++ b/code/modules/power/cable.dm
@@ -602,7 +602,7 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
tether_target = null
if(!tether_target)
- if(istype(target, /obj/vehicle/ridden))
+ if(istype(target, /obj/vehicle))
to_chat(user,"You tie one end of the cable around [target]")
tether_target = target
temp_tether = target.AddComponent(/datum/component/chain, user, 4)
From 532531dfb64529c0616bcc023e6c695e65fae328 Mon Sep 17 00:00:00 2001
From: Squalhardt <99915170+Oricana-16@users.noreply.github.com>
Date: Sun, 19 Feb 2023 22:20:27 -0500
Subject: [PATCH 5/7] Beam Tweaks
---
code/modules/power/cable.dm | 3 ++-
monkestation/code/datums/components/chain.dm | 22 +++++++++++++++++---
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm
index 60b8d08ae7bef..7b5ccfb3b1fdf 100644
--- a/code/modules/power/cable.dm
+++ b/code/modules/power/cable.dm
@@ -598,8 +598,9 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
if(!istype(target))
return ..()
- if(!temp_tether)
+ if(QDELETED(temp_tether))
tether_target = null
+ temp_tether = null
if(!tether_target)
if(istype(target, /obj/vehicle))
diff --git a/monkestation/code/datums/components/chain.dm b/monkestation/code/datums/components/chain.dm
index 2d20d12e8bc81..1403643b7671a 100644
--- a/monkestation/code/datums/components/chain.dm
+++ b/monkestation/code/datums/components/chain.dm
@@ -13,7 +13,7 @@ Like connecting a person to a wheelchair so they get dragged behind it
var/datum/beam/tether_beam
-/datum/component/chain/Initialize(target, max_dist=3, equal_force = TRUE)
+/datum/component/chain/Initialize(target, max_dist=3, equal_force = TRUE, draw_beam = TRUE)
if(!ismovableatom(parent) || !ismovableatom(target))
return COMPONENT_INCOMPATIBLE
@@ -22,16 +22,31 @@ Like connecting a person to a wheelchair so they get dragged behind it
src.max_dist = max_dist
src.equal_force = equal_force
- tether_beam = owner.Beam(target, "usb_cable_beam", 'icons/obj/wiremod.dmi')
+ if(draw_beam)
+ tether_beam = owner.Beam(target, "usb_cable_beam", 'icons/obj/wiremod.dmi', maxdistance = max_dist+1)
RegisterSignal(target, COMSIG_MOVABLE_PRE_MOVE, .proc/on_attachment_move)
RegisterSignal(owner, COMSIG_MOVABLE_PRE_MOVE, .proc/on_parent_move)
RegisterSignal(owner, COMSIG_ATOM_ATTACK_HAND, .proc/on_parent_touched)
RegisterSignal(owner, COMSIG_ATOM_TOOL_ACT(TOOL_WIRECUTTER), .proc/on_parent_wirecutters)
+ if(draw_beam)
+ RegisterSignal(owner, COMSIG_MOVABLE_MOVED, .proc/on_atom_moved)
+ RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/on_atom_moved)
+
/datum/component/chain/Destroy(force, silent)
. = ..()
- qdel(tether_beam)
+ if(tether_beam)
+ qdel(tether_beam)
+ tether_beam = null
+ owner = null
+ attachment_point = null
+
+/datum/component/chain/proc/on_atom_moved(atom/movable/mover, old_loc, movement_dir, forced, old_locs, momentum_change)
+ SIGNAL_HANDLER
+
+ spawn(0)
+ tether_beam.recalculate()
/datum/component/chain/proc/on_attachment_move(atom/movable/mover, newloc)
SIGNAL_HANDLER
@@ -54,6 +69,7 @@ Like connecting a person to a wheelchair so they get dragged behind it
if(dist > max_dist)
owner.visible_message("The tether snaps!")
qdel(src)
+ return
/datum/component/chain/proc/on_parent_move(atom/movable/mover, newloc)
SIGNAL_HANDLER
From cd63a6256d43f7c56139e8b06990e5642fef80ab Mon Sep 17 00:00:00 2001
From: Squalhardt <99915170+Oricana-16@users.noreply.github.com>
Date: Mon, 20 Feb 2023 01:53:46 -0500
Subject: [PATCH 6/7] Adds proximity check on cable
---
code/modules/power/cable.dm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm
index 7b5ccfb3b1fdf..e1679644dd808 100644
--- a/code/modules/power/cable.dm
+++ b/code/modules/power/cable.dm
@@ -594,7 +594,10 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
update_icon()
//MONKESTATION EDIT: Tethering people to vehicles
-/obj/item/stack/cable_coil/afterattack(atom/movable/target, mob/user)
+/obj/item/stack/cable_coil/afterattack(atom/movable/target, mob/user, proximity_flag)
+ if(!proximity_flag)
+ return
+
if(!istype(target))
return ..()
From 3b265170941f402aca4b68898ccbbd3203fc8f41 Mon Sep 17 00:00:00 2001
From: Squalhardt <99915170+Oricana-16@users.noreply.github.com>
Date: Wed, 1 Mar 2023 22:59:01 -0500
Subject: [PATCH 7/7] Small Tweak. untying from wheelchair.
---
code/modules/power/cable.dm | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm
index e1679644dd808..5b34fe1f5859e 100644
--- a/code/modules/power/cable.dm
+++ b/code/modules/power/cable.dm
@@ -605,6 +605,13 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
tether_target = null
temp_tether = null
+ if(target == tether_target)
+ to_chat(user,"You untie the cable from [target].")
+ qdel(temp_tether)
+ tether_target = null
+ temp_tether = null
+ return
+
if(!tether_target)
if(istype(target, /obj/vehicle))
to_chat(user,"You tie one end of the cable around [target]")