mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-24 00:51:46 +00:00
Rewrites shield handling
Rewrites shield handling to be less hardcoded. Shields now take into account the damage source and direction when blocking. Riot shields no longer block most bullets, but are better at blocking melee and thrown items than they were previously. Energy shields block projectiles with a similar probability as they did before, and block melee and thrown as well as riot shields do. Shields no longer block from directly behind the player. Weapons now only block melee attacks. Cool effects when blocking with an energy shield or energy sword (including holoswords).
This commit is contained in:
@@ -113,8 +113,26 @@
|
||||
slowdown = 1
|
||||
armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0)
|
||||
|
||||
/obj/item/clothing/suit/armor/reactive/IsShield()
|
||||
if(active)
|
||||
/obj/item/clothing/suit/armor/reactive/handle_shield(mob/user, var/damage, atom/damage_source = null, mob/attacker = null, var/attack_text = "the attack")
|
||||
if(prob(50))
|
||||
user.visible_message("<span class='danger'>The reactive teleport system flings [user] clear of the attack!</span>")
|
||||
var/list/turfs = new/list()
|
||||
for(var/turf/T in orange(6, user))
|
||||
if(istype(T,/turf/space)) continue
|
||||
if(T.density) continue
|
||||
if(T.x>world.maxx-6 || T.x<6) continue
|
||||
if(T.y>world.maxy-6 || T.y<6) continue
|
||||
turfs += T
|
||||
if(!turfs.len) turfs += pick(/turf in orange(6))
|
||||
var/turf/picked = pick(turfs)
|
||||
if(!isturf(picked)) return
|
||||
|
||||
var/datum/effect/effect/system/spark_spread/spark_system = new /datum/effect/effect/system/spark_spread()
|
||||
spark_system.set_up(5, 0, user.loc)
|
||||
spark_system.start()
|
||||
playsound(user.loc, "sparks", 50, 1)
|
||||
|
||||
user.loc = picked
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
@@ -252,8 +252,26 @@
|
||||
New()
|
||||
item_color = "red"
|
||||
|
||||
/obj/item/weapon/holo/esword/IsShield()
|
||||
if(active)
|
||||
/obj/item/weapon/holo/esword/handle_shield(mob/user, var/damage, atom/damage_source = null, mob/attacker = null, var/attack_text = "the attack")
|
||||
if(!active)
|
||||
return 0
|
||||
|
||||
//parry only melee holo attacks
|
||||
if(!istype(damage_source, /obj/item/weapon/holo) || (attacker && get_dist(user, attacker) > 1))
|
||||
return 0
|
||||
|
||||
//block as long as they are not directly behind us
|
||||
var/bad_arc = reverse_direction(user.dir) //arc of directions from which we cannot block
|
||||
if(!check_shield_arc(user, bad_arc, damage_source, attacker))
|
||||
return 0
|
||||
|
||||
if(prob(50))
|
||||
user.visible_message("<span class='danger'>\The [user] parries [attack_text] with \the [src]!</span>")
|
||||
|
||||
var/datum/effect/effect/system/spark_spread/spark_system = new /datum/effect/effect/system/spark_spread()
|
||||
spark_system.set_up(5, 0, user.loc)
|
||||
spark_system.start()
|
||||
playsound(user.loc, 'sound/weapons/blade1.ogg', 50, 1)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
// Should this all be in Touch()?
|
||||
if(istype(H))
|
||||
if((H != src) && check_shields(0, H.name))
|
||||
visible_message("\red <B>[H] attempted to touch [src]!</B>")
|
||||
if(H != src && check_shields(0, null, H, H.name))
|
||||
H.do_attack_animation(src)
|
||||
return 0
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ emp_act
|
||||
var/obj/item/organ/external/organ = get_organ()
|
||||
|
||||
//Shields
|
||||
if(check_shields(P.damage, "the [P.name]"))
|
||||
if(check_shields(P.damage, P, null, "the [P.name]"))
|
||||
P.on_hit(src, 2, def_zone)
|
||||
return 2
|
||||
|
||||
@@ -148,32 +148,9 @@ emp_act
|
||||
return gear
|
||||
return null
|
||||
|
||||
/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)
|
||||
var/obj/item/weapon/I = l_hand
|
||||
if(I.IsShield() && (prob(50 - round(damage / 3))))
|
||||
visible_message("\red <B>[src] blocks [attack_text] with the [l_hand.name]!</B>")
|
||||
return 1
|
||||
if(r_hand && istype(r_hand, /obj/item/weapon))
|
||||
var/obj/item/weapon/I = r_hand
|
||||
if(I.IsShield() && (prob(50 - round(damage / 3))))
|
||||
visible_message("\red <B>[src] blocks [attack_text] with the [r_hand.name]!</B>")
|
||||
return 1
|
||||
if(wear_suit && istype(wear_suit, /obj/item/))
|
||||
var/obj/item/I = wear_suit
|
||||
if(I.IsShield() && (prob(35)))
|
||||
visible_message("\red <B>The reactive teleport system flings [src] clear of [attack_text]!</B>")
|
||||
var/list/turfs = new/list()
|
||||
for(var/turf/T in orange(6))
|
||||
if(istype(T,/turf/space)) continue
|
||||
if(T.density) continue
|
||||
if(T.x>world.maxx-6 || T.x<6) continue
|
||||
if(T.y>world.maxy-6 || T.y<6) continue
|
||||
turfs += T
|
||||
if(!turfs.len) turfs += pick(/turf in orange(6))
|
||||
var/turf/picked = pick(turfs)
|
||||
if(!isturf(picked)) return
|
||||
src.loc = picked
|
||||
/mob/living/carbon/human/proc/check_shields(var/damage = 0, var/atom/damage_source = null, var/mob/attacker = null, var/attack_text = "the attack")
|
||||
for(var/obj/item/shield in list(l_hand, r_hand, wear_suit))
|
||||
if(shield && shield.handle_shield(src, damage, damage_source, attacker, attack_text))
|
||||
return 1
|
||||
return 0
|
||||
|
||||
@@ -206,7 +183,7 @@ emp_act
|
||||
if(user.a_intent == "disarm") effective_force = round(I.force/2)
|
||||
var/hit_area = affecting.name
|
||||
|
||||
if((user != src) && check_shields(effective_force, "the [I.name]"))
|
||||
if((user != src) && check_shields(effective_force, I, user, "the [I.name]"))
|
||||
return 0
|
||||
|
||||
if(istype(I,/obj/item/weapon/card/emag))
|
||||
@@ -335,7 +312,7 @@ emp_act
|
||||
|
||||
O.throwing = 0 //it hit, so stop moving
|
||||
|
||||
if ((O.thrower != src) && check_shields(throw_damage, "[O]"))
|
||||
if ((O.thrower != src) && check_shields(throw_damage, O, thrower, "[O]"))
|
||||
return
|
||||
|
||||
var/obj/item/organ/external/affecting = get_organ(zone)
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
|
||||
var/hit_area = affecting.name
|
||||
|
||||
if((user != target) && H.check_shields(7, "the [src.name]"))
|
||||
if((user != target) && H.check_shields(7, src, user, "\the [src]"))
|
||||
return
|
||||
|
||||
if (target != user && H.getarmor(target_zone, "melee") > 5 && prob(50))
|
||||
|
||||
Reference in New Issue
Block a user