diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 7933fab83f..e8c02fd05d 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -455,6 +455,10 @@ // /datum/mutation signals #define COMSIG_HUMAN_MUTATION_LOSS "human_mutation_loss" //from datum/mutation/human/on_losing(): (datum/mutation/human/lost_mutation) +///from base of mob/living/death(): (gibbed) +// Sent before any of the other death code has run, mob is still alive. +#define COMSIG_LIVING_PREDEATH "living_predeath" + /*******Component Specific Signals*******/ //Janitor #define COMSIG_TURF_IS_WET "check_turf_wet" //(): Returns bitflags of wet values. diff --git a/code/game/objects/items/implants/implant_deathrattle.dm b/code/game/objects/items/implants/implant_deathrattle.dm new file mode 100644 index 0000000000..826dc71843 --- /dev/null +++ b/code/game/objects/items/implants/implant_deathrattle.dm @@ -0,0 +1,74 @@ +/datum/deathrattle_group + var/name + var/list/datum/weakref/implant_refs = list() + +/datum/deathrattle_group/New() + // Give the group a unique name for debugging, and possible future + // use for making custom linked groups. + name = "[rand(100,999)] [pick(GLOB.phonetic_alphabet)]" + +/datum/deathrattle_group/proc/rattle(obj/item/implant/deathrattle/origin, mob/living/owner) + var/name = owner.mind ? owner.mind.name : owner.real_name + var/area = get_area_name(get_turf(owner)) + + for(var/r in implant_refs) + var/datum/weakref/R = r + + var/obj/item/implant/deathrattle/implant = R.resolve() + if(!implant || implant == origin) + continue + + // Not all the implants may be actually implanted in people. + if(!implant.imp_in) + continue + + // Deliberately the same message framing as nanite message + ghost deathrattle + var/mob/living/recipient = implant.imp_in + to_chat(recipient, "You hear a strange, robotic voice in your head... \"[name] has died at [area].\"") + SEND_SOUND(recipient, pick( + 'sound/items/knell1.ogg', + 'sound/items/knell2.ogg', + 'sound/items/knell3.ogg', + 'sound/items/knell4.ogg', + )) + +/datum/deathrattle_group/proc/register(obj/item/implant/deathrattle/implant) + implant.group = src + implant_refs += WEAKREF(implant) + + +/obj/item/implant/deathrattle + name = "deathrattle implant" + desc = "Hope no one else dies, prepare for when they do." + + activated = FALSE + + var/datum/deathrattle_group/group = null + +/obj/item/implant/deathrattle/Destroy() + group = null + return ..() + +/obj/item/implant/deathrattle/can_be_implanted_in(mob/living/target) + // Can be implanted in anything that's a mob. Syndicate cyborgs, talking fish, humans... + return TRUE + +/obj/item/implant/deathrattle/proc/on_predeath(datum/source, gibbed) + SIGNAL_HANDLER + + if(group) + group.rattle(origin = src, owner = source) + +/obj/item/implant/deathrattle/implant(mob/living/target, mob/user, silent = FALSE, force = FALSE) + . = ..() + if(.) + RegisterSignal(target, COMSIG_LIVING_PREDEATH, .proc/on_predeath) + + if(!group) + to_chat(target, "You hear a strange, robotic voice in your head... \"Warning: No other linked implants detected.\"") + + +/obj/item/implantcase/deathrattle + name = "implant case - 'Deathrattle'" + desc = "A glass case containing a deathrattle implant." + imp_type = /obj/item/implant/deathrattle diff --git a/code/game/objects/items/storage/uplink_kits.dm b/code/game/objects/items/storage/uplink_kits.dm index 941ba869bb..f25f6f3a51 100644 --- a/code/game/objects/items/storage/uplink_kits.dm +++ b/code/game/objects/items/storage/uplink_kits.dm @@ -546,3 +546,21 @@ . = ..() new /obj/item/cardpack/syndicate(src) new /obj/item/cardpack/syndicate(src) + +/obj/item/storage/box/syndie_kit/imp_deathrattle + name = "deathrattle implant box" + desc = "Contains eight linked deathrattle implants." + +/obj/item/storage/box/syndie_kit/imp_deathrattle/PopulateContents() + new /obj/item/implanter(src) + + var/datum/deathrattle_group/group = new + + var/implants = list() + for(var/j in 1 to 8) + var/obj/item/implantcase/deathrattle/case = new (src) + implants += case.imp + + for(var/i in implants) + group.register(i) + desc += " The implants are registered to the \"[group.name]\" group." diff --git a/code/modules/mob/living/death.dm b/code/modules/mob/living/death.dm index 5fd52975e0..2d529e976a 100644 --- a/code/modules/mob/living/death.dm +++ b/code/modules/mob/living/death.dm @@ -55,6 +55,8 @@ /mob/living/death(gibbed) + SEND_SIGNAL(src, COMSIG_LIVING_PREDEATH, gibbed) + stat = DEAD unset_machine() timeofdeath = world.time diff --git a/code/modules/uplink/uplink_items/uplink_implants.dm b/code/modules/uplink/uplink_items/uplink_implants.dm index 4839c96a2d..19dab96ccb 100644 --- a/code/modules/uplink/uplink_items/uplink_implants.dm +++ b/code/modules/uplink/uplink_items/uplink_implants.dm @@ -22,6 +22,17 @@ cost = 12 include_modes = list(/datum/game_mode/nuclear, /datum/game_mode/nuclear/clown_ops) +/datum/uplink_item/implants/deathrattle + name = "Box of Deathrattle Implants" + desc = "A collection of implants (and one reusable implanter) that should be injected into the team. When one of the team \ + dies, all other implant holders recieve a mental message informing them of their teammates' name \ + and the location of their death. Unlike most implants, these are designed to be implanted \ + in any creature, biological or mechanical." + item = /obj/item/storage/box/syndie_kit/imp_deathrattle + cost = 4 + surplus = 0 + include_modes = list(/datum/game_mode/nuclear, /datum/game_mode/nuclear/clown_ops) + /datum/uplink_item/implants/freedom name = "Freedom Implant" desc = "An implant injected into the body and later activated at the user's will. It will attempt to free the \ diff --git a/sound/items/knell1.ogg b/sound/items/knell1.ogg new file mode 100644 index 0000000000..3612ba651f Binary files /dev/null and b/sound/items/knell1.ogg differ diff --git a/sound/items/knell2.ogg b/sound/items/knell2.ogg new file mode 100644 index 0000000000..58a7531e3c Binary files /dev/null and b/sound/items/knell2.ogg differ diff --git a/sound/items/knell3.ogg b/sound/items/knell3.ogg new file mode 100644 index 0000000000..e5c4f3944d Binary files /dev/null and b/sound/items/knell3.ogg differ diff --git a/sound/items/knell4.ogg b/sound/items/knell4.ogg new file mode 100644 index 0000000000..cf30f2837b Binary files /dev/null and b/sound/items/knell4.ogg differ diff --git a/tgstation.dme b/tgstation.dme index f59457ed2f..b8c87ede3e 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1187,6 +1187,7 @@ #include "code\game\objects\items\implants\implant_abductor.dm" #include "code\game\objects\items\implants\implant_chem.dm" #include "code\game\objects\items\implants\implant_clown.dm" +#include "code\game\objects\items\implants\implant_deathrattle.dm" #include "code\game\objects\items\implants\implant_exile.dm" #include "code\game\objects\items\implants\implant_explosive.dm" #include "code\game\objects\items\implants\implant_freedom.dm"