Skip to content

Commit

Permalink
Merge pull request #4233 from MistakeNot4892/rework/twohanded
Browse files Browse the repository at this point in the history
Item damage calculation rework.
  • Loading branch information
out-of-phaze authored Aug 29, 2024
2 parents 1aec463 + e90253b commit dbaf165
Show file tree
Hide file tree
Showing 349 changed files with 1,319 additions and 1,386 deletions.
2 changes: 1 addition & 1 deletion code/__defines/items_clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
#define FIRE_MAX_FIRESUIT_STACKS 20 // If the number of stacks goes above this firesuits won't protect you anymore. If not, you can walk around while on fire like a badass.

#define THROWFORCE_GIBS 3 // Throw speed for gibbed or dismembered organs.
#define THROWFORCE_SPEED_DIVISOR 12 // The throwing speed value at which the throwforce multiplier is exactly 1.
#define THROWFORCE_SPEED_DIVISOR 12 // The throwing speed value at which the thrown force multiplier is exactly 1.
#define THROWNOBJ_KNOCKBACK_SPEED 15 // The minumum speed of a w_class 2 thrown object that will cause living mobs it hits to be knocked back. Heavier objects can cause knockback at lower speeds.
#define THROWNOBJ_KNOCKBACK_DIVISOR 2 // Affects how much speed the mob is knocked back with.

Expand Down
8 changes: 4 additions & 4 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ avoid code duplication. This includes items that may sometimes act as a standard
/atom/movable/proc/bash(obj/item/weapon, mob/user)
if(isliving(user) && user.a_intent == I_HELP)
return FALSE
if(!weapon.user_can_wield(user))
if(!weapon.user_can_attack_with(user))
return FALSE
if(weapon.item_flags & ITEM_FLAG_NO_BLUDGEON)
return FALSE
Expand All @@ -64,7 +64,7 @@ avoid code duplication. This includes items that may sometimes act as a standard
return TRUE
var/oldhealth = current_health
. = used_item.use_on_mob(src, user)
if(used_item.force && istype(ai) && current_health < oldhealth)
if(used_item.get_attack_force(user) && istype(ai) && current_health < oldhealth)
ai.retaliate(user)

/mob/living/human/attackby(obj/item/I, mob/user)
Expand Down Expand Up @@ -104,7 +104,7 @@ avoid code duplication. This includes items that may sometimes act as a standard

// TODO: revisit if this should be a silent failure/parent call instead, for mob-level storage interactions?
// like a horse with a saddlebag or something
if(!user_can_wield(user))
if(!user_can_attack_with(user))
return TRUE // skip other interactions

if(squash_item())
Expand Down Expand Up @@ -161,7 +161,7 @@ avoid code duplication. This includes items that may sometimes act as a standard
else
use_hitsound = "swing_hit"
playsound(loc, use_hitsound, 50, 1, -1)
return target.hit_with_weapon(src, user, force, hit_zone)
return target.hit_with_weapon(src, user, get_attack_force(user), hit_zone)

/obj/item/proc/handle_reflexive_fire(var/mob/user, var/atom/aiming_at)
return istype(user) && istype(aiming_at)
2 changes: 1 addition & 1 deletion code/datums/extensions/lockable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
if(!locked)
return FALSE

if(!used_item.user_can_wield(user))
if(!used_item.user_can_attack_with(user))
return TRUE

//TODO: This probably should be handled in a better way.
Expand Down
4 changes: 2 additions & 2 deletions code/datums/outfits/horror_killers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
glasses = /obj/item/clothing/glasses/thermal/plain/monocle
suit = /obj/item/clothing/suit/chaplain_hoodie
r_pocket = /obj/item/bikehorn
hands = list(/obj/item/twohanded/fireaxe)
hands = list(/obj/item/bladed/axe/fire)

id_slot = slot_wear_id_str
id_type = /obj/item/card/id/centcom/station
Expand All @@ -27,7 +27,7 @@
suit = /obj/item/clothing/suit/apron
l_pocket = /obj/item/knife/combat
r_pocket = /obj/item/scalpel
hands = list(/obj/item/twohanded/fireaxe)
hands = list(/obj/item/bladed/axe/fire)

/decl/outfit/masked_killer/post_equip(var/mob/living/human/H)
..()
Expand Down
12 changes: 6 additions & 6 deletions code/datums/trading/traders/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@
/obj/item/clothing/suit/judgerobe = TRADER_THIS_TYPE,
/obj/item/clothing/suit/wizrobe/magusred = TRADER_THIS_TYPE,
/obj/item/clothing/suit/wizrobe/magusblue = TRADER_THIS_TYPE,
/obj/item/clothing/costume/gladiator = TRADER_THIS_TYPE,
/obj/item/clothing/costume/kilt = TRADER_THIS_TYPE,
/obj/item/clothing/costume/redcoat = TRADER_THIS_TYPE,
/obj/item/clothing/costume/soviet = TRADER_THIS_TYPE,
/obj/item/clothing/costume/gladiator = TRADER_THIS_TYPE,
/obj/item/clothing/costume/kilt = TRADER_THIS_TYPE,
/obj/item/clothing/costume/redcoat = TRADER_THIS_TYPE,
/obj/item/clothing/costume/soviet = TRADER_THIS_TYPE,
/obj/item/harpoon = TRADER_THIS_TYPE,
/obj/item/sword = TRADER_ALL,
/obj/item/scythe = TRADER_THIS_TYPE,
/obj/item/star = TRADER_THIS_TYPE,
/obj/item/twohanded/baseballbat = TRADER_THIS_TYPE
)
/obj/item/baseball_bat = TRADER_THIS_TYPE
)
1 change: 0 additions & 1 deletion code/game/gamemodes/wizard/servant_items/champion.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
name = "leather boots"
desc = "Old-fashioned leather boots. Probably not something you want to get kicked with."
material = /decl/material/solid/organic/leather
force = 5
armor = list(
ARMOR_MELEE = ARMOR_MELEE_RESISTANT,
ARMOR_BULLET = ARMOR_BALLISTIC_MINOR,
Expand Down
7 changes: 5 additions & 2 deletions code/game/machinery/_machines_base/machinery_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@
take_damage(P.damage, P.atom_damage_type)

/obj/machinery/bash(obj/item/W, mob/user)
if(!istype(W) || W.force <= 5)
if(!istype(W))
return FALSE
var/force = W.get_attack_force(user)
if(force <= 5)
return FALSE
. = ..()
if(.)
user.setClickCooldown(W.attack_cooldown + W.w_class)
take_damage(W.force, W.atom_damage_type)
take_damage(force, W.atom_damage_type)
2 changes: 1 addition & 1 deletion code/game/machinery/alarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@
/obj/machinery/alarm/attackby(obj/item/used_item, mob/user)
if(!(stat & (BROKEN|NOPOWER)))
if (istype(used_item, /obj/item/card/id) || istype(used_item, /obj/item/modular_computer))// trying to unlock the interface with an ID card
if(!used_item.user_can_wield(user))
if(!used_item.user_can_attack_with(user))
return TRUE
if(allowed(user) && !wires.IsIndexCut(AALARM_WIRE_IDSCAN))
locked = !locked
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/atmoalter/canister.dm
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
/obj/machinery/portable_atmospherics/canister/bash(var/obj/item/W, var/mob/user)
. = ..()
if(.)
current_health -= W.force
current_health -= W.get_attack_force(user)
healthcheck()

/obj/machinery/portable_atmospherics/canister/attackby(var/obj/item/W, var/mob/user)
Expand Down
11 changes: 6 additions & 5 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@

/obj/machinery/camera/hitby(var/atom/movable/AM)
. = ..()
if(. && istype(AM, /obj))
var/obj/O = AM
if (O.throwforce >= src.toughness)
visible_message(SPAN_WARNING("[src] was hit by [O]!"))
take_damage(O.throwforce, O.atom_damage_type)
if(. && isobj(AM))
var/thrown_force = AM.get_thrown_attack_force()
if (thrown_force >= toughness)
visible_message(SPAN_DANGER("\The [src] was hit by \the [AM]!"))
var/obj/O = AM
take_damage(thrown_force, O.atom_damage_type)

/obj/machinery/camera/physical_attack_hand(mob/living/human/user)
if(!istype(user))
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/deployable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
else
switch(W.atom_damage_type)
if(BURN)
current_health -= W.force * 0.75
current_health -= W.get_attack_force(user) * 0.75
if(BRUTE)
current_health -= W.force * 0.5
current_health -= W.get_attack_force(user) * 0.5
if (current_health <= 0)
explode()
..()
Expand Down
15 changes: 5 additions & 10 deletions code/game/machinery/doors/_door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,8 @@
. = ..()
if(.)
visible_message(SPAN_DANGER("\The [src] was hit by \the [AM]."))
var/tforce = 0
if(ismob(AM))
tforce = 3 * TT.speed
else if(isobj(AM))
var/obj/hitter_obj = AM
tforce = hitter_obj.throwforce * (TT.speed/THROWFORCE_SPEED_DIVISOR)
playsound(src.loc, hitsound, 100, 1)
take_damage(tforce)
take_damage(AM.get_thrown_attack_force() * (TT.speed/THROWFORCE_SPEED_DIVISOR))

// This is legacy code that should be revisited, probably by moving the bulk of the logic into here.
/obj/machinery/door/physical_attack_hand(user)
Expand Down Expand Up @@ -333,20 +327,21 @@
/obj/machinery/door/bash(obj/item/weapon, mob/user)
if(isliving(user) && user.a_intent != I_HURT)
return FALSE
if(!weapon.user_can_wield(user))
if(!weapon.user_can_attack_with(user))
return FALSE
if(weapon.item_flags & ITEM_FLAG_NO_BLUDGEON)
return FALSE
if(!density)
return FALSE
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
user.do_attack_animation(src)
if(weapon.force < min_force)
var/force = weapon.get_attack_force(user)
if(force < min_force)
user.visible_message("<span class='danger'>\The [user] hits \the [src] with \the [weapon] with no visible effect.</span>")
else
user.visible_message("<span class='danger'>\The [user] forcefully strikes \the [src] with \the [weapon]!</span>")
playsound(src.loc, hitsound, 100, 1)
take_damage(weapon.force, weapon.atom_damage_type)
take_damage(force, weapon.atom_damage_type)
return TRUE

/obj/machinery/door/take_damage(damage, damage_type = BRUTE, damage_flags, inflicter, armor_pen = 0, silent, do_update_health)
Expand Down
22 changes: 11 additions & 11 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,12 @@ About the new airlock wires panel:
cut_sound = 'sound/weapons/circsawhit.ogg'
cut_delay *= 1.5

else if(istype(item,/obj/item/twohanded/fireaxe))
else if(istype(item,/obj/item/bladed/axe/fire))
//special case - zero delay, different message
if (src.lock_cut_state == BOLTS_EXPOSED)
return FALSE //can't actually cut the bolts, go back to regular smashing
var/obj/item/twohanded/fireaxe/F = item
if (!F.wielded)
var/obj/item/bladed/axe/fire/F = item
if (!F.is_held_twohanded())
return FALSE
user.visible_message(
SPAN_DANGER("\The [user] smashes the bolt cover open!"),
Expand Down Expand Up @@ -782,8 +782,8 @@ About the new airlock wires panel:
close(1)
return TRUE

if(istype(C, /obj/item/twohanded/fireaxe) && !arePowerSystemsOn() && !(user.a_intent == I_HURT))
var/obj/item/twohanded/fireaxe/F = C
if(istype(C, /obj/item/bladed/axe/fire) && !arePowerSystemsOn() && !(user.a_intent == I_HURT))
var/obj/item/bladed/axe/fire/F = C
if(F.is_held_twohanded(user))
if(locked)
to_chat(user, SPAN_WARNING("The airlock's bolts prevent it from being forced."))
Expand All @@ -794,7 +794,7 @@ About the new airlock wires panel:
else
close(1)
else
if(user.can_wield_item(F))
if(user.can_twohand_item(F))
to_chat(user, SPAN_WARNING("You need to be holding \the [C] in both hands to do that!"))
else
to_chat(user, SPAN_WARNING("You are too small to lever \the [src] open with \the [C]!"))
Expand All @@ -804,7 +804,7 @@ About the new airlock wires panel:
else if((stat & (BROKEN|NOPOWER)) && isanimal(user))
var/mob/living/simple_animal/A = user
var/obj/item/I = A.get_natural_weapon()
if(I?.force >= 10)
if(I?.get_attack_force(user) >= 10)
if(density)
visible_message(SPAN_DANGER("\The [A] forces \the [src] open!"))
open(1)
Expand All @@ -819,12 +819,12 @@ About the new airlock wires panel:

/obj/machinery/door/airlock/bash(obj/item/weapon, mob/user)
//if door is unbroken, hit with fire axe using harm intent
if (istype(weapon, /obj/item/twohanded/fireaxe) && !(stat & BROKEN) && user.a_intent == I_HURT && weapon.user_can_wield(user))
if (istype(weapon, /obj/item/bladed/axe/fire) && !(stat & BROKEN) && user.a_intent == I_HURT && weapon.user_can_attack_with(user))
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
var/obj/item/twohanded/fireaxe/F = weapon
if (F.wielded)
var/obj/item/bladed/axe/fire/F = weapon
if (F.is_held_twohanded())
playsound(src, 'sound/weapons/smash.ogg', 100, 1)
current_health -= F.force_wielded * 2
current_health -= F.get_attack_force(user) * 2
if(current_health <= 0)
user.visible_message(SPAN_DANGER("[user] smashes \the [weapon] into the airlock's control panel! It explodes in a shower of sparks!"), SPAN_DANGER("You smash \the [weapon] into the airlock's control panel! It explodes in a shower of sparks!"))
current_health = 0
Expand Down
3 changes: 1 addition & 2 deletions code/game/machinery/doors/blast_door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@
/obj/machinery/door/blast/attackby(obj/item/C, mob/user)
add_fingerprint(user, 0, C)
if(!panel_open) //Do this here so the door won't change state while prying out the circuit
var/obj/item/twohanded/zweihander = C
if(IS_CROWBAR(C) || (istype(C, /obj/item/twohanded/fireaxe) && zweihander.wielded))
if(IS_CROWBAR(C) || (istype(C, /obj/item/bladed/axe/fire) && C.is_held_twohanded()))
if(((stat & NOPOWER) || (stat & BROKEN)) && !( operating ))
to_chat(user, "<span class='notice'>You begin prying at \the [src]...</span>")
if(do_after(user, 2 SECONDS, src))
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/braces.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
w_class = ITEM_SIZE_NORMAL
icon = 'icons/obj/items/tool/maintenance_jack.dmi'
icon_state = ICON_STATE_WORLD
force = 17.5 //It has a hammer head, should probably do some more damage. - Cirra
_base_attack_force = 17 //It has a hammer head, should probably do some more damage. - Cirra
attack_cooldown = 2.5*DEFAULT_WEAPON_COOLDOWN
melee_accuracy_bonus = -25
material = /decl/material/solid/metal/steel
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@
"You hear someone struggle and metal straining.")
return TRUE

if(!blocked && (IS_CROWBAR(C) || istype(C,/obj/item/twohanded/fireaxe)))
if(!blocked && (IS_CROWBAR(C) || istype(C,/obj/item/bladed/axe/fire)))
if(operating)
return ..()

if(istype(C,/obj/item/twohanded/fireaxe))
var/obj/item/twohanded/fireaxe/F = C
if(!F.wielded)
if(istype(C,/obj/item/bladed/axe/fire))
var/obj/item/bladed/axe/fire/F = C
if(!F.is_held_twohanded())
return ..()

user.visible_message("<span class='danger'>\The [user] starts to force \the [src] [density ? "open" : "closed"] with \a [C]!</span>",\
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/windowdoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@

/obj/machinery/door/window/bash(obj/item/weapon, mob/user)
//Emags and energy swords? You may pass.
if (weapon.user_can_wield(user) && istype(weapon, /obj/item/energy_blade))
if (weapon.user_can_attack_with(user) && istype(weapon, /obj/item/energy_blade))
var/obj/item/energy_blade/blade = weapon
if(blade.is_special_cutting_tool() && emag_act(10, user))
spark_at(loc, amount=5)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/floor_light.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var/global/list/floor_light_cache = list()
qdel(src)
return TRUE

if(W.force && user.a_intent == I_HURT)
if(W.get_attack_force(user) && user.a_intent == I_HURT)
return physical_attack_hand(user)

return ..()
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/newscaster.dm
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ var/global/list/allCasters = list() //Global list that will contain reference to
icon_state = "newspaper"
w_class = ITEM_SIZE_SMALL //Let's make it fit in trashbags!
attack_verb = list("bapped","thwapped","smacked")
force = 0
_base_attack_force = 0
material = /decl/material/solid/organic/paper

var/screen = 0
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/pipe/construction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Buildable meters
/obj/item/pipe
name = "pipe"
desc = "A pipe."
var/connect_types = CONNECT_TYPE_REGULAR
force = 7
_base_attack_force = 7
icon = 'icons/obj/pipe-item.dmi'
icon_state = "simple"
randpixel = 5
Expand All @@ -17,6 +16,7 @@ Buildable meters
obj_flags = OBJ_FLAG_ROTATABLE
dir = SOUTH
material = /decl/material/solid/metal/steel
var/connect_types = CONNECT_TYPE_REGULAR
var/constructed_path = /obj/machinery/atmospherics/pipe/simple/hidden
var/pipe_class = PIPE_CLASS_BINARY
var/rotate_class = PIPE_ROTATE_STANDARD
Expand Down
5 changes: 3 additions & 2 deletions code/game/machinery/portable_turret.dm
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,10 @@ var/global/list/turret_icons

else
//if the turret was attacked with the intention of harming it:
var/force = I.get_attack_force(user) * 0.5
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
take_damage(I.force * 0.5, I.atom_damage_type)
if(I.force * 0.5 > 1) //if the force of impact dealt at least 1 damage, the turret gets pissed off
take_damage(force, I.atom_damage_type)
if(force > 1) //if the force of impact dealt at least 1 damage, the turret gets pissed off
if(!attacked && !emagged)
attacked = 1
spawn()
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/auras/starlight.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
/obj/aura/starborn/attackby(var/obj/item/I, var/mob/i_user)
if(I.atom_damage_type == BURN)
to_chat(i_user, "<span class='warning'>\The [I] seems to only feed into \the [user]'s flames.</span>")
user.heal_damage(BRUTE, I.force)
user.heal_damage(BRUTE, I.get_attack_force(user))
return AURA_FALSE
return 0
2 changes: 1 addition & 1 deletion code/game/objects/effects/chem/foam.dm
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
qdel(src)
return

if(prob(I.force * 20 - metal * 25))
if(prob(I.get_attack_force(user) * 20 - metal * 25))
user.visible_message("<span class='warning'>[user] smashes through the foamed metal.</span>", "<span class='notice'>You smash through the foamed metal with \the [I].</span>")
qdel(src)
else
Expand Down
Loading

0 comments on commit dbaf165

Please sign in to comment.