Skip to content

Commit

Permalink
Overmap Autopilot Adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
SierraKomodo committed Nov 23, 2018
1 parent 30a0384 commit 51d12e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
23 changes: 16 additions & 7 deletions code/modules/overmap/ships/computers/helm.dm
Expand Up @@ -12,7 +12,7 @@ LEGACY_RECORD_STRUCTURE(all_waypoints, waypoint)
var/list/known_sectors = list()
var/dx //desitnation
var/dy //coordinates
var/speedlimit = 2 //top speed for autopilot
var/speedlimit = 1/(45 SECONDS) //top speed for autopilot

/obj/machinery/computer/ship/helm/Initialize()
. = ..()
Expand Down Expand Up @@ -43,13 +43,22 @@ LEGACY_RECORD_STRUCTURE(all_waypoints, waypoint)
autopilot = 0
else
linked.decelerate()

var/brake_path = linked.get_brake_path()

if((!speedlimit || linked.get_speed() < speedlimit) && get_dist(linked.loc, T) > brake_path)
linked.accelerate(get_dir(linked.loc, T))
else
linked.decelerate()
var/brake_path = linked.get_brake_path()
var/direction = get_dir(linked.loc, T)
var/acceleration = linked.get_acceleration()
var/speed = linked.get_speed()
var/heading = linked.get_heading()

// Destination is current grid or speedlimit is exceeded
if ((get_dist(linked.loc, T) <= brake_path) || ((speedlimit) && (speed > speedlimit)))
linked.decelerate()
// Heading does not match direction
else if (heading & ~direction)
linked.accelerate(turn(heading & ~direction, 180))
// All other cases, move toward direction
else if (speed + acceleration <= speedlimit)
linked.accelerate(direction)

return

Expand Down
6 changes: 3 additions & 3 deletions code/modules/overmap/ships/ship.dm
Expand Up @@ -94,10 +94,10 @@
return round(num_burns/burns_per_grid)

/obj/effect/overmap/ship/proc/decelerate()
if(!is_still() && can_burn())
if (MOVING(speed[1]))
if(((speed[1]) || (speed[2])) && can_burn())
if (abs(speed[1]) > 0)
adjust_speed(-SIGN(speed[1]) * min(get_burn_acceleration(),abs(speed[1])), 0)
if (MOVING(speed[2]))
if (abs(speed[2]) > 0)
adjust_speed(0, -SIGN(speed[2]) * min(get_burn_acceleration(),abs(speed[2])))
last_burn = world.time

Expand Down

0 comments on commit 51d12e2

Please sign in to comment.