mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 14:39:58 +01:00
[MIRROR] Turns squashing mobs into an element (#2606)
* Turns squashing mobs into an element (#55725) Opens up room for extending squashing behavior for future cytology updates. * Turns squashing mobs into an element Co-authored-by: Qustinnus <Floydje123@hotmail.com>
This commit is contained in:
@@ -391,3 +391,10 @@
|
||||
|
||||
///Define for spawning megafauna instead of a mob for cave gen
|
||||
#define SPAWN_MEGAFAUNA "bluh bluh huge boss"
|
||||
|
||||
///Squash flags. For squashable element
|
||||
|
||||
///Whether or not the squashing requires the squashed mob to be lying down
|
||||
#define SQUASHED_SHOULD_BE_DOWN (1<<0)
|
||||
///Whether or not to gib when the squashed mob is moved over
|
||||
#define SQUASHED_SHOULD_BE_GIBBED (1<<0)
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
///This element allows something to be when crossed, for example for cockroaches.
|
||||
/datum/element/squashable
|
||||
element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH
|
||||
id_arg_index = 2
|
||||
///Chance on crossed to be squashed
|
||||
var/squash_chance = 50
|
||||
///How much brute is applied when mob is squashed
|
||||
var/squash_damage = 1
|
||||
///Squash flags, for extra checks etcetera.
|
||||
var/squash_flags = NONE
|
||||
///Special callback to call on squash instead, for things like hauberoach
|
||||
var/datum/callback/on_squash_callback
|
||||
|
||||
|
||||
/datum/element/squashable/Attach(mob/living/target, squash_chance, squash_damage, squash_flags, squash_callback)
|
||||
. = ..()
|
||||
if(!istype(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
if(squash_chance)
|
||||
src.squash_chance = squash_chance
|
||||
if(squash_damage)
|
||||
src.squash_damage = squash_damage
|
||||
if(squash_flags)
|
||||
src.squash_flags = squash_flags
|
||||
if(!src.on_squash_callback && squash_callback)
|
||||
on_squash_callback = CALLBACK(target, squash_callback)
|
||||
|
||||
RegisterSignal(target, COMSIG_MOVABLE_CROSSED, .proc/OnCrossed)
|
||||
|
||||
/datum/element/squashable/Detach(mob/living/target)
|
||||
UnregisterSignal(target, COMSIG_MOVABLE_CROSSED)
|
||||
|
||||
///Handles the squashing of the mob
|
||||
/datum/element/squashable/proc/OnCrossed(mob/living/target, atom/movable/crossing_movable)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
|
||||
if(squash_flags & SQUASHED_SHOULD_BE_DOWN && target.body_position != LYING_DOWN)
|
||||
return
|
||||
|
||||
var/should_squash = prob(squash_chance)
|
||||
|
||||
if(should_squash && on_squash_callback)
|
||||
if(on_squash_callback.Invoke(target, crossing_movable))
|
||||
return //Everything worked, we're done!
|
||||
if(isliving(crossing_movable))
|
||||
var/mob/living/crossing_mob = crossing_movable
|
||||
if(crossing_mob.mob_size > MOB_SIZE_SMALL && !(crossing_mob.movement_type & FLYING))
|
||||
if(HAS_TRAIT(crossing_mob, TRAIT_PACIFISM))
|
||||
crossing_mob.visible_message("<span class='notice'>[crossing_mob] carefully steps over [target].</span>", "<span class='notice'>You carefully step over [target] to avoid hurting it.</span>")
|
||||
return
|
||||
if(should_squash)
|
||||
crossing_mob.visible_message("<span class='notice'>[crossing_mob] squashed [target].</span>", "<span class='notice'>You squashed [target].</span>")
|
||||
Squish(target)
|
||||
else
|
||||
target.visible_message("<span class='notice'>[target] avoids getting crushed.</span>")
|
||||
else if(isstructure(crossing_movable))
|
||||
if(should_squash)
|
||||
crossing_movable.visible_message("<span class='notice'>[target] is crushed under [crossing_movable].</span>")
|
||||
Squish(target)
|
||||
else
|
||||
target.visible_message("<span class='notice'>[target] avoids getting crushed.</span>")
|
||||
|
||||
/datum/element/squashable/proc/Squish(mob/living/target)
|
||||
if(squash_flags & SQUASHED_SHOULD_BE_GIBBED)
|
||||
target.gib()
|
||||
else
|
||||
target.adjustBruteLoss(squash_damage)
|
||||
@@ -36,6 +36,10 @@
|
||||
/mob/living/simple_animal/hostile/cockroach/Initialize()
|
||||
. = ..()
|
||||
add_cell_sample()
|
||||
make_squashable()
|
||||
|
||||
/mob/living/simple_animal/hostile/cockroach/proc/make_squashable()
|
||||
AddElement(/datum/element/squashable, squash_chance = 50, squash_damage = 1)
|
||||
|
||||
/mob/living/simple_animal/hostile/cockroach/add_cell_sample()
|
||||
AddElement(/datum/element/swabable, CELL_LINE_TABLE_COCKROACH, CELL_VIRUS_TABLE_GENERIC_MOB, 1, 7)
|
||||
@@ -68,26 +72,6 @@
|
||||
return
|
||||
..()
|
||||
|
||||
/mob/living/simple_animal/hostile/cockroach/Crossed(atom/movable/AM)
|
||||
. = ..()
|
||||
if(isliving(AM))
|
||||
var/mob/living/A = AM
|
||||
if(A.mob_size > MOB_SIZE_SMALL && !(A.movement_type & FLYING))
|
||||
if(HAS_TRAIT(A, TRAIT_PACIFISM))
|
||||
A.visible_message("<span class='notice'>[A] carefully steps over [src].</span>", "<span class='notice'>You carefully step over [src] to avoid hurting it.</span>")
|
||||
return
|
||||
if(prob(squish_chance))
|
||||
A.visible_message("<span class='notice'>[A] squashed [src].</span>", "<span class='notice'>You squashed [src].</span>")
|
||||
adjustBruteLoss(1) //kills a normal cockroach
|
||||
else
|
||||
visible_message("<span class='notice'>[src] avoids getting crushed.</span>")
|
||||
else if(isstructure(AM))
|
||||
if(prob(squish_chance))
|
||||
AM.visible_message("<span class='notice'>[src] is crushed under [AM].</span>")
|
||||
adjustBruteLoss(1)
|
||||
else
|
||||
visible_message("<span class='notice'>[src] avoids getting crushed.</span>")
|
||||
|
||||
/mob/living/simple_animal/hostile/cockroach/ex_act() //Explosions are a terrible way to handle a cockroach.
|
||||
return
|
||||
|
||||
@@ -110,16 +94,15 @@
|
||||
. = ..()
|
||||
AddComponent(/datum/component/caltrop, 10, 15, 100, (CALTROP_BYPASS_SHOES | CALTROP_SILENT))
|
||||
|
||||
/mob/living/simple_animal/hostile/cockroach/hauberoach/Crossed(atom/movable/AM)
|
||||
var/mob/living/A = AM
|
||||
if(istype(A) && A.mob_size > MOB_SIZE_SMALL && !(A.movement_type & FLYING))
|
||||
if(!HAS_TRAIT(A, TRAIT_PIERCEIMMUNE))
|
||||
A.visible_message("<span class='danger'>[A] steps onto [src]'s spike!</span>", "<span class='userdanger'>You step onto [src]'s spike!</span>")
|
||||
else if(HAS_TRAIT(A, TRAIT_PACIFISM))
|
||||
A.visible_message("<span class='notice'>[A] carefully steps over [src].</span>", "<span class='notice'>You carefully step over [src] to avoid hurting it.</span>")
|
||||
else if(HAS_TRAIT(A, TRAIT_PIERCEIMMUNE))
|
||||
A.visible_message("<span class='danger'>[A] steps onto [src]'s spike, but is unfazed!</span>", "<span class='userdanger'>You step onto [src]'s spike, but you're unaffected!</span>")
|
||||
else
|
||||
A.visible_message("<span class='notice'>[A] squashes [src], not even noticing its spike.</span>", "<span class='notice'>You squashed [src], not even noticing its spike.</span>")
|
||||
adjustBruteLoss(1) //kills a normal cockroach
|
||||
..()
|
||||
/mob/living/simple_animal/hostile/cockroach/hauberoach/make_squashable()
|
||||
AddElement(/datum/element/squashable, squash_chance = 100, squash_damage = 1, squash_callback = /mob/living/simple_animal/hostile/cockroach/hauberoach/.proc/on_squish)
|
||||
|
||||
///Proc used to override the squashing behavior of the normal cockroach.
|
||||
/mob/living/simple_animal/hostile/cockroach/hauberoach/proc/on_squish(mob/living/cockroach, mob/living/living_target)
|
||||
if(!istype(living_target))
|
||||
return FALSE //We failed to run the invoke. Might be because we're a structure. Let the squashable element handle it then!
|
||||
if(!HAS_TRAIT(living_target, TRAIT_PIERCEIMMUNE))
|
||||
living_target.visible_message("<span class='danger'>[living_target] steps onto [cockroach]'s spike!</span>", "<span class='userdanger'>You step onto [cockroach]'s spike!</span>")
|
||||
return TRUE
|
||||
living_target.visible_message("<span class='notice'>[living_target] squashes [cockroach], not even noticing its spike.</span>", "<span class='notice'>You squashed [cockroach], not even noticing its spike.</span>")
|
||||
return FALSE
|
||||
|
||||
@@ -628,6 +628,7 @@
|
||||
#include "code\datums\elements\ridable.dm"
|
||||
#include "code\datums\elements\selfknockback.dm"
|
||||
#include "code\datums\elements\snail_crawl.dm"
|
||||
#include "code\datums\elements\squashable.dm"
|
||||
#include "code\datums\elements\squish.dm"
|
||||
#include "code\datums\elements\swabbable.dm"
|
||||
#include "code\datums\elements\tool_flash.dm"
|
||||
|
||||
Reference in New Issue
Block a user