From e0991fd16e09509683674c9f922fea0a445392d6 Mon Sep 17 00:00:00 2001 From: MistakeNot4892 Date: Fri, 10 Jan 2025 00:12:40 +1100 Subject: [PATCH] Ensuring sharpness is not deducated multiple times on a hit. --- code/game/objects/items/_item_materials.dm | 2 +- .../game/objects/items/flame/flame_fuelled.dm | 2 +- .../crates_lockers/closets/__closet.dm | 2 +- code/game/objects/structures/doors/_door.dm | 2 +- code/game/objects/structures/fishtanks.dm | 2 +- .../cooking_vessels/_cooking_vessel.dm | 2 +- code/modules/hydroponics/trays/tray.dm | 19 ++++++++++--------- code/modules/mechs/equipment/combat.dm | 2 +- code/modules/mob/grab/normal/grab_normal.dm | 2 +- .../modules/mob/living/human/human_defense.dm | 4 ++-- code/modules/mob/living/living_defense.dm | 2 +- .../modules/mob/living/silicon/robot/robot.dm | 2 +- .../item_sharpening/_item_sharpening.dme | 2 +- .../content/item_sharpening/effect_sharpen.dm | 4 ++-- mods/content/item_sharpening/item_sharpen.dm | 4 ++-- .../system/psionics/equipment/psipower.dm | 4 ++-- .../dionaea/mob/gestalt/gestalt_attacks.dm | 2 +- 17 files changed, 30 insertions(+), 29 deletions(-) diff --git a/code/game/objects/items/_item_materials.dm b/code/game/objects/items/_item_materials.dm index ecf48b7029e..0615330d3cf 100644 --- a/code/game/objects/items/_item_materials.dm +++ b/code/game/objects/items/_item_materials.dm @@ -12,7 +12,7 @@ /obj/item/apply_hit_effect(mob/living/target, mob/living/user, var/hit_zone) . = ..() - if(material && (material.is_brittle() || target.get_blocked_ratio(hit_zone, BRUTE, damage_flags(), armor_penetration, get_attack_force(user)) * 100 >= material.hardness/5)) + if(material && (material.is_brittle() || target.get_blocked_ratio(hit_zone, BRUTE, damage_flags(), armor_penetration, get_attack_force(user, dry_run = TRUE)) * 100 >= material.hardness/5)) apply_wear() /obj/item/on_parry(mob/user, damage_source, mob/attacker) diff --git a/code/game/objects/items/flame/flame_fuelled.dm b/code/game/objects/items/flame/flame_fuelled.dm index 07bcfe40859..42eec60835d 100644 --- a/code/game/objects/items/flame/flame_fuelled.dm +++ b/code/game/objects/items/flame/flame_fuelled.dm @@ -21,7 +21,7 @@ // Boilerplate from /obj/item/chems/glass. TODO generalize to a lower level. /obj/item/flame/fuelled/use_on_mob(mob/living/target, mob/living/user, animate = TRUE) - if(get_attack_force() && !(item_flags & ITEM_FLAG_NO_BLUDGEON) && user.check_intent(I_FLAG_HARM)) + if(get_attack_force(dry_run = TRUE) && !(item_flags & ITEM_FLAG_NO_BLUDGEON) && user.check_intent(I_FLAG_HARM)) . = ..() if(reagents?.total_volume && !QDELETED(target)) target.visible_message(SPAN_DANGER("Some of the contents of \the [src] splash onto \the [target].")) diff --git a/code/game/objects/structures/crates_lockers/closets/__closet.dm b/code/game/objects/structures/crates_lockers/closets/__closet.dm index 9e717d53f97..75c4ede0964 100644 --- a/code/game/objects/structures/crates_lockers/closets/__closet.dm +++ b/code/game/objects/structures/crates_lockers/closets/__closet.dm @@ -250,7 +250,7 @@ var/global/list/closets = list() /obj/structure/closet/attackby(obj/item/used_item, mob/user) - if(user.check_intent(I_FLAG_HARM) && used_item.get_attack_force(user)) + if(user.check_intent(I_FLAG_HARM) && used_item.get_attack_force(user, dry_run = TRUE)) return ..() if(!opened && (istype(used_item, /obj/item/stack/material) || IS_WRENCH(used_item)) ) diff --git a/code/game/objects/structures/doors/_door.dm b/code/game/objects/structures/doors/_door.dm index 745ad4bea2d..a3b3a94c88c 100644 --- a/code/game/objects/structures/doors/_door.dm +++ b/code/game/objects/structures/doors/_door.dm @@ -163,7 +163,7 @@ /obj/structure/door/attackby(obj/item/used_item, mob/user) add_fingerprint(user, 0, used_item) - if((user.check_intent(I_FLAG_HARM) && used_item.get_attack_force(user)) || istype(used_item, /obj/item/stack/material)) + if((user.check_intent(I_FLAG_HARM) && used_item.get_attack_force(user, dry_run = TRUE)) || istype(used_item, /obj/item/stack/material)) return ..() if(used_item.user_can_attack_with(user, silent = TRUE)) diff --git a/code/game/objects/structures/fishtanks.dm b/code/game/objects/structures/fishtanks.dm index b6724f46775..bc711de5671 100644 --- a/code/game/objects/structures/fishtanks.dm +++ b/code/game/objects/structures/fishtanks.dm @@ -69,7 +69,7 @@ var/global/list/fishtank_cache = list() return TRUE /obj/structure/glass_tank/attackby(var/obj/item/W, var/mob/user) - if(W.get_attack_force(user) < 5 || !user.check_intent(I_FLAG_HARM)) + if(W.get_attack_force(user, dry_run = TRUE) < 5 || !user.check_intent(I_FLAG_HARM)) attack_animation(user) visible_message(SPAN_NOTICE("\The [user] taps \the [src] with \the [W].")) else diff --git a/code/modules/food/cooking/cooking_vessels/_cooking_vessel.dm b/code/modules/food/cooking/cooking_vessels/_cooking_vessel.dm index f5884e492a0..c51181040bd 100644 --- a/code/modules/food/cooking/cooking_vessels/_cooking_vessel.dm +++ b/code/modules/food/cooking/cooking_vessels/_cooking_vessel.dm @@ -35,7 +35,7 @@ // Boilerplate from /obj/item/chems/glass. TODO generalize to a lower level. /obj/item/chems/cooking_vessel/use_on_mob(mob/living/target, mob/living/user, animate = TRUE) - if(get_attack_force() && !(item_flags & ITEM_FLAG_NO_BLUDGEON) && user.check_intent(I_FLAG_HARM)) + if(get_attack_force(dry_run = TRUE) && !(item_flags & ITEM_FLAG_NO_BLUDGEON) && user.check_intent(I_FLAG_HARM)) return ..() return FALSE diff --git a/code/modules/hydroponics/trays/tray.dm b/code/modules/hydroponics/trays/tray.dm index 5f5b3f9d272..d2f88048590 100644 --- a/code/modules/hydroponics/trays/tray.dm +++ b/code/modules/hydroponics/trays/tray.dm @@ -491,15 +491,16 @@ to_chat(user, "You [anchored ? "wrench" : "unwrench"] \the [src].") return TRUE - var/force = O.get_attack_force(user) - if(force && seed) - user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) - user.visible_message("\The [seed.display_name] has been attacked by [user] with \the [O]!") - playsound(get_turf(src), O.hitsound, 100, 1) - if(!dead) - plant_health -= force - check_plant_health() - return TRUE + if(seed) + var/force = O.get_attack_force(user) + if(force) + user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN) + user.visible_message("\The [seed.display_name] has been attacked by [user] with \the [O]!") + playsound(get_turf(src), O.hitsound, 100, 1) + if(!dead) + plant_health -= force + check_plant_health() + return TRUE if(mechanical) return component_attackby(O, user) diff --git a/code/modules/mechs/equipment/combat.dm b/code/modules/mechs/equipment/combat.dm index fbc24657a60..e9d182c1980 100644 --- a/code/modules/mechs/equipment/combat.dm +++ b/code/modules/mechs/equipment/combat.dm @@ -438,7 +438,7 @@ /obj/aura/mech_ballistic/attackby(obj/item/I, mob/user) . = ..() - if (shield && prob(shield.block_chance(I.get_attack_force(), I.armor_penetration, source = I, attacker = user))) + if (shield && prob(shield.block_chance(I.get_attack_force(dry_run = TRUE), I.armor_penetration, source = I, attacker = user))) user.visible_message(SPAN_WARNING("\The [I] is blocked by \the [user]'s [shield.name].")) playsound(user.loc, 'sound/weapons/Genhit.ogg', 50, 1) return AURA_FALSE|AURA_CANCEL diff --git a/code/modules/mob/grab/normal/grab_normal.dm b/code/modules/mob/grab/normal/grab_normal.dm index b919a34b3ec..fcb921974f8 100644 --- a/code/modules/mob/grab/normal/grab_normal.dm +++ b/code/modules/mob/grab/normal/grab_normal.dm @@ -228,7 +228,7 @@ if(!user.check_intent(I_FLAG_HARM)) return 0 // Not trying to hurt them. - if(!W.has_edge() || !W.get_attack_force(user) || W.atom_damage_type != BRUTE) + if(!W.has_edge() || !W.get_attack_force(user, dry_run = TRUE) || W.atom_damage_type != BRUTE) return 0 //unsuitable weapon user.visible_message("\The [user] begins to slit [affecting]'s throat with \the [W]!") diff --git a/code/modules/mob/living/human/human_defense.dm b/code/modules/mob/living/human/human_defense.dm index 7e457b8256f..5e0ebff949e 100644 --- a/code/modules/mob/living/human/human_defense.dm +++ b/code/modules/mob/living/human/human_defense.dm @@ -119,7 +119,7 @@ meteor_act visible_message("\The [user] misses [src] with \the [I]!") return null - if(check_shields(I.get_attack_force(user), I, user, target_zone, I)) + if(check_shields(I.get_attack_force(user, dry_run = TRUE), I, user, target_zone, I)) return null var/obj/item/organ/external/affecting = GET_EXTERNAL_ORGAN(src, hit_zone) @@ -152,7 +152,7 @@ meteor_act if(!affecting) return 0 - var/blocked = get_blocked_ratio(hit_zone, I.atom_damage_type, I.damage_flags(), I.armor_penetration, I.get_attack_force(user)) + var/blocked = get_blocked_ratio(hit_zone, I.atom_damage_type, I.damage_flags(), I.armor_penetration, I.get_attack_force(user, dry_run = TRUE)) // Handle striking to cripple. if(user.check_intent(I_FLAG_DISARM)) effective_force *= 0.66 //reduced effective force... diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 7a5c096451f..73b1db81faa 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -219,7 +219,7 @@ if(affecting && istype(supplied_wound) && supplied_wound.is_open() && dtype == BRUTE) // Can't embed in a small bruise. var/obj/item/I = O var/sharp = I.is_sharp() || I.has_edge() - embed_damage *= (1 - get_blocked_ratio(def_zone, BRUTE, O.damage_flags(), O.armor_penetration, I.get_attack_force(user))) + embed_damage *= (1 - get_blocked_ratio(def_zone, BRUTE, O.damage_flags(), O.armor_penetration, I.get_attack_force(user, dry_run = TRUE))) //blunt objects should really not be embedding in things unless a huge amount of force is involved var/embed_chance = embed_damage / (sharp ? I.w_class : (I.w_class*3)) diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 08ee95501bd..237ff1ba210 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -633,7 +633,7 @@ else to_chat(user, "Upgrade error!") return TRUE - if(!(istype(W, /obj/item/robotanalyzer) || istype(W, /obj/item/scanner/health)) && W.get_attack_force(user) && !user.check_intent(I_FLAG_HELP)) + if(!(istype(W, /obj/item/robotanalyzer) || istype(W, /obj/item/scanner/health)) && !user.check_intent(I_FLAG_HELP) && W.get_attack_force(user)) spark_at(src, 5, holder=src) return ..() diff --git a/mods/content/item_sharpening/_item_sharpening.dme b/mods/content/item_sharpening/_item_sharpening.dme index cf812cb8b32..c9af243f5e9 100644 --- a/mods/content/item_sharpening/_item_sharpening.dme +++ b/mods/content/item_sharpening/_item_sharpening.dme @@ -3,8 +3,8 @@ // BEGIN_INCLUDE #include "_item_sharpening.dm" #include "blade_sharpen.dm" -#include "grindstone.dm" #include "effect_sharpen.dm" +#include "grindstone.dm" #include "item_sharpen.dm" #include "whetstone.dm" //END_INCLUDE diff --git a/mods/content/item_sharpening/effect_sharpen.dm b/mods/content/item_sharpening/effect_sharpen.dm index d7ce982218e..c5711a326ab 100644 --- a/mods/content/item_sharpening/effect_sharpen.dm +++ b/mods/content/item_sharpening/effect_sharpen.dm @@ -14,6 +14,6 @@ if(distance <= 1) var/uses = item.get_item_effect_parameter(src, IE_CAT_DAMAGE, IE_PAR_USES) if(uses > 0) - to_chat(user, SPAN_NOTICE("\The [item] has been sharpened to a keen edge.")) + to_chat(user, SPAN_NOTICE("\The [item] has been honed to a keen edge.")) else - to_chat(user, SPAN_NOTICE("\The [item] is dull and in need of sharpening.")) + to_chat(user, SPAN_NOTICE("\The [item] in need of sharpening.")) diff --git a/mods/content/item_sharpening/item_sharpen.dm b/mods/content/item_sharpening/item_sharpen.dm index f302a6c609d..bc0d4480b0f 100644 --- a/mods/content/item_sharpening/item_sharpen.dm +++ b/mods/content/item_sharpening/item_sharpen.dm @@ -37,9 +37,9 @@ return FALSE if(can_sharpen_with(sharpening_with)) user.visible_message("\The [user] begins sharpening \the [src] with \the [sharpening_with].") - // TODO: play sharpening sound? Spawn sparks for metal? + playsound(loc, 'sound/foley/knife1.ogg', 50) // metallic scrape, TODO better sound if(user.do_skilled(10 SECONDS, SKILL_WEAPONS, src, check_holding = TRUE) && !QDELETED(sharpening_with) && can_sharpen_with(sharpening_with) && sharpen_with(user, sharpening_with)) - // TODO: play sharpening sound? Spawn sparks for metal? + playsound(loc, 'sound/foley/knife1.ogg', 50) user.visible_message("\The [user] sharpens \the [src] with \the [sharpening_with].") else to_chat(user, SPAN_WARNING("\The [src] cannot be [initial(_sharp) ? "further sharpened" : "sharpened"] with \the [sharpening_with].")) diff --git a/mods/content/psionics/system/psionics/equipment/psipower.dm b/mods/content/psionics/system/psionics/equipment/psipower.dm index 3d850f27cf2..9f5bca8a648 100644 --- a/mods/content/psionics/system/psionics/equipment/psipower.dm +++ b/mods/content/psionics/system/psionics/equipment/psipower.dm @@ -19,13 +19,13 @@ . = ..() /obj/item/ability/psionic/use_on_mob(mob/living/target, mob/living/user, animate = TRUE) - if(target.do_psionics_check(max(get_attack_force(user), maintain_cost), user)) + if(target.do_psionics_check(max(get_attack_force(user, dry_run = TRUE), maintain_cost), user)) to_chat(user, SPAN_WARNING("\The [src] flickers violently out of phase!")) return TRUE . = ..() /obj/item/ability/psionic/afterattack(var/atom/target, var/mob/living/user, var/proximity) - if(target.do_psionics_check(max(get_attack_force(user), maintain_cost), user)) + if(target.do_psionics_check(max(get_attack_force(user, dry_run = TRUE), maintain_cost), user)) to_chat(user, SPAN_WARNING("\The [src] flickers violently out of phase!")) return TRUE . = ..(target, user, proximity) diff --git a/mods/mobs/dionaea/mob/gestalt/gestalt_attacks.dm b/mods/mobs/dionaea/mob/gestalt/gestalt_attacks.dm index 05aeb1f74bb..33e83ed2037 100644 --- a/mods/mobs/dionaea/mob/gestalt/gestalt_attacks.dm +++ b/mods/mobs/dionaea/mob/gestalt/gestalt_attacks.dm @@ -1,6 +1,6 @@ /obj/structure/diona_gestalt/attackby(var/obj/item/thing, var/mob/user) . = ..() - if(thing.get_attack_force(user)) + if(thing.get_attack_force(user, dry_run = TRUE)) shed_atom(forcefully = TRUE) /obj/structure/diona_gestalt/hitby()