mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-10 07:41:16 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
107 lines
4.2 KiB
Plaintext
107 lines
4.2 KiB
Plaintext
/obj/item/swapper
|
|
name = "quantum spin inverter"
|
|
desc = "An experimental device that is able to swap the locations of two entities by switching their particles' spin values. Must be linked to another device to function."
|
|
icon = 'icons/obj/mining_zones/artefacts.dmi'
|
|
icon_state = "swapper"
|
|
inhand_icon_state = "electronic"
|
|
w_class = WEIGHT_CLASS_SMALL
|
|
item_flags = NOBLUDGEON
|
|
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
|
|
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
|
|
interaction_flags_click = NEED_DEXTERITY|ALLOW_RESTING
|
|
/// Cooldown for usage
|
|
var/cooldown = 30 SECONDS
|
|
/// Next available time
|
|
var/next_use = 0
|
|
/// Swapper linked to this obj
|
|
var/obj/item/swapper/linked_swapper
|
|
|
|
/obj/item/swapper/Destroy()
|
|
if(linked_swapper)
|
|
linked_swapper.linked_swapper = null //*inception music*
|
|
linked_swapper.update_appearance()
|
|
linked_swapper = null
|
|
return ..()
|
|
|
|
/obj/item/swapper/update_icon_state()
|
|
icon_state = "swapper[linked_swapper ? "-linked" : null]"
|
|
return ..()
|
|
|
|
/obj/item/swapper/attackby(obj/item/I, mob/user, list/modifiers, list/attack_modifiers)
|
|
if(istype(I, /obj/item/swapper))
|
|
var/obj/item/swapper/other_swapper = I
|
|
if(other_swapper.linked_swapper)
|
|
to_chat(user, span_warning("[other_swapper] is already linked. Break the current link to establish a new one."))
|
|
return
|
|
if(linked_swapper)
|
|
to_chat(user, span_warning("[src] is already linked. Break the current link to establish a new one."))
|
|
return
|
|
to_chat(user, span_notice("You establish a quantum link between the two devices."))
|
|
linked_swapper = other_swapper
|
|
other_swapper.linked_swapper = src
|
|
update_appearance()
|
|
linked_swapper.update_appearance()
|
|
else
|
|
return ..()
|
|
|
|
/obj/item/swapper/attack_self(mob/living/user)
|
|
if(world.time < next_use)
|
|
to_chat(user, span_warning("[src] is still recharging."))
|
|
return
|
|
//SKYRAT EDIT BEGIN
|
|
var/turf/my_turf = get_turf(src)
|
|
if(is_away_level(my_turf.z))
|
|
to_chat(user, "<span class='warning'>[src] cannot be used here!</span>")
|
|
return
|
|
//SKYRAT EDIT END
|
|
if(QDELETED(linked_swapper))
|
|
to_chat(user, span_warning("[src] is not linked with another swapper."))
|
|
return
|
|
playsound(src, 'sound/items/weapons/flash.ogg', 25, TRUE)
|
|
to_chat(user, span_notice("You activate [src]."))
|
|
playsound(linked_swapper, 'sound/items/weapons/flash.ogg', 25, TRUE)
|
|
if(ismob(linked_swapper.loc))
|
|
var/mob/holder = linked_swapper.loc
|
|
to_chat(holder, span_notice("[linked_swapper] starts buzzing."))
|
|
next_use = world.time + cooldown //only the one used goes on cooldown
|
|
addtimer(CALLBACK(src, PROC_REF(swap), user), 2.5 SECONDS)
|
|
|
|
/obj/item/swapper/examine(mob/user)
|
|
. = ..()
|
|
if(world.time < next_use)
|
|
. += span_warning("Time left to recharge: [DisplayTimeText(next_use - world.time)].")
|
|
if(linked_swapper)
|
|
. += span_notice("<b>Linked.</b> Alt-Click to break the quantum link.")
|
|
else
|
|
. += span_notice("<b>Not Linked.</b> Use on another quantum spin inverter to establish a quantum link.")
|
|
|
|
/obj/item/swapper/click_alt(mob/living/user)
|
|
to_chat(user, span_notice("You break the current quantum link."))
|
|
if(!QDELETED(linked_swapper))
|
|
linked_swapper.linked_swapper = null
|
|
linked_swapper.update_appearance()
|
|
linked_swapper = null
|
|
update_appearance()
|
|
return CLICK_ACTION_SUCCESS
|
|
|
|
/**
|
|
* Swaps two atoms following the activation of a swapper item.
|
|
* If a mob is holding a swapper, it will carry the mob as-per the rules of do_teleport().
|
|
*/
|
|
/obj/item/swapper/proc/swap(mob/user)
|
|
if(QDELETED(linked_swapper) || isnull(linked_swapper.loc) || world.time < linked_swapper.cooldown)
|
|
return
|
|
|
|
var/atom/movable/container_A = get_teleportable_container(src)
|
|
var/atom/movable/container_B = get_teleportable_container(linked_swapper)
|
|
var/target_A = container_A.drop_location()
|
|
var/target_B = container_B.drop_location()
|
|
|
|
playsound(target_A, 'sound/effects/swapper/swap_a.ogg', 30, TRUE)
|
|
playsound(target_B, 'sound/effects/swapper/swap_b.ogg', 30, TRUE)
|
|
if(do_teleport(container_A, target_B, channel = TELEPORT_CHANNEL_QUANTUM))
|
|
do_teleport(container_B, target_A, channel = TELEPORT_CHANNEL_QUANTUM)
|
|
if(ismob(container_B))
|
|
var/mob/swapped_mob = container_B
|
|
to_chat(swapped_mob, span_warning("[linked_swapper] activates, and you find yourself somewhere else."))
|