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 1d77099 commit b84528f
Showing 1 changed file with 16 additions and 7 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 = 0.002 //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.is_still()))
linked.accelerate(turn(heading & ~direction, 180))
// All other cases, move toward direction
else if (speed + acceleration <= speedlimit)
linked.accelerate(direction)

return

Expand Down

0 comments on commit b84528f

Please sign in to comment.