mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-20 14:45:05 +00:00
* Refactors `UnarmedAttack` so we don't have like 4 Unarmed Attack signals, kills two more snowflake species procs * Update chameleon.dm * Update _species.dm * Modular --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
46 lines
1.6 KiB
Plaintext
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, proximity)
|
|
SIGNAL_HANDLER
|
|
|
|
if (!proximity || !is_type_in_typecache(target, structure_types_typecache))
|
|
return NONE
|
|
|
|
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
|