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

Expansion Tracker

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description An advanced space compass add-on which allows the system-wide tracking of up to five entities. An advanced space compass add-on which allows the system-wide tracking of up to five entities.
Identifier oolite.oxp.Thargoid.Tracker oolite.oxp.Thargoid.Tracker
Title Tracker Tracker
Category Equipment Equipment
Author Thargoid Thargoid
Version 1.05 1.05
Tags equipment equipment
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Tracker_OXP n/a
Download URL https://wiki.alioth.net/img_auth.php/8/8c/Tracker-1.05.oxz n/a
License CC BY-NC-SA 3.0 CC BY-NC-SA 3.0
File Size n/a
Upload date 1610873357

Documentation

Also read http://wiki.alioth.net/index.php/Tracker

Readme.txt

Tracker OXP
-----------
v1.05, by Thargoid.

The Ships Systems Department of the Aquarian Shipbuilding Corporation would like to present to you their latest product, the Tracker. An invaluable add-on to the advanced space compass (ASC - which must also be fitted to the ship), it allows the simultaneous tracking of up to five distinct targets anywhere within the current system (or area of interstellar space).

Once purchased, it is selected by using the "shift-n" key, and then activated with the "n" key (under standard keyboard configuration). This will transfer the current target lock (be it an ident-lock or a missile-lock) to the system. It can then be viewed on the ASC by cycling through to the "T" indicator. Note that a target lock is required before the system can track the entity, so cloaked ships and certain other entities cannot be tracked.

The system has capacity to store five lock-ons. To remove an existing lock-on, just repeat the above procedure. If the target docks, lands on a planet/moon, enters witchspace or is destroyed then the lock is also lost.

Available from tech level 9 systems for 2500 credits to Commanders who already have an ASC fitted to their ship.

Requires v1.75 or later of Oolite. It will not run on older versions.


License
-------

This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 (https://creativecommons.org/licenses/by-nc-sa/3.0/)


Version history
---------------

15/03/2012 - Version 1.00
* Initial release.

16/03/2012 - Version 1.01
* Improved model (no dimensions or textures at all) thanks to Ramirez.

16/09/2012 - Version 1.02
* Revised model to with actual but minimal poly-count to stop issues.

01/08/2020 - Version 1.03
* Added collision exception to the tracker and tracked; set tracker's beacon label with tracked name; 
* Don't track telescope markers.

10/08/2020 - Version 1.04
* Disabed tracker beacons while player's ship is docked (so the tracked ships don't show on Station Interfaces (F4) In-system Distances; 
* Logging of tracker's destruction or invalidation; 
* Console messages when trying to track/untrack a target out of range, or without a target.

03/11/2020 - Version 1.05
* Changed messages from console to comms.
* Updated license to remove the "Thargoid clauses" after Thargoid allowed modification when retired from maintaining his OXps (http://aegidian.org/bb/viewtopic.php?f=4&t=17085).

Equipment

Name Visible Cost [deci-credits] Tech-Level
Tracker yes 25000 9+

Ships

Name
Tracker

Models

This expansion declares no models.

Scripts

Path
Config/script.js
this.name           = "tracker_worldScript.js";
this.author         = "Thargoid";
this.copyright      = "Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description    = "World script for the tracker OXP";
this.version        = "1.00";
"use strict";


this.compassTargetChanged = function(whom, mode) {
    if (player.ship.equipmentStatus("EQ_TRACKER") !== "EQUIPMENT_OK" || 
        player.ship.equipmentStatus("EQ_ADVANCED_COMPASS") !== "EQUIPMENT_OK") 
        return; 
    
    if (mode && mode === "COMPASS_MODE_BEACONS" && whom && whom.name === "Tracker")
        if(whom.target) { 
            player.consoleMessage("Tracked entity - " + whom.target.displayName, 5); 
        }
}
    
this.equipmentDamaged = function(equipment) {
    var _taggedShips, i;
    if (equipment === "EQ_TRACKER" || 
       (equipment === "EQ_ADVANCED_COMPASS" && player.ship.equipmentStatus("EQ_TRACKER") === "EQUIPMENT_OK")) {
        _taggedShips = system.shipsWithRole("tracker_beacon");
        i = _taggedShips.length;
        while (i--)
            _taggedShips[i].remove();
    }
}    
Scripts/tracker.js
"use strict";
this.name        = "Tracker";
this.author      = "Dybal";
this.copyright   = "2020 Dybal";
this.license     = "CC BY-NC-SA 4.0";
this.description = "Tracker worldscripts";
this.version     = "1.05";

//-----------------------------------------------------------------------------//
this.shipWillDockWithStation = function _shipWillDockWithStation() {
    var tracker_list = system.shipsWithPrimaryRole("tracker_beacon");
    var t;
    var i = tracker_list.length;
    
    while (i--) {
        t = tracker_list[i];
        if (t && t.isValid && t.script && t.script.$tracked) {
            t.beaconCode = null;
        }
    }
}

//-----------------------------------------------------------------------------//
this.shipLaunchedFromStation = function _shipLaunchedFromStation() {
    var tracker_list = system.shipsWithPrimaryRole("tracker_beacon");
    var t;
    var i = tracker_list.length;
    
    while (i--) {
        t = tracker_list[i];
        if (t && t.isValid && t.script && t.script.$tracked) {
            t.beaconCode = "Tracker:"+t.script.$trackedName;
        }
    }
}
Scripts/tracker_beacon.js
"use strict";
this.name        = "tracker_beacon.js";
this.author      = "Thargoid";
this.copyright   = "CC BY-NC-SA 3.0";
this.description = "Beacon script.";
this.version     = "1.04";

this.$tracked;
this.$trackedName;


//
// Event Handlers
//

//--------------------------------------------------------------------------------------------//
this.shipSpawned = function _shipSpawned() { 
    if (!this.ship || !this.ship.isValid || !this.ship.target) {
        log(this.name, "Incomplete tracker beacon:"+this.ship+(this.ship ? ", "+this.ship.isValid+", "+this.ship.target : ""));
        return;
    }
    log(this.name, "Tracker for "+this.ship.target.displayName+" spawned, adding collision exception and setting up beacon label");
    this.ship.addCollisionException(this.ship.target);
    this.$tracked = this.ship.target;
    this.$trackedName= this.ship.target.displayName;
    this.ship.beaconCode = "Tracker: "+this.$trackedName;
    this.ship.beaconLabel = "Tracker: "+this.$trackedName;
    this.callbackID = addFrameCallback(this.repositionTracker.bind(this)); 
}

//--------------------------------------------------------------------------------------------//
this.shipWillEnterWitchspace = function _shipWillEnterWitchspace() {
    log(this.name, "Tracker for " + this.$trackedName + " entering wormhole");
}

//--------------------------------------------------------------------------------------------//
this.shipDied = function _shipDied(whom, why) { 
    if (why && why === "scrape damage" && whom && this.ship && this.$tracked && whom === this.$tracked) {
        // in cases where the tag does manage to collide with the tracked entity, respawn the tag.
        var Tag = this.ship.spawnOne("tracker_beacon");
        Tag.target = this.$tracked;
        log(this.name, "Tracker for "+this.$trackedName+" collided with ship and was destroyed, creating a new one");
    } else {
        log(this.name, "Tracker for "+this.$trackedName+" was destroyed by '"+whom+"' with '"+why+"'");
    }
}


//
// Internal Functions
//

//--------------------------------------------------------------------------------------------//
this.repositionTracker = function _repositionTracker() {
    if (!this.ship || !this.ship.isValid || !this.$tracked || !this.$tracked.isValid) {
        // something has gone wrong
        if (this.ship && this.ship.isValid)
            // tracker is OK, but the tracked ship is not
            log(this.name, this.$trackedName+" is no more, removing tracker (tracker target:"+this.ship.target+")");
        else if (this.ship)
            // tracker exists but is not valid anymore
            log(this.name, "Tracker for "+this.$trackedName+" is not valid anymore, removing");
        else
            // tracker does not exist anymore but this FCB is still being called
            log(this.name, "Tracker undefined:"+this.ship+", tracked:"+this.$trackedName);
        if (this.callbackID) {
            removeFrameCallback(this.callbackID);
            delete this.callbackID;
        }
        this.ship.remove();
        return;
    }
        
    this.ship.position = this.$tracked.position
}

    
Scripts/tracker_trigger.js
"use strict";
this.name        = "tracker_trigger.js";
this.author      = "Thargoid";
this.copyright   = "CC BY-NC-SA 3.0";
this.description = "Script for setting up the tracker";
this.version     = "1.05";

//-----------------------------------------------------------------------------//
this.activated = function() {
    var _ship = player.ship;

    if (!_ship) return
    if  (!_ship.target) {
        player.commsMessage("No target to track.", 8)
        return;
    }   
    if (_ship.target.dataKey === "telescopemarker") {
        player.commsMessage("Target beyond range to attach/recall tracker.", 8)
        return;
    }
    var _target = _ship.target;
    var _tagArray = system.shipsWithPrimaryRole("tracker_beacon", _target, _target.collisionRadius) 
    // check if the target is already tagged - if so then activation is to remove it
    if (_tagArray.length > 0) {
        log(this.name,"Removing tracker from "+_tagArray[0].target);
        _tagArray[0].remove();
        player.commsMessage("Tracker called back from "+_target.displayName+".", 8);
        return;
    }
    
    if (system.countShipsWithPrimaryRole("tracker_beacon") > 4) {// if there are already 5 active tags in the system
        player.commsMessage("No trackers available.", 8);
        log(this.name, "Already tracking 5 ships:"+system.shipsWithPrimaryRole("tracker_beacon"));
        return;
    }
    
    // if we get this far, we're setting up tracking on the target
    var Tag = _target.spawnOne("tracker_beacon");
    if (!Tag)
        log(this.name, "Couldn't spawn tracker beacon for "+_target.displayName);
    else {
        Tag.target = _target;
        log(this.name, "Created tracker for "+_target.displayName+":"+Tag);
        player.commsMessage("Tracker attached to "+_target.displayName+".", 8);
    }
}