[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
+37 -17
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