mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-22 03:27:46 +01:00
More cargo train fixes
- Fixes #5906 - Fixes #5939 - Fixes #6282 - Fixes #6634 (properly this time) - Fixed a bug with updating train stats (causing trains to be super slow if hitched while running) - Updated train verbs (start/stop/remove key) to only show up if you are in the same turf - Moved all train specific verbs to their own verb category: "Vehicle"
This commit is contained in:
@@ -269,8 +269,12 @@
|
||||
move_delay = move_delay + tickcomp
|
||||
|
||||
if(istype(mob.buckled, /obj/vehicle))
|
||||
//manually set move_delay for vehicles so we dont inherit any mob movement penalties
|
||||
move_delay = world.time + mob.movement_delay() + 1 + config.run_speed + tickcomp
|
||||
//manually set move_delay for vehicles so we don't inherit any mob movement penalties
|
||||
//specific vehicle move delays are set in code\modules\vehicles\vehicle.dm
|
||||
move_delay = world.time + tickcomp
|
||||
//drunk driving
|
||||
if(mob.confused)
|
||||
direct = pick(cardinal)
|
||||
return mob.buckled.relaymove(mob,direct)
|
||||
|
||||
if(istype(mob.machine, /obj/machinery))
|
||||
@@ -289,6 +293,9 @@
|
||||
var/datum/organ/external/r_hand = driver.get_organ("r_hand")
|
||||
if((!l_hand || (l_hand.status & ORGAN_DESTROYED)) && (!r_hand || (r_hand.status & ORGAN_DESTROYED)))
|
||||
return // No hands to drive your chair? Tough luck!
|
||||
//drunk wheelchair driving
|
||||
if(mob.confused)
|
||||
direct = pick(cardinal)
|
||||
move_delay += 2
|
||||
return mob.buckled.relaymove(mob,direct)
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
overlays += I
|
||||
turn_off() //so engine verbs are correctly set
|
||||
|
||||
/obj/vehicle/train/cargo/engine/Move()
|
||||
/obj/vehicle/train/cargo/engine/Move(var/turf/destination)
|
||||
if(on && cell.charge < charge_use)
|
||||
turn_off()
|
||||
update_stats()
|
||||
@@ -55,6 +55,10 @@
|
||||
|
||||
if(is_train_head() && !on)
|
||||
return 0
|
||||
|
||||
//space check ~no flying space trains sorry
|
||||
if(on && istype(destination, /turf/space))
|
||||
return 0
|
||||
|
||||
return ..()
|
||||
|
||||
@@ -186,8 +190,8 @@
|
||||
|
||||
/obj/vehicle/train/cargo/engine/verb/start_engine()
|
||||
set name = "Start engine"
|
||||
set category = "Object"
|
||||
set src in view(1)
|
||||
set category = "Vehicle"
|
||||
set src in view(0)
|
||||
|
||||
if(!istype(usr, /mob/living/carbon/human))
|
||||
return
|
||||
@@ -207,8 +211,8 @@
|
||||
|
||||
/obj/vehicle/train/cargo/engine/verb/stop_engine()
|
||||
set name = "Stop engine"
|
||||
set category = "Object"
|
||||
set src in view(1)
|
||||
set category = "Vehicle"
|
||||
set src in view(0)
|
||||
|
||||
if(!istype(usr, /mob/living/carbon/human))
|
||||
return
|
||||
@@ -223,8 +227,8 @@
|
||||
|
||||
/obj/vehicle/train/cargo/engine/verb/remove_key()
|
||||
set name = "Remove key"
|
||||
set category = "Object"
|
||||
set src in view(1)
|
||||
set category = "Vehicle"
|
||||
set src in view(0)
|
||||
|
||||
if(!istype(usr, /mob/living/carbon/human))
|
||||
return
|
||||
@@ -251,7 +255,12 @@
|
||||
if(!istype(C,/obj/machinery) && !istype(C,/obj/structure/closet) && !istype(C,/obj/structure/largecrate) && !istype(C,/obj/structure/reagent_dispensers) && !istype(C,/obj/structure/ore_box) && !istype(C, /mob/living/carbon/human))
|
||||
return 0
|
||||
|
||||
..()
|
||||
//if there are any items you don't want to be able to interact with, add them to this check
|
||||
// ~no more shielded, emitter armed death trains
|
||||
if(istype(C, /obj/machinery))
|
||||
load_object(C)
|
||||
else
|
||||
..()
|
||||
|
||||
if(load)
|
||||
return 1
|
||||
@@ -262,6 +271,45 @@
|
||||
|
||||
return ..()
|
||||
|
||||
//Load the object "inside" the trolley and add an overlay of it.
|
||||
//This prevents the object from being interacted with until it has
|
||||
// been unloaded. A dummy object is loaded instead so the loading
|
||||
// code knows to handle it correctly.
|
||||
/obj/vehicle/train/cargo/trolley/proc/load_object(var/atom/movable/C)
|
||||
if(!isturf(C.loc)) //To prevent loading things from someone's inventory, which wouldn't get handled properly.
|
||||
return 0
|
||||
if(load || C.anchored)
|
||||
return 0
|
||||
|
||||
var/datum/vehicle_dummy_load/dummy_load = new()
|
||||
load = dummy_load
|
||||
|
||||
if(!load)
|
||||
return
|
||||
dummy_load.actual_load = C
|
||||
C.forceMove(src)
|
||||
|
||||
if(load_item_visible)
|
||||
C.pixel_x += load_offset_x
|
||||
C.pixel_y += load_offset_y
|
||||
C.layer = layer
|
||||
|
||||
overlays += C
|
||||
|
||||
//we can set these back now since we have already cloned the icon into the overlay
|
||||
C.pixel_x = initial(C.pixel_x)
|
||||
C.pixel_y = initial(C.pixel_y)
|
||||
C.layer = initial(C.layer)
|
||||
|
||||
/obj/vehicle/train/cargo/trolley/unload(var/mob/user, var/direction)
|
||||
if(istype(load, /datum/vehicle_dummy_load))
|
||||
var/datum/vehicle_dummy_load/dummy_load = load
|
||||
load = dummy_load.actual_load
|
||||
dummy_load.actual_load = null
|
||||
del(dummy_load)
|
||||
overlays.Cut()
|
||||
..()
|
||||
|
||||
//-------------------------------------------
|
||||
// Latching/unlatching procs
|
||||
//-------------------------------------------
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
/obj/vehicle/train/verb/unlatch_v()
|
||||
set name = "Unlatch"
|
||||
set desc = "Unhitches this train from the one in front of it."
|
||||
set category = "Object"
|
||||
set category = "Vehicle"
|
||||
set src in view(1)
|
||||
|
||||
if(!istype(usr, /mob/living/carbon/human))
|
||||
@@ -221,7 +221,7 @@
|
||||
var/train_length = 0
|
||||
while(T)
|
||||
train_length++
|
||||
if (powered && on)
|
||||
if (T.powered && T.on)
|
||||
active_engines++
|
||||
T.update_car(train_length, active_engines)
|
||||
T = T.lead
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
//Dummy object for holding items in vehicles.
|
||||
//Prevents items from being interacted with.
|
||||
/datum/vehicle_dummy_load
|
||||
var/name = "dummy load"
|
||||
var/actual_load
|
||||
|
||||
/obj/vehicle
|
||||
name = "vehicle"
|
||||
icon = 'icons/obj/vehicles.dmi'
|
||||
@@ -55,8 +61,10 @@
|
||||
if(on && powered)
|
||||
cell.use(charge_use)
|
||||
|
||||
if(load)
|
||||
load.forceMove(loc)// = loc
|
||||
//Dummy loads do not have to be moved as they are just an overlay
|
||||
//See load_object() proc in cargo_trains.dm for an example
|
||||
if(load && !istype(load, /datum/vehicle_dummy_load))
|
||||
load.forceMove(loc)
|
||||
load.set_dir(dir)
|
||||
|
||||
return 1
|
||||
@@ -263,8 +271,8 @@
|
||||
// calling this parent proc.
|
||||
//-------------------------------------------
|
||||
/obj/vehicle/proc/load(var/atom/movable/C)
|
||||
//define allowed items for loading in specific vehicle definitions
|
||||
|
||||
//This loads objects onto the vehicle so they can still be interacted with.
|
||||
//Define allowed items for loading in specific vehicle definitions.
|
||||
if(!isturf(C.loc)) //To prevent loading things from someone's inventory, which wouldn't get handled properly.
|
||||
return 0
|
||||
if(load || C.anchored)
|
||||
|
||||
Reference in New Issue
Block a user