forked from Kamik423/2mF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
planarBoostback.ks
27 lines (24 loc) · 1.14 KB
/
planarBoostback.ks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
PARAMETER landingpad.
PARAMETER k.
LOCK impact TO -landingpad:POSITION.
IF NOT BRAKES { TOGGLE BRAKES.}
LOCK STEERING TO -SHIP:VELOCITY:SURFACE.
WAIT 20.
TOGGLE BRAKES.
UNTIL (VANG(VXCL(SHIP:UP:FOREVECTOR, landingpad:POSITION), VXCL(SHIP:UP:FOREVECTOR, impact)) < 45) AND (VXCL(SHIP:UP:FOREVECTOR, impact):MAG > VXCL(SHIP:UP:FOREVECTOR, landingpad:POSITION):MAG){ //Less than 45º off of the launchpad to ensure right direction, and distance to impact > distance to launchpad
LOCK STEERING TO VXCL(SHIP:UP:FOREVECTOR, landingpad:POSITION):NORMALIZED * 2 - SHIP:VELOCITY:SURFACE:NORMALIZED.
LOCK THROTTLE TO MAX(ABS(-VXCL(SHIP:UP:FOREVECTOR, impact):MAG + VXCL(SHIP:UP:FOREVECTOR, landingpad:POSITION):MAG), 0) / 10000 + 0.5.
SET ps TO V(0,0,0).
SET vs TO SHIP:VELOCITY:SURFACE.
SET as TO V(0,0,0).
SET t TO 0.
UNTIL ps:Z < -SHIP:ALTITUDE {
SET t TO t + 1.
SET as TO (- vs:NORMALIZED * (vs:MAG ^ 2 * k * (0.99997 ^ ALT:RADAR)) / (SHIP:MASS * 1000)) - SHIP:UP:FOREVECTOR:NORMALIZED * 9.81.
SET vs TO vs + as.
SET ps TO ps + vs.
}
LOCK impact TO ps.
}
LOCK THROTTLE TO 0.
LOCK STEERING TO RETROGRADE.