Back to Index Page generated: May 8, 2024, 6:16:03 AM

Expansion Barrel Roll

Content

Warnings

  1. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Adds a barrel roll function to your auto-pilot. Adds a barrel roll function to your auto-pilot.
Identifier oolite.oxp.dybal.BarrelRoll oolite.oxp.dybal.BarrelRoll
Title Barrel Roll Barrel Roll
Category Equipment Equipment
Author Dybal Dybal
Version 1.1 1.1
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/d/db/BarrelRoll-1.1.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873485

Documentation

Also read http://wiki.alioth.net/index.php/Barrel%20Roll

Readme.txt

Barrel Roll OXP
---------------
v1.1, by Dybal

Barrel-rolling is a time-proven evasive tactic, when attacked, for those that can't afford or prefer not to fight back.

But manually keeping a ship barrel-rolling for minutes to hours until the attacker(s) give up is a boring, mindless and even painful task.

With that in mind, Think of It as Evolution in Action Corporation would like to present Barrel Roll Governor, a software add-on to your ship's auto-pilot.

Once primed (by pressing <Shift>-<N> in the default keyboard configuration) and activated (by pressing <N> in the default keyboard configuration), this little add-on keeps the ship in a barrel-roll until de-activated (by pressing <N> again), leaving you to just adjust heading through your yaw controls now and then to keep going in the direction you want, but otherwise free to browse the Galactic Net, eat your doughnut, drink you tea, pet your cat, or do whatever your prefer to while the time away.

Available at Tech Level 9 and above systems for 300 credits.


License 
-------

CC-BY-NC-SA 4.0 - Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
(https://creativecommons.org/licenses/by-nc-sa/4.0/)

Change log
----------

v1.1
- Changes price to make the equipment more accessible to new Jamesons.

v1.0
- Initial version

Equipment

Name Visible Cost [deci-credits] Tech-Level
Barrel Roll Governor yes 300 7+

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Scripts/barrel_roll.js
"use strict";
this.name           = "BarrelRoll";
this.author         = "Dybal";
this.copyright      = "2020 Dybal";
this.license        = "CC-BY-NC-SA 4.0";
this.description    = "Barrel Roll auto-pilot";
this.version        = "1.1";

this.$debug = false;
this.$logging = true;
this.$FCB_tracking_ID = null;
this.$rbEnabled = false;
this.$rbActive = false;


//
// Event Handlers
//

//------------------------------------------------------------------------------------------//
this.startUpComplete = function _BarrelRoll_startUpComplete() {
    this.ship = player.ship;
    if (this.ship.equipmentStatus("EQ_BARREL_ROLL") === "EQUIPMENT_OK")
        this.$rbEnabled = true;
    else
        this.$rbEnabled = false;
}

//------------------------------------------------------------------------------------------//
this.playerBoughtNewShip = this.playerReplacedShip = function _BarrelRoll_playerGotNewShip(ship) {
    this.ship = ship;
    if (this.ship.equipmentStatus("EQ_BARREL_ROLL") === "EQUIPMENT_OK")
        this.$rbEnabled = true;
    else
        this.$rbEnabled = false;
}

//------------------------------------------------------------------------------------------//
this.equipmentAdded = function _BarrelRoll_equipmentAdded(equipmentKey) {
    if (equipmentKey === "EQ_BARREL_ROLL") {
        if (this.$debug) log(this.name, "Barrel Roll added")
        this.$rbEnabled = true;
        this.$rbActive = false;
    }
}

//------------------------------------------------------------------------------------------//
this.equipmentRemoved = function _BarrelRoll_equipmentRemoved(equipmentKey) {
    if (equipmentKey === "EQ_BARREL_ROLL") {
        if (this.$debug) log(this.name, "Barrel Roll removed")
        this.$rbEnabled = false;
        if (this.$rbActive) {
            if (this.$FCB_tracking_ID && isValidFrameCallback(this.$FCB_tracking_ID)) 
                removeFrameCallback(this.$FCB_tracking_ID);
            this.$rbActive = false;
        }
    }
}

//------------------------------------------------------------------------------------------//
this.shipWillLaunchFromStation = this.shipWillExitWitchspace = function _BarrelRoll_StartFlight() {
    this.$rbActive = false;
}

//------------------------------------------------------------------------------------------//
this.activated = function _BarrelRoll_activated() {
    var ws = worldScripts.BarrelRoll;
    if (ws.$rbEnabled) {
        if (ws.$rbActive) {
            // de-activate
            if (ws.$FCB_tracking_ID && isValidFrameCallback(ws.$FCB_tracking_ID))
                removeFrameCallback(ws.$FCB_tracking_ID);
            ws.$rbActive = false;
            if (ws.$logging) log(ws.name, "De-activating")
        } else {
            if (!isValidFrameCallback(ws.$FCB_tracking_ID))
                ws.$FCB_tracking_ID = addFrameCallback(ws.$FCB.bind(ws)); 
            ws.$rbActive = true;
            if (ws.$logging) log(ws.name, "Activating")
        }
    }
}


//
// Internal Functions
//

//------------------------------------------------------------------------------------------//
this.$FCB = function _BarrelRoll_FCB(delta) {
    var ship = this.ship;
    var pitch, roll, heading, right, orientation;

    if (!this.$rbEnabled || !this.$rbActive || delta == 0) return;
    pitch = ship.maxPitch * delta;
    roll = ship.maxRoll * delta;
    heading = ship.heading;
    right = ship.vectorRight;
    // roll the ship anti-clock-wise
    orientation = ship.orientation.rotate(heading, -roll);
    // pitch the ship
    ship.orientation = orientation.rotate(orientation.vectorRight(), -pitch);
}