Skip to content

Commit

Permalink
z handling for projectors/teleporters and multiz runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
morrowwolf committed Nov 18, 2023
1 parent 39056ca commit f7fe3be
Show file tree
Hide file tree
Showing 11 changed files with 927 additions and 12 deletions.
5 changes: 3 additions & 2 deletions code/controllers/subsystem/fz_transitions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ SUBSYSTEM_DEF(fz_transitions)
projectors -= P
continue
if(!P.loc.clone)
P.loc.create_clone(P.vector_x, P.vector_y)
P.loc.create_clone(P.vector_x, P.vector_y, P.vector_z)

if(P.loc.contents)
for(var/atom/movable/O in P.loc.contents)
if(!istype(O, /obj/effect/projector) && !istype(O, /mob/dead/observer) && !istype(O, /obj/structure/stairs) && !istype(O, /obj/structure/catwalk) && O.type != /atom/movable/clone)
if(!O.clone) //Create a clone if it's on a projector
O.create_clone_movable(P.vector_x, P.vector_y)
O.create_clone_movable(P.vector_x, P.vector_y, P.vector_z)
else
O.clone.proj_x = P.vector_x //Make sure projection is correct
O.clone.proj_y = P.vector_y
O.clone.proj_z = P.vector_z


for(var/atom/movable/clone/C in clones)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/autocells/explosion.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
if(!V)
return

var/turf/new_turf = locate(in_turf.x + V.vector_x, in_turf.y + V.vector_y, in_turf.z)
var/turf/new_turf = locate(in_turf.x + V.vector_x, in_turf.y + V.vector_y, in_turf.z + V.vector_z)
transfer_turf(new_turf)

/datum/automata_cell/explosion/death()
Expand Down
5 changes: 3 additions & 2 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,11 @@ Parameters are passed from New.
/atom/clone
var/proj_x = 0
var/proj_y = 0
var/proj_z = 0

/atom/proc/create_clone(shift_x, shift_y) //NOTE: Use only for turfs, otherwise use create_clone_movable
/atom/proc/create_clone(shift_x, shift_y, shift_z) //NOTE: Use only for turfs, otherwise use create_clone_movable
var/turf/T = null
T = locate(src.x + shift_x, src.y + shift_y, src.z)
T = locate(src.x + shift_x, src.y + shift_y, src.z + shift_z)

T.appearance = src.appearance
T.setDir(src.dir)
Expand Down
6 changes: 4 additions & 2 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
var/atom/movable/mstr = null //Used by clones for referral
var/proj_x = 0
var/proj_y = 0
var/proj_z = 0
unacidable = TRUE

var/list/image/hud_list
Expand Down Expand Up @@ -275,19 +276,20 @@
return src.mstr.bullet_act(P)
/////////////////////

/atom/movable/proc/create_clone_movable(shift_x, shift_y)
/atom/movable/proc/create_clone_movable(shift_x, shift_y, shift_z)
var/atom/movable/clone/C = new /atom/movable/clone(src.loc)
C.density = FALSE
C.proj_x = shift_x
C.proj_y = shift_y
C.proj_z = shift_z

clones.Add(C)
C.mstr = src //Link clone and master
src.clone = C

/atom/movable/proc/update_clone()
///---Var-Copy---////
clone.forceMove(locate(x + clone.proj_x, y + clone.proj_y, z))
clone.forceMove(locate(x + clone.proj_x, y + clone.proj_y, z + clone.proj_z))
//Translate clone position by projection factor
//This is done first to reduce movement latency

Expand Down
1 change: 1 addition & 0 deletions code/game/objects/effects/projector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
layer = TURF_LAYER
var/vector_x = 0
var/vector_y = 0
var/vector_z = 0
icon = 'icons/landmarks.dmi'
icon_state = "projector"//for map editor
5 changes: 3 additions & 2 deletions code/game/objects/effects/step_triggers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
if(A && A.loc && A.type != /atom/movable/clone) //Prevent clones from teleporting
var/lx = A.x
var/ly = A.y
var/target = locate(A.x + vector_x, A.y + vector_y, A.z)
var/target = locate(A.x + vector_x, A.y + vector_y, A.z + vector_z)
var/target_dir = get_dir(A, target)

if(A.clone) //Clones have to be hard-synced both before and after the transition
Expand All @@ -124,7 +124,7 @@
var/mob/AM = A
sleep(AM.movement_delay() + 0.4) //Make the transition as seamless as possible

if(!Adjacent(A, locate(lx, ly, A.z))) //If the subject has moved too quickly, abort - this prevents double jumping
if(!(A in locate(lx, ly, A.z))) //If the subject has moved too quickly, abort - this prevents double jumping
return

for(var/mob/M in target) //If the target location is obstructed, abort
Expand All @@ -138,6 +138,7 @@
if(A.clone)
A.clone.proj_x *= -1 //Swap places with the clone
A.clone.proj_y *= -1
A.clone.proj_z *= -1
A.update_clone() //Update No. 2


Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/explosion_recursive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ explosion resistance exactly as much as their health
//check for stair-teleporters. If there is a stair teleporter, switch to the teleported-to tile instead
if(istype(A, /obj/effect/step_trigger/teleporter_vector))
var/obj/effect/step_trigger/teleporter_vector/V = A
var/turf/T = locate(V.x + V.vector_x, V.y + V.vector_y, V.z)
var/turf/T = locate(V.x + V.vector_x, V.y + V.vector_y, V.z + V.vector_z)
if(T)
spawn(0)
T.explosion_spread(Controller, power, direction)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var/list/department_radio_keys = list(

for(var/dst=0; dst<=1; dst++) //Will run twice if src has a clone
if(!dst && src.clone) //Will speak in src's location and the clone's
T = locate(src.loc.x + src.clone.proj_x, src.loc.y + src.clone.proj_y, src.loc.z)
T = locate(src.loc.x + src.clone.proj_x, src.loc.y + src.clone.proj_y, src.loc.z + src.clone.proj_z)
else
T = get_turf(src)
dst++ //Only speak once
Expand Down
Loading

0 comments on commit f7fe3be

Please sign in to comment.