diff --git a/code/datums/components/chasm.dm b/code/datums/components/chasm.dm index 475d588f65e..effdf308e8b 100644 --- a/code/datums/components/chasm.dm +++ b/code/datums/components/chasm.dm @@ -82,13 +82,14 @@ if((!ismob(M.buckled) || (buckled_to.buckled != M)) && !droppable(M.buckled)) return FALSE if(ishuman(AM)) - var/mob/living/carbon/human/H = AM - if(istype(H.belt, /obj/item/wormhole_jaunter)) - var/obj/item/wormhole_jaunter/J = H.belt - //To freak out any bystanders - H.visible_message(span_boldwarning("[H] falls into [parent]!")) - J.chasm_react(H) - return FALSE + var/mob/living/carbon/human/victim = AM + if(istype(victim.belt, /obj/item/wormhole_jaunter)) + var/obj/item/wormhole_jaunter/jaunter = victim.belt + var/turf/chasm = get_turf(victim) + var/fall_into_chasm = jaunter.chasm_react(victim) + if(!fall_into_chasm) + chasm.visible_message(span_boldwarning("[victim] falls into the [chasm]!")) //To freak out any bystanders + return fall_into_chasm return TRUE /datum/component/chasm/proc/drop(atom/movable/AM) diff --git a/code/modules/mining/equipment/wormhole_jaunter.dm b/code/modules/mining/equipment/wormhole_jaunter.dm index 66be7ab1550..438ea5d8063 100644 --- a/code/modules/mining/equipment/wormhole_jaunter.dm +++ b/code/modules/mining/equipment/wormhole_jaunter.dm @@ -20,13 +20,14 @@ activate(user, TRUE) /obj/item/wormhole_jaunter/proc/turf_check(mob/user) - var/turf/device_turf = get_turf(user) + var/turf/device_turf = get_turf(src) if(!device_turf || is_centcom_level(device_turf.z) || is_reserved_level(device_turf.z)) - to_chat(user, span_notice("You're having difficulties getting the [src.name] to work.")) + if(user) + to_chat(user, span_notice("You're having difficulties getting the [src.name] to work.")) return FALSE return TRUE -/obj/item/wormhole_jaunter/proc/get_destinations(mob/user) +/obj/item/wormhole_jaunter/proc/get_destinations() var/list/destinations = list() for(var/obj/item/beacon/B in GLOB.teleportbeacons) @@ -36,47 +37,61 @@ return destinations -/obj/item/wormhole_jaunter/proc/activate(mob/user, adjacent) - if(!turf_check(user)) - return +/obj/item/wormhole_jaunter/proc/can_jaunter_teleport() + var/list/destinations = get_destinations() + return destinations.len > 0 + +/obj/item/wormhole_jaunter/proc/activate(mob/user, adjacent, teleport) + if(!turf_check(user)) + return FALSE + + if(!can_jaunter_teleport()) + if(user) + to_chat(user, span_notice("\The [src] found no beacons in the world to anchor a wormhole to.")) + else + visible_message(span_notice("\The [src] found no beacons in the world to anchor a wormhole to!")) + return TRUE // used for chasm code + + var/list/destinations = get_destinations() + var/chosen_beacon = pick(destinations) + + var/obj/effect/portal/jaunt_tunnel/tunnel = new (get_turf(src), 100, null, FALSE, get_turf(chosen_beacon)) + if(teleport) + tunnel.teleport(user) + else if(adjacent) + try_move_adjacent(tunnel) - var/list/L = get_destinations(user) - if(!L.len) - to_chat(user, span_notice("The [src.name] found no beacons in the world to anchor a wormhole to.")) - return - var/chosen_beacon = pick(L) - var/obj/effect/portal/jaunt_tunnel/J = new (get_turf(src), 100, null, FALSE, get_turf(chosen_beacon)) - if(adjacent) - try_move_adjacent(J) playsound(src,'sound/effects/sparks4.ogg',50,TRUE) qdel(src) + return FALSE // used for chasm code /obj/item/wormhole_jaunter/emp_act(power) . = ..() if(. & EMP_PROTECT_SELF) return - var/mob/M = loc - if(istype(M)) - var/triggered = FALSE - if(M.get_item_by_slot(ITEM_SLOT_BELT) == src) - if(power == 1) - triggered = TRUE - else if(power == 2 && prob(50)) - triggered = TRUE + var/triggered = FALSE + if(power == 1) + triggered = TRUE + else if(power == 2 && prob(50)) + triggered = TRUE - if(triggered) - M.visible_message(span_warning("[src] overloads and activates!")) - SSblackbox.record_feedback("tally", "jaunter", 1, "EMP") // EMP accidental activation - activate(M) + var/mob/M = loc + if(istype(M) && triggered) + M.visible_message(span_warning("Your [src.name] overloads and activates!")) + SSblackbox.record_feedback("tally", "jaunter", 1, "EMP") // EMP accidental activation + activate(M, FALSE, TRUE) + else if(triggered) + visible_message(span_warning("\The [src] overloads and activates!")) + activate() /obj/item/wormhole_jaunter/proc/chasm_react(mob/user) - if(user.get_item_by_slot(ITEM_SLOT_BELT) == src) - to_chat(user, span_notice("Your [name] activates, saving you from the chasm!")) + var/fall_into_chasm = activate(user, FALSE, TRUE) + + if(!fall_into_chasm) + to_chat(user, span_notice("Your [src.name] activates, saving you from the chasm!")) SSblackbox.record_feedback("tally", "jaunter", 1, "Chasm") // chasm automatic activation - activate(user, FALSE) - else - to_chat(user, span_userdanger("[src] is not attached to your belt, preventing it from saving you from the chasm. RIP.")) + return fall_into_chasm //jaunter tunnel /obj/effect/portal/jaunt_tunnel