Files
Bubberstation/code/datums/mutations/chameleon.dm
Ghom 14fb86e3e8 Mutation code cleanup, mutations now have sources to avoid concurrency problems. (#91346)
## About The Pull Request
This PR aims to clean or bring up to date portions of code about dna,
the dna console and mutations. This includes taking care of or removing
some of the awful choices like the pratically useless
`datum/mutation/human` pathing, or the class variable, in favor of using
sources to avoid potential issues with extraneous sources of a mutation.

The files changed are over a hundred just because I removed the
`datum/mutation/human` path, but the actual bulk of the code is mainly
shared between the datum/dna.dm, _mutations.dm and dna_console.dm.

## Why It's Good For The Game
Mutation shitcode is hurting my future plans for infusions a little.
Also it's a much needed refactor. Drafted 'till I'm sure it works
without issues.

## Changelog

🆑
refactor: Refactored mutation code backend. Report any issue.
/🆑
2025-06-08 13:57:10 +02:00

65 lines
2.5 KiB
Plaintext

//Chameleon causes the owner to slowly become transparent when not moving.
/datum/mutation/chameleon
name = "Chameleon"
desc = "A genome that causes the holder's skin to become transparent over time."
quality = POSITIVE
difficulty = 16
text_gain_indication = span_notice("You feel one with your surroundings.")
text_lose_indication = span_notice("You feel oddly exposed.")
instability = POSITIVE_INSTABILITY_MAJOR
power_coeff = 1
/datum/mutation/chameleon/on_acquiring(mob/living/carbon/human/owner)
. = ..()
if(!.)
return
owner.alpha = CHAMELEON_MUTATION_DEFAULT_TRANSPARENCY
RegisterSignal(owner, COMSIG_MOVABLE_MOVED, PROC_REF(on_move))
RegisterSignal(owner, COMSIG_LIVING_UNARMED_ATTACK, PROC_REF(on_attack_hand))
/datum/mutation/chameleon/on_life(seconds_per_tick, times_fired)
owner.alpha = max(owner.alpha - (12.5 * (GET_MUTATION_POWER(src)) * seconds_per_tick), 0)
//Upgraded mutation of the base variant, used for changelings. No instability and better power_coeff
/datum/mutation/chameleon/changeling
instability = 0
power_coeff = 2.5
locked = TRUE
/**
* Resets the alpha of the host to the chameleon default if they move.
*
* Arguments:
* - [source][/atom/movable]: The source of the signal. Presumably the host mob.
* - [old_loc][/atom]: The location the host mob used to be in.
* - move_dir: The direction the host mob moved in.
* - forced: Whether the movement was caused by a forceMove or moveToNullspace.
* - [old_locs][/list/atom]: The locations the host mob used to be in.
*/
/datum/mutation/chameleon/proc/on_move(atom/movable/source, atom/old_loc, move_dir, forced, list/atom/old_locs)
SIGNAL_HANDLER
owner.alpha = CHAMELEON_MUTATION_DEFAULT_TRANSPARENCY
/**
* Resets the alpha of the host if they click on something nearby.
*
* Arguments:
* - [source][/mob/living/carbon/human]: The host mob that just clicked on something.
* - [target][/atom]: The thing the host mob clicked on.
* - proximity: Whether the host mob can physically reach the thing that they clicked on.
* - [modifiers][/list]: The set of click modifiers associated with this attack chain call.
*/
/datum/mutation/chameleon/proc/on_attack_hand(mob/living/carbon/human/source, atom/target, proximity, list/modifiers)
SIGNAL_HANDLER
if(!proximity) //stops tk from breaking chameleon
return
owner.alpha = CHAMELEON_MUTATION_DEFAULT_TRANSPARENCY
/datum/mutation/chameleon/on_losing(mob/living/carbon/human/owner)
if(..())
return
owner.alpha = 255
UnregisterSignal(owner, list(COMSIG_MOVABLE_MOVED, COMSIG_LIVING_UNARMED_ATTACK))