diff --git a/code/modules/vehicles/cargo_train.dm b/code/modules/vehicles/cargo_train.dm
index 559c9dbc352..7bb30f5f08b 100644
--- a/code/modules/vehicles/cargo_train.dm
+++ b/code/modules/vehicles/cargo_train.dm
@@ -11,7 +11,8 @@
load_offset_y = 9
var/car_limit = 3 //how many cars an engine can pull before performance degrades
- var/lead_engine = 0 //if the engine is the lead engine - set automatically
+ var/lead_engine = 1 //if the engine is the lead engine - set automatically
+ active_engines = 1
/obj/vehicle/train/cargo/trolley
name = "cargo train trolley"
@@ -35,8 +36,6 @@
/obj/vehicle/train/cargo/engine/initialize()
..()
- if(!lead)
- lead_engine = 1
/obj/vehicle/train/cargo/engine/Move()
if(on && cell.charge < power_use)
@@ -85,6 +84,11 @@
..()
+/obj/vehicle/train/cargo/trolley/Bump(atom/Obstacle)
+ if(!lead)
+ return //so people can't knock others over by pushing a trolley around
+ ..()
+
//-------------------------------------------
// Train procs
//-------------------------------------------
@@ -107,6 +111,7 @@
D << "\red \b You ran over [H]!"
visible_message("\red \The [src] ran over [H]!")
attack_log += text("\[[time_stamp()]\] ran over [H.name] ([H.ckey]), driven by [D.name] ([D.ckey])")
+ msg_admin_attack("[D.name] ([D.ckey]) ran over [H.name] ([H.ckey]). (JMP)")
else
attack_log += text("\[[time_stamp()]\] ran over [H.name] ([H.ckey])")
@@ -184,8 +189,12 @@
/obj/vehicle/train/cargo/trolley/latch(var/obj/vehicle/train/T)
if(..())
//if this is a trolley, and is now part of a train, anchor it so it cant be pushed around
- if(lead || tow)
+ if(lead)
anchored = 1
+ lead.anchored = 1
+ if(tow)
+ anchored = 1
+ tow.anchored = 1
return 1
else
return 0
@@ -205,6 +214,8 @@
//check if this is not the lead engine
if(lead)
lead_engine = 0
+ if(tow)
+ tow.anchored = 1
return 1
else
return 0
diff --git a/code/modules/vehicles/train.dm b/code/modules/vehicles/train.dm
index 521fde0cd75..dd8ee3064ff 100644
--- a/code/modules/vehicles/train.dm
+++ b/code/modules/vehicles/train.dm
@@ -35,9 +35,8 @@
return 0
/obj/vehicle/train/Bump(atom/Obstacle)
- if(!istype(Obstacle, /atom/movable) || !anchored)
+ if(!istype(Obstacle, /atom/movable))
return
-
var/atom/movable/A = Obstacle
if(!A.anchored)
@@ -47,15 +46,17 @@
A.Move(T)
else if(!ismob(A)) //always bump objects even if emagged
A.Move(T)
-
if(istype(A, /mob/living))
var/mob/living/M = A
+ var/mob/living/D
if(istype(load, /mob/living/carbon/human))
- load << "\red You hit [M]!"
+ D = load
+ D << "\red You hit [M]!"
visible_message("\red [src] knocks over [M]!")
M.apply_effects(5, 5) //knock people down if you hit them
if(emagged) //and do damage if it's emagged
M.apply_damages(5 * train_length / move_delay) // according to how fast the train is going and how heavy it is
+ msg_admin_attack("[D.name] ([D.ckey]) hit [M.name] ([M.ckey]) with [src]. (JMP)")
//-------------------------------------------
@@ -151,18 +152,22 @@
return 1
-/obj/vehicle/train/proc/unlatch()
+/obj/vehicle/train/proc/unlatch(var/obj/vehicle/train/T)
if(!lead && !tow)
return 0
- if(tow)
- tow.lead = null
- tow.update_stats()
- tow = null
- if(lead)
- lead.tow = null
- lead.update_stats()
- lead = null
+ if(T)
+ if(T == tow)
+ tow = null
+ else if(T == lead)
+ lead = null
+ else
+ if(tow)
+ tow.unlatch(src)
+ tow = null
+ if(lead)
+ lead.unlatch(src)
+ lead = null
update_stats()