Shards only do damage if you hit things with them (#6478)

This commit is contained in:
Atermonera
2019-10-20 13:54:30 -08:00
committed by VirgoBot
parent 0287ce5527
commit 524520cb8b

View File

@@ -63,55 +63,48 @@
/obj/item/weapon/material/shard/afterattack(var/atom/target, mob/living/carbon/human/user as mob)
var/active_hand //hand the shard is in
var/will_break
var/gloves_are_heavy = FALSE//this is a fucking mess
var/will_break = FALSE
var/protected_hands = FALSE //this is a fucking mess
var/break_damage = 4
var/light_glove_d = rand(2, 4)
var/no_glove_d = rand(4, 6)
var/list/h_gloves = list(/obj/item/clothing/gloves/captain, /obj/item/clothing/gloves/cyborg,
/obj/item/clothing/gloves/swat, /obj/item/clothing/gloves/combat,
/obj/item/clothing/gloves/botanic_leather, /obj/item/clothing/gloves/duty,
/obj/item/clothing/gloves/tactical, /obj/item/clothing/gloves/vox,
/obj/item/clothing/gloves/gauntlets)
var/list/forbidden_gloves = list(
/obj/item/clothing/gloves/sterile,
/obj/item/clothing/gloves/knuckledusters
)
if(istype(user.l_hand, src))
if(src == user.l_hand)
active_hand = BP_L_HAND
else
else if(src == user.r_hand)
active_hand = BP_R_HAND
else
return // If it's not actually in our hands anymore, we were probably gentle with it
active_hand = (src == user.l_hand) ? BP_L_HAND : BP_R_HAND // May not actually be faster than an if-else block, but a little bit cleaner -Ater
if(prob(75))
will_break = TRUE
else
will_break = FALSE
if(user.gloves && (user.gloves.body_parts_covered & HANDS))
var/obj/item/clothing/gloves/UG = user.gloves.type
for(var/I in h_gloves)
if(UG == I)
gloves_are_heavy = TRUE
if(will_break)
user.visible_message("<span class='danger'>[user] hit \the [target] with \the [src], shattering it!</span>", "<span class='warning'>You shatter \the [src] in your hand!</span>")
playsound(user, pick('sound/effects/Glassbr1.ogg', 'sound/effects/Glassbr2.ogg', 'sound/effects/Glassbr3.ogg'), 30, 1)
qdel(src)
if(user.gloves && (user.gloves.body_parts_covered & HANDS) && istype(user.gloves, /obj/item/clothing/gloves)) // Not-gloves aren't gloves, and therefore don't protect us
protected_hands = TRUE // If we're wearing gloves we can probably handle it just fine
for(var/I in forbidden_gloves)
if(istype(user.gloves, I)) // forbidden_gloves is a blacklist, so if we match anything in there, our hands are not protected
protected_hands = FALSE
break
if(gloves_are_heavy == FALSE)
to_chat(user, "<span class='warning'>\The [src] partially cuts into your hand through your gloves as you hit \the [target]!</span>")
if(will_break)
user.visible_message("<span class='danger'>[user] hit \the [target] with \the [src], shattering it!</span>", "<span class='warning'>You shatter \the [src] in your hand!</span>")
user.apply_damage(light_glove_d + break_damage, BRUTE, active_hand, 0 ,0, src, src.sharp, src.edge)
playsound(user, pick('sound/effects/Glassbr1.ogg', 'sound/effects/Glassbr2.ogg', 'sound/effects/Glassbr3.ogg'), 30, 1)
qdel(src)
else
user.apply_damage(light_glove_d, BRUTE, active_hand, 0 ,0, src, src.sharp, src.edge)
else
if(user.gloves && !protected_hands)
to_chat(user, "<span class='warning'>\The [src] partially cuts into your hand through your gloves as you hit \the [target]!</span>")
user.apply_damage(light_glove_d + will_break ? break_damage : 0, BRUTE, active_hand, 0, 0, src, src.sharp, src.edge) // Ternary to include break damage
else if(!user.gloves)
to_chat(user, "<span class='warning'>\The [src] cuts into your hand as you hit \the [target]!</span>")
if(will_break)
user.visible_message("<span class='danger'>[user] hit \the [target] with \the [src], shattering it!</span>", "<span class='warning'>You shatter \the [src] in your hand!</span>")
user.apply_damage(no_glove_d + break_damage, BRUTE, active_hand, 0 ,0, src, src.sharp, src.edge)
playsound(user, pick('sound/effects/Glassbr1.ogg', 'sound/effects/Glassbr2.ogg', 'sound/effects/Glassbr3.ogg'), 30, 1)
qdel(src)
else
user.apply_damage(no_glove_d, BRUTE, active_hand, 0 ,0, src, src.sharp, src.edge)
user.apply_damage(no_glove_d + will_break ? break_damage : 0, BRUTE, active_hand, 0, 0, src, src.sharp, src.edge)
if(will_break && src.loc == user) // If it's not in our hand anymore
user.visible_message("<span class='danger'>[user] hit \the [target] with \the [src], shattering it!</span>", "<span class='warning'>You shatter \the [src] in your hand!</span>")
playsound(user, pick('sound/effects/Glassbr1.ogg', 'sound/effects/Glassbr2.ogg', 'sound/effects/Glassbr3.ogg'), 30, 1)
qdel(src)
return
/obj/item/weapon/material/shard/Crossed(AM as mob|obj)
..()