From c3eb6102b40dc2c4fabe265badc0dd0220107307 Mon Sep 17 00:00:00 2001 From: Zuhayr Date: Wed, 1 Apr 2015 17:06:49 -0700 Subject: [PATCH] Added a few null checks. --- code/game/antagonist/antagonist_build.dm | 1 + code/game/antagonist/outsider/deathsquad.dm | 5 +++-- code/modules/organs/organ_external.dm | 24 ++++++--------------- code/modules/projectiles/targeting.dm | 10 ++++----- code/modules/surgery/organs_internal.dm | 6 ++++-- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/code/game/antagonist/antagonist_build.dm b/code/game/antagonist/antagonist_build.dm index dc6800c750..34631d36fb 100644 --- a/code/game/antagonist/antagonist_build.dm +++ b/code/game/antagonist/antagonist_build.dm @@ -82,6 +82,7 @@ /datum/antagonist/proc/create_id(var/assignment, var/mob/living/carbon/human/player) var/obj/item/weapon/card/id/W = new id_type(player) + if(!W) return W.name = "[player.real_name]'s ID Card" W.access |= default_access W.assignment = "[assignment]" diff --git a/code/game/antagonist/outsider/deathsquad.dm b/code/game/antagonist/outsider/deathsquad.dm index 05fb6d1ec9..73c2c7fd78 100644 --- a/code/game/antagonist/outsider/deathsquad.dm +++ b/code/game/antagonist/outsider/deathsquad.dm @@ -44,8 +44,9 @@ var/datum/antagonist/deathsquad/deathsquad player.implant_loyalty(player) var/obj/item/weapon/card/id/id = create_id("Asset Protection", player) - id.access |= get_all_accesses() - id.icon_state = "centcom" + if(id) + id.access |= get_all_accesses() + id.icon_state = "centcom" create_radio(DTH_FREQ, player) /datum/antagonist/deathsquad/apply(var/datum/mind/player) diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index ec8a8b293d..eba5430fd4 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -3,13 +3,16 @@ ****************************************************/ /obj/item/organ/external name = "external" + min_broken_damage = 30 + max_damage = 0 + dir = SOUTH + organ_tag = "limb" + var/icon_name = null var/body_part = null var/icon_position = 0 - var/model var/force_icon - var/damage_state = "00" var/brute_dam = 0 var/burn_dam = 0 @@ -26,38 +29,25 @@ var/list/wounds = list() var/number_wounds = 0 // cache the number of wounds, which is NOT wounds.len! var/perma_injury = 0 - var/obj/item/organ/external/parent var/list/obj/item/organ/external/children - - // Internal organs of this body part - var/list/internal_organs = list() - + var/list/internal_organs = list() // Internal organs of this body part var/damage_msg = "\red You feel an intense pain" var/broken_description - var/open = 0 var/stage = 0 var/cavity = 0 var/sabotaged = 0 // If a prosthetic limb is emagged, it will detonate when it fails. var/encased // Needs to be opened with a saw to access the organs. - var/obj/item/hidden = null var/list/implants = list() - - // how often wounds should be updated, a higher number means less often - var/wound_update_accuracy = 1 - + var/wound_update_accuracy = 1 // how often wounds should be updated, a higher number means less often var/joint = "joint" // Descriptive string used in dislocation. var/amputation_point // Descriptive string used in amputation. var/dislocated = 0 // If you target a joint, you can dislocate the limb, causing temporary damage to the organ. var/can_grasp var/can_stand - min_broken_damage = 30 - max_damage = 0 - dir = SOUTH - /obj/item/organ/external/attackby(obj/item/weapon/W as obj, mob/user as mob) switch(stage) if(0) diff --git a/code/modules/projectiles/targeting.dm b/code/modules/projectiles/targeting.dm index 388b53a256..4e49a785e7 100644 --- a/code/modules/projectiles/targeting.dm +++ b/code/modules/projectiles/targeting.dm @@ -23,7 +23,7 @@ //Removing the lock and the buttons. /obj/item/weapon/gun/dropped(mob/user as mob) stop_aim() - if (user.client) + if(user && user.client) user.client.remove_gun_icons() return ..() @@ -47,7 +47,7 @@ /obj/item/weapon/gun/proc/PreFire(atom/A as mob|obj|turf|area, mob/living/user as mob|obj, params) //Lets not spam it. if(lock_time > world.time - 2) return - + user.set_dir(get_cardinal_dir(src, A)) if(isliving(A) && !(A in aim_targets)) Aim(A) //Clicked a mob, aim at them @@ -58,7 +58,7 @@ if(isliving(M) && (M in view(user)) && !(M in aim_targets)) Aim(M) //Aha! Aim at them! return 1 - + return 0 //Aiming at the target mob. @@ -83,12 +83,12 @@ if(src != M.get_active_hand()) stop_aim() return - + //reflex firing is disabled when help intent is set if (M.a_intent == I_HELP) M << "\red You refrain from firing your [src] as your intent is set to help." return - + M.last_move_intent = world.time var/firing_check = can_hit(T,usr) //0 if it cannot hit them, 1 if it is capable of hitting, and 2 if a special check is preventing it from firing. if(firing_check > 0) diff --git a/code/modules/surgery/organs_internal.dm b/code/modules/surgery/organs_internal.dm index bb0a6314c8..3f02eb8651 100644 --- a/code/modules/surgery/organs_internal.dm +++ b/code/modules/surgery/organs_internal.dm @@ -343,9 +343,11 @@ var/o_a = (O.gender == PLURAL) ? "" : "a " var/o_do = (O.gender == PLURAL) ? "don't" : "doesn't" - if(target.species.has_organ[O.organ_tag]) + if(O.organ_tag == "limb") + return 0 + else if(target.species.has_organ[O.organ_tag]) - if(!O.health) + if(O.is_damaged()) user << "\red \The [O.organ_tag] [o_is] in no state to be transplanted." return 2