diff --git a/code/datums/brain_damage/special.dm b/code/datums/brain_damage/special.dm index c743bf200da..c2c644fba41 100644 --- a/code/datums/brain_damage/special.dm +++ b/code/datums/brain_damage/special.dm @@ -120,6 +120,87 @@ user.visible_message("[user] [slip_in_message].", null, null, null, user) user.visible_message("[user] [slip_out_message].", "...and find your way to the other side.") +/datum/brain_trauma/special/quantum_alignment + name = "Quantum Alignment" + desc = "Patient is prone to frequent spontaneous quantum entanglement, against all odds, causing spatial anomalies." + scan_desc = "quantum alignment" + gain_text = "You feel faintly connected to everything around you..." + lose_text = "You no longer feel connected to your surroundings." + var/atom/linked_target = null + var/linked = FALSE + var/returning = FALSE + var/snapback_time = 0 + +/datum/brain_trauma/special/quantum_alignment/on_life() + if(linked) + if(QDELETED(linked_target)) + linked_target = null + linked = FALSE + else if(!returning && world.time > snapback_time) + start_snapback() + return + if(prob(4)) + try_entangle() + +/datum/brain_trauma/special/quantum_alignment/proc/try_entangle() + //Check for pulled mobs + if(ismob(owner.pulling)) + entangle(owner.pulling) + return + //Check for adjacent mobs + for(var/mob/living/L in oview(1, owner)) + if(owner.Adjacent(L)) + entangle(L) + return + //Check for pulled objects + if(isobj(owner.pulling)) + entangle(owner.pulling) + return + + //Check main hand + var/obj/item/held_item = owner.get_active_held_item() + if(held_item && !(HAS_TRAIT(held_item, TRAIT_NODROP))) + entangle(held_item) + return + + //Check off hand + held_item = owner.get_inactive_held_item() + if(held_item && !(HAS_TRAIT(held_item, TRAIT_NODROP))) + entangle(held_item) + return + + //Just entangle with the turf + entangle(get_turf(owner)) + +/datum/brain_trauma/special/quantum_alignment/proc/entangle(atom/target) + to_chat(owner, "You start feeling a strong sense of connection to [target].") + linked_target = target + linked = TRUE + snapback_time = world.time + rand(450, 6000) + +/datum/brain_trauma/special/quantum_alignment/proc/start_snapback() + if(QDELETED(linked_target)) + linked_target = null + linked = FALSE + return + to_chat(owner, "Your connection to [linked_target] suddenly feels extremely strong... you can feel it pulling you!") + owner.playsound_local(owner, 'sound/magic/lightning_chargeup.ogg', 75, FALSE) + returning = TRUE + addtimer(CALLBACK(src, .proc/snapback), 100) + +/datum/brain_trauma/special/quantum_alignment/proc/snapback() + returning = FALSE + if(QDELETED(linked_target)) + to_chat(owner, "The connection fades abruptly, and the pull with it.") + linked_target = null + linked = FALSE + return + to_chat(owner, "You're pulled through spacetime!") + do_teleport(owner, get_turf(linked_target), null, TRUE, channel = TELEPORT_CHANNEL_QUANTUM) + owner.playsound_local(owner, 'sound/magic/repulse.ogg', 100, FALSE) + linked_target = null + linked = FALSE + /datum/brain_trauma/special/psychotic_brawling name = "Violent Psychosis" desc = "Patient fights in unpredictable ways, ranging from helping his target to hitting them with brutal strength."