diff --git a/code/datums/elements/blood_walk.dm b/code/datums/elements/blood_walk.dm new file mode 100644 index 00000000000..e27ba3ccc7c --- /dev/null +++ b/code/datums/elements/blood_walk.dm @@ -0,0 +1,50 @@ +///Blood walk, a bespoke element that causes you to make blood wherever you walk. +/datum/element/blood_walk + element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH + id_arg_index = 2 + + ///A unique blood type we might want to spread + var/blood_type + ///The sound that plays when we spread blood. + var/sound_played + ///How loud will the sound be, if there is one. + var/sound_volume + ///The chance of spawning blood whenever walking + var/blood_spawn_chance + + +/datum/element/blood_walk/Attach( + datum/target, + blood_type = /obj/effect/decal/cleanable/blood, + sound_played, + sound_volume = 80, + blood_spawn_chance = 100, +) + . = ..() + if(!ismovable(target)) + return ELEMENT_INCOMPATIBLE + + src.blood_type = blood_type + src.sound_played = sound_played + src.sound_volume = sound_volume + src.blood_spawn_chance = blood_spawn_chance + RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/spread_blood) + +/datum/element/blood_walk/Detach(datum/target) + . = ..() + UnregisterSignal(target, COMSIG_MOVABLE_MOVED) + +///Spawns blood (if possible) under the source, and plays a sound effect (if any) +/datum/element/blood_walk/proc/spread_blood(datum/source) + SIGNAL_HANDLER + + var/atom/movable/movable_source = source + var/turf/current_turf = movable_source.loc + if(!isturf(current_turf)) + return + if(!prob(blood_spawn_chance)) + return + + new blood_type(current_turf) + if(!isnull(sound_played)) + playsound(movable_source, sound_played, sound_volume, TRUE, 2, TRUE) diff --git a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm index 3770a343c10..5a7cddeac83 100644 --- a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm +++ b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm @@ -673,10 +673,9 @@ web_speed = 0.7 menu_description = "Self-sufficient spider variant capable of healing themselves and producing webbbing fast, but has less health and damage. Toxin injection of 10u per bite." -/mob/living/simple_animal/hostile/giant_spider/hunter/flesh/Moved(atom/oldloc, dir) +/mob/living/simple_animal/hostile/giant_spider/hunter/flesh/Initialize(mapload) . = ..() - if(prob(5)) - new /obj/effect/decal/cleanable/blood/bubblegum(loc) + AddElement(/datum/element/blood_walk, /obj/effect/decal/cleanable/blood/bubblegum, blood_spawn_chance = 5) /mob/living/simple_animal/hostile/giant_spider/hunter/flesh/AttackingTarget() if(is_busy) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm index 0a83602fbca..72771671034 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm @@ -99,6 +99,8 @@ Difficulty: Hard hallucination_charge_surround.spawn_blood = TRUE RegisterSignal(src, COMSIG_BLOOD_WARP, .proc/blood_enrage) RegisterSignal(src, COMSIG_FINISHED_CHARGE, .proc/after_charge) + if(spawn_blood) + AddElement(/datum/element/blood_walk, /obj/effect/decal/cleanable/blood/bubblegum, 'sound/effects/meteorimpact.ogg', 200) /mob/living/simple_animal/hostile/megafauna/bubblegum/Destroy() QDEL_NULL(triple_charge) @@ -305,12 +307,6 @@ Difficulty: Hard update_approach() . = ..() -/mob/living/simple_animal/hostile/megafauna/bubblegum/Moved(atom/OldLoc, Dir, Forced = FALSE) - . = ..() - if(spawn_blood) - new /obj/effect/decal/cleanable/blood/bubblegum(src.loc) - playsound(src, 'sound/effects/meteorimpact.ogg', 200, TRUE, 2, TRUE) - /mob/living/simple_animal/hostile/megafauna/bubblegum/hallucination name = "bubblegum's hallucination" desc = "Is that really just a hallucination?" diff --git a/tgstation.dme b/tgstation.dme index 75060df1ec3..a9740fff013 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -879,6 +879,7 @@ #include "code\datums\elements\basic_body_temp_sensitive.dm" #include "code\datums\elements\beauty.dm" #include "code\datums\elements\bed_tucking.dm" +#include "code\datums\elements\blood_walk.dm" #include "code\datums\elements\bsa_blocker.dm" #include "code\datums\elements\chemical_transfer.dm" #include "code\datums\elements\chewable.dm"