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

Expansion Cargo Spotter

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description A piece of equipment which highlights scoopable items in a virtual glow on your visual display. A piece of equipment which highlights scoopable items in a virtual glow on your visual display.
Identifier oolite.oxp.Thargoid.CargoSpotter oolite.oxp.Thargoid.CargoSpotter
Title Cargo Spotter Cargo Spotter
Category Equipment Equipment
Author Thargoid Thargoid
Version 1.1 1.1
Tags equipment equipment
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Cargo_Spotter_OXP n/a
Download URL https://wiki.alioth.net/img_auth.php/8/88/CargoSpotter-1.1.oxz n/a
License Creative Commons Attribution - Non-Commercial - Share Alike 3.0 Creative Commons Attribution - Non-Commercial - Share Alike 3.0
File Size n/a
Upload date 1610873354

Documentation

Also read http://wiki.alioth.net/index.php/Cargo%20Spotter

Readme.txt

Cargo Spotter OXP
-----------------
by Thargoid

A little OXP, which adds a new piece of equipment for any scavenger, miner or bounty hunter. As small scoopable items like cargo pods, splinters and escape pods can often be difficult to see, this addition to the ships HUD overlays them with a virtual flashing glow. Thus they are easier to spot from a distance and home in on.

The update costs 300 credits, and should be available in systems of tech level 12 or higher.

This OXP uses Cim's new visual effects class. Thus it requires Oolite version 1.77 or above to work.


License
-------

This OXP is released under the Creative Commons Attribution - Non-Commercial - Share Alike 3.0 license.


Version history
---------------
v1.00 (08/01/2013)
* First release

v1.01 (26/02/2013)
* Minor script tweak to add missing $ (thanks to UK_Eliter for the notification).

v1.1 (Oct/2020)
* Changes equipment from primeable to always active (to reduce the chain of primeable equipments).
* Updates 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
Cargo Spotter yes 3000 12+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/cargoSpotter_glow.js
"use strict";
this.name        = "cargoSpotter_glow.js";
this.author      = "Thargoid";
this.copyright   = "CC BY-NC-SA 3.0";
this.description = "Glow script.";
this.version     = "1.1";

//------------------------------------------------------------------------------------//
this.effectSpawned = function _cspotter_effectSpawned() { 
    if (!this.visualEffect) return;
    this.callbackID = addFrameCallback(this.$positionGlow.bind(this)); 
}

//------------------------------------------------------------------------------------//
this.effectRemoved = function _cspotter_effectRemoved() {
    if(this.callbackID)  removeFrameCallback(this.callbackID); 
    delete this.callbackID;
}   

//------------------------------------------------------------------------------------//
this.$positionGlow = function _cspotter_positionGlow() {
    if (missionVariables.cargoSpotter !== "ACTIVE" || !this.visualEffect || !this.visualEffect.isValid
        || !this.visualEffect.hasOwnProperty("$cargoSpotter_cargoEntity") || !this.visualEffect.$cargoSpotter_cargoEntity.isInSpace
        || !player.ship || !player.ship.isValid || this.visualEffect.position.distanceTo(player.ship.position) > 25600) { 

            delete this.visualEffect.$cargoSpotter_cargoEntity.$cargoSpotter_tagged;
            this.visualEffect.remove();
            return;
    }
    this.visualEffect.position = this.visualEffect.$cargoSpotter_cargoEntity.position;
}
Scripts/cargoSpotter_worldScript.js
"use strict";
this.name        = "cargoSpotter_worldScript.js";
this.author      = "Thargoid";
this.copyright   = "CC BY-NC-SA 3.0";
this.description = "Script for Cargo Spotter";
this.version     = "1.1";

//
// Event Handlers
//

//-----------------------------------------------------------------------------------//
this.startUp = this.shipLaunchedFromStation = this.shipExitedWitchspace = function _cspotter_start() { 
    if (player.ship.equipmentStatus("EQ_CARGOSPOTTER") === "EQUIPMENT_OK") {
        missionVariables.cargoSpotter = "ACTIVE"; 
        this.$startTimer();
    } else 
        missionVariables.cargoSpotter = "INACTIVE";
}

//-----------------------------------------------------------------------------------//
this.shipDied = this.shipDockedWithStation = this.shipWillEnterWitchspace = this.$stopTimer = function _cspotter_stopTimer() {
    missionVariables.cargoSpotter = "INACTIVE";
    if (this.scanTimer && this.scanTimer.isRunning) {
        this.scanTimer.stop();  
        delete this.scanTimer;
    }
}

//-----------------------------------------------------------------------------------//
this.equipmentDamaged = function _cspotter_equipmentDamaged(equipment) {
    if(equipment === "EQ_CARGOSPOTTER")  { 
        missionVariables.cargoSpotter = "INACTIVE";
        this.$stopTimer(); 
    }
}    

//
// Internal functions
//

//-----------------------------------------------------------------------------------//
this.$startTimer = function _cspotter_startTimer() { 
    if (!this.scanTimer)
        this.scanTimer = new Timer(this, this.$findCargo, 0, 1)
    else
        this.scanTimer.start();
}
    
//-----------------------------------------------------------------------------------//
this.$findCargo = function _cspotter_findCargo() { // cargo pods, alloys, boulders/splinters && uncontrolled thargons
    function _cspotter_targetCargo(entity) { 
        return (    entity.isShip && 
                    (entity.isCargo || entity.isBoulder || (entity.hasRole("thargon") && entity.AI === "dumbAI.plist") ) && 
                    entity.isInSpace && !entity.hasOwnProperty("$cargoSpotter_tagged")); 
    }

    var cargoArray = system.filteredEntities(this, _cspotter_targetCargo, player.ship, 25600); 
    if (cargoArray.length === 0) return;
    
    var i = cargoArray.length;
    var c;
    while (i--) {
        c = cargoArray[i];
        c.$cargoSpotter_tagged = true;
        this.glowKey = "cargoSpotter_blueGlow"; // default highlight glow for cargopods & alloys
        if (c.hasRole("thargon")) this.glowKey = "cargoSpotter_greenGlow";  // highlight inactive thargons in green
        if (c.isBoulder || c.hasRole("splinter")) this.glowKey = "cargoSpotter_grayGlow";  // highlight rocks in grey
        if (c.hasRole("escape-capsule")) this.glowKey = "cargoSpotter_redGlow";  // highlight escape pods in red            
        this.glow = system.addVisualEffect(this.glowKey, c.position);
        this.glow.$cargoSpotter_cargoEntity = c;
    }
}