Cargo train fixes

- Partial fix for #6634
- Fixes #7414
- Fixes #7609
This commit is contained in:
Loganbacca
2015-01-02 00:05:47 +13:00
parent cdfa2a5205
commit dbeec8915e
5 changed files with 44 additions and 12 deletions
+5 -2
View File
@@ -262,12 +262,15 @@
move_delay += 7+config.walk_speed
move_delay += mob.movement_delay()
var/tickcomp = 0 //moved this out here so we can use it for vehicles
if(config.Tickcomp)
move_delay -= 1.3
var/tickcomp = ((1/(world.tick_lag))*1.3)
// move_delay -= 1.3 //~added to the tickcomp calculation below
tickcomp = ((1/(world.tick_lag))*1.3) - 1.3
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
return mob.buckled.relaymove(mob,direct)
if(istype(mob.machine, /obj/machinery))
+19
View File
@@ -262,6 +262,25 @@
return ..()
//-------------------------------------------
// Latching/unlatching procs
//-------------------------------------------
/obj/vehicle/train/cargo/engine/latch(obj/vehicle/train/T, mob/user)
if(!istype(T) || !Adjacent(T))
return 0
//if we are attaching a trolley to an engine we don't care what direction
// it is in and it should probably be attached with the engine in the lead
if(istype(T, /obj/vehicle/train/cargo/trolley))
T.attach_to(src, user)
else
var/T_dir = get_dir(src, T) //figure out where T is wrt src
if(dir == T_dir) //if car is ahead
src.attach_to(T, user)
else if(reverse_direction(dir) == T_dir) //else if car is behind
T.attach_to(src, user)
//-------------------------------------------------------
// Stat update procs
+11 -10
View File
@@ -116,7 +116,7 @@
set desc = "Unhitches this train from the one in front of it."
set category = "Object"
set src in view(1)
if(!istype(usr, /mob/living/carbon/human))
return
@@ -131,6 +131,7 @@
//-------------------------------------------
//attempts to attach src as a follower of the train T
//Note: there is a modified version of this in code\modules\vehicles\cargo_train.dm specifically for cargo train engines
/obj/vehicle/train/proc/attach_to(obj/vehicle/train/T, mob/user)
if (get_dist(src, T) > 1)
user << "\red [src] is too far away from [T] to hitch them together."
@@ -139,11 +140,11 @@
if (lead)
user << "\red [src] is already hitched to something."
return
if (T.tow)
user << "\red [T] is already towing something."
return
//check for cycles.
var/obj/vehicle/train/next_car = T
while (next_car)
@@ -151,15 +152,15 @@
user << "\red That seems very silly."
return
next_car = next_car.lead
//latch with src as the follower
lead = T
T.tow = src
set_dir(lead.dir)
if(user)
user << "\blue You hitch [src] to [T]."
update_stats()
@@ -168,10 +169,10 @@
if (!lead)
user << "\red [src] is not hitched to anything."
return
lead.tow = null
lead.update_stats()
user << "\blue You unhitch [src] from [lead]."
lead = null
@@ -190,7 +191,7 @@
//returns 1 if this is the lead car of the train
/obj/vehicle/train/proc/is_train_head()
if (lead)
if (lead)
return 0
return 1
@@ -209,7 +210,7 @@
if (T.tow == src)
lead.tow = null
lead.update_stats()
lead = null
update_stats()
return
+6
View File
@@ -39,6 +39,7 @@
/obj/vehicle/Move()
if(world.time > l_move_time + move_delay)
var/old_loc = get_turf(src)
if(on && powered && cell.charge < charge_use)
turn_off()
@@ -48,6 +49,7 @@
anchored = init_anc
return 0
set_dir(get_dir(old_loc, loc))
anchored = init_anc
if(on && powered)
@@ -154,6 +156,10 @@
/obj/vehicle/attack_ai(mob/user as mob)
return
// For downstream compatibility (in particular Paradise)
/obj/vehicle/proc/handle_rotation()
return
//-------------------------------------------
// Vehicle procs
//-------------------------------------------