does the quirky thing where a beam with origin/target in a container doesn't cut the map in half because byond is quirky and things inside things are x/y/z=0 (#11585)

* Update beam.dm

* god i hate this

* Update beam.dm

* ok

* touching kevinz PR in an inappropriate way.

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
kevinz000
2020-03-26 16:21:10 -07:00
committed by GitHub
parent b7c801a173
commit 0c60294c0f
+17 -11
View File
@@ -9,8 +9,8 @@
var/max_distance = 0
var/sleep_time = 3
var/finished = 0
var/target_oldloc = null
var/origin_oldloc = null
var/turf/target_oldloc
var/turf/origin_oldloc
var/static_beam = 0
var/beam_type = /obj/effect/ebeam //must be subtype
var/timing_id = null
@@ -23,13 +23,13 @@
target_oldloc = get_turf(target)
sleep_time = beam_sleep_time
if(origin_oldloc == origin && target_oldloc == target)
static_beam = 1
static_beam = TRUE
max_distance = maxdistance
base_icon = new(beam_icon,beam_icon_state)
icon = beam_icon
icon_state = beam_icon_state
beam_type = btype
if(time < INFINITY)
if(time < INFINITY)
addtimer(CALLBACK(src,.proc/End), time)
/datum/beam/proc/Start()
@@ -42,10 +42,14 @@
return
recalculating = TRUE
timing_id = null
if(origin && target && get_dist(origin,target)<max_distance && origin.z == target.z)
var/origin_turf = get_turf(origin)
var/target_turf = get_turf(target)
if(!static_beam && (origin_turf != origin_oldloc || target_turf != target_oldloc))
var/turf/origin_turf
if(origin)
origin_turf = get_turf(origin)
var/turf/target_turf
if(target)
target_turf = get_turf(target)
if(origin_turf && target_turf && (get_dist(origin_turf, target_turf) < max_distance) && (origin_turf.z == target_turf.z))
if(!static_beam && ((origin_turf != origin_oldloc) || (target_turf != target_oldloc)))
origin_oldloc = origin_turf //so we don't keep checking against their initial positions, leading to endless Reset()+Draw() calls
target_oldloc = target_turf
Reset()
@@ -90,13 +94,15 @@
return ..()
/datum/beam/proc/Draw()
var/Angle = round(Get_Angle(origin,target))
if(!origin_oldloc || !target_oldloc)
return
var/Angle = round(Get_Angle(origin_oldloc,target_oldloc))
var/matrix/rot_matrix = matrix()
rot_matrix.Turn(Angle)
//Translation vector for origin and target
var/DX = (32*target.x+target.pixel_x)-(32*origin.x+origin.pixel_x)
var/DY = (32*target.y+target.pixel_y)-(32*origin.y+origin.pixel_y)
var/DX = (32*target_oldloc.x+target_oldloc.pixel_x)-(32*origin_oldloc.x+origin_oldloc.pixel_x)
var/DY = (32*target_oldloc.y+target_oldloc.pixel_y)-(32*origin_oldloc.y+origin_oldloc.pixel_y)
var/N = 0
var/length = round(sqrt((DX)**2+(DY)**2)) //hypotenuse of the triangle formed by target and origin's displacement