[READY]Fixes hitscan beams going across the station, hitscan projectiles now properly cross zlevels and generate beams. (#35344)

* Cross Z support

* Fixes projectile cross-Z

* removes unnecessary code

* don't draw impacts if you're not impacting

* fix

* unneeded var

* No mapcheck()ing anymore, space does it for us 2.0
This commit is contained in:
kevinz000
2018-02-17 16:41:25 -08:00
committed by CitadelStationBot
parent 7fe1c87666
commit da8a12b906
4 changed files with 40 additions and 55 deletions

View File

@@ -129,34 +129,6 @@
/datum/point/proc/return_py()
return MODULUS(y, world.icon_size) - 16 - 1
/datum/point/proc/mapcheck()
. = FALSE
var/maxx = world.icon_size * world.maxx
var/maxy = world.icon_size * world.maxy
var/move_zx = 0
var/move_zy = 0
if(x < 0)
x += maxx
move_zx -= 1
if(y < 0)
y += maxy
move_zy -= 1
if(x > maxx)
x -= maxx
move_zx += 1
if(y > maxy)
y -= maxy
move_zy += 1
var/datum/space_level/S = SSmapping.get_level(z)
if(move_zx != 0)
var/datum/space_level/L = S.neigbours["[move_zx < 0? WEST : EAST]"]
z = L.z_value
. = TRUE
if(move_zy != 0)
var/datum/space_level/L = S.neigbours["[move_zy < 0? SOUTH : NORTH]"]
z = L.z_value
. = TRUE
/datum/point/vector
var/speed = 32 //pixels per iteration
var/iteration = 0
@@ -216,8 +188,6 @@
iteration++
x += mpx * 1
y += mpy * 1
if(mapcheck())
on_z_change()
/datum/point/vector/proc/return_vector_after_increments(amount = 7, multiplier = 1, force_simulate = FALSE)
var/datum/point/vector/v = copy_to()

View File

@@ -129,13 +129,8 @@
if ((!(A) || src != A.loc))
return
if(destination_z)
var/old_z = A.z
A.x = destination_x
A.y = destination_y
A.z = destination_z
if (old_z != destination_z)
A.onTransitZ(old_z, destination_z)
if(destination_z && destination_x && destination_y)
A.forceMove(locate(destination_x, destination_y, destination_z))
if(isliving(A))
var/mob/living/L = A

View File

@@ -223,7 +223,7 @@
return current_target
var/list/new_baseturfs = list(current_target)
for(var/i=0;current_target != next_target;i++)
if(i > 100)
if(i > 100)
// A baseturfs list over 100 members long is silly
// Because of how this is all structured it will only runtime/message once per type
stack_trace("A turf <[type]> created a baseturfs list over 100 members long. This is most likely an infinite loop.")

View File

@@ -295,11 +295,6 @@
var/turf/ending = return_predicted_turf_after_moves(moves, forced_angle)
return getline(current, ending)
/obj/item/projectile/proc/before_z_change(turf/oldloc, turf/newloc)
var/datum/point/pcache = trajectory.copy_to()
if(hitscan)
store_hitscan_collision(pcache)
/obj/item/projectile/Process_Spacemove(var/movement_dir = 0)
return TRUE //Bullets don't drift in space
@@ -373,14 +368,29 @@
return TRUE
/obj/item/projectile/forceMove(atom/target)
var/zc = target.z == z
var/old = loc
if(zc)
before_z_change(old, target)
if(hitscan)
finalize_hitscan_and_generate_tracers(FALSE)
. = ..()
if(trajectory && !trajectory_ignore_forcemove && isturf(target))
trajectory.initialize_location(target.x, target.y, target.z, 0, 0)
if(hitscan)
record_hitscan_start(RETURN_PRECISE_POINT(src))
if(zc)
after_z_change(old, target)
/obj/item/projectile/proc/after_z_change(atom/olcloc, atom/newloc)
/obj/item/projectile/proc/before_z_change(atom/oldloc, atom/newloc)
/obj/item/projectile/proc/record_hitscan_start(datum/point/pcache)
beam_segments = list() //initialize segment list with the list for the first segment
beam_index = pcache
beam_segments[beam_index] = null //record start.
if(pcache)
beam_segments = list()
beam_index = pcache
beam_segments[beam_index] = null //record start.
/obj/item/projectile/proc/process_hitscan()
var/safety = range * 3
@@ -406,10 +416,12 @@
trajectory.increment(trajectory_multiplier)
var/turf/T = trajectory.return_turf()
if(T.z != loc.z)
var/old = loc
before_z_change(loc, T)
trajectory_ignore_forcemove = TRUE
forceMove(T)
trajectory_ignore_forcemove = FALSE
after_z_change(old, loc)
if(!hitscanning)
pixel_x = trajectory.return_px()
pixel_y = trajectory.return_py()
@@ -496,14 +508,24 @@
/obj/item/projectile/Destroy()
if(hitscan)
if(loc)
var/datum/point/pcache = trajectory.copy_to()
beam_segments[beam_index] = pcache
generate_hitscan_tracers()
finalize_hitscan_and_generate_tracers()
STOP_PROCESSING(SSprojectiles, src)
qdel(trajectory)
cleanup_beam_segments()
return ..()
/obj/item/projectile/proc/generate_hitscan_tracers(cleanup = TRUE, duration = 3)
/obj/item/projectile/proc/cleanup_beam_segments()
QDEL_LIST_ASSOC(beam_segments)
beam_segments = list()
qdel(beam_index)
/obj/item/projectile/proc/finalize_hitscan_and_generate_tracers(impacting = TRUE)
if(trajectory && beam_index)
var/datum/point/pcache = trajectory.copy_to()
beam_segments[beam_index] = pcache
generate_hitscan_tracers(null, null, impacting)
/obj/item/projectile/proc/generate_hitscan_tracers(cleanup = TRUE, duration = 3, impacting = TRUE)
if(!length(beam_segments))
return
if(tracer_type)
@@ -517,7 +539,7 @@
M.Turn(original_angle)
thing.transform = M
QDEL_IN(thing, duration)
if(impact_type && duration > 0)
if(impacting && impact_type && duration > 0)
var/datum/point/p = beam_segments[beam_segments[beam_segments.len]]
var/atom/movable/thing = new impact_type
p.move_atom_to_src(thing)
@@ -526,9 +548,7 @@
thing.transform = M
QDEL_IN(thing, duration)
if(cleanup)
QDEL_LIST(beam_segments)
beam_segments = null
QDEL_NULL(beam_index)
cleanup_beam_segments()
/obj/item/projectile/experience_pressure_difference()
return