Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: PersistentRotation mod support #589

Closed
formicant opened this issue May 18, 2015 · 3 comments
Closed

Request: PersistentRotation mod support #589

formicant opened this issue May 18, 2015 · 3 comments

Comments

@formicant
Copy link
Contributor

It would be nice if MechJeb was compatible with MarcusA380’s PersistentRotation plugin.
My guess is that turning on SAS during autowarp will fix the issue. I can be wrong though.

@surge9000
Copy link

I think it would be nice too!

SAS and Mechjeb are probably mutually exclusive.
What's happening is that Mechjeb is basically flinging itself at the target and relying on the 'stop-rotating-under-warp' bug/cheat, when it should be spending a few more seconds aligning carefully before warping.
Should be a relatively simple fix - just add an appropriate wait before warping (would be less than 2s unless the ship is rotating wildly or has poor attitude control).

@samschr
Copy link

samschr commented May 27, 2015

Actually I don't think that would work as a fix. Mechjeb can't completely zero any craft's rotation due to KSP's rounding issues, so no matter how long it tries to wait to orient the craft correctly it'll still have some minuscule amount of rotation. That doesn't happen when warping using SAS under this plugin because, as far as I can tell, activating SAS tells Persistent Rotation to treat the craft's rotation as zero through the warp, whereas Smart A.S.S. isn't keyed to do the same. To fix this you'd either need to have Mechjeb "spoof" SAS as being on whenever it uses it's own Smart A.S.S. or PersistentRotation itself would have to somehow know whenever Mechjeb is holding a position.

@formicant
Copy link
Contributor Author

I succeeded with this straightforward way:

First, I added an if in the SetFlightCtrlState method in MechJebModuleAttitudeController.cs

. . .
private void SetFlightCtrlState(Vector3d act, Vector3d deltaEuler, FlightCtrlState s, float drive_limit)
{
    . . .
    // Disable the new SAS so it won't interfere. 
    // Todo : enable it when it's a good idea or the user had it enabled before
    if(TimeWarp.WarpMode != TimeWarp.Modes.HIGH || TimeWarp.CurrentRateIndex == 0)
        part.vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, false);
    . . .
}

Then, I added a new method to MechJebModuleWarpController.cs

// Turn SAS on during regular warp
void SetTimeWarpRate(int rateIndex, bool instant)
{
    if(rateIndex != TimeWarp.CurrentRateIndex)
    {
        if(TimeWarp.WarpMode == TimeWarp.Modes.HIGH && TimeWarp.CurrentRateIndex == 0)
            part.vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, true);
        TimeWarp.SetRate(rateIndex, instant);
        if(rateIndex == 0)
            part.vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, false);
    }
}

And replaced TimeWarp.SetRate invocations with SetTimeWarpRate everywhere in the class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants