Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduces the chance for grenades to go off in your hands #3441

Merged
merged 10 commits into from
Oct 15, 2024
13 changes: 12 additions & 1 deletion code/game/objects/items/grenades/grenade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,18 @@

/obj/item/grenade/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
var/obj/projectile/P = hitby
if(damage && attack_type == PROJECTILE_ATTACK && P.damage_type != STAMINA && prob(15))
var/list/valid_hands = list(FALSE, FALSE)

//checks if the projectile hits an arm holding a grenade
if (istype(owner.held_items[1], (/obj/item/grenade)))
if (P.def_zone == "l_arm")
valid_hands[1] = TRUE

if (istype(owner.held_items[2], (/obj/item/grenade)))
if (P.def_zone == "r_arm")
valid_hands[2] = TRUE

if(damage && attack_type == PROJECTILE_ATTACK && P.damage_type != STAMINA && (valid_hands[1] || valid_hands[2]) && prob(5)) //5% chance to go off
owner.visible_message("<span class='danger'>[attack_text] hits [owner]'s [src], setting it off! What a shot!</span>")
var/turf/T = get_turf(src)
log_game("A projectile ([hitby]) detonated a grenade held by [key_name(owner)] at [COORD(T)]")
Expand Down
Loading