mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 02:34:00 +00:00
Shards only do damage if you hit things with them (#6478)
This commit is contained in:
@@ -63,55 +63,48 @@
|
|||||||
|
|
||||||
/obj/item/weapon/material/shard/afterattack(var/atom/target, mob/living/carbon/human/user as mob)
|
/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/active_hand //hand the shard is in
|
||||||
var/will_break
|
var/will_break = FALSE
|
||||||
var/gloves_are_heavy = FALSE//this is a fucking mess
|
var/protected_hands = FALSE //this is a fucking mess
|
||||||
var/break_damage = 4
|
var/break_damage = 4
|
||||||
var/light_glove_d = rand(2, 4)
|
var/light_glove_d = rand(2, 4)
|
||||||
var/no_glove_d = rand(4, 6)
|
var/no_glove_d = rand(4, 6)
|
||||||
var/list/h_gloves = list(/obj/item/clothing/gloves/captain, /obj/item/clothing/gloves/cyborg,
|
var/list/forbidden_gloves = list(
|
||||||
/obj/item/clothing/gloves/swat, /obj/item/clothing/gloves/combat,
|
/obj/item/clothing/gloves/sterile,
|
||||||
/obj/item/clothing/gloves/botanic_leather, /obj/item/clothing/gloves/duty,
|
/obj/item/clothing/gloves/knuckledusters
|
||||||
/obj/item/clothing/gloves/tactical, /obj/item/clothing/gloves/vox,
|
)
|
||||||
/obj/item/clothing/gloves/gauntlets)
|
|
||||||
|
|
||||||
if(istype(user.l_hand, src))
|
if(src == user.l_hand)
|
||||||
active_hand = BP_L_HAND
|
active_hand = BP_L_HAND
|
||||||
else
|
else if(src == user.r_hand)
|
||||||
active_hand = BP_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))
|
if(prob(75))
|
||||||
will_break = TRUE
|
will_break = TRUE
|
||||||
else
|
|
||||||
will_break = FALSE
|
|
||||||
|
|
||||||
if(user.gloves && (user.gloves.body_parts_covered & HANDS))
|
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
|
||||||
var/obj/item/clothing/gloves/UG = user.gloves.type
|
protected_hands = TRUE // If we're wearing gloves we can probably handle it just fine
|
||||||
for(var/I in h_gloves)
|
for(var/I in forbidden_gloves)
|
||||||
if(UG == I)
|
if(istype(user.gloves, I)) // forbidden_gloves is a blacklist, so if we match anything in there, our hands are not protected
|
||||||
gloves_are_heavy = TRUE
|
protected_hands = FALSE
|
||||||
if(will_break)
|
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(gloves_are_heavy == FALSE)
|
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>")
|
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.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
|
||||||
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)
|
else if(!user.gloves)
|
||||||
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
|
|
||||||
to_chat(user, "<span class='warning'>\The [src] cuts into your hand as you hit \the [target]!</span>")
|
to_chat(user, "<span class='warning'>\The [src] cuts into your hand as you hit \the [target]!</span>")
|
||||||
if(will_break)
|
user.apply_damage(no_glove_d + will_break ? break_damage : 0, BRUTE, active_hand, 0, 0, src, src.sharp, src.edge)
|
||||||
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)
|
if(will_break && src.loc == user) // If it's not in our hand anymore
|
||||||
playsound(user, pick('sound/effects/Glassbr1.ogg', 'sound/effects/Glassbr2.ogg', 'sound/effects/Glassbr3.ogg'), 30, 1)
|
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>")
|
||||||
qdel(src)
|
playsound(user, pick('sound/effects/Glassbr1.ogg', 'sound/effects/Glassbr2.ogg', 'sound/effects/Glassbr3.ogg'), 30, 1)
|
||||||
else
|
qdel(src)
|
||||||
user.apply_damage(no_glove_d, BRUTE, active_hand, 0 ,0, src, src.sharp, src.edge)
|
return
|
||||||
|
|
||||||
/obj/item/weapon/material/shard/Crossed(AM as mob|obj)
|
/obj/item/weapon/material/shard/Crossed(AM as mob|obj)
|
||||||
..()
|
..()
|
||||||
|
|||||||
Reference in New Issue
Block a user