diff --git a/code/datums/mind.dm b/code/datums/mind.dm
index b251ae729c4..41a6c7e00a4 100644
--- a/code/datums/mind.dm
+++ b/code/datums/mind.dm
@@ -39,6 +39,7 @@
var/list/spell_list = list() // Wizard mode & "Give Spell" badmin button.
var/datum/martial_art/martial_art
+ var/list/known_martial_arts = list()
var/role_alt_title
diff --git a/code/modules/martial_arts/adminfu.dm b/code/modules/martial_arts/adminfu.dm
index 69107e5252c..d17228f4827 100644
--- a/code/modules/martial_arts/adminfu.dm
+++ b/code/modules/martial_arts/adminfu.dm
@@ -2,6 +2,7 @@
name = "Way of the Dancing Admin"
has_explaination_verb = TRUE
combos = list(/datum/martial_combo/adminfu/healing_palm)
+ weight = 99999999 //Matt Malvor?
/datum/martial_art/adminfu/harm_act(mob/living/carbon/human/A, mob/living/carbon/human/D)
MARTIAL_ARTS_ACT_CHECK
diff --git a/code/modules/martial_arts/brawling.dm b/code/modules/martial_arts/brawling.dm
index 3c464a91571..cee3f297d42 100644
--- a/code/modules/martial_arts/brawling.dm
+++ b/code/modules/martial_arts/brawling.dm
@@ -1,5 +1,6 @@
/datum/martial_art/boxing
name = "Boxing"
+ weight = 1
/datum/martial_art/boxing/disarm_act(mob/living/carbon/human/A, mob/living/carbon/human/D)
to_chat(A, "Can't disarm while boxing!")
@@ -43,6 +44,7 @@
/datum/martial_art/drunk_brawling
name = "Drunken Brawling"
+ weight = 2
/datum/martial_art/drunk_brawling/grab_act(mob/living/carbon/human/A, mob/living/carbon/human/D)
if(prob(70))
diff --git a/code/modules/martial_arts/cqc.dm b/code/modules/martial_arts/cqc.dm
index c382abdb63b..b83825d7089 100644
--- a/code/modules/martial_arts/cqc.dm
+++ b/code/modules/martial_arts/cqc.dm
@@ -1,5 +1,6 @@
/datum/martial_art/cqc
name = "CQC"
+ weight = 6
has_explaination_verb = TRUE
can_parry = TRUE
combos = list(/datum/martial_combo/cqc/slam, /datum/martial_combo/cqc/kick, /datum/martial_combo/cqc/restrain, /datum/martial_combo/cqc/pressure, /datum/martial_combo/cqc/consecutive)
@@ -26,8 +27,10 @@
for(var/obj/item/slapper/parry/smacking_hand in held_items)
qdel(smacking_hand)
can_parry = FALSE
+ weight = 0
else
can_parry = TRUE
+ weight = 5
/datum/martial_art/cqc/under_siege/can_use(mob/living/carbon/human/H)
var/area/A = get_area(H)
diff --git a/code/modules/martial_arts/grav_stomp.dm b/code/modules/martial_arts/grav_stomp.dm
index e3cb6a07a9b..e024be28a48 100644
--- a/code/modules/martial_arts/grav_stomp.dm
+++ b/code/modules/martial_arts/grav_stomp.dm
@@ -1,5 +1,6 @@
/datum/martial_art/grav_stomp
name = "Gravitational Boots"
+ weight = 4
/datum/martial_art/grav_stomp/harm_act(mob/living/carbon/human/A, mob/living/carbon/human/D)
MARTIAL_ARTS_ACT_CHECK
diff --git a/code/modules/martial_arts/krav_maga.dm b/code/modules/martial_arts/krav_maga.dm
index 0a094dc2297..ba4f0da8fa2 100644
--- a/code/modules/martial_arts/krav_maga.dm
+++ b/code/modules/martial_arts/krav_maga.dm
@@ -1,5 +1,6 @@
/datum/martial_art/krav_maga
name = "Krav Maga"
+ weight = 7 //Higher weight, since you can choose to put on or take off the gloves
var/datum/action/neck_chop/neckchop = new/datum/action/neck_chop()
var/datum/action/leg_sweep/legsweep = new/datum/action/leg_sweep()
var/datum/action/lung_punch/lungpunch = new/datum/action/lung_punch()
@@ -24,12 +25,15 @@
button_icon_state = "neckchop"
/datum/action/neck_chop/Trigger()
+ var/mob/living/carbon/human/H = owner //This is a janky solution, but I want to refactor krav anyway and un-jank this (written in may 2023)
+ if(!istype(H.mind.martial_art, /datum/martial_art/krav_maga))
+ to_chat(owner, "You don't know how to do that right now.")
+ return
if(owner.incapacitated())
to_chat(owner, "You can't use Krav Maga while you're incapacitated.")
return
to_chat(owner, "Your next attack will be a Neck Chop.")
owner.visible_message("[owner] assumes the Neck Chop stance!")
- var/mob/living/carbon/human/H = owner
H.mind.martial_art.combos.Cut()
H.mind.martial_art.combos.Add(/datum/martial_combo/krav_maga/neck_chop)
H.mind.martial_art.reset_combos()
@@ -39,6 +43,10 @@
button_icon_state = "legsweep"
/datum/action/leg_sweep/Trigger()
+ var/mob/living/carbon/human/H = owner
+ if(!istype(H.mind.martial_art, /datum/martial_art/krav_maga))
+ to_chat(owner, "You don't know how to do that right now.")
+ return
if(owner.incapacitated())
to_chat(owner, "You can't use Krav Maga while you're incapacitated.")
return
@@ -47,7 +55,6 @@
return
to_chat(owner, "Your next attack will be a Leg Sweep.")
owner.visible_message("[owner] assumes the Leg Sweep stance!")
- var/mob/living/carbon/human/H = owner
H.mind.martial_art.combos.Cut()
H.mind.martial_art.combos.Add(/datum/martial_combo/krav_maga/leg_sweep)
H.mind.martial_art.reset_combos()
@@ -58,12 +65,15 @@
button_icon_state = "lungpunch"
/datum/action/lung_punch/Trigger()
+ var/mob/living/carbon/human/H = owner
+ if(!istype(H.mind.martial_art, /datum/martial_art/krav_maga))
+ to_chat(owner, "You don't know how to do that right now.")
+ return
if(owner.incapacitated())
to_chat(owner, "You can't use Krav Maga while you're incapacitated.")
return
to_chat(owner, "Your next attack will be a Lung Punch.")
owner.visible_message("[owner] assumes the Lung Punch stance!")
- var/mob/living/carbon/human/H = owner
H.mind.martial_art.combos.Cut()
H.mind.martial_art.combos.Add(/datum/martial_combo/krav_maga/lung_punch)
H.mind.martial_art.reset_combos()
diff --git a/code/modules/martial_arts/martial.dm b/code/modules/martial_arts/martial.dm
index b441814497b..be26479cc5a 100644
--- a/code/modules/martial_arts/martial.dm
+++ b/code/modules/martial_arts/martial.dm
@@ -33,6 +33,8 @@
var/in_stance = FALSE
/// If the martial art allows parrying.
var/can_parry = FALSE
+ /// The priority of which martial art is picked from all the ones someone knows, the higher the number, the higher the priority.
+ var/weight = 0
/datum/martial_art/New()
. = ..()
@@ -136,27 +138,29 @@
/datum/martial_art/proc/teach(mob/living/carbon/human/H, make_temporary = FALSE)
if(!H.mind)
return
+ for(var/datum/martial_art/MA in H.mind.known_martial_arts)
+ if(istype(MA, src))
+ return
if(has_explaination_verb)
H.verbs |= /mob/living/carbon/human/proc/martial_arts_help
- if(make_temporary)
- temporary = TRUE
- if(temporary)
- if(H.mind.martial_art)
- base = H.mind.martial_art.base
- else
- base = src
- H.mind.martial_art = src
+ H.mind.known_martial_arts.Add(src)
+ H.mind.martial_art = get_highest_weight(H)
/datum/martial_art/proc/remove(mob/living/carbon/human/H)
+ var/datum/martial_art/MA = src
if(!H.mind)
return
- if(H.mind.martial_art != src)
- return
- H.mind.martial_art = null // Remove reference
+ H.mind.known_martial_arts.Remove(MA)
+ H.mind.martial_art = get_highest_weight(H)
H.verbs -= /mob/living/carbon/human/proc/martial_arts_help
- if(base)
- base.teach(H)
- base = null
+
+/// Returns the martial art with the highest weight from all the ones someone knows.
+/datum/martial_art/proc/get_highest_weight(mob/living/carbon/human/H)
+ var/datum/martial_art/highest_weight = null
+ for(var/datum/martial_art/MA in H.mind.known_martial_arts)
+ if(!highest_weight || MA.weight > highest_weight.weight)
+ highest_weight = MA
+ return highest_weight
/mob/living/carbon/human/proc/martial_arts_help()
set name = "Show Info"
@@ -220,7 +224,7 @@
return
if(slot == slot_gloves)
var/mob/living/carbon/human/H = user
- style.teach(H,1)
+ style.teach(H, TRUE)
return
/obj/item/clothing/gloves/boxing/dropped(mob/user)
@@ -243,7 +247,7 @@
if(HAS_TRAIT(user, TRAIT_PACIFISM))
to_chat(user, "In spite of the grandiosity of the belt, you don't feel like getting into any fights.")
return
- style.teach(H,1)
+ style.teach(H, TRUE)
to_chat(user, "You have an urge to flex your muscles and get into a fight. You have the knowledge of a thousand wrestlers before you. You can remember more by using the Recall teaching verb in the wrestling tab.")
return
diff --git a/code/modules/martial_arts/mimejutsu.dm b/code/modules/martial_arts/mimejutsu.dm
index 635af53a241..8eb960c0e88 100644
--- a/code/modules/martial_arts/mimejutsu.dm
+++ b/code/modules/martial_arts/mimejutsu.dm
@@ -1,5 +1,6 @@
/datum/martial_art/mimejutsu
name = "Mimejutsu"
+ weight = 6
has_explaination_verb = TRUE
combos = list(/datum/martial_combo/mimejutsu/mimechucks, /datum/martial_combo/mimejutsu/smokebomb, /datum/martial_combo/mimejutsu/silent_palm)
diff --git a/code/modules/martial_arts/plasma_fist.dm b/code/modules/martial_arts/plasma_fist.dm
index e2492877d28..fb7efce42a4 100644
--- a/code/modules/martial_arts/plasma_fist.dm
+++ b/code/modules/martial_arts/plasma_fist.dm
@@ -1,5 +1,6 @@
/datum/martial_art/plasma_fist
name = "Plasma Fist"
+ weight = 6
combos = list(/datum/martial_combo/plasma_fist/tornado_sweep, /datum/martial_combo/plasma_fist/throwback, /datum/martial_combo/plasma_fist/plasma_fist)
has_explaination_verb = TRUE
diff --git a/code/modules/martial_arts/sleeping_carp.dm b/code/modules/martial_arts/sleeping_carp.dm
index a955b3dde94..ea5e8488e62 100644
--- a/code/modules/martial_arts/sleeping_carp.dm
+++ b/code/modules/martial_arts/sleeping_carp.dm
@@ -1,5 +1,6 @@
//Used by the gang of the same name. Uses combos. Basic attacks bypass armor and never miss
/datum/martial_art/the_sleeping_carp
+ weight = 8
name = "The Sleeping Carp"
deflection_chance = 100
reroute_deflection = TRUE
diff --git a/code/modules/martial_arts/wrestling.dm b/code/modules/martial_arts/wrestling.dm
index 6beddf8251d..0145a4c24e1 100644
--- a/code/modules/martial_arts/wrestling.dm
+++ b/code/modules/martial_arts/wrestling.dm
@@ -1,5 +1,6 @@
/datum/martial_art/wrestling
name = "Wrestling"
+ weight = 3
help_verb = /mob/living/carbon/human/proc/wrestling_help
// combo refence since wrestling uses a different format to sleeping carp and plasma fist.