Parrying Refactor, Adding Parrying to Select Two-handed Weapons: Parry This You Filthy Casual! (#26043)

* Refactors parrying and how parrying is handled. Also gives most of the melee wizard weapons parrying as well as most two handed weapons.

* Forgor the blood spear :)

* Renames `special_parry_condition` to `requires_two_hands`

* Apply suggestions from code review

Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Signed-off-by: Spaghetti-bit <yumyumkillkill@gmail.com>

* Update code/datums/components/parry.dm

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: Spaghetti-bit <yumyumkillkill@gmail.com>

* Apply suggestions from code review

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: Spaghetti-bit <yumyumkillkill@gmail.com>

* applies suggestion from @lewcc

* Removes the two handed requirement from cult spear as per @Qwerty's request

* Apply suggestions from code review (1/2) from hal

Co-authored-by: Charlie <69320440+hal9000PR@users.noreply.github.com>
Signed-off-by: Spaghetti-bit <yumyumkillkill@gmail.com>

* Apply suggestions from code review (2/2)

* ...accidentally removed an icon in `energy_melee_weapons.dm` when I deconflicted stuff. 💀 ready for review.

* Again, variable added back during deconflict. issues resolved.

* Update code/game/objects/items/weapons/shields.dm

Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com>

---------

Signed-off-by: Spaghetti-bit <yumyumkillkill@gmail.com>
Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Co-authored-by: Charlie <69320440+hal9000PR@users.noreply.github.com>
This commit is contained in:
Spaghetti-bit
2024-07-30 05:33:02 -07:00
committed by GitHub
parent 6f00060c77
commit cbeedfca9f
12 changed files with 99 additions and 78 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ LIGHTERS ARE IN LIGHTERS.DM
else if(istype(I, /obj/item/melee/energy/sword/saber))
var/obj/item/melee/energy/sword/saber/S = I
if(S.active)
if(HAS_TRAIT(S, TRAIT_ITEM_ACTIVE))
light("<span class='warning'>[user] makes a violent slashing motion, barely missing [user.p_their()] nose as light flashes. [user.p_they(TRUE)] light[user.p_s()] [user.p_their()] [name] with [S] in the process.</span>")
else if(istype(I, /obj/item/assembly/igniter))
@@ -14,7 +14,6 @@
name = "generic energy blade"
desc = "If you can see this and didn't spawn it in as an admin, make an issue report on GitHub."
icon = 'icons/obj/weapons/energy_melee.dmi'
var/active = FALSE
/// Damage done when active. Does not stack with force_off.
var/force_on = 30
/// Damage done when thrown while active. Does not stack with throwforce_off.
@@ -78,8 +77,21 @@
if(HAS_TRAIT(user, TRAIT_CLUMSY) && prob(50))
to_chat(user, "<span class='warning'>You accidentally cut yourself with [src], like a doofus!</span>")
user.take_organ_damage(5,5)
active = !active
if(active)
if(HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
REMOVE_TRAIT(src, TRAIT_ITEM_ACTIVE, TRAIT_GENERIC)
force = force_off
throwforce = throwforce_off
hitsound = initial(hitsound)
throw_speed = initial(throw_speed)
if(length(attack_verb_on))
attack_verb = list()
icon_state = initial(icon_state)
w_class = initial(w_class)
playsound(user, 'sound/weapons/saberoff.ogg', 35, 1) //changed it from 50% volume to 35% because deafness
set_light(0)
to_chat(user, "<span class='notice'>[src] can now be concealed.</span>")
else
ADD_TRAIT(src, TRAIT_ITEM_ACTIVE, TRAIT_GENERIC)
force = force_on
throwforce = throwforce_on
hitsound = 'sound/weapons/blade1.ogg'
@@ -95,18 +107,7 @@
w_class = w_class_on
playsound(user, 'sound/weapons/saberon.ogg', 35, 1) //changed it from 50% volume to 35% because deafness
to_chat(user, "<span class='notice'>[src] is now active.</span>")
else
force = force_off
throwforce = throwforce_off
hitsound = initial(hitsound)
throw_speed = initial(throw_speed)
if(length(attack_verb_on))
attack_verb = list()
icon_state = initial(icon_state)
w_class = initial(w_class)
playsound(user, 'sound/weapons/saberoff.ogg', 35, 1) //changed it from 50% volume to 35% because deafness
set_light(0)
to_chat(user, "<span class='notice'>[src] can now be concealed.</span>")
if(ishuman(user))
var/mob/living/carbon/human/H = user
H.update_inv_l_hand()
@@ -115,7 +116,9 @@
return
/obj/item/melee/energy/get_heat()
return active * 3500
if(HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
return 3500
return 0
/obj/item/melee/energy/proc/try_sharpen(obj/item/item, amount, max_amount)
SIGNAL_HANDLER // COMSIG_ITEM_SHARPEN_ACT
@@ -180,14 +183,14 @@
..()
if(item_color == null)
item_color = pick("red", "blue", "green", "purple")
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.5, _parryable_attack_types = ALL_ATTACK_TYPES)
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.5, _parryable_attack_types = ALL_ATTACK_TYPES, _requires_activation = TRUE)
/obj/item/melee/energy/sword/examine(mob/user)
. = ..()
. += "<span class='notice'>Can parry melee attacks and sometimes blocks ranged energy attacks. Use in hand to turn off and on.</span>"
/obj/item/melee/energy/sword/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
if(active)
if(HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
return ..()
return FALSE
@@ -198,7 +201,7 @@
/obj/item/melee/energy/sword/cyborg/attack(mob/M, mob/living/silicon/robot/R)
if(R.cell)
var/obj/item/stock_parts/cell/C = R.cell
if(active && !(C.use(hitcost)))
if(HAS_TRAIT(src, TRAIT_ITEM_ACTIVE) && !(C.use(hitcost)))
attack_self(R)
to_chat(R, "<span class='notice'>It's out of charge!</span>")
return
@@ -251,7 +254,7 @@
item_color = "rainbow"
to_chat(user, "<span class='warning'>RNBW_ENGAGE</span>")
if(active)
if(HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
icon_state = "swordrainbow"
// Updating overlays, copied from welder code.
// I tried calling attack_self twice, which looked cool, except it somehow didn't update the overlays!!
@@ -265,7 +268,7 @@
/obj/item/melee/energy/sword/saber/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
if(!active)
if(!HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
return FALSE
. = ..()
if(!.) // they did not block the attack
@@ -322,13 +325,16 @@
icon_state = "blade"
force = 30 //Normal attacks deal esword damage
hitsound = 'sound/weapons/blade1.ogg'
active = TRUE
throwforce = 1//Throwing or dropping the item deletes it.
throw_speed = 3
throw_range = 1
w_class = WEIGHT_CLASS_BULKY //So you can't hide it in your pocket or some such.
sharp = TRUE
/obj/item/melee/energy/blade/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_ITEM_ACTIVE, ROUNDSTART_TRAIT)
/obj/item/melee/energy/blade/attack_self(mob/user)
return
@@ -374,7 +380,7 @@
return
var/datum/status_effect/saw_bleed/B = target.has_status_effect(STATUS_EFFECT_SAWBLEED)
if(!B)
if(!active) //This isn't in the above if-check so that the else doesn't care about active
if(!HAS_TRAIT(src, TRAIT_ITEM_ACTIVE)) //This isn't in the above if-check so that the else doesn't care about active
target.apply_status_effect(STATUS_EFFECT_SAWBLEED)
else
B.add_bleed(B.bleed_buildup)
@@ -394,8 +400,21 @@
if(HAS_TRAIT(H, TRAIT_CLUMSY) && prob(50))
to_chat(H, "<span class='warning'>You accidentally cut yourself with [src], like a doofus!</span>")
H.take_organ_damage(10,10)
active = !active
if(active)
if(HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
REMOVE_TRAIT(src, TRAIT_ITEM_ACTIVE, TRAIT_GENERIC)
force = force_off
throwforce = throwforce_off
hitsound = initial(hitsound)
throw_speed = initial(throw_speed)
if(length(attack_verb_on))
attack_verb = list()
icon_state = initial(icon_state)
w_class = initial(w_class)
playsound(user, 'sound/magic/fellowship_armory.ogg', 35, 1) //changed it from 50% volume to 35% because deafness
set_light(0)
to_chat(user, "<span class='notice'>You close [src]. It will now attack rapidly and cause fauna to bleed.</span>")
else
ADD_TRAIT(src, TRAIT_ITEM_ACTIVE, TRAIT_GENERIC)
force = force_on
throwforce = throwforce_on
hitsound = 'sound/weapons/bladeslice.ogg'
@@ -409,20 +428,8 @@
icon_state = "sword[item_color]"
set_light(brightness_on, l_color=colormap[item_color])
w_class = w_class_on
playsound(user, 'sound/magic/fellowship_armory.ogg', 35, TRUE, frequency = 90000 - (active * 30000))
playsound(user, 'sound/magic/fellowship_armory.ogg', 35, TRUE, frequency = 90000 - (HAS_TRAIT(src, TRAIT_ITEM_ACTIVE) * 30000))
to_chat(user, "<span class='notice'>You open [src]. It will now cleave enemies in a wide arc and deal additional damage to fauna.</span>")
else
force = force_off
throwforce = throwforce_off
hitsound = initial(hitsound)
throw_speed = initial(throw_speed)
if(length(attack_verb_on))
attack_verb = list()
icon_state = initial(icon_state)
w_class = initial(w_class)
playsound(user, 'sound/magic/fellowship_armory.ogg', 35, 1) //changed it from 50% volume to 35% because deafness
set_light(0)
to_chat(user, "<span class='notice'>You close [src]. It will now attack rapidly and cause fauna to bleed.</span>")
if(ishuman(user))
var/mob/living/carbon/human/H = user
@@ -433,27 +440,27 @@
/obj/item/melee/energy/cleaving_saw/examine(mob/user)
. = ..()
. += "<span class='notice'>It is [active ? "open, will cleave enemies in a wide arc and deal additional damage to fauna":"closed, and can be used for rapid consecutive attacks that cause fauna to bleed"].<br>\
. += "<span class='notice'>It is [HAS_TRAIT(src, TRAIT_ITEM_ACTIVE) ? "open, will cleave enemies in a wide arc and deal additional damage to fauna":"closed, and can be used for rapid consecutive attacks that cause fauna to bleed"].<br>\
Both modes will build up existing bleed effects, doing a burst of high damage if the bleed is built up high enough.<br>\
Transforming it immediately after an attack causes the next attack to come out faster.</span>"
/obj/item/melee/energy/cleaving_saw/suicide_act(mob/user)
user.visible_message("<span class='suicide'>[user] is [active ? "closing [src] on [user.p_their()] neck" : "opening [src] into [user.p_their()] chest"]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
user.visible_message("<span class='suicide'>[user] is [HAS_TRAIT(src, TRAIT_ITEM_ACTIVE) ? "closing [src] on [user.p_their()] neck" : "opening [src] into [user.p_their()] chest"]! It looks like [user.p_theyre()] trying to commit suicide!</span>")
transform_cooldown = 0
transform_weapon(user, TRUE)
return BRUTELOSS
/obj/item/melee/energy/cleaving_saw/melee_attack_chain(mob/user, atom/target, params)
..()
if(!active)
if(!HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
user.changeNext_move(CLICK_CD_MELEE * 0.5) //when closed, it attacks very rapidly
/obj/item/melee/energy/cleaving_saw/attack(mob/living/target, mob/living/carbon/human/user)
if(!active || swiping || !target.density || get_turf(target) == get_turf(user))
if(!active)
if(!HAS_TRAIT(src, TRAIT_ITEM_ACTIVE) || swiping || !target.density || get_turf(target) == get_turf(user))
if(!HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
faction_bonus_force = 0
..()
if(!active)
if(!HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
faction_bonus_force = initial(faction_bonus_force)
else
var/turf/user_turf = get_turf(user)
+16 -14
View File
@@ -139,32 +139,34 @@
throw_speed = 3
throw_range = 4
w_class = WEIGHT_CLASS_NORMAL
var/active = FALSE
/obj/item/shield/riot/tele/add_parry_component()
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.7, _parryable_attack_types = ALL_ATTACK_TYPES, _parry_cooldown = (5 / 3) SECONDS, _requires_activation = TRUE)
/obj/item/shield/riot/tele/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
if(active)
if(HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
return ..()
return FALSE // by not calling the parent the hit_reaction signal is never sent
/obj/item/shield/riot/tele/attack_self(mob/living/user)
active = !active
icon_state = "teleriot[active]"
playsound(src.loc, 'sound/weapons/batonextend.ogg', 50, 1)
if(active)
force = 8
throwforce = 5
throw_speed = 2
w_class = WEIGHT_CLASS_BULKY
slot_flags = SLOT_FLAG_BACK
to_chat(user, "<span class='notice'>You extend \the [src].</span>")
else
if(HAS_TRAIT(src, TRAIT_ITEM_ACTIVE))
REMOVE_TRAIT(src,TRAIT_ITEM_ACTIVE, TRAIT_GENERIC)
force = 3
throwforce = 3
throw_speed = 3
w_class = WEIGHT_CLASS_NORMAL
slot_flags = null
to_chat(user, "<span class='notice'>[src] can now be concealed.</span>")
else
ADD_TRAIT(src, TRAIT_ITEM_ACTIVE, TRAIT_GENERIC)
force = 8
throwforce = 5
throw_speed = 2
w_class = WEIGHT_CLASS_BULKY
slot_flags = SLOT_FLAG_BACK
to_chat(user, "<span class='notice'>You extend \the [src].</span>")
icon_state = "teleriot[HAS_TRAIT(src, TRAIT_ITEM_ACTIVE)]"
playsound(loc, 'sound/weapons/batonextend.ogg', 50, TRUE)
if(ishuman(user))
var/mob/living/carbon/human/H = user
H.update_inv_l_hand()
+9 -10
View File
@@ -29,6 +29,7 @@
/obj/item/fireaxe/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_FORCES_OPEN_DOORS_ITEM, ROUNDSTART_TRAIT)
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.7, _parryable_attack_types = MELEE_ATTACK, _parry_cooldown = (10 / 3) SECONDS, _requires_two_hands = TRUE) // 2.3333 seconds of cooldown for 30% uptime
AddComponent(/datum/component/two_handed, force_unwielded = force_unwielded, force_wielded = force_wielded, icon_wielded = "[base_icon_state]1")
/obj/item/fireaxe/update_icon_state() //Currently only here to fuck with the on-mob icons.
@@ -52,10 +53,6 @@
force_wielded = 23
needs_permit = TRUE
/obj/item/fireaxe/boneaxe/Initialize(mapload)
. = ..()
AddComponent(/datum/component/two_handed, force_wielded = force_wielded, icon_wielded = "[base_icon_state]1")
/obj/item/fireaxe/energized
desc = "Someone with a love for fire axes decided to turn this one into a high-powered energy weapon. Seems excessive."
force_wielded = 35
@@ -109,7 +106,6 @@
throw_range = 5
w_class = WEIGHT_CLASS_SMALL
var/w_class_on = WEIGHT_CLASS_BULKY
armour_penetration_flat = 10
armour_penetration_percentage = 50
origin_tech = "magnets=4;syndicate=5"
@@ -123,8 +119,6 @@
var/blade_color
var/brightness_on = 2
var/colormap = list(red = LIGHT_COLOR_RED, blue = LIGHT_COLOR_LIGHTBLUE, green = LIGHT_COLOR_GREEN, purple = LIGHT_COLOR_PURPLE, rainbow = LIGHT_COLOR_WHITE)
var/force_unwielded = 3
var/force_wielded = 34
var/wieldsound = 'sound/weapons/saberon.ogg'
@@ -134,7 +128,7 @@
. = ..()
if(!blade_color)
blade_color = pick("red", "blue", "green", "purple")
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.25, _parryable_attack_types = ALL_ATTACK_TYPES, _parry_cooldown = (4 / 3) SECONDS) // 0.3333 seconds of cooldown for 75% uptime
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.25, _parryable_attack_types = ALL_ATTACK_TYPES, _parry_cooldown = (4 / 3) SECONDS, _requires_two_hands = TRUE) // 0.3333 seconds of cooldown for 75% uptime
AddComponent(/datum/component/two_handed, force_wielded = force_wielded, force_unwielded = force_unwielded, wieldsound = wieldsound, unwieldsound = unwieldsound, wield_callback = CALLBACK(src, PROC_REF(on_wield)), unwield_callback = CALLBACK(src, PROC_REF(on_unwield)), only_sharp_when_wielded = TRUE)
/obj/item/dualsaber/update_icon_state()
@@ -261,6 +255,7 @@
/obj/item/spear/Initialize(mapload)
. = ..()
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.7, _parryable_attack_types = MELEE_ATTACK, _parry_cooldown = (10 / 3) SECONDS, _requires_two_hands = TRUE) // 2.3333 seconds of cooldown for 30% uptime
AddComponent(/datum/component/two_handed, \
force_wielded = force_wielded, \
force_unwielded = force_unwielded, \
@@ -566,6 +561,7 @@
/obj/item/singularityhammer/Initialize(mapload)
. = ..()
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.25, _parryable_attack_types = ALL_ATTACK_TYPES, _parry_cooldown = (4 / 3) SECONDS, _requires_two_hands = TRUE) // 0.3333 seconds of cooldown for 75% uptime
AddComponent(/datum/component/two_handed, \
force_wielded = 40, \
force_unwielded = force, \
@@ -635,6 +631,7 @@
/obj/item/mjollnir/Initialize(mapload)
. = ..()
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.25, _parryable_attack_types = ALL_ATTACK_TYPES, _parry_cooldown = (4 / 3) SECONDS, _requires_two_hands = TRUE) // 0.3333 seconds of cooldown for 75% uptime
AddComponent(/datum/component/two_handed, \
force_wielded = 25, \
force_unwielded = force, \
@@ -685,6 +682,7 @@
/obj/item/knighthammer/Initialize(mapload)
. = ..()
START_PROCESSING(SSobj, src)
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.25, _parryable_attack_types = ALL_ATTACK_TYPES, _parry_cooldown = (4 / 3) SECONDS, _requires_two_hands = TRUE) // 0.3333 seconds of cooldown for 75% uptime
AddComponent(/datum/component/two_handed, \
force_wielded = 30, \
force_unwielded = force, \
@@ -889,6 +887,7 @@
/obj/item/push_broom/Initialize(mapload)
. = ..()
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.25, _parryable_attack_types = ALL_ATTACK_TYPES, _parry_cooldown = (7 / 5) SECONDS, _requires_two_hands = TRUE)
AddComponent(/datum/component/two_handed, \
force_wielded = 12, \
force_unwielded = force, \
@@ -959,7 +958,7 @@
/obj/item/push_broom/traitor/Initialize(mapload)
. = ..()
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.25, _parryable_attack_types = ALL_ATTACK_TYPES, _parry_cooldown = (4 / 3) SECONDS) // 0.3333 seconds of cooldown for 75% uptime
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.25, _parryable_attack_types = ALL_ATTACK_TYPES, _parry_cooldown = (4 / 3) SECONDS, _requires_two_hands = TRUE) // 0.3333 seconds of cooldown for 75% uptime
// parent component handles this
AddComponent(/datum/component/two_handed, force_wielded = 25, force_unwielded = force)
@@ -1047,7 +1046,7 @@
. = ..()
ADD_TRAIT(src, TRAIT_FORCES_OPEN_DOORS_ITEM, ROUNDSTART_TRAIT)
ADD_TRAIT(src, TRAIT_SUPERMATTER_IMMUNE, ROUNDSTART_TRAIT) //so it can't be dusted by the SM
AddComponent(/datum/component/parry, _stamina_constant = 0, _stamina_coefficient = 0.25, _parryable_attack_types = ALL_ATTACK_TYPES)
AddComponent(/datum/component/parry, _stamina_constant = 2, _stamina_coefficient = 0.25, _parryable_attack_types = ALL_ATTACK_TYPES, _parry_cooldown = (4 / 3) SECONDS, _requires_two_hands = TRUE) // 0.3333 seconds of cooldown for 75% uptime
AddComponent(/datum/component/two_handed, force_wielded = 40, force_unwielded = force, icon_wielded = "[base_icon_state]1")
/obj/item/supermatter_halberd/update_icon_state()