Skip to content

Commit

Permalink
add: More knives for martial art & shields penetration (#4220)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiquidPotroh authored Jan 20, 2024
1 parent 96c9ed9 commit 69a9fe8
Show file tree
Hide file tree
Showing 15 changed files with 195 additions and 117 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#define BLOCK_CAPSAICIN 262144 // Prevents from passing capsaicin onto human

#define NOSHARPENING 524288 // Prevents from sharpening item with whetstone

// Update flags for [/atom/proc/update_appearance]
/// Update the atom's name
Expand Down
14 changes: 9 additions & 5 deletions code/__HELPERS/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,17 @@
return 0

//Checks for specific types in a list
/proc/is_type_in_list(atom/A, list/L)
/proc/is_type_in_list(atom/A, list/L, include_children = TRUE)
if(!L || !L.len || !A)
return 0
return FALSE
for(var/type in L)
if(istype(A, type))
return 1
return 0
if(include_children)
if(istype(A, type))
return TRUE
else
if(A.type == type)
return TRUE
return FALSE

//Checks for specific types in specifically structured (Assoc "type" = TRUE) lists ('typecaches')
/proc/is_type_in_typecache(atom/A, list/L)
Expand Down
48 changes: 48 additions & 0 deletions code/datums/components/sharpening.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Sharpening component
*
* Makes an item sharpenable with a whetstone
*
*/
/datum/component/sharpening
dupe_mode = COMPONENT_DUPE_UNIQUE
var/damage_increase

/datum/component/sharpening/Initialize(damage_increase = 0)
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE
src.damage_increase = damage_increase

/datum/component/sharpening/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_SHARPEN_ACT, PROC_REF(on_sharpen))

/datum/component/sharpening/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_ITEM_SHARPEN_ACT))

/datum/component/sharpening/proc/on_sharpen(obj/item/item, amount, max_amount)
SIGNAL_HANDLER

if(!item || HAS_TRAIT(item, TRAIT_WIELDED))
return COMPONENT_BLOCK_SHARPEN_BLOCKED

if(amount <= damage_increase)
return COMPONENT_BLOCK_SHARPEN_ALREADY
// Already sharpened items can only be sharpened with the best whetstone on the difference between them
amount -= damage_increase

var/force = item.force
var/datum/component/two_handed/TH_component = item.GetComponent(/datum/component/two_handed)
if(TH_component)
force = TH_component.force_wielded

var/obj/item/clothing/gloves/color/black/razorgloves/razorgloves = item
if(istype(razorgloves))
force = razorgloves.razor_damage_high

if(force >= max_amount || item.throwforce >= max_amount || item.flags & NOSHARPENING)
return COMPONENT_BLOCK_SHARPEN_MAXED

damage_increase = min(damage_increase + amount, (max_amount - force))
item.sharpen_act(damage_increase)

return COMPONENT_BLOCK_SHARPEN_APPLIED
49 changes: 7 additions & 42 deletions code/datums/components/twohanded.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
var/icon_wielded = FALSE
/// Reference to the offhand created for the item
var/obj/item/twohanded/offhand/offhand_item = null
/// The amount of increase recived from sharpening the item
var/sharpened_increase = 0
/// A callback on the parent to be called when the item is wielded
var/datum/callback/wield_callback
/// A callback on the parent to be called when the item is unwielded
Expand Down Expand Up @@ -111,7 +109,6 @@
RegisterSignal(parent, COMSIG_ITEM_ATTACK, PROC_REF(on_attack))
RegisterSignal(parent, COMSIG_ATOM_UPDATE_ICON, PROC_REF(on_update_icon))
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
RegisterSignal(parent, COMSIG_ITEM_SHARPEN_ACT, PROC_REF(on_sharpen))


// Remove all siginals registered to the parent item
Expand All @@ -121,8 +118,7 @@
COMSIG_ITEM_ATTACK_SELF,
COMSIG_ITEM_ATTACK,
COMSIG_ATOM_UPDATE_ICON,
COMSIG_MOVABLE_MOVED,
COMSIG_ITEM_SHARPEN_ACT))
COMSIG_MOVABLE_MOVED))


/// Triggered on equip of the item containing the component
Expand Down Expand Up @@ -241,8 +237,9 @@
parent_item.force *= force_multiplier
else if(force_wielded)
parent_item.force = force_wielded
if(sharpened_increase)
parent_item.force += sharpened_increase
var/datum/component/sharpening/sharpening = item.GetComponent(/datum/component/sharpening)
if(sharpening)
parent_item.force += sharpening.damage_increase
if(sharp_when_wielded)
parent_item.sharp = TRUE

Expand Down Expand Up @@ -303,8 +300,9 @@

// update item stats
var/obj/item/parent_item = parent
if(sharpened_increase)
parent_item.force -= sharpened_increase
var/datum/component/sharpening/sharpening = item.GetComponent(/datum/component/sharpening)
if(sharpening)
parent_item.force -= sharpening.damage_increase
if(force_multiplier)
parent_item.force /= force_multiplier
else
Expand Down Expand Up @@ -408,39 +406,6 @@
return COMPONENT_BLOCK_SWAP


/**
* on_sharpen Triggers on usage of a sharpening stone on the item
*
* Has no usage for now.
*/
/datum/component/two_handed/proc/on_sharpen(obj/item/item, amount, max_amount)
SIGNAL_HANDLER

if(!item)
return COMPONENT_BLOCK_SHARPEN_BLOCKED
if(wielded)
return COMPONENT_BLOCK_SHARPEN_BLOCKED
if(sharpened_increase)
return COMPONENT_BLOCK_SHARPEN_ALREADY

var/wielded_val = 0
if(force_multiplier)
var/obj/item/parent_item = parent
if(wielded)
wielded_val = parent_item.force
else
wielded_val = parent_item.force * force_multiplier
else
wielded_val = force_wielded

if(wielded_val > max_amount)
return COMPONENT_BLOCK_SHARPEN_MAXED

sharpened_increase = min(amount, (max_amount - wielded_val))

return COMPONENT_BLOCK_SHARPEN_APPLIED


/**
* The offhand dummy item for two handed items
*
Expand Down
14 changes: 13 additions & 1 deletion code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/g
var/is_speedslimepotioned = FALSE
var/cant_be_faster = FALSE
var/armour_penetration = 0 //percentage of armour effectiveness to remove
var/shields_penetration = 0 //amount by which block_chance decreases
/// Allows you to override the attack animation with an attack effect
var/attack_effect_override
var/list/allowed = null //suit storage stuff.
Expand Down Expand Up @@ -167,7 +168,6 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/g
///Datum used in item pixel shift TGUI
var/datum/ui_module/item_pixel_shift/item_pixel_shift


/obj/item/New()
..()
for(var/path in actions_types)
Expand Down Expand Up @@ -1261,3 +1261,15 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/g

// This is instant on byond's end, but to our clients this looks like a quick drop
animate(src, alpha = old_alpha, pixel_x = old_x, pixel_y = old_y, transform = old_transform, time = 3, easing = CUBIC_EASING)

/obj/item/proc/sharpen_act(increase)
force += increase
throwforce += increase

/obj/item/proc/get_force()
var/datum/component/sharpening/sharpening = GetComponent(/datum/component/sharpening)
return initial(force) + sharpening?.damage_increase

/obj/item/proc/get_throwforce()
var/datum/component/sharpening/sharpening = GetComponent(/datum/component/sharpening)
return initial(throwforce) + sharpening?.damage_increase
86 changes: 50 additions & 36 deletions code/game/objects/items/weapons/kitchen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,49 @@
"<span class='suicide'>[user] is slitting [user.p_their()] stomach open with the [name]! It looks like [user.p_theyre()] trying to commit seppuku.</span>"))
return BRUTELOSS

/obj/item/kitchen/knife/throw_at(atom/target, range, speed, mob/thrower, spin = TRUE, diagonals_first = FALSE, datum/callback/callback, force = INFINITY, dodgeable = TRUE)
. = ..()
playsound(src, 'sound/weapons/knife_holster/knife_throw.ogg', 30, 1)

/obj/item/kitchen/knife/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum)
var/datum/martial_art/throwing/MA = throwingdatum?.thrower?.mind?.martial_art
if(istype(MA) && is_type_in_list(src, MA.knife_types, FALSE))
embed_chance = MA.knife_embed_chance
throwforce = get_throwforce() + MA.knife_bonus_damage
shields_penetration = initial(shields_penetration) + MA.shields_penetration_bonus
. = ..()

/obj/item/kitchen/knife/after_throw(datum/callback/callback)
embed_chance = initial(embed_chance)
throwforce = get_throwforce()
shields_penetration = initial(shields_penetration)
. = ..()

/obj/item/kitchen/knife/attack(mob/living/target, mob/living/user, def_zone)
var/datum/martial_art/throwing/MA = user?.mind?.martial_art
if(istype(MA) && is_type_in_list(src, MA.knife_types, FALSE))
force = get_force() + MA.knife_bonus_damage
if(user.zone_selected == BODY_ZONE_HEAD && user.a_intent == INTENT_HARM)
if(MA.neck_cut(target, user))
return TRUE
. = ..()

/obj/item/kitchen/knife/attack_obj(obj/O, mob/living/user, params)
var/datum/martial_art/throwing/MA = user?.mind?.martial_art
if(istype(MA) && is_type_in_list(src, MA.knife_types, FALSE))
force = get_force() + MA.knife_bonus_damage
. = ..()

/obj/item/kitchen/knife/afterattack(atom/target, mob/user, proximity, params)
force = get_force()
. = ..()

//this ensures that an afterattack will always be called for knives
/obj/item/kitchen/knife/melee_attack_chain(mob/user, atom/target, params)
if(!tool_attack_chain(user, target) && pre_attackby(target, user, params))
target.attackby(src, user, params)
afterattack(target, user, 1, params)

/obj/item/kitchen/knife/plastic
name = "plastic knife"
desc = "The bluntest of blades."
Expand Down Expand Up @@ -179,35 +222,6 @@
bayonet = TRUE
embed_chance = 90

/obj/item/kitchen/knife/combat/throw_at(atom/target, range, speed, mob/thrower, spin = TRUE, diagonals_first = FALSE, datum/callback/callback, force = INFINITY, dodgeable = TRUE)
. = ..()
playsound(src, 'sound/weapons/knife_holster/knife_throw.ogg', 30, 1)

/obj/item/kitchen/knife/combat/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum)
var/datum/martial_art/throwing/MA = throwingdatum?.thrower?.mind?.martial_art
if(istype(MA))
embed_chance = MA.knife_embed_chance
throwforce = initial(throwforce) + MA.knife_bonus_damage
. = ..()

/obj/item/kitchen/knife/combat/after_throw(datum/callback/callback)
embed_chance = initial(embed_chance)
throwforce = initial(throwforce)
. = ..()

/obj/item/kitchen/knife/combat/attack(mob/living/target, mob/living/user, def_zone)
var/datum/martial_art/throwing/MA = user?.mind?.martial_art
if(istype(MA))
force = initial(force) + MA.knife_bonus_damage
if(user.zone_selected == BODY_ZONE_HEAD && user.a_intent == INTENT_HARM)
MA.neck_cut(target, user)
return
. = ..()

/obj/item/kitchen/knife/combat/afterattack(atom/target, mob/user, proximity, params)
force = initial(force)
. = ..()

/obj/item/kitchen/knife/combat/survival
name = "survival knife"
icon_state = "survivalknife"
Expand All @@ -217,7 +231,7 @@
throwforce = 15

/obj/item/kitchen/knife/combat/throwing
name = "Throwing knife"
name = "throwing knife"
desc = "A well-sharpened black knife. Designed to be thrown. It is made from a single piece of metal. The markings are scratched.\nAn excellent solution for live problems and cake cutting."
icon_state = "throwingknife"
item_state = "throwingknife"
Expand Down Expand Up @@ -283,19 +297,19 @@
. = ..()
if(sh)
size = sh.icon_state
if(istype(sh, /obj/item/shard/plasma))
name = "plasma glass shiv"
desc = "A plasma glass shard with some cloth wrapped around it"
force = 9
throwforce = 11
materials = list(MAT_PLASMA = MINERAL_MATERIAL_AMOUNT * 0.5, MAT_GLASS = MINERAL_MATERIAL_AMOUNT)
update_icon()

/obj/item/kitchen/knife/glassshiv/update_icon()
if(!size)
size = pick("large", "medium", "small")
icon_state = "[size]_[initial(icon_state)]"

/obj/item/kitchen/knife/glassshiv/plasma
name = "plasma glass shiv"
desc = "A plasma glass shard with some cloth wrapped around it"
force = 9
throwforce = 11
materials = list(MAT_PLASMA = MINERAL_MATERIAL_AMOUNT * 0.5, MAT_GLASS = MINERAL_MATERIAL_AMOUNT)

/*
* Rolling Pins
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/weapons/melee/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
max_integrity = 200
armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 100, "acid" = 30)
resistance_flags = FIRE_PROOF
flags = NOSHARPENING
toolspeed = 1
light_power = 2
var/brightness_on = 2
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/weapons/melee/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
block_chance = 30
armour_penetration = 30
sharp = TRUE
flags = NOSHARPENING
origin_tech = "combat=5"
attack_verb = list("slashed", "stabbed", "sliced", "caned")
hitsound = 'sound/weapons/bladeslice.ogg'
Expand Down
5 changes: 4 additions & 1 deletion code/game/objects/items/weapons/shards.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@
var/obj/item/stack/sheet/cloth/CL = I
CL.use(1)
to_chat(user, "<span class='notice'>You wrap the [name] with some cloth.</span>")
new /obj/item/kitchen/knife/glassshiv(user.loc, src)
if(istype(src, /obj/item/shard/plasma))
new /obj/item/kitchen/knife/glassshiv/plasma(user.loc, src)
else
new /obj/item/kitchen/knife/glassshiv(user.loc, src)
qdel(src)
return ..()

Expand Down
Loading

0 comments on commit 69a9fe8

Please sign in to comment.