This commit is contained in:
silicons
2020-07-28 12:08:02 -07:00
parent 469ea17063
commit c720e800df
3 changed files with 103 additions and 52 deletions

View File

@@ -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)

View File

@@ -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 = "<span class='holoparasite'>It glows with a strange <font color=\"[spawner.guardiancolor]\">light</font>!</span>"))
QDEL_IN(K, 1 MINUTES)
to_chat(src, "<span class='danger'><B>Success! Bomb armed!</span></B>")
bomb_cooldown = world.time + 200
B.spawner = src
B.disguise(A)
else
to_chat(src, "<span class='danger'><B>Your powers are on cooldown! You must wait 20 seconds between bombs.</span></B>")
/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, "<span class='holoparasite'>[src] glows with a strange <font color=\"[spawner.guardiancolor]\">light</font>, and you don't touch it.</span>")
return FALSE
to_chat(spawner, "<span class='danger'>One of your explosive traps caught [victim]!</span>")
to_chat(victim, "<span class='danger'>[bomb] was boobytrapped!</span>")
/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, "<span class='danger'><B>Failure! Your trap didn't catch anyone this time.</span></B>")
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, "<span class='danger'><B>[src] was boobytrapped!</span></B>")
to_chat(spawner, "<span class='danger'><B>Success! Your trap caught [user]</span></B>")
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, "<span class='holoparasite'>[src] glows with a strange <font color=\"[spawner.guardiancolor]\">light</font>, and you don't touch it.</span>")
/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)
. += "<span class='holoparasite'>It glows with a strange <font color=\"[spawner.guardiancolor]\">light</font>!</span>"
/mob/living/simple_animal/hostile/guardian/bomb/proc/on_failure(atom/bomb)
to_chat(spawner, "<span class='danger'><b>Failure! Your trap didn't catch anyone this time.</span></B>")