Checks for temporary martial arts on mind transfer (#28746)

* Checks for temporary martial arts on mind transfer

* Makes transferring its own proc

* Makes sure martial arts are qdeleted on removal

* Improves teaching and removing
This commit is contained in:
Really-Good-Soda-Flavor
2017-07-04 11:34:05 +02:00
committed by AnturK
parent a2b21ab93d
commit d23c6f910d
4 changed files with 59 additions and 32 deletions
+31 -11
View File
@@ -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
+8 -9
View File
@@ -52,16 +52,15 @@
owner.visible_message("<span class='danger'>[owner] assumes the Lung Punch stance!</span>", "<b><i>Your next attack will be a Lung Punch.</i></b>")
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, "<span class = 'userdanger'>You know the arts of Krav Maga!</span>")
to_chat(H, "<span class = 'danger'>Place your cursor over a move at the top of the screen to see what it does.</span>")
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, "<span class = 'userdanger'>You know the arts of Krav Maga!</span>")
to_chat(H, "<span class = 'danger'>Place your cursor over a move at the top of the screen to see what it does.</span>")
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, "<span class = 'userdanger'>You suddenly forget the arts of Krav Maga...</span>")
neckchop.Remove(H)
legsweep.Remove(H)
+10 -11
View File
@@ -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, "<span class = 'userdanger'>SNAP INTO A THIN TIM!</span>")
to_chat(H, "<span class = 'danger'>Place your cursor over a move at the top of the screen to see what it does.</span>")
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, "<span class = 'userdanger'>SNAP INTO A THIN TIM!</span>")
to_chat(H, "<span class = 'danger'>Place your cursor over a move at the top of the screen to see what it does.</span>")
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, "<span class = 'userdanger'>You no longer feel that the tower of power is too sweet to be sour...</span>")
drop.Remove(H)
kick.Remove(H)
+10 -1
View File
@@ -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)