Refactor reactive armour teleport proc (#17490)

* Add zlevel teleport check to reactive armour

* Refactor to use do_teleport

* spaces

* bag of holding causes unsafe teleport

* keep same range for RD armor BoH teleport

* fix

* extra comment, style

* Update code/datums/helper_datums/teleport.dm

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>

* Update code/datums/helper_datums/teleport.dm

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
This commit is contained in:
datlo
2022-03-21 14:23:10 +00:00
committed by GitHub
co-authored by AffectedArc07
parent 4644f6968a
commit 8199f5d1b2
2 changed files with 25 additions and 27 deletions
+5 -20
View File
@@ -335,27 +335,12 @@
/obj/item/clothing/suit/armor/reactive/teleport/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
if(!active)
return 0
if(reaction_check(hitby))
if(reaction_check(hitby) && is_teleport_allowed(owner.z))
var/mob/living/carbon/human/H = owner
owner.visible_message("<span class='danger'>The reactive teleport system flings [H] clear of [attack_text]!</span>")
var/list/turfs = new/list()
for(var/turf/T in orange(tele_range, H))
if(istype(T, /turf/space))
continue
if(T.density)
continue
if(T.x>world.maxx-tele_range || T.x<tele_range)
continue
if(T.y>world.maxy-tele_range || T.y<tele_range)
continue
turfs += T
if(!turfs.len)
turfs += pick(/turf in orange(tele_range, H))
var/turf/picked = pick(turfs)
if(!isturf(picked))
return
H.forceMove(picked)
return TRUE
if(do_teleport(owner, owner, 6, safe_turf_pick = TRUE)) //Teleport on the same spot with a precision of 6 gets a random tile near the owner.
owner.visible_message("<span class='danger'>The reactive teleport system flings [H] clear of [attack_text]!</span>")
return TRUE
return FALSE
return FALSE
/obj/item/clothing/suit/armor/reactive/fire