From 286ff345880a961b0e391a08fdf16dec4713dbff Mon Sep 17 00:00:00 2001 From: Cael_Aislinn Date: Sun, 1 Sep 2013 13:37:07 +1000 Subject: [PATCH] moved human helpers out of human.dm to new file human_helpers.dm, added two new mon helpers to check for mutations and mutantraces Signed-off-by: Cael_Aislinn --- code/modules/mob/living/carbon/carbon.dm | 9 +- code/modules/mob/living/carbon/human/human.dm | 122 +----------------- .../mob/living/carbon/human/human_helpers.dm | 116 +++++++++++++++++ code/modules/mob/mob_helpers.dm | 5 +- tgstation.dme | 1 + 5 files changed, 130 insertions(+), 123 deletions(-) create mode 100644 code/modules/mob/living/carbon/human/human_helpers.dm diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index ededd417cba..f2be95e217c 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -532,4 +532,11 @@ if(istype(wear_mask, /obj/item/clothing/mask/muzzle)) return - ..(message) \ No newline at end of file + ..(message) + +/mob/living/carbon/proc/is_mutantrace(var/mrace) + if(mrace) + if(src.dna && src.dna.mutantrace == mrace) + return 1 + else + return src.dna && src.dna.mutantrace ? 1 : 0 diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index e886a58683b..ebbe0d17232 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -326,15 +326,6 @@ return -/mob/living/carbon/human/restrained() - if (handcuffed) - return 1 - if (istype(wear_suit, /obj/item/clothing/suit/straight_jacket)) - return 1 - return 0 - - - /mob/living/carbon/human/var/co2overloadtime = null /mob/living/carbon/human/var/temperature_resistance = T0C+75 @@ -394,72 +385,6 @@ if(istype(MB)) MB.RunOver(src) -//gets assignment from ID or ID inside PDA or PDA itself -//Useful when player do something with computers -/mob/living/carbon/human/proc/get_assignment(var/if_no_id = "No id", var/if_no_job = "No job") - var/obj/item/weapon/card/id/id = get_idcard() - if(id) - . = id.assignment - else - var/obj/item/device/pda/pda = wear_id - if(istype(pda)) - . = pda.ownjob - else - return if_no_id - if(!.) - return if_no_job - -//gets name from ID or ID inside PDA or PDA itself -//Useful when player do something with computers -/mob/living/carbon/human/proc/get_authentification_name(var/if_no_id = "Unknown") - var/obj/item/weapon/card/id/id = get_idcard() - if(id) - return id.registered_name - var/obj/item/device/pda/pda = wear_id - if(istype(pda)) - return pda.owner - return if_no_id - -//repurposed proc. Now it combines get_id_name() and get_face_name() to determine a mob's name variable. Made into a seperate proc as it'll be useful elsewhere -/mob/living/carbon/human/proc/get_visible_name() - var/face_name = get_face_name("") - var/id_name = get_id_name("") - if(face_name) - if(id_name && (id_name != face_name)) - return "[face_name] (as [id_name])" - return face_name - if(id_name) - return id_name - return "Unknown" - -//Returns "Unknown" if facially disfigured and real_name if not. Useful for setting name when polyacided or when updating a human's name variable -/mob/living/carbon/human/proc/get_face_name(if_no_face="Unknown") - if( wear_mask && (wear_mask.flags_inv&HIDEFACE) ) //Wearing a mask which hides our face, use id-name if possible - return if_no_face - if( head && (head.flags_inv&HIDEFACE) ) - return if_no_face //Likewise for hats - var/datum/limb/O = get_organ("head") - if( (status_flags&DISFIGURED) || (O.brutestate+O.burnstate)>2 || cloneloss>50 || !real_name ) //disfigured. use id-name if possible - return if_no_face - return real_name - -//gets name from ID or PDA itself, ID inside PDA doesn't matter -//Useful when player is being seen by other mobs -/mob/living/carbon/human/proc/get_id_name(var/if_no_id = "Unknown") - var/obj/item/weapon/storage/wallet/wallet = wear_id - var/obj/item/device/pda/pda = wear_id - var/obj/item/weapon/card/id/id = wear_id - if(istype(wallet)) id = wallet.front_id - if(istype(id)) . = id.registered_name - else if(istype(pda)) . = pda.owner - if(!.) . = if_no_id //to prevent null-names making the mob unclickable - return - -//gets ID card object from special clothes slot or null. -/mob/living/carbon/human/proc/get_idcard() - if(wear_id) - return wear_id.GetID() - //Added a safety check in case you want to shock a human mob directly through electrocute_act. /mob/living/carbon/human/electrocute_act(var/shock_damage, var/obj/source, var/siemens_coeff = 1.0, var/safety = 0) if(!safety) @@ -548,51 +473,6 @@ if(!modified) usr << "\red Unable to locate a data core entry for this person." - -///eyecheck() -///Returns a number between -1 to 2 -/mob/living/carbon/human/eyecheck() - var/number = 0 - if(istype(src.head, /obj/item/clothing/head)) //are they wearing something on their head - var/obj/item/clothing/head/HFP = src.head //if yes gets the flash protection value from that item - number += HFP.flash_protect - if(istype(src.glasses, /obj/item/clothing/glasses)) //glasses - var/obj/item/clothing/glasses/GFP = src.glasses - number += GFP.flash_protect - if(istype(src.wear_mask, /obj/item/clothing/mask)) //mask - var/obj/item/clothing/mask/MFP = src.wear_mask - number += MFP.flash_protect - return number - -///tintcheck() -///Checks eye covering items for visually impairing tinting, such as welding masks -///Checked in life.dm. 0 & 1 = no impairment, 2 = welding mask overlay, 3 = You can see jack, but you can't see shit. -/mob/living/carbon/human/tintcheck() - var/tinted = 0 - if(istype(src.head, /obj/item/clothing/head)) - var/obj/item/clothing/head/HT = src.head - tinted += HT.tint - if(istype(src.glasses, /obj/item/clothing/glasses)) - var/obj/item/clothing/glasses/GT = src.glasses - tinted += GT.tint - if(istype(src.wear_mask, /obj/item/clothing/mask)) - var/obj/item/clothing/mask/MT = src.wear_mask - tinted += MT.tint - return tinted - -/mob/living/carbon/human/IsAdvancedToolUser() - return 1//Humans can use guns and such - - -/mob/living/carbon/human/abiotic(var/full_body = 0) - if(full_body && ((src.l_hand && !( src.l_hand.abstract )) || (src.r_hand && !( src.r_hand.abstract )) || (src.back || src.wear_mask || src.head || src.shoes || src.w_uniform || src.wear_suit || src.glasses || src.ears || src.gloves))) - return 1 - - if( (src.l_hand && !src.l_hand.abstract) || (src.r_hand && !src.r_hand.abstract) ) - return 1 - - return 0 - /mob/living/carbon/human/proc/play_xylophone() if(!src.xylophone) visible_message("[src] begins playing \his ribcage like a xylophone. It's quite spooky.","You begin to play a spooky refrain on your ribcage.","You hear a spooky xylophone melody.") @@ -600,4 +480,4 @@ playsound(loc, song, 50, 1, -1) xylophone = 1 spawn(1200) - xylophone = 0 \ No newline at end of file + xylophone = 0 diff --git a/code/modules/mob/living/carbon/human/human_helpers.dm b/code/modules/mob/living/carbon/human/human_helpers.dm new file mode 100644 index 00000000000..ac4ea3dc30d --- /dev/null +++ b/code/modules/mob/living/carbon/human/human_helpers.dm @@ -0,0 +1,116 @@ + +/mob/living/carbon/human/restrained() + if (handcuffed) + return 1 + if (istype(wear_suit, /obj/item/clothing/suit/straight_jacket)) + return 1 + return 0 + +//gets assignment from ID or ID inside PDA or PDA itself +//Useful when player do something with computers +/mob/living/carbon/human/proc/get_assignment(var/if_no_id = "No id", var/if_no_job = "No job") + var/obj/item/weapon/card/id/id = get_idcard() + if(id) + . = id.assignment + else + var/obj/item/device/pda/pda = wear_id + if(istype(pda)) + . = pda.ownjob + else + return if_no_id + if(!.) + return if_no_job + +//gets name from ID or ID inside PDA or PDA itself +//Useful when player do something with computers +/mob/living/carbon/human/proc/get_authentification_name(var/if_no_id = "Unknown") + var/obj/item/weapon/card/id/id = get_idcard() + if(id) + return id.registered_name + var/obj/item/device/pda/pda = wear_id + if(istype(pda)) + return pda.owner + return if_no_id + +//repurposed proc. Now it combines get_id_name() and get_face_name() to determine a mob's name variable. Made into a seperate proc as it'll be useful elsewhere +/mob/living/carbon/human/proc/get_visible_name() + var/face_name = get_face_name("") + var/id_name = get_id_name("") + if(face_name) + if(id_name && (id_name != face_name)) + return "[face_name] (as [id_name])" + return face_name + if(id_name) + return id_name + return "Unknown" + +//Returns "Unknown" if facially disfigured and real_name if not. Useful for setting name when polyacided or when updating a human's name variable +/mob/living/carbon/human/proc/get_face_name(if_no_face="Unknown") + if( wear_mask && (wear_mask.flags_inv&HIDEFACE) ) //Wearing a mask which hides our face, use id-name if possible + return if_no_face + if( head && (head.flags_inv&HIDEFACE) ) + return if_no_face //Likewise for hats + var/datum/limb/O = get_organ("head") + if( (status_flags&DISFIGURED) || (O.brutestate+O.burnstate)>2 || cloneloss>50 || !real_name ) //disfigured. use id-name if possible + return if_no_face + return real_name + +//gets name from ID or PDA itself, ID inside PDA doesn't matter +//Useful when player is being seen by other mobs +/mob/living/carbon/human/proc/get_id_name(var/if_no_id = "Unknown") + var/obj/item/weapon/storage/wallet/wallet = wear_id + var/obj/item/device/pda/pda = wear_id + var/obj/item/weapon/card/id/id = wear_id + if(istype(wallet)) id = wallet.front_id + if(istype(id)) . = id.registered_name + else if(istype(pda)) . = pda.owner + if(!.) . = if_no_id //to prevent null-names making the mob unclickable + return + +//gets ID card object from special clothes slot or null. +/mob/living/carbon/human/proc/get_idcard() + if(wear_id) + return wear_id.GetID() + +///eyecheck() +///Returns a number between -1 to 2 +/mob/living/carbon/human/eyecheck() + var/number = 0 + if(istype(src.head, /obj/item/clothing/head)) //are they wearing something on their head + var/obj/item/clothing/head/HFP = src.head //if yes gets the flash protection value from that item + number += HFP.flash_protect + if(istype(src.glasses, /obj/item/clothing/glasses)) //glasses + var/obj/item/clothing/glasses/GFP = src.glasses + number += GFP.flash_protect + if(istype(src.wear_mask, /obj/item/clothing/mask)) //mask + var/obj/item/clothing/mask/MFP = src.wear_mask + number += MFP.flash_protect + return number + +///tintcheck() +///Checks eye covering items for visually impairing tinting, such as welding masks +///Checked in life.dm. 0 & 1 = no impairment, 2 = welding mask overlay, 3 = You can see jack, but you can't see shit. +/mob/living/carbon/human/tintcheck() + var/tinted = 0 + if(istype(src.head, /obj/item/clothing/head)) + var/obj/item/clothing/head/HT = src.head + tinted += HT.tint + if(istype(src.glasses, /obj/item/clothing/glasses)) + var/obj/item/clothing/glasses/GT = src.glasses + tinted += GT.tint + if(istype(src.wear_mask, /obj/item/clothing/mask)) + var/obj/item/clothing/mask/MT = src.wear_mask + tinted += MT.tint + return tinted + +/mob/living/carbon/human/abiotic(var/full_body = 0) + if(full_body && ((src.l_hand && !( src.l_hand.abstract )) || (src.r_hand && !( src.r_hand.abstract )) || (src.back || src.wear_mask || src.head || src.shoes || src.w_uniform || src.wear_suit || src.glasses || src.ears || src.gloves))) + return 1 + + if( (src.l_hand && !src.l_hand.abstract) || (src.r_hand && !src.r_hand.abstract) ) + return 1 + + return 0 + +/mob/living/carbon/human/IsAdvancedToolUser() + return 1//Humans can use guns and such diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 6025aebd33f..ed698b4e20d 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -441,4 +441,7 @@ proc/is_special_character(mob/M) // returns 1 for special characters and 2 for h if(M.viruses && (locate(/datum/disease/jungle_fever) in M.viruses)) return 2 return 1 - return 0 \ No newline at end of file + return 0 + +/mob/proc/has_mutation(var/mutation) + return mutation in src.mutations ? 1 : 0 diff --git a/tgstation.dme b/tgstation.dme index 5211324f23f..1e73f208e6f 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -872,6 +872,7 @@ #include "code\modules\mob\living\carbon\human\human_damage.dm" #include "code\modules\mob\living\carbon\human\human_defense.dm" #include "code\modules\mob\living\carbon\human\human_defines.dm" +#include "code\modules\mob\living\carbon\human\human_helpers.dm" #include "code\modules\mob\living\carbon\human\human_movement.dm" #include "code\modules\mob\living\carbon\human\inventory.dm" #include "code\modules\mob\living\carbon\human\life.dm"