From 01d6b87d69fd6990fe18b047619aa08539b208d6 Mon Sep 17 00:00:00 2001 From: Aronai Sieyes Date: Tue, 14 Apr 2020 15:56:40 -0400 Subject: [PATCH] Allow fighters to traverse overmap ships predictably --- code/game/mecha/combat/fighter.dm | 81 +++++++++++++++++++++++++-- code/modules/multi-tile/multi-tile.dm | 2 + 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/code/game/mecha/combat/fighter.dm b/code/game/mecha/combat/fighter.dm index abada3f283..171c96395e 100644 --- a/code/game/mecha/combat/fighter.dm +++ b/code/game/mecha/combat/fighter.dm @@ -9,15 +9,15 @@ var/ground_capable = FALSE //If we can fly over normal turfs and not just space icon = 'icons/mecha/fighters64x64.dmi' - + icon_state = "" initial_icon = "" - + step_in = 2 //Fast health = 400 maxhealth = 400 - + infra_luminosity = 6 opacity = FALSE @@ -50,6 +50,77 @@ . = ..() consider_gravity() +//We don't get lost quite as easy. +/obj/mecha/combat/fighter/touch_map_edge() + //No overmap enabled or no driver to choose + if(!using_map.use_overmap || !occupant || !can_ztravel()) + return ..() + + var/obj/effect/overmap/visitable/our_ship = get_overmap_sector(z) + + //We're not on the overmap + if(!our_ship) + return ..() + + //Stored for safety checking after user input + var/this_x = x + var/this_y = y + var/this_z = z + var/this_occupant = occupant + + var/what_edge + + var/new_x + var/new_y + var/new_z + + if(x <= TRANSITIONEDGE) + what_edge = WEST + new_x = world.maxx - TRANSITIONEDGE - 2 + new_y = rand(TRANSITIONEDGE + 2, world.maxy - TRANSITIONEDGE - 2) + + else if (x >= (world.maxx - TRANSITIONEDGE + 1)) + what_edge = EAST + new_x = TRANSITIONEDGE + 1 + new_y = rand(TRANSITIONEDGE + 2, world.maxy - TRANSITIONEDGE - 2) + + else if (y <= TRANSITIONEDGE) + what_edge = SOUTH + new_y = world.maxy - TRANSITIONEDGE -2 + new_x = rand(TRANSITIONEDGE + 2, world.maxx - TRANSITIONEDGE - 2) + + else if (y >= (world.maxy - TRANSITIONEDGE + 1)) + what_edge = NORTH + new_y = TRANSITIONEDGE + 1 + new_x = rand(TRANSITIONEDGE + 2, world.maxx - TRANSITIONEDGE - 2) + + var/list/choices = list() + for(var/obj/effect/overmap/visitable/V in range(1, our_ship)) + choices[V.name] = V + + var/choice = input("Choose an overmap destination:", "Destination", null) as null|anything in choices + if(!choice) + var/backwards = turn(what_edge, 180) + forceMove(get_step(src,backwards)) //Move them back a step, then. + set_dir(backwards) + return + else + var/obj/effect/overmap/visitable/V = choices[choice] + if(occupant != this_occupant || this_x != x || this_y != y || this_z != z || get_dist(V,our_ship) > 1) //Sanity after user input + to_chat(occupant, "You or they appear to have moved!") + return + var/list/levels = V.get_space_zlevels() + if(!levels.len) + to_chat(occupant, "You don't appear to be able to get there from here!") + return + new_z = pick(levels) + var/turf/destination = locate(new_x, new_y, new_z) + if(!destination || destination.density) + to_chat(occupant, "You don't appear to be able to get there from here! Is it blocked?") + return + else + forceMove(destination) + //Modified phazon code /obj/mecha/combat/fighter/Topic(href, href_list) ..() @@ -97,7 +168,7 @@ /obj/mecha/combat/fighter/handle_equipment_movement() . = ..() - consider_gravity(TRUE) + consider_gravity(TRUE) /obj/mecha/combat/fighter/proc/start_hover() if(!ion_trail.on) //We'll just use this to store if we're floating or not @@ -162,7 +233,7 @@ step_in = 3 //Slightly slower than others ground_capable = TRUE - + // Paint colors! Null if not set. var/stripe1_color var/stripe2_color diff --git a/code/modules/multi-tile/multi-tile.dm b/code/modules/multi-tile/multi-tile.dm index b8dd9ef512..3c590c5b6d 100644 --- a/code/modules/multi-tile/multi-tile.dm +++ b/code/modules/multi-tile/multi-tile.dm @@ -11,6 +11,8 @@ var/list/checked_turfs = list() for(var/turf/T in locs) var/turf/Tcheck = get_step(T, stepdir) + if(!Tcheck) //Map edge + continue if(Tcheck in checked_turfs) continue if(Tcheck in locs)