diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index d5ce9a990fe..06723250fa2 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -36,6 +36,7 @@ var/siemens_coefficient = 1 // for electrical admittance/conductance (electrocution checks and shit) var/slowdown = 0 // How much clothing is slowing you down. Negative values speeds you up var/canremove = 1 //Mostly for Ninja code at this point but basically will not allow the item to be removed if set to 0. /N + var/reflect_chance = 0 //This var dictates what % of a time an object will reflect an energy based weapon's shot var/armor = list(melee = 0, bullet = 0, laser = 0,energy = 0, bomb = 0, bio = 0, rad = 0) var/list/allowed = null //suit storage stuff. var/obj/item/device/uplink/hidden/hidden_uplink = null // All items can have an uplink hidden inside, just remember to add the triggers. @@ -557,6 +558,10 @@ /obj/item/proc/IsShield() return 0 +/obj/item/proc/IsReflect(var/def_zone) //This proc determines if and at what% an object will reflect energy projectiles if it's in l_hand,r_hand or wear_suit + if(prob(reflect_chance)) + return 1 + /obj/item/proc/get_loc_turf() var/atom/L = loc while(L && !istype(L, /turf/)) diff --git a/code/game/objects/items/weapons/swords_axes_etc.dm b/code/game/objects/items/weapons/swords_axes_etc.dm index 9645d74cf90..2a30c76ed4a 100644 --- a/code/game/objects/items/weapons/swords_axes_etc.dm +++ b/code/game/objects/items/weapons/swords_axes_etc.dm @@ -299,6 +299,7 @@ active = !active if (active) force = 10 + reflect_chance = 80 icon_state = "eshield[active]" w_class = 4 playsound(user, 'sound/weapons/saberon.ogg', 50, 1) @@ -307,6 +308,7 @@ force = 3 icon_state = "eshield[active]" w_class = 1 + reflect_chance = 0 playsound(user, 'sound/weapons/saberoff.ogg', 50, 1) user << "\blue [src] can now be concealed." if(istype(user,/mob/living/carbon/human)) diff --git a/code/game/objects/items/weapons/twohanded.dm b/code/game/objects/items/weapons/twohanded.dm index f909c71ef21..36cc29638eb 100644 --- a/code/game/objects/items/weapons/twohanded.dm +++ b/code/game/objects/items/weapons/twohanded.dm @@ -219,8 +219,10 @@ obj/item/weapon/twohanded/ /obj/item/weapon/twohanded/dualsaber/update_icon() if(wielded) icon_state = "dualsaber[blade_color][wielded]" + reflect_chance = 80 else icon_state = "dualsaber0" + reflect_chance = 0 /obj/item/weapon/twohanded/dualsaber/attack(target as mob, mob/living/user as mob) ..() diff --git a/code/modules/clothing/suits/armor.dm b/code/modules/clothing/suits/armor.dm index c2fbc746027..2d58731f4f4 100644 --- a/code/modules/clothing/suits/armor.dm +++ b/code/modules/clothing/suits/armor.dm @@ -60,9 +60,17 @@ icon_state = "armor_reflec" item_state = "armor_reflec" blood_overlay_type = "armor" + reflect_chance = 40 armor = list(melee = 10, bullet = 10, laser = 80, energy = 50, bomb = 0, bio = 0, rad = 0) siemens_coefficient = 0 +/obj/item/clothing/suit/armor/laserproof/IsReflect(var/def_zone) + var/hit_reflect_chance = reflect_chance + if(!(def_zone in list("chest", "groin"))) //If not shot where ablative is covering you, you don't get the reflection bonus! + hit_reflect_chance = 0 + if (prob(hit_reflect_chance)) + return 1 + /obj/item/clothing/suit/armor/swat name = "swat suit" desc = "A heavily armored suit that protects against moderate damage. Used in special operations." diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 73b840d96c4..616a0d2ba1d 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -12,35 +12,31 @@ emp_act var/datum/organ/external/organ = get_organ(check_zone(def_zone)) + if(istype(P, /obj/item/projectile/energy) || istype(P, /obj/item/projectile/beam)) + if(check_reflect(def_zone)) // Checks if you've passed a reflection% check + visible_message("The [P.name] gets reflected by [src]!", \ + "The [P.name] gets reflected by [src]!") + // Find a turf near or on the original location to bounce to + if(P.starting) + var/new_x = P.starting.x + pick(0, 0, 0, 0, 0, -1, 1, -2, 2) + var/new_y = P.starting.y + pick(0, 0, 0, 0, 0, -1, 1, -2, 2) + var/turf/curloc = get_turf(src) + + // redirect the projectile + P.original = locate(new_x, new_y, P.z) + P.starting = curloc + P.current = curloc + P.firer = src + P.yo = new_y - curloc.y + P.xo = new_x - curloc.x + + return -1 // complete projectile permutation + //Shields if(check_shields(P.damage, "the [P.name]")) P.on_hit(src, 2, def_zone) return 2 - //Laserproof armour - if(wear_suit && istype(wear_suit, /obj/item/clothing/suit/armor/laserproof)) - if(istype(P, /obj/item/projectile/energy) || istype(P, /obj/item/projectile/beam)) - var/reflectchance = 40 - round(P.damage/3) - if(!(def_zone in list("chest", "groin"))) - reflectchance /= 2 - if(prob(reflectchance)) - visible_message("\red The [P.name] gets reflected by [src]'s [wear_suit.name]!") - - // Find a turf near or on the original location to bounce to - if(P.starting) - var/new_x = P.starting.x + pick(0, 0, 0, 0, 0, -1, 1, -2, 2) - var/new_y = P.starting.y + pick(0, 0, 0, 0, 0, -1, 1, -2, 2) - var/turf/curloc = get_turf(src) - - // redirect the projectile - P.original = locate(new_x, new_y, P.z) - P.starting = curloc - P.current = curloc - P.firer = src - P.yo = new_y - curloc.y - P.xo = new_x - curloc.x - - return -1 // complete projectile permutation //Shrapnel if (P.damage_type == BRUTE) @@ -138,6 +134,20 @@ emp_act return 1 return 0 +/mob/living/carbon/human/proc/check_reflect(var/def_zone) //Reflection checks for anything in your l_hand, r_hand, or wear_suit based on reflect_chance var of the object + if(wear_suit && istype(wear_suit, /obj/item/)) + var/obj/item/I = wear_suit + if(I.IsReflect(def_zone) == 1) + return 1 + if(l_hand && istype(l_hand, /obj/item/)) + var/obj/item/I = l_hand + if(I.IsReflect(def_zone) == 1) + return 1 + if(r_hand && istype(r_hand, /obj/item/)) + var/obj/item/I = r_hand + if(I.IsReflect(def_zone) == 1) + return 1 + return 0 /mob/living/carbon/human/proc/check_shields(var/damage = 0, var/attack_text = "the attack") if(l_hand && istype(l_hand, /obj/item/weapon))//Current base is the prob(50-d/3)