diff --git a/code/datums/components/irradiated.dm b/code/datums/components/irradiated.dm index fb80a974480..4467668d31f 100644 --- a/code/datums/components/irradiated.dm +++ b/code/datums/components/irradiated.dm @@ -129,7 +129,7 @@ if (should_halt_effects(parent)) return - var/obj/affected_limb = human_parent.get_bodypart(ran_zone()) + var/obj/affected_limb = human_parent.get_bodypart(human_parent.get_random_valid_zone()) human_parent.visible_message( span_boldwarning("[human_parent]'s [affected_limb.name] bubbles unnaturally, then bursts into blisters!"), span_boldwarning("Your [affected_limb.name] bubbles unnaturally, then bursts into blisters!"), diff --git a/code/datums/diseases/advance/symptoms/itching.dm b/code/datums/diseases/advance/symptoms/itching.dm index 89b4bb0dc4b..a96609702db 100644 --- a/code/datums/diseases/advance/symptoms/itching.dm +++ b/code/datums/diseases/advance/symptoms/itching.dm @@ -38,8 +38,7 @@ if(!.) return var/mob/living/carbon/M = A.affected_mob - var/picked_bodypart = pick(BODY_ZONE_HEAD, BODY_ZONE_CHEST, BODY_ZONE_R_ARM, BODY_ZONE_L_ARM, BODY_ZONE_R_LEG, BODY_ZONE_L_LEG) - var/obj/item/bodypart/bodypart = M.get_bodypart(picked_bodypart) + var/obj/item/bodypart/bodypart = M.get_bodypart(M.get_random_valid_zone(even_weights = TRUE)) if(bodypart && IS_ORGANIC_LIMB(bodypart) && !bodypart.is_pseudopart) //robotic limbs will mean less scratching overall (why are golems able to damage themselves with self-scratching, but not androids? the world may never know) var/can_scratch = scratch && !M.incapacitated() M.visible_message("[can_scratch ? span_warning("[M] scratches [M.p_their()] [bodypart.plaintext_zone].") : ""]", span_warning("Your [bodypart.plaintext_zone] itches. [can_scratch ? " You scratch it." : ""]")) diff --git a/code/datums/elements/ranged_attacks.dm b/code/datums/elements/ranged_attacks.dm index 0b09496e24e..b245a5fc9f2 100644 --- a/code/datums/elements/ranged_attacks.dm +++ b/code/datums/elements/ranged_attacks.dm @@ -35,7 +35,13 @@ if(casingtype) var/obj/item/ammo_casing/casing = new casingtype(startloc) playsound(firer, projectilesound, 100, TRUE) - casing.fire_casing(target, firer, null, null, null, ran_zone(), 0, firer) + var/target_zone + if(ismob(target)) + var/mob/target_mob + target_zone = target_mob.get_random_valid_zone() + else + target_zone = ran_zone() + casing.fire_casing(target, firer, null, null, null, target_zone, 0, firer) else if(projectiletype) var/obj/projectile/P = new projectiletype(startloc) diff --git a/code/datums/martial/boxing.dm b/code/datums/martial/boxing.dm index 186313c3c26..ed6da90812e 100644 --- a/code/datums/martial/boxing.dm +++ b/code/datums/martial/boxing.dm @@ -29,7 +29,7 @@ return FALSE - var/obj/item/bodypart/affecting = D.get_bodypart(ran_zone(A.zone_selected)) + var/obj/item/bodypart/affecting = D.get_bodypart(D.get_random_valid_zone(A.zone_selected)) var/armor_block = D.run_armor_check(affecting, MELEE) playsound(D.loc, species.attack_sound, 25, TRUE, -1) diff --git a/code/datums/martial/krav_maga.dm b/code/datums/martial/krav_maga.dm index 0b48873e2df..a801d56daa7 100644 --- a/code/datums/martial/krav_maga.dm +++ b/code/datums/martial/krav_maga.dm @@ -129,7 +129,7 @@ if(check_streak(attacker, defender)) return TRUE log_combat(attacker, defender, "punched") - var/obj/item/bodypart/affecting = defender.get_bodypart(ran_zone(attacker.zone_selected)) + var/obj/item/bodypart/affecting = defender.get_bodypart(defender.get_random_valid_zone(attacker.zone_selected)) var/picked_hit_type = pick("punch", "kick") var/bonus_damage = 0 if(defender.body_position == LYING_DOWN) diff --git a/code/datums/martial/sleeping_carp.dm b/code/datums/martial/sleeping_carp.dm index 10a9a76831a..ae947eb6b52 100644 --- a/code/datums/martial/sleeping_carp.dm +++ b/code/datums/martial/sleeping_carp.dm @@ -27,7 +27,7 @@ ///Gnashing Teeth: Harm Harm, consistent 20 force punch on every second harm punch /datum/martial_art/the_sleeping_carp/proc/strongPunch(mob/living/A, mob/living/D) ///this var is so that the strong punch is always aiming for the body part the user is targeting and not trying to apply to the chest before deviating - var/obj/item/bodypart/affecting = D.get_bodypart(ran_zone(A.zone_selected)) + var/obj/item/bodypart/affecting = D.get_bodypart(D.get_random_valid_zone(A.zone_selected)) A.do_attack_animation(D, ATTACK_EFFECT_PUNCH) var/atk_verb = pick("precisely kick", "brutally chop", "cleanly hit", "viciously slam") D.visible_message(span_danger("[A] [atk_verb]s [D]!"), \ @@ -80,7 +80,7 @@ add_to_streak("H",D) if(check_streak(A,D)) return TRUE - var/obj/item/bodypart/affecting = D.get_bodypart(ran_zone(A.zone_selected)) + var/obj/item/bodypart/affecting = D.get_bodypart(D.get_random_valid_zone(A.zone_selected)) A.do_attack_animation(D, ATTACK_EFFECT_PUNCH) var/atk_verb = pick("kick", "chop", "hit", "slam") D.visible_message(span_danger("[A] [atk_verb]s [D]!"), \ diff --git a/code/datums/station_traits/positive_traits.dm b/code/datums/station_traits/positive_traits.dm index af3fbc378d0..b756ad042c7 100644 --- a/code/datums/station_traits/positive_traits.dm +++ b/code/datums/station_traits/positive_traits.dm @@ -110,7 +110,7 @@ trait_type = STATION_TRAIT_POSITIVE weight = 5 show_in_report = TRUE - report_message = "Our workers accidentaly forgot more of their personal belongings in the maintenace areas." + report_message = "Our workers accidentally forgot more of their personal belongings in the maintenace areas." blacklist = list(/datum/station_trait/empty_maint) trait_to_give = STATION_TRAIT_FILLED_MAINT diff --git a/code/modules/clothing/shoes/cowboy.dm b/code/modules/clothing/shoes/cowboy.dm index 0c3116a5f56..f942bcf3611 100644 --- a/code/modules/clothing/shoes/cowboy.dm +++ b/code/modules/clothing/shoes/cowboy.dm @@ -22,10 +22,13 @@ RegisterSignal(user, COMSIG_LIVING_SLAM_TABLE, .proc/table_slam, override = TRUE) if(slot == ITEM_SLOT_FEET) for(var/mob/living/occupant in contents) + var/target_zone = user.get_random_valid_zone(blacklisted_parts = list(BODY_ZONE_CHEST, BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM), even_weights = TRUE, bypass_warning = TRUE) + if(!target_zone) //we broke their legs right on off! + break occupant.forceMove(user.drop_location()) user.visible_message(span_warning("[user] recoils as something slithers out of [src]."), span_userdanger("You feel a sudden stabbing pain in your [pick("foot", "toe", "ankle")]!")) user.Knockdown(20) //Is one second paralyze better here? I feel you would fall on your ass in some fashion. - user.apply_damage(5, BRUTE, pick(BODY_ZONE_R_LEG, BODY_ZONE_L_LEG)) + user.apply_damage(5, BRUTE, target_zone) if(istype(occupant, /mob/living/simple_animal/hostile/retaliate)) user.reagents.add_reagent(/datum/reagent/toxin, 7) diff --git a/code/modules/events/spacevine.dm b/code/modules/events/spacevine.dm index 329ce5ea1b7..1947326b3f8 100644 --- a/code/modules/events/spacevine.dm +++ b/code/modules/events/spacevine.dm @@ -249,7 +249,7 @@ /datum/spacevine_mutation/aggressive_spread/aggrospread_act(obj/structure/spacevine/vine, mob/living/living_mob) var/mob/living/carbon/victim = living_mob //If the mob is carbon then it now also exists as a victim, and not just an living mob. if(istype(victim)) //If the mob (M) is a carbon subtype (C) we move on to pick a more complex damage proc, with damage zones, wounds and armor mitigation. - var/obj/item/bodypart/limb = pick(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG, BODY_ZONE_HEAD, BODY_ZONE_CHEST) //Picks a random bodypart. Does not runtime even if it's missing. + var/obj/item/bodypart/limb = victim.get_bodypart(victim.get_random_valid_zone(even_weights = TRUE)) //Picks a random bodypart. var/armor = victim.run_armor_check(limb, MELEE, null, null) //armor = the armor value of that randomly chosen bodypart. Nulls to not print a message, because it would still print on pierce. var/datum/spacevine_mutation/thorns/thorn = locate() in vine.mutations //Searches for the thorns mutation in the "mutations"-list inside obj/structure/spacevine, and defines T if it finds it. if(thorn && (prob(40))) //If we found the thorns mutation there is now a chance to get stung instead of lashed or smashed. diff --git a/code/modules/mob/living/carbon/alien/alien_defense.dm b/code/modules/mob/living/carbon/alien/alien_defense.dm index 8b17812a631..941eb62fc73 100644 --- a/code/modules/mob/living/carbon/alien/alien_defense.dm +++ b/code/modules/mob/living/carbon/alien/alien_defense.dm @@ -64,7 +64,7 @@ In all, this is a lot like the monkey code. /N /mob/living/carbon/alien/attack_paw(mob/living/carbon/human/user, list/modifiers) if(..()) if (stat != DEAD) - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(user.zone_selected)) + var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(user.zone_selected)) apply_damage(rand(1, 3), BRUTE, affecting) diff --git a/code/modules/mob/living/carbon/alien/humanoid/humanoid_defense.dm b/code/modules/mob/living/carbon/alien/humanoid/humanoid_defense.dm index 16777169158..6f016d58304 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/humanoid_defense.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/humanoid_defense.dm @@ -38,7 +38,7 @@ visible_message(span_danger("[user] knocks [src] down!"), \ span_userdanger("[user] knocks you down!"), span_hear("You hear a sickening sound of flesh hitting flesh!"), null, user) to_chat(user, span_danger("You knock [src] down!")) - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(user.zone_selected)) + var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(user.zone_selected)) apply_damage(damage, BRUTE, affecting) log_combat(user, src, "attacked") else diff --git a/code/modules/mob/living/carbon/alien/larva/larva_defense.dm b/code/modules/mob/living/carbon/alien/larva/larva_defense.dm index debec99bd69..3fa78271d6f 100644 --- a/code/modules/mob/living/carbon/alien/larva/larva_defense.dm +++ b/code/modules/mob/living/carbon/alien/larva/larva_defense.dm @@ -12,7 +12,7 @@ if ((stat != DEAD) && (damage > 4.9)) Unconscious(rand(100,200)) - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(user.zone_selected)) + var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(user.zone_selected)) apply_damage(damage, BRUTE, affecting) else playsound(loc, 'sound/weapons/punchmiss.ogg', 25, TRUE, -1) diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index fd756810510..e446ea83802 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -78,7 +78,7 @@ var/zone_hit_chance = 80 if(body_position == LYING_DOWN) // half as likely to hit a different zone if they're on the ground zone_hit_chance += 10 - affecting = get_bodypart(ran_zone(user.zone_selected, zone_hit_chance)) + affecting = get_bodypart(get_random_valid_zone(user.zone_selected, zone_hit_chance)) if(!affecting) //missing limb? we select the first bodypart (you can never have zero, because of chest) affecting = bodyparts[1] SEND_SIGNAL(I, COMSIG_ITEM_ATTACK_ZONE, src, user, affecting) @@ -228,7 +228,7 @@ return dam_zone var/obj/item/bodypart/affecting if(dam_zone && attacker.client) - affecting = get_bodypart(ran_zone(dam_zone)) + affecting = get_bodypart(get_random_valid_zone(dam_zone)) else var/list/things_to_ruin = shuffle(bodyparts.Copy()) for(var/B in things_to_ruin) diff --git a/code/modules/mob/living/carbon/damage_procs.dm b/code/modules/mob/living/carbon/damage_procs.dm index 27ffce5a8ae..1dcb1252e70 100644 --- a/code/modules/mob/living/carbon/damage_procs.dm +++ b/code/modules/mob/living/carbon/damage_procs.dm @@ -12,7 +12,7 @@ BP = def_zone else if(!def_zone) - def_zone = ran_zone(def_zone) + def_zone = get_random_valid_zone(def_zone) BP = get_bodypart(check_zone(def_zone)) if(!BP) BP = bodyparts[1] diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 46f373964ce..ef25cbd4846 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -183,7 +183,7 @@ var/zone_hit_chance = 80 if(body_position == LYING_DOWN) // half as likely to hit a different zone if they're on the ground zone_hit_chance += 10 - affecting = get_bodypart(ran_zone(user.zone_selected, zone_hit_chance)) + affecting = get_bodypart(get_random_valid_zone(user.zone_selected, zone_hit_chance)) var/target_area = parse_zone(check_zone(user.zone_selected)) //our intended target SEND_SIGNAL(I, COMSIG_ITEM_ATTACK_ZONE, src, user, affecting) @@ -219,9 +219,7 @@ /mob/living/carbon/human/attack_paw(mob/living/carbon/human/user, list/modifiers) var/dam_zone = pick(BODY_ZONE_CHEST, BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_PRECISE_R_HAND, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(dam_zone)) - if(!affecting) - affecting = get_bodypart(BODY_ZONE_CHEST) + var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(dam_zone)) var/martial_result = user.apply_martial_art(src, modifiers) if (martial_result != MARTIAL_ATTACK_INVALID) @@ -304,9 +302,7 @@ span_userdanger("[user] lunges at you!"), span_hear("You hear a swoosh!"), null, user) to_chat(user, span_danger("You lunge at [src]!")) return FALSE - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(user.zone_selected)) - if(!affecting) - affecting = get_bodypart(BODY_ZONE_CHEST) + var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(user.zone_selected)) var/armor_block = run_armor_check(affecting, MELEE,"","",10) playsound(loc, 'sound/weapons/slice.ogg', 25, TRUE, -1) @@ -332,9 +328,7 @@ return FALSE if(stat != DEAD) L.amount_grown = min(L.amount_grown + damage, L.max_grown) - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(L.zone_selected)) - if(!affecting) - affecting = get_bodypart(BODY_ZONE_CHEST) + var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(L.zone_selected)) var/armor_block = run_armor_check(affecting, MELEE) apply_damage(damage, BRUTE, affecting, armor_block) @@ -349,9 +343,7 @@ var/dam_zone = dismembering_strike(user, pick(BODY_ZONE_CHEST, BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_PRECISE_R_HAND, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG)) if(!dam_zone) //Dismemberment successful return TRUE - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(dam_zone)) - if(!affecting) - affecting = get_bodypart(BODY_ZONE_CHEST) + var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(dam_zone)) var/armor = run_armor_check(affecting, MELEE, armour_penetration = user.armour_penetration) var/attack_direction = get_dir(user, src) apply_damage(damage, user.melee_damage_type, affecting, armor, wound_bonus = user.wound_bonus, bare_wound_bonus = user.bare_wound_bonus, sharpness = user.sharpness, attack_direction = attack_direction) @@ -367,9 +359,7 @@ var/dam_zone = dismembering_strike(user, pick(BODY_ZONE_CHEST, BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_PRECISE_R_HAND, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG)) if(!dam_zone) //Dismemberment successful return TRUE - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(dam_zone)) - if(!affecting) - affecting = get_bodypart(BODY_ZONE_CHEST) + var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(dam_zone)) var/armor = run_armor_check(affecting, MELEE, armour_penetration = user.armour_penetration) var/attack_direction = get_dir(user, src) apply_damage(damage, user.melee_damage_type, affecting, armor, wound_bonus = user.wound_bonus, bare_wound_bonus = user.bare_wound_bonus, sharpness = user.sharpness, attack_direction = attack_direction) @@ -394,9 +384,7 @@ if(!dam_zone) //Dismemberment successful return TRUE - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(dam_zone)) - if(!affecting) - affecting = get_bodypart(BODY_ZONE_CHEST) + var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(dam_zone)) var/armor_block = run_armor_check(affecting, MELEE) apply_damage(damage, BRUTE, affecting, armor_block, wound_bonus=wound_mod) @@ -489,8 +477,8 @@ if(stat == DEAD) return show_message(span_userdanger("The blob attacks you!")) - var/dam_zone = pick(BODY_ZONE_CHEST, BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_PRECISE_R_HAND, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) - var/obj/item/bodypart/affecting = get_bodypart(ran_zone(dam_zone)) + var/dam_zone = pick(BODY_ZONE_CHEST, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) + var/obj/item/bodypart/affecting = get_bodypart(get_random_valid_zone(dam_zone)) apply_damage(5, BRUTE, affecting, run_armor_check(affecting, MELEE)) diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index caa22dd026d..c7bfb69c91a 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -1114,7 +1114,7 @@ GLOBAL_LIST_EMPTY(features_by_species) var/damage = rand(user.dna.species.punchdamagelow, user.dna.species.punchdamagehigh) - var/obj/item/bodypart/affecting = target.get_bodypart(ran_zone(user.zone_selected)) + var/obj/item/bodypart/affecting = target.get_bodypart(target.get_random_valid_zone(user.zone_selected)) var/miss_chance = 100//calculate the odds that a punch misses entirely. considers stamina and brute damage of the puncher. punches miss by default to prevent weird cases if(user.dna.species.punchdamagelow) @@ -1333,7 +1333,7 @@ GLOBAL_LIST_EMPTY(features_by_species) BP = def_zone else if(!def_zone) - def_zone = ran_zone(def_zone) + def_zone = H.get_random_valid_zone(def_zone) BP = H.get_bodypart(check_zone(def_zone)) if(!BP) BP = H.bodyparts[1] diff --git a/code/modules/mob/living/carbon/human/species_types/monkeys.dm b/code/modules/mob/living/carbon/human/species_types/monkeys.dm index 0dcfe6b2460..2cb5254b9ae 100644 --- a/code/modules/mob/living/carbon/human/species_types/monkeys.dm +++ b/code/modules/mob/living/carbon/human/species_types/monkeys.dm @@ -93,7 +93,7 @@ var/obj/item/bodypart/affecting = null if(ishuman(victim)) var/mob/living/carbon/human/human_victim = victim - affecting = human_victim.get_bodypart(pick(BODY_ZONE_CHEST, BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_PRECISE_R_HAND, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG)) + affecting = human_victim.get_bodypart(human_victim.get_random_valid_zone(even_weights = TRUE)) var/armor = victim.run_armor_check(affecting, MELEE) if(prob(25)) victim.visible_message(span_danger("[user]'s bite misses [victim]!"), diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index da7cfba2084..aa9f2ab3330 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -99,7 +99,7 @@ /mob/living/hitby(atom/movable/AM, skipcatch, hitpush = TRUE, blocked = FALSE, datum/thrownthing/throwingdatum) if(isitem(AM)) var/obj/item/thrown_item = AM - var/zone = ran_zone(BODY_ZONE_CHEST, 65)//Hits a random part of the body, geared towards the chest + var/zone = get_random_valid_zone(BODY_ZONE_CHEST, 65)//Hits a random part of the body, geared towards the chest var/nosell_hit = SEND_SIGNAL(thrown_item, COMSIG_MOVABLE_IMPACT_ZONE, src, zone, throwingdatum) // TODO: find a better way to handle hitpush and skipcatch for humans if(nosell_hit) skipcatch = TRUE diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index a38ba295507..9ac8f09772e 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -426,7 +426,13 @@ if(casingtype) var/obj/item/ammo_casing/casing = new casingtype(startloc) playsound(src, projectilesound, 100, TRUE) - casing.fire_casing(targeted_atom, src, null, null, null, ran_zone(), 0, src) + var/targeted_zone + if(ismob(targeted_atom)) + var/mob/targeted_mob = targeted_atom + targeted_zone = targeted_mob.get_random_valid_zone() + else + targeted_zone = ran_zone() + casing.fire_casing(targeted_atom, src, null, null, null, targeted_zone, 0, src) else if(projectiletype) var/obj/projectile/P = new projectiletype(startloc) playsound(src, projectilesound, 100, TRUE) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm index 8c3b776b7bb..f80fdd0c112 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm @@ -205,7 +205,7 @@ Difficulty: Hard if(!faction_check_mob(L)) to_chat(L, span_userdanger("[src] rends you!")) playsound(T, attack_sound, 100, TRUE, -1) - var/limb_to_hit = L.get_bodypart(pick(BODY_ZONE_HEAD, BODY_ZONE_CHEST, BODY_ZONE_R_ARM, BODY_ZONE_L_ARM, BODY_ZONE_R_LEG, BODY_ZONE_L_LEG)) + var/limb_to_hit = L.get_bodypart(L.get_random_valid_zone(even_weights = TRUE)) L.apply_damage(10, BRUTE, limb_to_hit, L.run_armor_check(limb_to_hit, MELEE, null, null, armour_penetration), wound_bonus = CANT_WOUND) SLEEP_CHECK_DEATH(3, src) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm index ef0a9cadd60..d8a87f3a620 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm @@ -702,7 +702,7 @@ Difficulty: Hard flash_color(L.client, "#660099", 1) playsound(L,'sound/weapons/sear.ogg', 50, TRUE, -4) to_chat(L, span_userdanger("You're struck by a [name]!")) - var/limb_to_hit = L.get_bodypart(pick(BODY_ZONE_HEAD, BODY_ZONE_CHEST, BODY_ZONE_R_ARM, BODY_ZONE_L_ARM, BODY_ZONE_R_LEG, BODY_ZONE_L_LEG)) + var/limb_to_hit = L.get_bodypart(L.get_random_valid_zone(even_weights = TRUE)) var/armor = L.run_armor_check(limb_to_hit, MELEE, "Your armor absorbs [src]!", "Your armor blocks part of [src]!", FALSE, 50, "Your armor was penetrated by [src]!") L.apply_damage(damage, BURN, limb_to_hit, armor, wound_bonus=CANT_WOUND) if(ishostile(L)) diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 53ff7adfb0f..0b9b84cf5a5 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -57,10 +57,10 @@ * * Setting even_weight to TRUE will make it just a straight up pick() between all possible bodyparts. * */ -/mob/proc/get_random_valid_zone(list/blacklisted_parts, even_weights, base_zone, base_probability = 80) +/mob/proc/get_random_valid_zone(base_zone, base_probability = 80, list/blacklisted_parts, even_weights, bypass_warning) return BODY_ZONE_CHEST //even though they don't really have a chest, let's just pass the default of check_zone to be safe. -/mob/living/carbon/get_random_valid_zone(list/blacklisted_parts, even_weights, base_zone, base_probability = 80) +/mob/living/carbon/get_random_valid_zone(base_zone, base_probability = 80, list/blacklisted_parts, even_weights, bypass_warning) var/list/limbs = list() for(var/obj/item/bodypart/part as anything in bodyparts) var/limb_zone = part.body_zone //cache the zone since we're gonna check it a ton. @@ -80,7 +80,7 @@ var/chest_blacklisted if((BODY_ZONE_CHEST in blacklisted_parts)) chest_blacklisted = TRUE - if(!limbs.len) + if(bypass_warning && !limbs.len) CRASH("limbs is empty and the chest is blacklisted. this may not be intended!") return (((chest_blacklisted && !base_zone) || even_weights) ? pick_weight(limbs) : ran_zone(base_zone, base_probability, limbs)) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index aaf03043589..a9065b10501 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -270,9 +270,11 @@ if(clumsy_check) if(istype(user)) if(HAS_TRAIT(user, TRAIT_CLUMSY) && prob(40)) + var/target_zone = user.get_random_valid_zone(blacklisted_parts = list(BODY_ZONE_CHEST, BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM), even_weights = TRUE, bypass_warning = TRUE) + if(!target_zone) + return to_chat(user, span_userdanger("You shoot yourself in the foot with [src]!")) - var/shot_leg = pick(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG) - process_fire(user, user, FALSE, null, shot_leg) + process_fire(user, user, FALSE, null, target_zone) SEND_SIGNAL(user, COMSIG_MOB_CLUMSY_SHOOT_FOOT) if(!tk_firing(user) && !HAS_TRAIT(src, TRAIT_NODROP)) user.dropItemToGround(src, TRUE) diff --git a/code/modules/projectiles/guns/ballistic.dm b/code/modules/projectiles/guns/ballistic.dm index 60dc45dc251..0a426cceb6a 100644 --- a/code/modules/projectiles/guns/ballistic.dm +++ b/code/modules/projectiles/guns/ballistic.dm @@ -462,9 +462,8 @@ SpinAnimation(4,2) if(flip_cooldown <= world.time) if(HAS_TRAIT(user, TRAIT_CLUMSY) && prob(40)) - to_chat(user, span_userdanger("While trying to flip [src] you pull the trigger and accidentaly shoot yourself!")) - var/flip_mistake = pick(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG, BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_CHEST) - process_fire(user, user, FALSE, flip_mistake) + to_chat(user, span_userdanger("While trying to flip [src] you pull the trigger and accidentally shoot yourself!")) + process_fire(user, user, FALSE, user.get_random_valid_zone(even_weights = TRUE)) user.dropItemToGround(src, TRUE) return flip_cooldown = (world.time + 30) diff --git a/code/modules/research/experimentor.dm b/code/modules/research/experimentor.dm index 2f3ff2286ad..5fdd9143af4 100644 --- a/code/modules/research/experimentor.dm +++ b/code/modules/research/experimentor.dm @@ -256,7 +256,7 @@ else if(prob(EFFECT_PROB_VERYLOW-malfunction_probability_coeff)) visible_message(span_danger("[src] malfunctions and destroys [exp_on], lashing its arms out at nearby people!")) for(var/mob/living/m in oview(1, src)) - m.apply_damage(15, BRUTE, pick(BODY_ZONE_HEAD,BODY_ZONE_CHEST,BODY_ZONE_PRECISE_GROIN)) + m.apply_damage(15, BRUTE, pick(BODY_ZONE_HEAD,BODY_ZONE_CHEST,BODY_ZONE_CHEST)) investigate_log("Experimentor dealt minor brute to [m].", INVESTIGATE_EXPERIMENTOR) ejectItem(TRUE) else if(prob(EFFECT_PROB_LOW-malfunction_probability_coeff)) @@ -388,7 +388,7 @@ visible_message(span_warning("[src] malfunctions, activating its emergency coolant systems!")) throwSmoke(loc) for(var/mob/living/m in oview(1, src)) - m.apply_damage(5, BURN, pick(BODY_ZONE_HEAD,BODY_ZONE_CHEST,BODY_ZONE_PRECISE_GROIN)) + m.apply_damage(5, BURN, pick(BODY_ZONE_HEAD,BODY_ZONE_CHEST,BODY_ZONE_CHEST)) investigate_log("Experimentor has dealt minor burn damage to [key_name(m)]", INVESTIGATE_EXPERIMENTOR) ejectItem() //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm b/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm index 434e66c79db..88a5555518c 100644 --- a/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm +++ b/code/modules/vehicles/mecha/equipment/tools/mining_tools.dm @@ -130,7 +130,7 @@ target.gib() else //drill makes a hole - var/obj/item/bodypart/target_part = target.get_bodypart(ran_zone(BODY_ZONE_CHEST)) + var/obj/item/bodypart/target_part = target.get_bodypart(target.get_random_valid_zone(BODY_ZONE_CHEST)) target.apply_damage(10, BRUTE, BODY_ZONE_CHEST, target.run_armor_check(target_part, MELEE)) //blood splatters diff --git a/code/modules/vehicles/scooter.dm b/code/modules/vehicles/scooter.dm index cb61a2c0d98..1d95097735b 100644 --- a/code/modules/vehicles/scooter.dm +++ b/code/modules/vehicles/scooter.dm @@ -150,8 +150,7 @@ for(var/mob/living/carbon/victim in location) if(victim.body_position == LYING_DOWN) playsound(location, 'sound/items/trayhit2.ogg', 40) - var/body_part = pick(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG, BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_CHEST) - victim.apply_damage(damage = 25, damagetype = BRUTE, def_zone = body_part, wound_bonus = 20) + victim.apply_damage(damage = 25, damagetype = BRUTE, def_zone = victim.get_random_valid_zone(even_weights = TRUE), wound_bonus = 20) victim.Paralyze(1.5 SECONDS) skater.adjustStaminaLoss(instability) victim.visible_message(span_danger("[victim] straight up gets grinded into the ground by [skater]'s [src]! Radical!"))