From c720e800dfbb5237d3de7dd6dd1e707a2b3cae2f Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:08:02 -0700 Subject: [PATCH 1/5] whew! --- code/datums/components/killerqueen.dm | 91 +++++++++++++++++++ .../simple_animal/guardian/types/explosive.dm | 63 +++---------- tgstation.dme | 1 + 3 files changed, 103 insertions(+), 52 deletions(-) create mode 100644 code/datums/components/killerqueen.dm 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" From 4ab175d8126d497b88e60490ee592667619be3b2 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:10:34 -0700 Subject: [PATCH 2/5] sigh --- .../mob/living/simple_animal/guardian/types/explosive.dm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 4f44a51b32..c5369afc20 100644 --- a/code/modules/mob/living/simple_animal/guardian/types/explosive.dm +++ b/code/modules/mob/living/simple_animal/guardian/types/explosive.dm @@ -37,7 +37,7 @@ if(isobj(A) && Adjacent(A)) if(bomb_cooldown <= world.time && !stat) 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!")) + examine_message = "It glows with a strange light!") QDEL_IN(K, 1 MINUTES) to_chat(src, "Success! Bomb armed!") bomb_cooldown = world.time + 200 @@ -46,10 +46,10 @@ /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.") + 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(src, "One of your explosive traps caught [victim]!") to_chat(victim, "[bomb] was boobytrapped!") /mob/living/simple_animal/hostile/guardian/bomb/proc/on_failure(atom/bomb) - to_chat(spawner, "Failure! Your trap didn't catch anyone this time.") + to_chat(src, "Failure! Your trap didn't catch anyone this time.") From fd738fd16a4e800287f637ef81b6a287b1f76dfe Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:12:30 -0700 Subject: [PATCH 3/5] spelling --- code/datums/components/killerqueen.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/components/killerqueen.dm b/code/datums/components/killerqueen.dm index 9930b0d3ac..783ec789b7 100644 --- a/code/datums/components/killerqueen.dm +++ b/code/datums/components/killerqueen.dm @@ -65,7 +65,7 @@ detonate(user) /datum/component/killerqueen/proc/bump_detonate(datum/source, atom/A) - detonate(user) + detonate(A) /datum/component/killerqueen/proc/touch_detonate(datum/source, mob/user) detonate(user) From 78b6a60e80f0f44e91df063b36839b036f494e89 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:25:27 -0700 Subject: [PATCH 4/5] oh --- code/datums/components/killerqueen.dm | 2 +- .../mob/living/simple_animal/guardian/types/explosive.dm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/datums/components/killerqueen.dm b/code/datums/components/killerqueen.dm index 783ec789b7..7c469a503b 100644 --- a/code/datums/components/killerqueen.dm +++ b/code/datums/components/killerqueen.dm @@ -46,7 +46,7 @@ /datum/component/killerqueen/Destroy() if(!exploded) - failure.Invoke(parent) + failure?.Invoke(parent) return ..() /datum/component/killerqueen/RegisterWithParent() 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 c5369afc20..2bc3cc9480 100644 --- a/code/modules/mob/living/simple_animal/guardian/types/explosive.dm +++ b/code/modules/mob/living/simple_animal/guardian/types/explosive.dm @@ -36,7 +36,7 @@ return if(isobj(A) && Adjacent(A)) if(bomb_cooldown <= world.time && !stat) - var/datum/component/killerqueen/K = A.AddComponent(/datum/component/killerqueen, CALLBACK(src, .proc/on_explode), CALLBACK(src, .proc/on_failure), \ + var/datum/component/killerqueen/K = A.AddComponent(/datum/component/killerqueen, EXPLODE_HEAVY, 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!") From c87c2bd850f0452b20b05a99ba644aefcd8e6d66 Mon Sep 17 00:00:00 2001 From: silicons <2003111+silicons@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:31:35 -0700 Subject: [PATCH 5/5] smh --- code/datums/components/killerqueen.dm | 2 +- .../mob/living/simple_animal/guardian/types/explosive.dm | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/code/datums/components/killerqueen.dm b/code/datums/components/killerqueen.dm index 7c469a503b..1c660d0a87 100644 --- a/code/datums/components/killerqueen.dm +++ b/code/datums/components/killerqueen.dm @@ -70,7 +70,7 @@ /datum/component/killerqueen/proc/touch_detonate(datum/source, mob/user) detonate(user) -/datum/component/killerqueen/proc/on_examine(datum/source, list/examine_return) +/datum/component/killerqueen/proc/on_examine(datum/source, mob/examiner, list/examine_return) if(examine_message) examine_return += examine_message 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 2bc3cc9480..26e5d791f3 100644 --- a/code/modules/mob/living/simple_animal/guardian/types/explosive.dm +++ b/code/modules/mob/living/simple_animal/guardian/types/explosive.dm @@ -50,6 +50,7 @@ return FALSE to_chat(src, "One of your explosive traps caught [victim]!") to_chat(victim, "[bomb] was boobytrapped!") + return TRUE /mob/living/simple_animal/hostile/guardian/bomb/proc/on_failure(atom/bomb) to_chat(src, "Failure! Your trap didn't catch anyone this time.")