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

Expansion SniperLock Fix

Content

Warnings

  1. Required Expansions mismatch between OXP Manifest and Expansion Manager at character position 0070 (DIGIT ZERO vs LATIN SMALL LETTER N)
  2. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0
  3. No version in dependency reference to oolite.oxp.CommonSenseOTB.SniperLock:null

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Fixes a compatibility problem between SniperLock and Telescope. Fixes a compatibility problem between SniperLock and Telescope.
Identifier oolite.oxp.dybal.SniperLock_Fix oolite.oxp.dybal.SniperLock_Fix
Title SniperLock Fix SniperLock Fix
Category Equipment Equipment
Author Dybal Dybal
Version 1.0 1.0
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
  • oolite.oxp.CommonSenseOTB.SniperLock:0
  • oolite.oxp.CommonSenseOTB.SniperLock:
  • Optional Expansions
    Conflict Expansions
    Information URL n/a
    Download URL https://wiki.alioth.net/img_auth.php/7/7c/SniperLock_Fix-1.0.oxz n/a
    License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
    File Size n/a
    Upload date 1610873343

    Documentation

    Also read http://wiki.alioth.net/index.php/SniperLock%20Fix

    Readme.txt

    SniperLock Fix
    --------------
    v1.0, by Dybal
    
    SniperLock Fix, as the name suggests, fixes a icompatibility problem in SniperLock.
    
    The problem caused travel direction reversal while using Torus Drive if SniperLock was locked on a farway target through Telescope.
    
    Since SniperLock's license includes the "Thargoid clauses", which restrict CC BY-NC-SA 3.0 so the code can be re-used (if id collisions were avoided) but the original OXP can't be modified, it was necessary to create this OXP to wrap the SniperLock function and only call it when it's safe.
    
    License
    -------
    
    CC-BY-NC-SA 4.0 - Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
    (https://creativecommons.org/licenses/by-nc-sa/4.0/)
    
    

    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
    Config/script.js
    "use strict";
    this.name           = "sniperlock_fix";
    this.author         = "Dybal";
    this.copyright      = "2020 Dybal";
    this.license        = "CC-BY-NC-SA 4.0";
    this.description    = "Fixes a bug in SniperLock";
    this.version        = "1.0";
    
    
    //
    // Event Handlers
    //
    
    //------------------------------------------------------------------------------------------//
    this.startUp = function _sniperlockFix_startUp() {
        var ws = worldScripts.sniperlock;
        if (ws && ws.sniperLock) {
            log(this.name, "Wrapping SniperLock's sniperLock function");
            ws.$sniperlockFix_saved_sniperLock = ws.sniperLock;
            ws.sniperLock = this.$FCB_Wrap;
            ws.$lastOK = true;
        }
    }
    
    
    //
    // Internal Functions
    //
    
    //------------------------------------------------------------------------------------------//
    this.$FCB_Wrap = function _sniperlockFix_FCB_Wrap(delta) {
        var that = _sniperlockFix_FCB_Wrap;
        var ws = (that.ws = that.ws || worldScripts.sniperlock);
        var sniperLock = (that.sniperLock || ws.$sniperlockFix_saved_sniperLock);
        var reset = (that.reset = that.reset || ws.shipTargetAcquired);
        var pship = player.ship;
    
        if (!sniperLock || !pship.target) return;
        if (pship.speed > pship.maxSpeed && pship.target.dataKey === "telescopemarker") {
            if (ws.$lastOK) {
                // resets to clean the stored target positions
                // avoids using old target positions when sniperlock resumes
                log(this.name, "resetting SniperLock");
                reset.call(ws);
            }
            ws.$lastOK = false;
        } else {
            sniperLock.call(ws, delta);
            ws.$lastOK = true;
        }
    }