Skip to content

Commit

Permalink
Adding grindstones and whetstones.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Jan 9, 2025
1 parent e26b64e commit 5c9340d
Show file tree
Hide file tree
Showing 30 changed files with 307 additions and 85 deletions.
15 changes: 15 additions & 0 deletions code/__defines/item_effects.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Identifiers for various categories of item effects.
#define IE_CAT_DAMAGE "weff_damage"
#define IE_CAT_STRIKE "weff_strike"
#define IE_CAT_PARRY "weff_parry"
#define IE_CAT_USED "weff_used"
#define IE_CAT_WIELDED "weff_wield"
#define IE_CAT_VISUAL "weff_visual"
#define IE_CAT_LISTENER "weff_listener"
#define IE_CAT_EXAMINE "weff_visible"
#define IE_CAT_RANGED "weff_ranged"
#define IE_CAT_PROCESS "weff_process"

// Identifiers for parameters for item effects.
#define IE_PAR_USES "uses"
#define IE_PAR_MAX_USES "max_uses"
2 changes: 1 addition & 1 deletion code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ avoid code duplication. This includes items that may sometimes act as a standard

var/oldhealth = current_health
. = used_item.use_on_mob(src, user)
if(used_item.get_attack_force(user) && istype(ai) && current_health < oldhealth)
if(used_item.get_attack_force(user, dry_run = TRUE) && istype(ai) && current_health < oldhealth)
ai.retaliate(user)

if(!. && user == src && user.get_target_zone() == BP_MOUTH && can_devour(used_item, silent = TRUE))
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.get_attack_force(user) && user.check_intent(I_FLAG_HARM))
if(W.get_attack_force(user, dry_run = TRUE) && user.check_intent(I_FLAG_HARM))
return physical_attack_hand(user)

return ..()
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/__item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@
. += wielded_parry_bonus

/obj/item/proc/on_disarm_attempt(mob/target, mob/living/attacker)
var/force = get_attack_force(attacker)
var/force = get_attack_force(attacker, dry_run = TRUE)
if(force < 1)
return 0
if(!istype(attacker))
Expand Down Expand Up @@ -1008,7 +1008,7 @@ modules/mob/living/human/life.dm if you die, you will be zoomed out.
descriptors += "sharp"
if(edge)
descriptors += "edged"
if(get_attack_force() >= 10 && !sharp && !edge)
if(get_attack_force(dry_run = TRUE) >= 10 && !sharp && !edge)
descriptors += "heavy"
if(material)
descriptors += "made of [material.solid_name]"
Expand Down
21 changes: 15 additions & 6 deletions code/game/objects/items/_item_force.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@
VAR_PROTECTED/_hardness_force_factor = 0.25

/obj/item/proc/get_max_weapon_force()
. = get_attack_force()
. = get_attack_force(dry_run = TRUE)
if(can_be_twohanded)
. = round(. * _wielded_force_multiplier)

/obj/item/proc/get_attack_force(mob/living/user)
// `dry_run` param is used for things like the grindstone modpack to avoid
// depleting sharpness when not actually being used to attack.
/obj/item/proc/get_attack_force(mob/living/user, dry_run = FALSE)
if(_base_attack_force <= 0 || (item_flags & ITEM_FLAG_NO_BLUDGEON))
return 0
if(isnull(_cached_attack_force))
update_attack_force()
if(_cached_attack_force <= 0)
return 0
return istype(user) ? user.modify_attack_force(src, _cached_attack_force, _wielded_force_multiplier) : _cached_attack_force
return istype(user) ? user.modify_attack_force(src, _cached_attack_force, _wielded_force_multiplier, dry_run) : _cached_attack_force

// Existing hitby() code expects mobs, structures and machines to be thrown, it seems.
/atom/movable/proc/get_thrown_attack_force()
Expand Down Expand Up @@ -108,10 +110,17 @@
return _cached_attack_force

// TODO: consider strength, athletics, mob size
/mob/living/proc/modify_attack_force(obj/item/weapon, supplied_force, wield_mult)
// `dry_run` param used in grindstone modpack to avoid depleting sharpness on non-attacks.
/mob/living/proc/modify_attack_force(obj/item/weapon, supplied_force, wield_mult, dry_run)
if(!istype(weapon) || !weapon.is_held_twohanded())
return supplied_force
return round(supplied_force * wield_mult)
. = supplied_force
else
. = supplied_force * wield_mult
var/list/item_effects = weapon.get_item_effects(IE_CAT_DAMAGE)
if(length(item_effects))
for(var/decl/item_effect/damage_effect as anything in item_effects)
. = damage_effect.modify_attack_damage(., weapon, src, parameters = item_effects[damage_effect])
return round(.)

// Debug proc - leaving in for future work. Linter hates protected var access so leave commented.
/*
Expand Down
2 changes: 2 additions & 0 deletions code/game/objects/items/blades/_blade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
slot_flags = SLOT_LOWER_BODY
material = /decl/material/solid/metal/steel
_base_attack_force = 10

var/decl/material/hilt_material = /decl/material/solid/organic/wood/oak
var/decl/material/guard_material = /decl/material/solid/organic/wood/oak
var/decl/material/pommel_material = /decl/material/solid/organic/wood/oak

/// Cache var for blade material shine calculation.
var/tmp/shine

Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/_structure_materials.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@

/obj/structure/proc/update_material_name(var/override_name)
var/base_name = override_name || initial(name)
if(istype(material))
if(istype(material) && (material_alteration & MAT_FLAG_ALTERATION_NAME))
SetName("[material.adjective_name] [base_name]")
else
SetName(base_name)

/obj/structure/proc/update_material_desc(var/override_desc)
var/base_desc = override_desc || initial(desc)
if(istype(material))
if(istype(material) && (material_alteration & MAT_FLAG_ALTERATION_DESC))
desc = "[base_desc] This one is made of [material.solid_name]."
else
desc = base_desc
Expand Down
6 changes: 3 additions & 3 deletions code/modules/crafting/working/_working.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
work_sound.stop(src)
update_icon()

/obj/structure/working/attackby(obj/item/W, mob/user)
/obj/structure/working/attackby(obj/item/used_item, mob/user)

if(user.check_intent(I_FLAG_HARM))
return ..()
Expand All @@ -58,12 +58,12 @@
to_chat(user, SPAN_WARNING("\The [src] is currently in use, please wait for it to be finished."))
return TRUE

if(try_take_input(W, user))
if(try_take_input(used_item, user))
return TRUE

return ..()

/obj/structure/working/proc/try_take_input(obj/item/W, mob/user, silent)
/obj/structure/working/proc/try_take_input(obj/item/used_item, mob/user, silent)
return FALSE

/obj/structure/working/proc/try_unload_material(mob/user)
Expand Down
16 changes: 8 additions & 8 deletions code/modules/crafting/working/textiles/loom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@
weaving_type = null
weaving_progress = 0

/obj/structure/working/loom/try_take_input(obj/item/W, mob/user)
/obj/structure/working/loom/try_take_input(obj/item/used_item, mob/user)

if(istype(W, /obj/item/stack/material/thread))
if(istype(used_item, /obj/item/stack/material/thread))

if(!W.material.has_textile_fibers)
to_chat(user, SPAN_WARNING("\The [W] isn't suitable for making cloth."))
if(!used_item.material.has_textile_fibers)
to_chat(user, SPAN_WARNING("\The [used_item] isn't suitable for making cloth."))
return TRUE

var/loaded = FALSE
if(loaded_thread)
if(!loaded_thread.can_merge_stacks(W))
if(!loaded_thread.can_merge_stacks(used_item))
to_chat(user, SPAN_WARNING("\The [src] is already wound with \the [loaded_thread]."))
return TRUE
var/obj/item/stack/feeding = W
var/obj/item/stack/feeding = used_item
feeding.transfer_to(loaded_thread)
loaded = TRUE
else if(user.try_unequip(W, src))
loaded_thread = W
else if(user.try_unequip(used_item, src))
loaded_thread = used_item
loaded = TRUE
if(loaded)
weaving_color = loaded_thread.get_color()
Expand Down
22 changes: 11 additions & 11 deletions code/modules/crafting/working/textiles/spinning_wheel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
/obj/structure/working/spinning_wheel/proc/can_process(obj/item/thing)
return istype(thing) && thing.has_textile_fibers()

/obj/structure/working/spinning_wheel/try_take_input(obj/item/W, mob/user)
/obj/structure/working/spinning_wheel/try_take_input(obj/item/used_item, mob/user)

if(istype(W.storage))
if(istype(used_item.storage))
var/list/loading_growns = list()
for(var/obj/item/thing in W.get_stored_inventory())
for(var/obj/item/thing in used_item.get_stored_inventory())
if(can_process(thing))
loading_growns += thing

if(!length(loading_growns))
to_chat(user, SPAN_WARNING("Nothing in \the [W] is suitable for processing on \the [src]."))
to_chat(user, SPAN_WARNING("Nothing in \the [used_item] is suitable for processing on \the [src]."))
return TRUE

if(length(loaded) >= MAX_LOADED)
Expand All @@ -42,24 +42,24 @@

var/loaded_items = 0
for(var/obj/item/thing as anything in loading_growns)
if(W.storage.remove_from_storage(thing, src, TRUE))
if(used_item.storage.remove_from_storage(thing, src, TRUE))
loaded_items++
LAZYADD(loaded, thing)
if(length(loaded) >= MAX_LOADED)
break
if(loaded_items)
W.storage.finish_bulk_removal()
to_chat(user, SPAN_NOTICE("You prepare \the [src] with [loaded_items] items from \the [W]."))
used_item.storage.finish_bulk_removal()
to_chat(user, SPAN_NOTICE("You prepare \the [src] with [loaded_items] items from \the [used_item]."))
update_icon()
return TRUE

if(can_process(W))
if(can_process(used_item))
if(length(loaded) >= MAX_LOADED)
to_chat(user, SPAN_WARNING("\The [src] is already fully stocked and ready for spinning."))
return TRUE
if(user.try_unequip(W, src))
LAZYADD(loaded, W)
to_chat(user, SPAN_NOTICE("You prepare \the [src] with \the [W]."))
if(user.try_unequip(used_item, src))
LAZYADD(loaded, used_item)
to_chat(user, SPAN_NOTICE("You prepare \the [src] with \the [used_item]."))
update_icon()
return TRUE
return TRUE
Expand Down
15 changes: 4 additions & 11 deletions code/modules/item_effects/_item_effect.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
#define ITEM_EFFECT_STRIKE "weff_strike"
#define ITEM_EFFECT_PARRY "weff_parry"
#define ITEM_EFFECT_USED "weff_used"
#define ITEM_EFFECT_WIELDED "weff_wield"
#define ITEM_EFFECT_VISUAL "weff_visual"
#define ITEM_EFFECT_LISTENER "weff_listener"
#define ITEM_EFFECT_VISIBLE "weff_visible"
#define ITEM_EFFECT_RANGED "weff_ranged"
#define ITEM_EFFECT_PROCESS "weff_process"

/decl/item_effect
abstract_type = /decl/item_effect

Expand Down Expand Up @@ -75,6 +65,9 @@
SHOULD_CALL_PARENT(FALSE)
return FALSE

/decl/item_effect/proc/examined(obj/item/item, mob/user)
/decl/item_effect/proc/on_examined(obj/item/item, mob/user, distance, list/parameters)
SHOULD_CALL_PARENT(FALSE)
return FALSE

/decl/item_effect/proc/modify_attack_damage(base_damage, obj/item/used_item, mob/user, dry_run, list/parameters)
return base_damage
2 changes: 1 addition & 1 deletion code/modules/item_effects/item_effect_aura.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
user.remove_aura(aura_type)
return TRUE

/decl/item_effect/aura/examined(obj/item/item, mob/user)
/decl/item_effect/aura/on_examined(obj/item/item, mob/user)
var/obj/aura/aura = aura_type
to_chat(user, SPAN_NOTICE("\The [item] grants \a [initial(aura.name)] to the wielder."))

Expand Down
8 changes: 4 additions & 4 deletions code/modules/item_effects/item_effect_charges.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
abstract_type = /decl/item_effect/charges

/decl/item_effect/charges/do_ranged_effect(mob/user, obj/item/item, atom/target, list/parameters)
var/charges = (LAZYACCESS(parameters, "charges") || 0)
var/charges = (LAZYACCESS(parameters, IE_PAR_USES) || 0)
if(charges <= 0)
return FALSE
item.set_item_effect_parameter(src, ITEM_EFFECT_RANGED, "charges", charges-1)
item.set_item_effect_parameter(src, IE_CAT_RANGED, IE_PAR_USES, charges-1)
return TRUE

/decl/item_effect/charges/examined(obj/item/item, mob/user)
to_chat(user, SPAN_NOTICE("\The [item] has [item.get_item_effect_parameter(src, ITEM_EFFECT_RANGED, "charges") || 0] charge\s of [effect_descriptor] left."))
/decl/item_effect/charges/on_examined(obj/item/item, mob/user)
to_chat(user, SPAN_NOTICE("\The [item] has [item.get_item_effect_parameter(src, IE_CAT_RANGED, IE_PAR_USES) || 0] charge\s of [effect_descriptor] left."))

/obj/item/projectile/fireball
name = "fireball"
Expand Down
28 changes: 14 additions & 14 deletions code/modules/item_effects/item_effect_debug.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/decl/item_effect/debug/hear_speech(obj/item/item, mob/user, message, decl/language/speaking)
log_debug("[type]: [item] heard [user] say [message] in [speaking] ([json_encode(args)])")

/decl/item_effect/debug/examined(obj/item/item, mob/user)
/decl/item_effect/debug/on_examined(obj/item/item, mob/user)
log_debug("[type]: [user] examined [item] ([json_encode(args)])")

/decl/item_effect/debug/do_process_effect(obj/item/item, list/parameters)
Expand All @@ -46,21 +46,21 @@
/obj/item/sword/katana/debug/Initialize()
. = ..()
add_item_effect(/decl/item_effect/debug, list(
ITEM_EFFECT_VISUAL = list("vis" = "ual"),
ITEM_EFFECT_STRIKE = list("foo" = "bar"),
ITEM_EFFECT_PARRY = list("fizz" = "buzz"),
ITEM_EFFECT_USED = list("aard" = "vark"),
ITEM_EFFECT_VISIBLE = list("ooo" = "aaa"),
ITEM_EFFECT_LISTENER = list("walla walla" = "bing bong"),
ITEM_EFFECT_PROCESS = list("hyonk" = "hjonk")
(IE_CAT_VISUAL) = list("vis" = "ual"),
(IE_CAT_STRIKE) = list("foo" = "bar"),
(IE_CAT_PARRY) = list("fizz" = "buzz"),
(IE_CAT_USED) = list("aard" = "vark"),
(IE_CAT_EXAMINE) = list("ooo" = "aaa"),
(IE_CAT_LISTENER) = list("walla walla" = "bing bong"),
(IE_CAT_PROCESS) = list("hyonk" = "hjonk")
))
add_item_effect(/decl/item_effect/charges/fireball, list(
ITEM_EFFECT_VISIBLE,
ITEM_EFFECT_RANGED = list("charges" = 5)
(IE_CAT_EXAMINE),
(IE_CAT_RANGED) = list(IE_PAR_USES = 5)
))
add_item_effect(/decl/item_effect/aura/regeneration, list(
ITEM_EFFECT_VISIBLE,
ITEM_EFFECT_WIELDED
(IE_CAT_EXAMINE),
(IE_CAT_WIELDED)
))

/obj/item/staff/crystal/beacon/fireball
Expand All @@ -71,6 +71,6 @@
/obj/item/staff/crystal/beacon/fireball/Initialize(ml, material_key)
. = ..()
add_item_effect(/decl/item_effect/charges/fireball, list(
ITEM_EFFECT_VISIBLE,
ITEM_EFFECT_RANGED = list("charges" = 5)
(IE_CAT_EXAMINE),
(IE_CAT_RANGED) = list(IE_PAR_USES = 5)
))
Loading

0 comments on commit 5c9340d

Please sign in to comment.