Files
Bubberstation/code/datums/components/mind_martial_art.dm
MrMelbert 52678d41b5 Everyone is kung fu fighting: Refactors martial arts / You can have multiple martial arts and swap between them (#89840)
## About The Pull Request

Refactors martial arts off the mind. Don't worry the martial arts you
learn still transfer with mindswap

Instead, they are just tracked on a list on the mob, and they also
independently track the datum that created them

This fixes a lot of jank with martial arts, like say, having your krav
maga gloves transfer across slime clones or something...

But it also opens an opportunity: As we track all martial arts
available, I added a verb (ic tab) that lets you swap between the ones
you know


![image](https://github.com/user-attachments/assets/6db1fc14-2859-444b-88ed-773962602f85)

(Some don't let you swap like that one brain trauma)

## Why It's Good For The Game

Aforementioned fixes a lot of jank

Recently martial arts have just been up and disappearing and this was
entirely spurred on by that bug

Probably fixes #84710 (haven't checked) 
Probably fixes #89247
Probably fixes #89948
Probably fixes #90067

## Changelog

🆑 Melbert
refactor: Refactored martial arts, if you notice any oddities like
managing to know two martial arts at once or having your powers
disappear, report it!
add: If you know multiple martial arts, such as krav maga from gloves
and cqc from a book, you can now swap between them at will via a button
in the IC tab!
/🆑

---------

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2025-03-16 03:16:49 +00:00

39 lines
1.3 KiB
Plaintext

/// A martial art that is owned by this mind and will transfer as mind moves
/datum/component/mindbound_martial_arts
dupe_mode = COMPONENT_DUPE_SELECTIVE
/// The style transferred between minds
var/datum/martial_art/style
/datum/component/mindbound_martial_arts/Initialize(style_type)
if(!istype(parent, /datum/mind))
return COMPONENT_INCOMPATIBLE
style = new style_type(src)
/datum/component/mindbound_martial_arts/CheckDupeComponent(datum/component/new_comp, new_style_type)
return style.type == new_style_type
/datum/component/mindbound_martial_arts/RegisterWithParent()
RegisterSignal(parent, COMSIG_MIND_TRANSFERRED, PROC_REF(mind_transferred))
var/datum/mind/mind = parent
style.teach(mind.current)
/datum/component/mindbound_martial_arts/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_MIND_TRANSFERRED)
var/datum/mind/mind = parent
style.unlearn(mind.current)
/datum/component/mindbound_martial_arts/Destroy()
QDEL_NULL(style)
return ..()
/// Signal proc for [COMSIG_MOB_MIND_TRANSFERRED_OUT_OF] to pass martial arts between bodies on mind transfer
/// By this point the martial art's holder is the old body, but the mind that owns it is in the new body
/datum/component/mindbound_martial_arts/proc/mind_transferred(datum/mind/source, mob/living/old_body)
SIGNAL_HANDLER
style.unlearn(old_body)
style.teach(source.current)