From e76cc064df63c548ec743757d9047a925ee12af8 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Thu, 31 Jul 2014 15:20:45 -0400 Subject: [PATCH] Fixes siemens_coefficent not affecting shock damage Also cleans up electrocute_act() Conflicts: code/game/gamemodes/events/ninja_equipment.dm code/modules/mob/living/carbon/carbon.dm code/modules/mob/living/carbon/human/human.dm --- code/game/gamemodes/events/ninja_equipment.dm | 7 ++-- code/modules/mob/living/carbon/carbon.dm | 36 +++++++++++-------- code/modules/mob/living/carbon/human/human.dm | 22 ++++++------ .../mob/living/carbon/human/human_defense.dm | 27 ++++++++------ code/modules/power/power.dm | 3 ++ 5 files changed, 58 insertions(+), 37 deletions(-) diff --git a/code/game/gamemodes/events/ninja_equipment.dm b/code/game/gamemodes/events/ninja_equipment.dm index f1ed059acbe..ae6d6892050 100644 --- a/code/game/gamemodes/events/ninja_equipment.dm +++ b/code/game/gamemodes/events/ninja_equipment.dm @@ -553,8 +553,11 @@ ________________________________________________________________________________ var/damage = min(cell.charge, rand(50,150))//Uses either the current energy left over or between 50 and 150. if(damage>1)//So they don't spam it when energy is a factor. spark_system.start()//SPARKS THERE SHALL BE SPARKS - U.electrocute_act(damage, src,0.1,1)//The last argument is a safety for the human proc that checks for gloves. - cell.charge -= damage + U.electrocute_act(damage, src, 0.1) + if(cell.charge < damage) + cell.use(cell.charge) + else + cell.use(damage) else A << "\red ERROR: \black Not enough energy remaining." diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 4ba7c31f01e..9a99d66a6b9 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -77,27 +77,33 @@ return -/mob/living/carbon/electrocute_act(var/shock_damage, var/obj/source, var/siemens_coeff = 1.0) +/mob/living/carbon/electrocute_act(var/shock_damage, var/obj/source, var/siemens_coeff = 1.0, var/def_zone = null) if(status_flags & GODMODE) return 0 //godmode shock_damage *= siemens_coeff if (shock_damage<1) return 0 - src.take_overall_damage(0,shock_damage,used_weapon="Electrocution") - //src.burn_skin(shock_damage) - //src.adjustFireLoss(shock_damage) //burn_skin will do this for us - //src.updatehealth() - src.visible_message( - "\red [src] was shocked by the [source]!", \ - "\red You feel a powerful shock course through your body!", \ - "\red You hear a heavy electrical crack." \ - ) -// if(src.stunned < shock_damage) src.stunned = shock_damage - Stun(10)//This should work for now, more is really silly and makes you lay there forever -// if(src.weakened < 20*siemens_coeff) src.weakened = 20*siemens_coeff - Weaken(10) + + src.apply_damage(shock_damage, BURN, def_zone, used_weapon="Electrocution") + + playsound(loc, "sparks", 50, 1, -1) + if (shock_damage > 10) + src.visible_message( + "\red [src] was shocked by the [source]!", \ + "\red You feel a powerful shock course through your body!", \ + "\red You hear a heavy electrical crack." \ + ) + Stun(10)//This should work for now, more is really silly and makes you lay there forever + Weaken(10) + else + src.visible_message( + "\red [src] was mildly shocked by the [source].", \ + "\red You feel a mild shock course through your body.", \ + "\red You hear a light zapping." \ + ) return shock_damage + /mob/living/carbon/proc/swap_hand() var/obj/item/item_in_hand = src.get_active_hand() if(item_in_hand) //this segment checks if the item in your hand is twohanded. @@ -563,4 +569,4 @@ return /mob/living/carbon/proc/canBeHandcuffed() - return 0 + return 0 \ No newline at end of file diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index fcc79568bba..5f6fcf39c9f 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -557,16 +557,18 @@ if (istype(id)) return id -//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) - if(gloves) - var/obj/item/clothing/gloves/G = gloves - siemens_coeff = G.siemens_coefficient - //If they have shock immunity mutation - if(M_NO_SHOCK in src.mutations) - siemens_coeff = 0 - return ..(shock_damage,source,siemens_coeff) +//Removed the horrible safety parameter. It was only being used by ninja code anyways. +//Now checks siemens_coefficient of the affected area by default +/mob/living/carbon/human/electrocute_act(var/shock_damage, var/obj/source, var/base_siemens_coeff = 1.0, var/def_zone = null) + if(status_flags & GODMODE) return 0 //godmode + + if (!def_zone) + def_zone = pick("l_hand", "r_hand") + + var/datum/organ/external/affected_organ = get_organ(check_zone(def_zone)) + var/siemens_coeff = base_siemens_coeff * get_siemens_coefficient_organ(affected_organ) + + return ..(shock_damage, source, siemens_coeff, def_zone) /mob/living/carbon/human/Topic(href, href_list) diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 7000b41f25b..8409fca4fac 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -54,15 +54,7 @@ emp_act //BEGIN BOOK'S TASER NERF. if(istype(P, /obj/item/projectile/beam/stun)) var/datum/organ/external/select_area = get_organ(def_zone) // We're checking the outside, buddy! - var/list/body_parts = list(head, wear_mask, wear_suit, w_uniform, gloves, shoes) // What all are we checking? - // var/deflectchance=90 //Is it a CRITICAL HIT with that taser? - for(var/bp in body_parts) //Make an unregulated var to pass around. - if(!bp) - continue //Does this thing we're shooting even exist? - if(bp && istype(bp ,/obj/item/clothing)) // If it exists, and it's clothed - var/obj/item/clothing/C = bp // Then call an argument C to be that clothing! - if(C.body_parts_covered & select_area.body_part) // Is that body part being targeted covered? - P.agony=P.agony*C.siemens_coefficient + P.agony *= get_siemens_coefficient_organ(select_area) apply_effect(P.agony,AGONY,0) flash_pain() src <<"\red You have been shot!" @@ -119,6 +111,21 @@ emp_act organnum++ return (armorval/max(organnum, 1)) +//this proc returns the Siemens coefficient of electrical resistivity for a particular external organ. +/mob/living/carbon/human/proc/get_siemens_coefficient_organ(var/datum/organ/external/def_zone) + if (!def_zone) + return 1.0 + + var/siemens_coefficient = 1.0 + + var/list/clothing_items = list(head, wear_mask, wear_suit, w_uniform, gloves, shoes) // What all are we checking? + for(var/obj/item/clothing/C in clothing_items) + if(!istype(C)) //is this necessary? + continue + else if(C.body_parts_covered & def_zone.body_part) // Is that body part being targeted covered? + siemens_coefficient *= C.siemens_coefficient + + return siemens_coefficient //this proc returns the armour value for a particular external organ. /mob/living/carbon/human/proc/getarmor_organ(var/datum/organ/external/def_zone, var/type) @@ -193,7 +200,7 @@ emp_act /mob/living/carbon/human/proc/attacked_by(var/obj/item/I, var/mob/living/user, var/def_zone) if(!I || !user) return 0 - var/target_zone = def_zone? def_zone : get_zone_with_miss_chance(user.zone_sel.selecting, src) + var/target_zone = def_zone? check_zone(def_zone) : get_zone_with_miss_chance(user.zone_sel.selecting, src) if(user == src) // Attacking yourself can't miss target_zone = user.zone_sel.selecting diff --git a/code/modules/power/power.dm b/code/modules/power/power.dm index 636971a0177..8cfddc18c2d 100644 --- a/code/modules/power/power.dm +++ b/code/modules/power/power.dm @@ -455,6 +455,9 @@ //No animations will be performed by this proc. /proc/electrocute_mob(mob/living/carbon/M as mob, var/power_source, var/obj/source, var/siemens_coeff = 1.0) if(istype(M.loc,/obj/mecha)) return 0 //feckin mechs are dumb + + //This is for performance optimization only. + //DO NOT modify siemens_coeff here. That is checked in human/electrocute_act() if(istype(M,/mob/living/carbon/human)) var/mob/living/carbon/human/H = M if(H.gloves)