Files
Bubberstation/code/datums/components/explode_on_attack.dm
SkyratBot a4c123c212 [MIRROR] new wizard ability and basic leaper refactor [MDB IGNORE] (#24805)
* new wizard ability and basic leaper refactor

* Update riding_mob.dm

* Modular

---------

Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
2023-11-05 22:01:26 -05:00

41 lines
1.2 KiB
Plaintext

/**
* Bombs the user after an attack
*/
/datum/component/explode_on_attack
/// range of bomb impact
var/impact_range
/// should we be destroyed after the explosion?
var/destroy_on_explode
/// list of mobs we wont bomb on attack
var/list/mob_type_dont_bomb
/datum/component/explode_on_attack/Initialize(impact_range = 1, destroy_on_explode = TRUE, list/mob_type_dont_bomb = list())
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
src.impact_range = impact_range
src.destroy_on_explode = destroy_on_explode
src.mob_type_dont_bomb = mob_type_dont_bomb
/datum/component/explode_on_attack/RegisterWithParent()
RegisterSignal(parent, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(bomb_target))
/datum/component/explode_on_attack/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_HOSTILE_PRE_ATTACKINGTARGET)
/datum/component/explode_on_attack/proc/bomb_target(mob/living/owner, atom/victim)
SIGNAL_HANDLER
if(!isliving(victim))
return
if(is_type_in_typecache(victim, mob_type_dont_bomb))
return
explosion(owner, light_impact_range = impact_range, explosion_cause = src)
if(destroy_on_explode && owner)
qdel(owner)
return COMPONENT_HOSTILE_NO_ATTACK