From 84c55f0a4c58dcd692672d65e1f4c7df9de0d3f0 Mon Sep 17 00:00:00 2001 From: Raeschen Date: Mon, 4 Apr 2022 17:56:26 +0200 Subject: [PATCH] Change fail behavior 5% to a random teleport within 10 tiles --- .../objects/items/weapons/teleportation.dm | 4 ++-- .../objects/items/weapons/teleportation_ch.dm | 21 +++++++++++++++++++ vorestation.dme | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 code/game/objects/items/weapons/teleportation_ch.dm diff --git a/code/game/objects/items/weapons/teleportation.dm b/code/game/objects/items/weapons/teleportation.dm index c1ad302407..d364edeecc 100644 --- a/code/game/objects/items/weapons/teleportation.dm +++ b/code/game/objects/items/weapons/teleportation.dm @@ -175,8 +175,8 @@ Frequency: for(var/mob/O in hearers(user, null)) O.show_message("Locked In.", 2) var/obj/effect/portal/P = new /obj/effect/portal( get_turf(src) ) - P.target = T + P.failchance = 0 //CHOMPEdit : we make our own failchance + P.target = handle_fail(T) //CHOMPEdit P.creator = src - P.failchance = 0 //CHOMPEdit : funny 5% chance to be spaced and die makes the hand tele kinda useless. src.add_fingerprint(user) return diff --git a/code/game/objects/items/weapons/teleportation_ch.dm b/code/game/objects/items/weapons/teleportation_ch.dm new file mode 100644 index 0000000000..e1bcbcf339 --- /dev/null +++ b/code/game/objects/items/weapons/teleportation_ch.dm @@ -0,0 +1,21 @@ +//Handle the failchance of a hand tele +//Default action is to randomise you in space. +//This proc allows custom actions. +/obj/item/weapon/hand_tele/proc/handle_fail(var/target) + + // Failure + if(prob(5) || !target) + + var/list/turfs = list( ) + for(var/turf/T in orange(10)) + if(T.x>world.maxx-8 || T.x<8) continue //putting them at the edge is dumb + if(T.y>world.maxy-8 || T.y<8) continue + if(T.block_tele) continue + turfs += T + + target = pick(turfs) + return target + + // Success + else + return target \ No newline at end of file diff --git a/vorestation.dme b/vorestation.dme index de599fdda0..65bf55abf6 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -1362,6 +1362,7 @@ #include "code\game\objects\items\weapons\tape.dm" #include "code\game\objects\items\weapons\taskmanager_ch.dm" #include "code\game\objects\items\weapons\teleportation.dm" +#include "code\game\objects\items\weapons\teleportation_ch.dm" #include "code\game\objects\items\weapons\towels.dm" #include "code\game\objects\items\weapons\traps.dm" #include "code\game\objects\items\weapons\traps_vr.dm"