Skip to content

Commit

Permalink
Ensuring sharpness is not deducated multiple times on a hit.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 9, 2025
1 parent d1a5c81 commit e0991fd
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion code/game/objects/items/_item_materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/flame/flame_fuelled.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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]."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) )
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/doors/_door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/fishtanks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 10 additions & 9 deletions code/modules/hydroponics/trays/tray.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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("<span class='danger'>\The [seed.display_name] has been attacked by [user] with \the [O]!</span>")
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("<span class='danger'>\The [seed.display_name] has been attacked by [user] with \the [O]!</span>")
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)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mechs/equipment/combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/grab/normal/grab_normal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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("<span class='danger'>\The [user] begins to slit [affecting]'s throat with \the [W]!</span>")

Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/human/human_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ meteor_act
visible_message("<span class='danger'>\The [user] misses [src] with \the [I]!</span>")
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)
Expand Down Expand Up @@ -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...
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/living_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/robot/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..()

Expand Down
2 changes: 1 addition & 1 deletion mods/content/item_sharpening/_item_sharpening.dme
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mods/content/item_sharpening/effect_sharpen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
4 changes: 2 additions & 2 deletions mods/content/item_sharpening/item_sharpen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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]."))
Expand Down
4 changes: 2 additions & 2 deletions mods/content/psionics/system/psionics/equipment/psipower.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mods/mobs/dionaea/mob/gestalt/gestalt_attacks.dm
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit e0991fd

Please sign in to comment.