From aaaa4d9ca4ac7b8af14662d7eae62baf38c8bfc9 Mon Sep 17 00:00:00 2001 From: skull132 Date: Wed, 9 Nov 2016 22:46:06 +0200 Subject: [PATCH] Fixes #1128 (#1144) Reverts changes done by Nanako to the vehicles, trams, and trolleys; and updates the existing maths to work IAW the updated movement system. And yes, this is tested and working. --- code/modules/vehicles/cargo_train.dm | 17 +++++++----- code/modules/vehicles/train.dm | 11 +++----- code/modules/vehicles/vehicle.dm | 29 ++++++--------------- html/changelogs/Skull132_revert-trolley.yml | 12 +++++++++ 4 files changed, 33 insertions(+), 36 deletions(-) create mode 100644 html/changelogs/Skull132_revert-trolley.yml diff --git a/code/modules/vehicles/cargo_train.dm b/code/modules/vehicles/cargo_train.dm index 46b0d1851d4..0c5987c3f36 100644 --- a/code/modules/vehicles/cargo_train.dm +++ b/code/modules/vehicles/cargo_train.dm @@ -6,7 +6,7 @@ on = 0 powered = 1 locked = 0 - move_speed = 3 + load_item_visible = 1 load_offset_x = 0 mob_offset_y = 7 @@ -29,7 +29,7 @@ anchored = 0 passenger_allowed = 0 locked = 0 - //move_speed = 3 + load_item_visible = 1 load_offset_x = 0 load_offset_y = 4 @@ -352,12 +352,15 @@ /obj/vehicle/train/cargo/engine/update_car(var/train_length, var/active_engines) src.train_length = train_length src.active_engines = active_engines - move_speed = initial(move_speed) //so that engines that have been turned off don't lag behind + //Update move delay - if(is_train_head() && on) - var/remainder = (car_limit * active_engines) - (train_length - active_engines) - if (remainder) - move_speed -= 0.25 * remainder //makes cargo trains 10% slower than running when not overweight + if(!is_train_head() || !on) + move_delay = initial(move_delay) //so that engines that have been turned off don't lag behind + else + move_delay = max(0, (-car_limit * active_engines) + train_length - active_engines) //limits base overweight so you cant overspeed trains + move_delay *= (1 / max(1, active_engines)) * 2 //overweight penalty (scaled by the number of engines) + move_delay += config.walk_speed //base reference speed + move_delay *= config.vehicle_delay_multiplier //makes cargo trains 10% slower than running when not overweight /obj/vehicle/train/cargo/trolley/update_car(var/train_length, var/active_engines) src.train_length = train_length diff --git a/code/modules/vehicles/train.dm b/code/modules/vehicles/train.dm index d3136822aca..d6c0b934e1c 100644 --- a/code/modules/vehicles/train.dm +++ b/code/modules/vehicles/train.dm @@ -2,6 +2,7 @@ name = "train" dir = 4 + move_delay = 1 health = 100 maxhealth = 100 @@ -28,19 +29,13 @@ var/old_loc = get_turf(src) if(..()) if(tow) - tow.forceMove(old_loc) + tow.Move(old_loc) return 1 else if(lead) unattach() return 0 -obj/vehicle/train/forceMove() - var/old_loc = get_turf(src) - ..() - if(tow) - tow.forceMove(old_loc) - /obj/vehicle/train/Bump(atom/Obstacle) if(!istype(Obstacle, /atom/movable)) return @@ -56,7 +51,7 @@ obj/vehicle/train/forceMove() var/mob/living/M = A visible_message("\red [src] knocks over [M]!") M.apply_effects(5, 5) //knock people down if you hit them - M.apply_damages(10 * move_speed) // and do damage according to how fast the train is going + M.apply_damages(22 / move_delay) // and do damage according to how fast the train is going if(istype(load, /mob/living/carbon/human)) var/mob/living/D = load D << "\red You hit [M]!" diff --git a/code/modules/vehicles/vehicle.dm b/code/modules/vehicles/vehicle.dm index 31d573854e6..c3bdc7b742d 100644 --- a/code/modules/vehicles/vehicle.dm +++ b/code/modules/vehicles/vehicle.dm @@ -28,10 +28,7 @@ var/stat = 0 var/emagged = 0 var/powered = 0 //set if vehicle is powered and should use fuel when moving - - move_speed = 2//Expressed in tiles per second. This is used to control how fast the vehicle moves - - var/move_delay//DO NOT MANUALLY SET THIS. For internal use only + var/move_delay = 1 //set this to limit the speed of the vehicle var/obj/item/weapon/cell/cell var/charge_use = 5 //set this to adjust the amount of power the vehicle uses per move @@ -48,22 +45,8 @@ /obj/vehicle/New() ..() //spawn the cell you want in each vehicle - calc_delay() - -/obj/vehicle/proc/calc_delay() - if (!move_speed || move_speed < 0)//Shouldn't happen - move_speed = 0 - move_delay = 999999999 - return 0 - - move_delay = (1 / move_speed) * 10 * config.vehicle_delay_multiplier - return 1 - /obj/vehicle/Move() - if (!move_speed) - return 0 - if(world.time > l_move_time + move_delay) var/old_loc = get_turf(src) if(on && powered && cell.charge < charge_use) @@ -197,7 +180,6 @@ // Vehicle procs //------------------------------------------- /obj/vehicle/proc/turn_on() - calc_delay() if(stat) return 0 if(powered && cell.charge < charge_use) @@ -326,7 +308,6 @@ if(ismob(C)) buckle_mob(C) - calc_delay() return 1 /obj/vehicle/user_unbuckle_mob(var/mob/user) @@ -374,9 +355,15 @@ unbuckle_mob(load) load = null - calc_delay() + return 1 +// This exists to stop a weird jumping motion when you disembark. +// It essentially makes disembarkation count as a movement. +// Yes, it's not the full calculation. But it's relatively close, and will make it seamless. +/obj/vehicle/post_buckle_mob(var/mob/M) + if (M.client) + M.client.move_delay = M.movement_delay() + config.walk_speed //------------------------------------------------------- // Stat update procs diff --git a/html/changelogs/Skull132_revert-trolley.yml b/html/changelogs/Skull132_revert-trolley.yml new file mode 100644 index 00000000000..c27ff305130 --- /dev/null +++ b/html/changelogs/Skull132_revert-trolley.yml @@ -0,0 +1,12 @@ +author: Skull132 + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "Fixed the trolleys and trams by reverting code, and simply tweaking the values to reference the updated move system. All issues, including edgecases, should be resolved now."