Files
vgstation13/code/modules/multiz/structures.dm
kane-f 84bf965ae8 Multi-z 3: With a vengeance (#30178)
* fix map

* Fixing bad syntax

* Maybe this will work

* Travis wanted me to remove this

* Unticking attempt

* Unticking attempt 2

* Removing all useless broken zshadow stuff

* Maybe now?

* Oh weird

* Adding up/down pipe sprites

* Adding darkness overlay, attempt #1

* Second attempt, now works

* Turf tweaks, now much less visually glitchy, plus walls now make blank floors above them for less weirdness

* Fix, plus keeps this floor in place

* Really bad fix that stops space looking weird

* Now everything should work normally, except lighting overlays

* Updates the map

* Consistency

* Adds new fall damage sound

* Typo

* Jetpack fun

* Better

* Less bad brackets and parantheses pain

* OHhh

* These fly too, brooms next whenever I figure those out

* Finishing pipe icons

* Making it easier to build catwalks and stuff on turfs without clicking the stuff below by mistake

* Bringing back zshadow, but with no icon

* Oh it's this issue again

* Final fix, better attempt at image relay

* Now for it looking nice, vis_contents are bad here too

* Attempt at refactoring this, light overlays are now finally underneath players, at the cost of blocking everything else, but exxion wanted to testmerge it

* Map change

* Changing it back, test server stays on box anyways

* Removing non-working solution

* Removes broken lighting overlays

* Finally fixes up floor generation above walls

* Adding bones of a 3d implementation of spiral block for git push origin multizfungit push origin multiz

* More, almost done

* Finalised

* Cube option

* Logic fix

* Syntax

* Attempting to make item fall on arc

* Compile

* Now this is no longer needed

* BRACE FOR ENABLING MULTI-Z ZAS

* Attempt at fixing glass floor tiles

* Splitting off explosion proc into destroy part, bones of calling it recursively and smaller on above and below layers, implementation of multi-z explosion suggested by DeityLink

* Missing var

* Removing unused var and fixes consistency

* Fixing logic and syntax etc, still needs testing before uncomment

* Uncommenting, some fixes too

* Makes this a seperate function otherwise it won't call at all, MULTI Z EXPLOSIONS NOW CONFIRMED WORKING

* Client proc to test this

* Adds to list

* Typo not drawing red on main layer

* Here too

* Adding debug logs for clarity

* Better

* Even better

* Experimental multi-Z EMP support, cylindrical effect for now

* Better distance falloff

* Sound/visual support on other layers?

* Z cap for EMP sound

* Booms too

* Adds back accidentally deleted file

* Muuuch more sane check

* Attempt at connecting heard speech between multi Z

* Cleaner

* Missing bracket

* Removing zshadow mobs entirely again, no need for them whatsoever

* Multi-z visible messages

* Emotes

* Fix?

* Wew

* K

* Much nicer function

* I forget about this define

* Ohhhh

* Comma fix

* Aaa

* This might fix

* Removing visible message one for now

* Trying this solution

* Typo

* RIP location, hope this won't break anything

* Actually location gets to come back, fix is here

* I give up, the tests are clearly what's borken

* Let's see what this does with those nullspaces test items (yes really)

* Indent fix, plus nice comments

* MULTI-Z SOUND???

* Woops

* Jetpack and etc trails over open space now!

* No macros, this is why we can't have nice things

* Watch how coder stops potion of levitation, broom and fairy wing wielders from falling with ONE NEAT TRICK

* Gotta make leapers not fall somehow

* Bad oversight

* Fully allows going down stairs with weird border objects

* Flying now works properly for humans on open space

* Now, fall instantly on stop

* Oversight

* Oh this function

* New helper functions

* Oversight again

* Replacing lines with abs(), multi z singulo pull attempt

* Quick supermatter fix

* Don't cut overlays

* Move down here

* Typo

* Now actually works, implementation could be better though

* Additional helper function for z distances because BYOND hates comparing z

* Reimplementing for sound

* abs() to keep positive for max comparisons in line distances

* Keeping gas overlays outside of multi-z viewing to stop some glitches

* That didn't work

* Testing removal from float planes for stuff that never needed to be on it

* Fixes gas overlays showing up all wrong in multi Z ZAS

* Gutting this controller, no longer needed period, system works fine without it

* Now glass floors look mostly perfect on open spaces

* Var name change for fun stuff later

* Knew I'd miss one

* Gravity based fall delay?

* Settle with using sleep() for now, what could go wrong?

* Lagged the game horribly, so everything

* Here all along, huh

* Just remove it for now, it kinda works but not ideally at all

* Thank you TK code for giving me a nice and working way to do this

* Comments, oversights

* No wait it was right the first time

* Now for the damage multiplier

* Knockdown too

* Nicer format

* This should still be min, plus now have a debug log and shifted around logic

* Now for mech stuff

* Clamping knockdown

* Definition fix

* Dusting this off, hopeful fix to things not falling

* Probably don't need this, I forget

* Hahaha nope, this did nothing

* Finally, a way to make fall() call in mid air after a delay without horrible lag

* Tunes pipe layering if on same zlevel, getting there

* Now fully tuned

* Adding bones for pipe item support

* Test

* z_up pipe item icon state

* z_up and z_down pipe item icon state

* Adding these to pipe dispensers

* Typo

* RCDs too

* Moved here

* Moved back

* Makes space work nicer

* Oh and here

* Fall updates

* Don't need this

* Oversights everywhere

* Fixes

* More

* More, and new stuff

* Even more

* Dampening these a bit

* So many, so moved to new file

* Forgot this

* Refactor

* Forgot to actually use

* Indentation issues

* Works better like this

* Refactors into nicer proc

* One oversight

* Stair frames, to construct into stairs

* Stack recipe for em

* Cutting useless stuff

* Fixes

* Last fixes

* Stops uncrossing at non existant aboves

* Better logic

* Better logic

* Fix

* Fixes nullspace checking runtime

* Removes redundant check on stairs

* Replaces CanPass with Cross, functionality is same and definition is duplicate of it

* Missed one

* Darkening and falling tweaks

* Better call for gravity

* Oversight

* Stops falling in space, zero-g open space movement fixes etc

* Consistency

* Fixes slipping on open spaces with catwalks (lattices make sense I guess) and stairs not being snapped down to

* Var name fix

* Much nicer system with no recursive function or last_fall variable use

* Adds buildFrom()s so z-pipes can actually be fitted, stops spam of fall() calls on enter with lock for nicer gravity

* Makes z distances pay attention to multi z support

* Maybe this is better

* Left this in

* Adding visible and hidden variants for mapping

* Counts glass floors as open space for the purpose of open space checks

* Bracket fix

* Makes it a macro for easy viewing

* Space looks much better like this honestly

* Makes schematics actually show up on RPD in multi-z

* Making these tied to WORLD_ICON_SIZE

* Changes for someone to test

* Now the fix actually works

* Removes forceMove(), nicer solution

* Giving stairs all their dirs

* Fixing stair position problem and other things

* Stair deconstruction

* Removing redundant enter() check to move()

* Some updates as requested

* .dme and map/file fixes

* .dme and map/file fixes

* Updating can_falls

* Ladder climb fix

* Some port notes updates

* Docs itself

* Removing unused edge_type var

* Removing landmark object, converts it code side

* Removing unsimmed walls doing it, not necessary

* Updated descs

* Fixing observer non-standards in file

* More file cleanup

* Jetpacks allow z-travelling

* Now they really do

* Robots too

* Updating docs

* Code cleanup

* Catch one

* Indent fix

* Not sure what that even is

* Catching these

* Applying some old fixes

* Removing unused file

* Moving nodes back to original places, or an attempt to

* Here too

* Removing unused file

* Moving these back too

* Some fixes for now

* Some more

* Even more, almost done

* Better pipe icons

* More icons

* Disposal pipe construction

* Mixup

* List optimisation, new fixes

Co-authored-by: Damian <damian@autistici.org>
Co-authored-by: kanef <kanef9x@protonmail.com>
2021-08-27 08:14:13 -05:00

278 lines
8.5 KiB
Plaintext

//////////////////////////////
//Contents: Ladders, Stairs.//
//////////////////////////////
/obj/structure/z_ladder
name = "ladder"
desc = "A ladder. You can climb it up and down."
icon_state = "ladder01"
icon = 'icons/obj/structures.dmi'
density = 0
opacity = 0
anchored = 1
var/allowed_directions = DOWN
var/obj/structure/z_ladder/target_up
var/obj/structure/z_ladder/target_down
var/const/climb_time = 2 SECONDS
/obj/structure/z_ladder/New()
if(world.has_round_started())
initialize()
..()
/obj/structure/z_ladder/initialize()
// the upper will connect to the lower
if(allowed_directions & DOWN) //we only want to do the top one, as it will initialize the ones before it.
for(var/obj/structure/z_ladder/L in GetBelow(src))
if(L.allowed_directions & UP)
target_down = L
L.target_up = src
return
update_icon()
/obj/structure/z_ladder/Destroy()
if(target_down)
target_down.target_up = null
target_down = null
if(target_up)
target_up.target_down = null
target_up = null
return ..()
/obj/structure/z_ladder/attackby(obj/item/C, mob/user)
attack_hand(user)
/obj/structure/z_ladder/attack_hand(var/mob/M)
if(!M.may_climb_ladders(src))
return
var/obj/structure/z_ladder/target_ladder = getTargetLadder(M)
if(!target_ladder)
return
if(!M.Move(get_turf(src)))
to_chat(M, "<span class='notice'>You fail to reach \the [src].</span>")
return
var/direction = target_ladder == target_up ? "up" : "down"
M.visible_message("<span class='notice'>\The [M] begins climbing [direction] \the [src]!</span>",
"You begin climbing [direction] \the [src]!",
"You hear the grunting and clanging of a metal ladder being used.")
target_ladder.visible_message("<span class='notice'>You hear something coming [direction] \the [src]</span>")
if(do_after(M, src, climb_time))
climbLadder(M, target_ladder)
/obj/structure/z_ladder/attack_ghost(var/mob/M)
var/target_ladder = getTargetLadder(M)
if(target_ladder)
M.forceMove(get_turf(target_ladder))
/obj/structure/z_ladder/proc/getTargetLadder(var/mob/M)
if((!target_up && !target_down) || (target_up && !istype(target_up.loc, /turf) || (target_down && !istype(target_down.loc,/turf))))
to_chat(M, "<span class='notice'>\The [src] is incomplete and can't be climbed.</span>")
return
if(target_down && target_up)
var/direction = alert(M,"Do you want to go up or down?", "Ladder", "Up", "Down", "Cancel")
if(direction == "Cancel")
return
if(!M.may_climb_ladders(src))
return
switch(direction)
if("Up")
return target_up
if("Down")
return target_down
else
return target_down || target_up
/mob/proc/may_climb_ladders(var/ladder)
if(!Adjacent(ladder))
to_chat(src, "<span class='warning'>You need to be next to \the [ladder] to start climbing.</span>")
return FALSE
if(!held_items.len)
to_chat(src, "<span class='warning'>You do not have hands to grab \the [ladder].</span>")
return FALSE
if(incapacitated())
to_chat(src, "<span class='warning'>You are physically unable to climb \the [ladder].</span>")
return FALSE
return TRUE
/mob/dead/observer/ghost/may_climb_ladders(var/ladder)
return TRUE
/obj/structure/z_ladder/proc/climbLadder(var/mob/M, var/target_ladder)
var/turf/T = get_turf(target_ladder)
for(var/atom/A in T)
if(!A.Cross(M, M.loc, 1.5, 0))
to_chat(M, "<span class='notice'>\The [A] is blocking \the [src].</span>")
return FALSE
return M.Move(T)
/obj/structure/z_ladder/Cross(obj/mover, turf/source, height, airflow)
return airflow || !density
/obj/structure/z_ladder/update_icon()
icon_state = "ladder[!!(allowed_directions & UP)][!!(allowed_directions & DOWN)]"
/obj/structure/z_ladder/up
allowed_directions = UP
icon_state = "ladder10"
/obj/structure/z_ladder/updown
allowed_directions = UP|DOWN
icon_state = "ladder11"
/obj/structure/stairs
name = "\improper stairs"
desc = "Stairs leading to another deck."
icon = 'icons/obj/stairs.dmi'
icon_state = "stairs"
density = 0
opacity = 0
anchored = 1
/obj/structure/stairs/New()
if(world.has_round_started())
initialize()
..()
/obj/structure/stairs/initialize()
for(var/turf/turf in locs)
var/turf/simulated/open/above = GetAbove(turf)
if(!above)
warning("Stair created without level above: ([loc.x], [loc.y], [loc.z])")
return qdel(src)
if(!istype(above))
above.ChangeTurf(/turf/simulated/open)
// Handles if we can go up these stairs for Move()
/obj/structure/stairs/Uncross(atom/movable/mover, turf/target)
// Needs to have a target elsewhere in move to return true, for some reason runtimes without the ?
if(target?.z != z)
return 1
if(mover.dir == dir)
return 0
return 1
// And now the actual going, fail uncross to move up, hence bumped()
/obj/structure/stairs/Bumped(atom/movable/A)
if(A.dir == dir)
var/turf/simulated/open/above = GetAbove(A)
if(!above || !istype(above))
return
var/turf/target = get_step(above, dir)
A.Move(target)
if(isliving(A))
var/mob/living/L = A
if(L.pulling)
L.pulling.Move(target)
/obj/structure/stairs/Cross(obj/mover, turf/source, height, airflow)
return airflow || !density
/obj/structure/stairs/attackby(obj/item/W, mob/user)
if(iswelder(W))
var/obj/item/tool/weldingtool/WT = W
if(WT.remove_fuel(1, user))
user.visible_message("<span class='warning'>[user] begins slicing through \the [src]'s step plates.</span>", \
"<span class='notice'>You begin slicing through \the [src]'s step plates.</span>", \
"<span class='warning'>You hear welding noises.</span>")
playsound(src, 'sound/items/Welder.ogg', 100, 1)
if(do_after(user, src, 100))
if(!istype(src))
return
playsound(src, 'sound/items/Welder.ogg', 100, 1)
user.visible_message("<span class='warning'>[user] slices through \the [src]'s step plates.</span>", \
"<span class='notice'>You slice through \the [src]'s step plates.</span>", \
"<span class='warning'>You hear welding noises.</span>")
var/obj/structure/stairs_frame/SF = null
switch(dir)
if(NORTH)
SF = new /obj/structure/stairs_frame(get_step(loc,SOUTH))
if(EAST)
SF = new /obj/structure/stairs_frame(get_step(loc,WEST))
if(SOUTH)
SF = new /obj/structure/stairs_frame(loc)
if(WEST)
SF = new /obj/structure/stairs_frame(loc)
SF.dir = dir
SF.anchored = anchored
qdel(src)
// type paths to make mapping easier.
/obj/structure/stairs/north
dir = NORTH
bound_height = 2 * WORLD_ICON_SIZE
bound_y = -WORLD_ICON_SIZE
pixel_y = -WORLD_ICON_SIZE
/obj/structure/stairs/south
dir = SOUTH
bound_height = 2 * WORLD_ICON_SIZE
/obj/structure/stairs/east
dir = EAST
bound_width = 2 * WORLD_ICON_SIZE
bound_x = -WORLD_ICON_SIZE
pixel_x = -WORLD_ICON_SIZE
/obj/structure/stairs/west
dir = WEST
bound_width = 2 * WORLD_ICON_SIZE
/obj/structure/stairs_frame
name = "\improper stair frame"
desc = "Frames of stairs that are supposed to lead to another deck."
icon = 'icons/obj/stairs.dmi'
icon_state = "stairframe"
density = 0
/obj/structure/stairs_frame/attackby(obj/item/W, mob/user)
if(W.is_wirecutter(user))
W.playtoolsound(src, 100)
user.visible_message("<span class='warning'>[user] dissasembles \the [src].</span>", \
"<span class='notice'>You dissasemble \the [src].</span>")
new /obj/item/stack/sheet/metal(get_turf(src), 4)
qdel(src)
if(W.is_wrench(user))
user.visible_message("<span class='warning'>[user] [anchored ? "unanchors" : "anchors"] \the [src].</span>", \
"<span class='notice'>You [anchored ? "unanchor" : "anchor"] \the [src].</span>")
add_hiddenprint(user)
add_fingerprint(user)
anchored = !anchored
else if(istype(W, /obj/item/stack/sheet/metal))
var/obj/item/stack/sheet/metal/S = W
if(!anchored)
to_chat(user, "<span class='warning'>The [src] must be anchored first!.</span>")
return
else
if(S.amount < 4)
return ..() // ?
user.visible_message("<span class='notice'>[user] starts installing step plates to \the [src].</span>", \
"<span class='notice'>You start installing step plates to \the [src].</span>")
if(do_after(user, src, 80))
if(S.amount < 4) //User being tricky
return
S.use(4)
user.visible_message("<span class='notice'>[user] finishes installing step plates to \the [src].</span>", \
"<span class='notice'>You finish installing step plates to \the [src].</span>")
switch(dir)
if(NORTH)
new /obj/structure/stairs/north(get_step(loc,NORTH))
if(EAST)
new /obj/structure/stairs/east(get_step(loc,EAST))
if(SOUTH)
new /obj/structure/stairs/south(loc)
if(WEST)
new /obj/structure/stairs/west(loc)
qdel(src)
return