diff --git a/code/datums/components/killerqueen.dm b/code/datums/components/killerqueen.dm new file mode 100644 index 0000000000..9930b0d3ac --- /dev/null +++ b/code/datums/components/killerqueen.dm @@ -0,0 +1,91 @@ +/** + * KILLER QUEEN + * + * Simple contact bomb component + * Blows up the first person to touch it. + */ +/datum/component/killerqueen + can_transfer = TRUE + /// strength of explosion on the touch-er. 0 to disable. usually only used if the normal explosion is disabled (this is the default). + var/ex_strength = EXPLODE_HEAVY + /// callback to invoke with (parent, victim) before standard detonation - useful for losing a reference to this component or implementing custom behavior. return FALSE to prevent explosion. + var/datum/callback/pre_explode + /// callback to invoke with (parent) when deleting without an explosion + var/datum/callback/failure + /// did we explode + var/exploded = FALSE + /// examine message + var/examine_message + /// light explosion radius + var/light = 0 + /// heavy explosion radius + var/heavy = 0 + /// dev explosion radius + var/dev = 0 + /// flame explosion radius + var/flame = 0 + /// only triggered by living mobs + var/living_only = TRUE + + +/datum/component/killerqueen/Initialize(ex_strength = EXPLODE_HEAVY, datum/callback/pre_explode, datum/callback/failure, examine_message, light = 0, heavy = 0, dev = 0, flame = 0, living_only = TRUE) + . = ..() + if(. & COMPONENT_INCOMPATIBLE) + return + if(!isatom(parent)) + return COMPONENT_INCOMPATIBLE + src.ex_strength = ex_strength + src.pre_explode = pre_explode + src.failure = failure + src.examine_message = examine_message + src.light = light + src.heavy = heavy + src.dev = dev + src.flame = flame + src.living_only = living_only + +/datum/component/killerqueen/Destroy() + if(!exploded) + failure.Invoke(parent) + return ..() + +/datum/component/killerqueen/RegisterWithParent() + . = ..() + RegisterSignal(parent, list(COMSIG_ATOM_ATTACK_HAND, COMSIG_ATOM_ATTACK_PAW, COMSIG_ATOM_ATTACK_ANIMAL), .proc/touch_detonate) + RegisterSignal(parent, COMSIG_MOVABLE_BUMP, .proc/bump_detonate) + RegisterSignal(parent, COMSIG_PARENT_ATTACKBY, .proc/attackby_detonate) + RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/on_examine) + +/datum/component/killerqueen/UnregisterFromParent() + . = ..() + UnregisterSignal(parent, list(COMSIG_ATOM_ATTACK_ANIMAL, COMSIG_ATOM_ATTACK_HAND, COMSIG_ATOM_ATTACK_PAW, + COMSIG_MOVABLE_BUMP, COMSIG_PARENT_ATTACKBY, COMSIG_PARENT_EXAMINE)) + +/datum/component/killerqueen/proc/attackby_detonate(datum/source, obj/item/I, mob/user) + detonate(user) + +/datum/component/killerqueen/proc/bump_detonate(datum/source, atom/A) + detonate(user) + +/datum/component/killerqueen/proc/touch_detonate(datum/source, mob/user) + detonate(user) + +/datum/component/killerqueen/proc/on_examine(datum/source, list/examine_return) + if(examine_message) + examine_return += examine_message + +/datum/component/killerqueen/proc/detonate(atom/victim) + if(!isliving(victim) && living_only) + return + if(pre_explode && !pre_explode.Invoke(parent, victim)) + return + if(ex_strength) + victim.ex_act(ex_strength) + if(light || heavy || dev || flame) + explosion(parent, dev, heavy, light, flame_range = flame) + else + var/turf/T = get_turf(parent) + playsound(T, 'sound/effects/explosion2.ogg', 200, 1) + new /obj/effect/temp_visual/explosion(T) + exploded = TRUE + qdel(src) diff --git a/code/modules/mob/living/simple_animal/guardian/types/explosive.dm b/code/modules/mob/living/simple_animal/guardian/types/explosive.dm index d396434708..4f44a51b32 100644 --- a/code/modules/mob/living/simple_animal/guardian/types/explosive.dm +++ b/code/modules/mob/living/simple_animal/guardian/types/explosive.dm @@ -36,61 +36,20 @@ return if(isobj(A) && Adjacent(A)) if(bomb_cooldown <= world.time && !stat) - var/obj/guardian_bomb/B = new /obj/guardian_bomb(get_turf(A)) + var/datum/component/killerqueen/K = A.AddComponent(/datum/component/killerqueen, CALLBACK(src, .proc/on_explode), CALLBACK(src, .proc/on_failure), \ + examine_message = "It glows with a strange light!")) + QDEL_IN(K, 1 MINUTES) to_chat(src, "Success! Bomb armed!") bomb_cooldown = world.time + 200 - B.spawner = src - B.disguise(A) else to_chat(src, "Your powers are on cooldown! You must wait 20 seconds between bombs.") -/obj/guardian_bomb - name = "bomb" - desc = "You shouldn't be seeing this!" - var/obj/stored_obj - var/mob/living/simple_animal/hostile/guardian/spawner +/mob/living/simple_animal/hostile/guardian/bomb/proc/on_explode(atom/bomb, atom/victim) + if((victim == src) || (victim == summoner) || (hasmatchingsummoner(victim))) + to_chat(victim, "[src] glows with a strange light, and you don't touch it.") + return FALSE + to_chat(spawner, "One of your explosive traps caught [victim]!") + to_chat(victim, "[bomb] was boobytrapped!") - -/obj/guardian_bomb/proc/disguise(obj/A) - A.forceMove(src) - stored_obj = A - opacity = A.opacity - anchored = A.anchored - density = A.density - appearance = A.appearance - addtimer(CALLBACK(src, .proc/disable), 600) - -/obj/guardian_bomb/proc/disable() - stored_obj.forceMove(get_turf(src)) - to_chat(spawner, "Failure! Your trap didn't catch anyone this time.") - qdel(src) - -/obj/guardian_bomb/proc/detonate(mob/living/user) - if(isliving(user)) - if(user != spawner && user != spawner.summoner && !spawner.hasmatchingsummoner(user)) - to_chat(user, "[src] was boobytrapped!") - to_chat(spawner, "Success! Your trap caught [user]") - var/turf/T = get_turf(src) - stored_obj.forceMove(T) - playsound(T,'sound/effects/explosion2.ogg', 200, 1) - new /obj/effect/temp_visual/explosion(T) - user.ex_act(EXPLODE_HEAVY) - qdel(src) - else - to_chat(user, "[src] glows with a strange light, and you don't touch it.") - -/obj/guardian_bomb/Bump(atom/A) - detonate(A) - ..() - -/obj/guardian_bomb/attackby(mob/living/user) - detonate(user) - -//ATTACK HAND IGNORING PARENT RETURN VALUE -/obj/guardian_bomb/attack_hand(mob/living/user, act_intent = user.a_intent, unarmed_attack_flags) - detonate(user) - -/obj/guardian_bomb/examine(mob/user) - . = stored_obj.examine(user) - if(get_dist(user,src)<=2) - . += "It glows with a strange light!" +/mob/living/simple_animal/hostile/guardian/bomb/proc/on_failure(atom/bomb) + to_chat(spawner, "Failure! Your trap didn't catch anyone this time.") diff --git a/tgstation.dme b/tgstation.dme index 75914f9d66..220904c85b 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -422,6 +422,7 @@ #include "code\datums\components\igniter.dm" #include "code\datums\components\infective.dm" #include "code\datums\components\jousting.dm" +#include "code\datums\components\killerqueen.dm" #include "code\datums\components\knockback.dm" #include "code\datums\components\knockoff.dm" #include "code\datums\components\lifesteal.dm"