Files
Bubberstation/code/datums/elements/structure_repair.dm
SkyratBot ae2c7f8fbb [MIRROR] Basic Constructs: parent type + Harvester [MDB IGNORE] (#24258)
* Basic Constructs: parent type + Harvester (#78807)

## About The Pull Request

I kind of hate cult as a whole, but I like these little guys. Let's
basic-ize them.

This PR begins the process with the harbinger of the Red Harvest, the
Harvester! Their actual capabilities have been changed very little,
except that most of their unique properties have been moved to
components and elements. The basic parent type of constructs has also
been set up to make the next bunch of conversions easier.

- Constructs capable of repair now receive the healing hands component.
Healing hands has been extended, to allow the healing particles to come
in custom colors, and to allow it to print the target's health if the
target is not a carbon.
- Repairing constructs also receive a new element: Structure repair is a
lighter-weight variant on healing hands that allows repairing clicked-on
atoms of specified types.
- Constructs capable of damaging walls, meanwhile, receive the wall
smasher element.

Harvesters in specific have two special elements:
- The existing "amputating limbs" element, making them instantly rip a
limb off of any carbon they attack. As before, if they attempt this on a
carbon with no arms or legs, the harvester will hear Nar'Sie's call to
bring the victim to her.
- A new "wall walker" element, allowing them to walk through walls of
specified type (cult walls for harvesters) and allowing them to drag any
atom through as well.

Other than laying the groundwork, there's not much else here. I started
with Harvesters specifically because they are only ever
player-controlled, which makes things easy.

I'm not completely happy with the use of healing hands here - it gets
the job done, but currently loses a bit of the previous flavor (a
healing beam as a visual; printing the target's health in cult span). I
may extend it further to allow this behavior.

I've included an UpdatePaths script, even if these things shouldn't be
mapped, just in case something fucky is going on on a downstream. You
never know.
## Why It's Good For The Game

Constructs, currently, occupy _19_ spots on the simple animal list. This
is something close to 10% of all the remaining ones. Also, like
everything to do with cult, construct code is janky, old, and
desperately in need of updating. This is the first step.
## Changelog
🆑
refactor: Harvester constructs have been updated to the basic mob
framework. This should have very little impact on their behavior, but
please report any issues.
/🆑

---------

Co-authored-by: san7890 <the@ san7890.com>

* Basic Constructs: parent type + Harvester

---------

Co-authored-by: lizardqueenlexi <105025397+lizardqueenlexi@users.noreply.github.com>
Co-authored-by: san7890 <the@ san7890.com>
2023-10-10 18:37:00 -04:00

46 lines
1.6 KiB
Plaintext

/// Intercepts attacks from mobs with this component to instead repair specified structures.
/datum/element/structure_repair
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// How much to heal structures by
var/heal_amount
/// Typecache of types of structures to repair
var/list/structure_types_typecache
/datum/element/structure_repair/Attach(
datum/target,
heal_amount = 5,
structure_types_typecache = typecacheof(list(/obj/structure)),
)
. = ..()
if (!isliving(target))
return ELEMENT_INCOMPATIBLE
src.heal_amount = heal_amount
src.structure_types_typecache = structure_types_typecache
RegisterSignals(target, list(COMSIG_LIVING_UNARMED_ATTACK, COMSIG_HOSTILE_PRE_ATTACKINGTARGET), PROC_REF(try_repair))
/datum/element/structure_repair/Detach(datum/source)
UnregisterSignal(source, list(COMSIG_LIVING_UNARMED_ATTACK, COMSIG_HOSTILE_PRE_ATTACKINGTARGET))
return ..()
/// If the target is of a valid type, interrupt the attack chain to repair it instead
/datum/element/structure_repair/proc/try_repair(mob/living/fixer, atom/target)
SIGNAL_HANDLER
if (!is_type_in_typecache(target, structure_types_typecache))
return
if (target.get_integrity() >= target.max_integrity)
target.balloon_alert(fixer, "not damaged!")
return COMPONENT_CANCEL_ATTACK_CHAIN
target.repair_damage(heal_amount)
fixer.Beam(target, icon_state = "sendbeam", time = 0.4 SECONDS)
fixer.visible_message(
span_danger("[fixer] repairs [target]."),
span_danger("You repair [target], leaving it at <b>[round(target.get_integrity() * 100 / target.max_integrity)]%</b> stability."),
)
return COMPONENT_CANCEL_ATTACK_CHAIN