Back to Index Page generated: Nov 12, 2024, 11:02:04 PM

Expansion Shieldtastic Crosshairs

Content

Warnings

  1. http://wiki.alioth.net/index.php/Shieldtastic%20Crosshairs -> 404 Not Found

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Adds two semi-circular indicators, showing the state of the shields, around the central cross-hairs. Compatible with most HUDs. Adds two semi-circular indicators, showing the state of the shields, around the central cross-hairs. Compatible with most HUDs.
Identifier oolite.oxp.Wildeblood.ShieldtasticCrosshairs oolite.oxp.Wildeblood.ShieldtasticCrosshairs
Title Shieldtastic Crosshairs Shieldtastic Crosshairs
Category HUDs HUDs
Author Wildeblood Wildeblood
Version 1.0 1.0
Tags crosshairs crosshairs
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://aegidian.org/bb/viewtopic.php?f=4&t=14368 n/a
Download URL https://wiki.alioth.net/img_auth.php/9/95/ShieldtasticCrosshairs_1.0.oxz ShieldtasticCrosshairs.oxz
License See within. See within.
File Size n/a
Upload date 1610873375

Documentation

Shieldtastic Crosshairs READ ME.txt

------------------------------------
Shieldtastic Crosshairs OXP ver. 1.0
------------------------------------
  Date: October 8th, 2014
Author: Wildeblood


---------------------
Installation and use:
---------------------

Adds two semi-circular indicators showing the state of the shields around the central cross-hairs. Compatible with most HUDs.


-----------
Change Log:
-----------

1.0 (October 8th, 2014) First published.

Equipment

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

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/shieldtastic_crosshairs.js
"use strict";

this.name    = "Shieldtastic Crosshairs";
this.version = "1.0";

this.warningLevel_1 = 0.9;
this.warningLevel_2 = 0.6;
this.dangerLevel    = 0.3;

/* ====================================================================================
			START-UP
======================================================================================= */

    this.startUp = function () {
        "use strict";
        if (worldScripts["Auto Crosshairs"]) {
            this._monitorShields = this._monitorShields_v2;
        }
        delete this._monitorShields_v2;
        delete this.startUp;
    }

/* ====================================================================================
			STARTING & STOPPING FRAME CALLBACK

	FCB starts when player.alertCondition becomes > 1. Player is mass-locked.
======================================================================================= */

    this.alertConditionChanged = function (newLevel, oldLevel) {
        "use strict";
        if (newLevel > 1 &&
            !this.$runningFCB) {
            if (player.ship.crosshairs === null) {
                this.$ooliteQuirk = [
                    player.ship.hud,
                    player.ship.reticleTargetSensitive,
                    player.ship.scannerNonLinear,
                    player.ship.scannerUltraZoom
                ];
            }
            this.$runningFCB = addFrameCallback(this._monitorShields.bind(this));
        }
    }

    this._ooliteQuirk = function () {
        "use strict";
        if (player.ship.hud == this.$ooliteQuirk[0]) {
            player.ship.reticleTargetSensitive = this.$ooliteQuirk[1];
            player.ship.scannerNonLinear = this.$ooliteQuirk[2];
            player.ship.scannerUltraZoom = this.$ooliteQuirk[3];
        } else {
            // The HUD has changed, so preserving these settings is no longer our responsibility.
            delete this.$ooliteQuirk;
        }
    }

    this.shipWillDockWithStation = this.shipWillEnterWitchspace = this.shipDied = function () {
        "use strict";
        this._endFCB();
    }

    this._endFCB = function () {
        "use strict";
        if (this.$runningFCB) {
            removeFrameCallback(this.$runningFCB);
            delete this.$runningFCB;
         // FixMe: what if player.ship.crosshairs == null was not so to begin with?
            player.ship.crosshairs = null; // "crosshairs.plist";
            if (this.$ooliteQuirk) {
                this._ooliteQuirk();
                delete this.$ooliteQuirk;
            }
            this.$lastForeStep = "-1";
            this.$lastAftStep = "-1";
        }
    }

/* ====================================================================================
			FRAME CALLBACK
======================================================================================= */

    this._monitorShields = function (delta) {
        "use strict";
        var self = player.ship;
        var fore = self.forwardShield / self.maxForwardShield;
        var aft  = self.aftShield / self.maxAftShield;
        if (player.alertCondition < 2 &&    // Not mass-locked, and
            fore == 1 && aft == 1) {        // both shields fully charged...
            this._endFCB();
            return;
        }
        var foreStep = 3;
        if (fore < this.dangerLevel) {
            foreStep = 0;
        } else if (fore < this.warningLevel_2) {
            foreStep = 1;
        } else if (fore < this.warningLevel_1) {
            foreStep = 2;
        }
        var aftStep = 3;
        if (aft < this.dangerLevel) {
            aftStep = 0;
        } else if (aft < this.warningLevel_2) {
            aftStep = 1;
        } else if (aft < this.warningLevel_1) {
            aftStep = 2;
        }
        if (foreStep != this.$lastForeStep ||
            aftStep != this.$lastAftStep) {
            self.crosshairs = "shieldtastic_crosshairs_" + foreStep + aftStep + ".plist";
        //  worldScripts["Auto Crosshairs"].$offTargetCrosshairs = "shieldtastic_crosshairs_" + foreStep + aftStep + ".plist";
            this.$lastForeStep = foreStep;
            this.$lastAftStep = aftStep;
        }
    }

    this._monitorShields_v2 = function (delta) {
        "use strict";
        var self = player.ship;
        var fore = self.forwardShield / self.maxForwardShield;
        var aft  = self.aftShield / self.maxAftShield;
        if (player.alertCondition < 2 &&    // Not mass-locked, and
            fore == 1 && aft == 1) {        // both shields fully charged...
            this._endFCB();
            return;
        }
        var foreStep = 3;
        if (fore < this.dangerLevel) {
            foreStep = 0;
        } else if (fore < this.warningLevel_2) {
            foreStep = 1;
        } else if (fore < this.warningLevel_1) {
            foreStep = 2;
        }
        var aftStep = 3;
        if (aft < this.dangerLevel) {
            aftStep = 0;
        } else if (aft < this.warningLevel_2) {
            aftStep = 1;
        } else if (aft < this.warningLevel_1) {
            aftStep = 2;
        }
        if (foreStep != this.$lastForeStep ||
            aftStep != this.$lastAftStep) {
            self.crosshairs = "shieldtastic_crosshairs_" + foreStep + aftStep + ".plist";
            worldScripts["Auto Crosshairs"].$offTargetCrosshairs = "shieldtastic_crosshairs_" + foreStep + aftStep + ".plist";
            this.$lastForeStep = foreStep;
            this.$lastAftStep = aftStep;
        }
    }

/* ====================================================================================
			COPYRIGHT NOTICE

	(C) 2013,2014 Wildeblood. All rights reserved. 
	Free to use, but DO NOT PROMULGATE MODIFIED VERSIONS.

This was created by some fellow with the user name "Wildeblood" on the Oolite forums, 
he'll tell you his real name if you bother to ask.
To use means to play with, modify or re-use in whole or in part, and to distribute freely.
To use DOES NOT imply to use for commercial gain, which would be a breach of copyright.
To promulgate means to make official announcements.
======================================================================================= */