Files
Bubberstation/code/datums/elements/wall_smasher.dm
T
9664d24c13 Refactors UnarmedAttack so we don't have like 4 Unarmed Attack signals, kills two more snowflake species procs (#78991)
## About The Pull Request

- Deletes `spec_unarmedattack`
- Deletes `spec_unarmedattacked`
- Replaces `COMSIG_HUMAN_EARLY_UNARMED_ATTACK` with
`COMSIG_LIVING_EARLY_UNARMED_ATTACK`
- Replaces uses of `COMSIG_HUMAN_MELEE_UNARMED_ATTACK` with
`COMSIG_LIVING_EARLY_UNARMED_ATTACK`
- Fixes(?)(I've never seen this work) / Elementizes Monkey ability to
bite while handcuffed
- Monkey clever `attack paw` / `attack hand` thing is now handled the
same on the human level (via `resolve_unarmed_attack`)

## Why It's Good For The Game

Atomized from swing branch. I was really annoyed with these two signals,
this kinda unifies the behavior between living and human mobs (they were
already quite similar).

One thing of note is that this will make dis-coordinated humans use
`attack_paw` rather than `attack_hand`, so they'll bite people instead
of punching them. I'm not sure if this is what we want, if we wanna
tweak that before then I can by all means.

## Changelog

🆑 Melbert
refactor: Refactored unarmed attacking mechanisms, this means
dis-coordinated humans will now bite people like monkeys (like how
coordinated monkeys punch people like humans?)
refactor: Dis-coordinated humans smashing up machines now use their
hands, rather than their paws
/🆑

---------

Co-authored-by: san7890 <the@san7890.com>
2023-10-15 22:25:19 -06:00

72 lines
2.6 KiB
Plaintext

/**
* # Wall Smasher
* An element you put on mobs to let their attacks break walls
* If put in the hands of a player this can cause a lot of problems, be careful
*/
/datum/element/wall_smasher
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// Either ENVIRONMENT_SMASH_WALLS or ENVIRONMENT_SMASH_RWALLS, as in '_DEFINES/mobs.dm'
var/strength_flag
/datum/element/wall_smasher/Attach(datum/target, strength_flag = ENVIRONMENT_SMASH_WALLS)
. = ..()
if (. == ELEMENT_INCOMPATIBLE)
return ELEMENT_INCOMPATIBLE
if (!isliving(target))
return ELEMENT_INCOMPATIBLE
src.strength_flag = strength_flag
RegisterSignal(target, COMSIG_LIVING_UNARMED_ATTACK, PROC_REF(on_unarm_attack)) // Players
RegisterSignal(target, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(on_pre_attackingtarget)) // AI
if (isanimal_or_basicmob(target))
var/mob/living/simple_animal/animal_target = target
animal_target.environment_smash = strength_flag
/datum/element/wall_smasher/Detach(datum/target)
UnregisterSignal(target, list(COMSIG_LIVING_UNARMED_ATTACK, COMSIG_HOSTILE_PRE_ATTACKINGTARGET))
if (isanimal_or_basicmob(target))
var/mob/living/simple_animal/animal_target = target
animal_target.environment_smash = initial(animal_target.environment_smash)
return ..()
/datum/element/wall_smasher/proc/on_unarm_attack(mob/living/puncher, atom/target, proximity, modifiers)
SIGNAL_HANDLER
return try_smashing(puncher, target)
/datum/element/wall_smasher/proc/on_pre_attackingtarget(mob/living/puncher, atom/target)
SIGNAL_HANDLER
return try_smashing(puncher, target)
/datum/element/wall_smasher/proc/try_smashing(mob/living/puncher, atom/target)
if (!isturf(target))
return NONE
if (isfloorturf(target))
return NONE
if (isindestructiblewall(target))
return NONE
puncher.changeNext_move(CLICK_CD_MELEE)
puncher.do_attack_animation(target)
if (ismineralturf(target))
var/turf/closed/mineral/mineral_wall = target
mineral_wall.gets_drilled(puncher)
return COMPONENT_HOSTILE_NO_ATTACK
if (!iswallturf(target)) // In case you're some kind of non-wall non-mineral closed turf yet to be invented
return COMPONENT_HOSTILE_NO_ATTACK
var/turf/closed/wall/wall_turf = target
if (istype(wall_turf, /turf/closed/wall/r_wall) && strength_flag != ENVIRONMENT_SMASH_RWALLS)
playsound(wall_turf, 'sound/effects/bang.ogg', 50, vary = TRUE)
wall_turf.balloon_alert(puncher, "too tough!")
return COMPONENT_HOSTILE_NO_ATTACK
wall_turf.dismantle_wall(devastated = TRUE)
playsound(wall_turf, 'sound/effects/meteorimpact.ogg', 100, vary = TRUE)
return COMPONENT_HOSTILE_NO_ATTACK