diff --git a/code/datums/martial.dm b/code/datums/martial.dm
index e7adf28b911..e804b80e48d 100644
--- a/code/datums/martial.dm
+++ b/code/datums/martial.dm
@@ -2,13 +2,12 @@
var/name = "Martial Art"
var/streak = ""
var/max_streak_length = 6
- var/current_target = null
- var/temporary = 0
- var/datum/martial_art/base = null // The permanent style
+ var/current_target
+ var/datum/martial_art/base // The permanent style. This will be null unless the martial art is temporary
var/deflection_chance = 0 //Chance to deflect projectiles
var/block_chance = 0 //Chance to block melee attacks using items while on throw mode.
var/restraining = 0 //used in cqc's disarm_act to check if the disarmed is being restrained and so whether they should be put in a chokehold or not
- var/help_verb = null
+ var/help_verb
var/no_guns = FALSE
var/allow_temp_override = TRUE //if this martial art can be overridden by temporary martial arts
@@ -77,19 +76,40 @@
return 1
/datum/martial_art/proc/teach(mob/living/carbon/human/H,make_temporary=0)
- if(make_temporary)
- temporary = 1
- if(temporary && H.mind.martial_art)
- if(!H.mind.martial_art.allow_temp_override)
- return
- base = H.mind.martial_art
+ if(H.mind.martial_art)
+ if(make_temporary)
+ if(!H.mind.martial_art.allow_temp_override)
+ return FALSE
+ store(H.mind.martial_art,H)
+ else
+ H.mind.martial_art.on_remove(H)
+ if(H.mind.martial_art != H.mind.default_martial_art && !H.mind.martial_art.base)
+ QDEL_NULL(H.mind.martial_art)
+ else if(make_temporary)
+ base = H.mind.default_martial_art
if(help_verb)
H.verbs += help_verb
H.mind.martial_art = src
+ return TRUE
+
+/datum/martial_art/proc/store(datum/martial_art/M,mob/living/carbon/human/H)
+ if(H.mind && base)
+ if(H.mind.default_martial_art != base && !base.base)
+ QDEL_NULL(base)
+ M.on_remove(H)
+ base = M
/datum/martial_art/proc/remove(mob/living/carbon/human/H)
if(H.mind.martial_art != src)
return
- H.mind.martial_art = base
+ on_remove(H)
+ if(base)
+ base.teach(H)
+ else
+ var/datum/martial_art/X = H.mind.default_martial_art
+ X.teach(H)
+
+/datum/martial_art/proc/on_remove(mob/living/carbon/human/H)
if(help_verb)
H.verbs -= help_verb
+ return
diff --git a/code/datums/martial/krav_maga.dm b/code/datums/martial/krav_maga.dm
index f0196bb15f1..94637f10e3d 100644
--- a/code/datums/martial/krav_maga.dm
+++ b/code/datums/martial/krav_maga.dm
@@ -52,16 +52,15 @@
owner.visible_message("[owner] assumes the Lung Punch stance!", "Your next attack will be a Lung Punch.")
H.mind.martial_art.streak = "quick_choke"//internal name for lung punch
-/datum/martial_art/krav_maga/teach(var/mob/living/carbon/human/H,var/make_temporary=0)
- ..()
- to_chat(H, "You know the arts of Krav Maga!")
- to_chat(H, "Place your cursor over a move at the top of the screen to see what it does.")
- neckchop.Grant(H)
- legsweep.Grant(H)
- lungpunch.Grant(H)
+/datum/martial_art/krav_maga/teach(mob/living/carbon/human/H,make_temporary=0)
+ if(..())
+ to_chat(H, "You know the arts of Krav Maga!")
+ to_chat(H, "Place your cursor over a move at the top of the screen to see what it does.")
+ neckchop.Grant(H)
+ legsweep.Grant(H)
+ lungpunch.Grant(H)
-/datum/martial_art/krav_maga/remove(var/mob/living/carbon/human/H)
- ..()
+/datum/martial_art/krav_maga/on_remove(mob/living/carbon/human/H)
to_chat(H, "You suddenly forget the arts of Krav Maga...")
neckchop.Remove(H)
legsweep.Remove(H)
diff --git a/code/datums/martial/wrestling.dm b/code/datums/martial/wrestling.dm
index fb47def85ac..8ebf17469ce 100644
--- a/code/datums/martial/wrestling.dm
+++ b/code/datums/martial/wrestling.dm
@@ -100,18 +100,17 @@
var/mob/living/carbon/human/H = owner
H.mind.martial_art.streak = "drop"
-/datum/martial_art/wrestling/teach(var/mob/living/carbon/human/H,var/make_temporary=0)
- ..()
- to_chat(H, "SNAP INTO A THIN TIM!")
- to_chat(H, "Place your cursor over a move at the top of the screen to see what it does.")
- drop.Grant(H)
- kick.Grant(H)
- slam.Grant(H)
- throw_wrassle.Grant(H)
- strike.Grant(H)
+/datum/martial_art/wrestling/teach(mob/living/carbon/human/H,make_temporary=0)
+ if(..())
+ to_chat(H, "SNAP INTO A THIN TIM!")
+ to_chat(H, "Place your cursor over a move at the top of the screen to see what it does.")
+ drop.Grant(H)
+ kick.Grant(H)
+ slam.Grant(H)
+ throw_wrassle.Grant(H)
+ strike.Grant(H)
-/datum/martial_art/wrestling/remove(var/mob/living/carbon/human/H)
- ..()
+/datum/martial_art/wrestling/on_remove(mob/living/carbon/human/H)
to_chat(H, "You no longer feel that the tower of power is too sweet to be sour...")
drop.Remove(H)
kick.Remove(H)
diff --git a/code/datums/mind.dm b/code/datums/mind.dm
index 692fdd80cb9..f23f01d068e 100644
--- a/code/datums/mind.dm
+++ b/code/datums/mind.dm
@@ -117,7 +117,7 @@
C.last_mind = src
transfer_antag_huds(hud_to_transfer) //inherit the antag HUD
transfer_actions(new_character)
-
+ transfer_martial_arts(new_character)
if(active || force_key_move)
new_character.key = key //now transfer the key to link the client to our new body
@@ -1623,6 +1623,15 @@
spell_list -= S
qdel(S)
+/datum/mind/proc/transfer_martial_arts(mob/living/new_character)
+ if(!ishuman(new_character))
+ return
+ if(martial_art)
+ if(martial_art.base) //Is the martial art temporary?
+ martial_art.remove(new_character)
+ else
+ martial_art.teach(new_character)
+
/datum/mind/proc/transfer_actions(mob/living/new_character)
if(current && current.actions)
for(var/datum/action/A in current.actions)