<commit_before>/**
  * 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)
	var/atom/A = parent
	if(!A.density)
		return
	detonate(A)

/datum/component/killerqueen/proc/touch_detonate(datum/source, mob/user)
	detonate(user)

/datum/component/killerqueen/proc/on_examine(datum/source, mob/examiner, 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)
<commit_msg>Update killerqueen.dm<commit_after>/**
  * 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)
	var/atom/us = parent
	if(!us.density)		// lazy anti-item-throw-OHKO, we need something better at some point
		return
	detonate(A)

/datum/component/killerqueen/proc/touch_detonate(datum/source, mob/user)
	detonate(user)

/datum/component/killerqueen/proc/on_examine(datum/source, mob/examiner, 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)

{'fraction_non_alphanumeric': 0.10845418080839248, 'fraction_numerical': 0.004319654427645789, 'mean_word_length': 4.762666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6067688', 'n_tokens_mistral': 2492, 'n_tokens_neox': 2323, 'n_words': 476}