Fixes the juggernaut reflect and refactors the reflect to be a proc instead of copy pasta

This commit is contained in:
joep van der velden
2019-12-12 17:25:15 +01:00
parent 1029bf7e7a
commit f005908970
4 changed files with 20 additions and 39 deletions
@@ -16,20 +16,8 @@ emp_act
if(check_reflect(def_zone)) // Checks if you've passed a reflection% check
visible_message("<span class='danger'>The [P.name] gets reflected by [src]!</span>", \
"<span class='userdanger'>The [P.name] gets reflected by [src]!</span>")
// 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.firer = src
P.original = locate(new_x, new_y, P.z)
P.starting = curloc
P.current = curloc
P.yo = new_y - curloc.y
P.xo = new_x - curloc.x
P.Angle = null
P.reflect_back(src)
return -1 // complete projectile permutation
@@ -474,19 +474,9 @@
if(P.is_reflectable)
H.visible_message("<span class='danger'>The [P.name] gets reflected by [H]'s glass skin!</span>", \
"<span class='userdanger'>The [P.name] gets reflected by [H]'s glass skin!</span>")
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(H)
P.reflect_back(H)
// redirect the projectile
P.firer = src
P.original = locate(new_x, new_y, P.z)
P.starting = curloc
P.current = curloc
P.yo = new_y - curloc.y
P.xo = new_x - curloc.x
P.Angle = null
return FALSE
return TRUE
@@ -132,19 +132,7 @@
visible_message("<span class='danger'>The [P.name] gets reflected by [src]'s shell!</span>", \
"<span class='userdanger'>The [P.name] gets reflected by [src]'s shell!</span>")
// Find a turf near or on the original location to bounce to
if(P.starting)
var/new_x = P.starting.x + pick(0, 0, -1, 1, -2, 2, -2, 2, -2, 2, -3, 3, -3, 3)
var/new_y = P.starting.y + pick(0, 0, -1, 1, -2, 2, -2, 2, -2, 2, -3, 3, -3, 3)
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
P.reflect_back(src, list(0, 0, -1, 1, -2, 2, -2, 2, -2, 2, -3, 3, -3, 3))
return -1 // complete projectile permutation