mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-31 20:11:56 +00:00
## About The Pull Request Fixes #72677 and also converted the "Wumborian Fugu" mob to a basic mob rather than a simple one. I will be totally honest: I didn't need to do that in order to fix the bug. I just didn't like looking at the rest of the code in that file. Also I have some kind of sickness which makes me do this. This ended up being one of those "see something related and fix it as well" ones so there's a couple of only tangentially related changes in here. If you want me to split it up I will but I think this one is _probably_ fine because the wide-ranging changes are pretty simple ones? So what this PR does is: - Refactors simple mob into basic mob. - Cleans up its really ugly ability to work in a hopefully nicer way. - A one line fix to the linked issue above. - Modifies the default cooldown on `basic_melee_attack` and `attack_obstructions` to be a widely used cooldown rather than a random value used by no mob that we have. - Renamed behaviour "try_mob_ability" to "targeted_mob_ability" and added a new AI behaviour called "use_mob_ability", the difference between the two being that the former requires a target and the latter does not. I... don't actually use this because I realised after adding it that I still want a target for this mob, but someone will need it eventually. - Change everywhere that is passing references to abilities to actions to pass weak references instead. - Adds an element to handle "spawn this stuff when a related mob dies". - Found a few places where people were setting `environment_smash ` as if it did anything (including me) and replaced them with the proper ai_controller implementation instead, updated the comment to make it clearer although that won't prevent copy/paste errors. - Registered to the "movement speed updated" signal to ensure that basic mobs actually notice that you have applied a movement speed modifier. ## Why It's Good For The Game Fixes a linked issue. Refactors some code which made me sad whenever I saw it. Restores some mob behaviour which nobody noticed was missing, but was. Fixes some apparently unreliable code I added in a recent PR reliant on basic mobs using movespeed modifiers. Adds element we will definitely need again in the future. ## Changelog 🆑 fix: The Fugu Gland can once more be used on Ian, Carp, Giant Spiders, or other basic mobs. fix: Syndicate mobs will once again attack windows to try to reach you, and space ruin spiders won't. fix: Netherworld-themed mobs will correctly adjust their speed as they take damage. refactor: Made the Wumborian Fugu into a basic mob, which should act largely the same way but may have slightly different speed and reaction times. /🆑
72 lines
2.6 KiB
Plaintext
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
|
|
RegisterSignals(target, list(COMSIG_LIVING_UNARMED_ATTACK, COMSIG_HUMAN_EARLY_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_HUMAN_EARLY_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
|
|
try_smashing(puncher, target)
|
|
|
|
/datum/element/wall_smasher/proc/on_pre_attackingtarget(mob/living/puncher, atom/target)
|
|
SIGNAL_HANDLER
|
|
try_smashing(puncher, target)
|
|
|
|
/datum/element/wall_smasher/proc/try_smashing(mob/living/puncher, atom/target)
|
|
if (!isturf(target))
|
|
return
|
|
if (isfloorturf(target))
|
|
return
|
|
if (isindestructiblewall(target))
|
|
return
|
|
|
|
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
|