Back to Index Page generated: Dec 20, 2024, 7:22:09 AM

Expansion Waypoint Here

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Allows you to set up to 8 waypoints to mark your current location so you can find your way back there later. Does not use any missile pylons. Allows you to set up to 8 waypoints to mark your current location so you can find your way back there later. Does not use any missile pylons.
Identifier oolite.oxp.Neelix.WaypointHere oolite.oxp.Neelix.WaypointHere
Title Waypoint Here Waypoint Here
Category Equipment Equipment
Author Neelix Neelix
Version 0.8 0.8
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/Waypoint_Here n/a
Download URL https://wiki.alioth.net/img_auth.php/7/72/WaypointHere.oxz n/a
License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
File Size n/a
Upload date 1610873335

Documentation

Also read http://wiki.alioth.net/index.php/Waypoint%20Here

readme.txt

Waypoint Here
By Neelix and phkb

Overview
========
Want to be able to find your way back to a specific location within a system without leaving behind an expensive piece of equipment that uses up a valuable missile pylon and could be damaged or scooped before you get back? The latest advances in HUD technology allow Talaxian Enterprises to offer a solution.

Waypoint here is a software upgrade for your Advanced Space Compass.  It allows you to set up to eight waypoints, anywhere in the system. If your HUD is configured to display waypoints these will be visible on-screen, with a range indicator.

Usage
=====
To use Waypoint Here functions, you'll need to first prime it with 'Shift-N'.
To add a waypoint at your current location, press 'n'. Your position and orientation will be recorded and one of 8 ASC beacons will be assigned.
To clear a waypoint, select the waypoint you want to remove on the ASC and press 'b'.

Details
=======
* Tech Level: 10
* Price 2500Cr

There are 8 available beacons, called Alpha, Bravo, Charlie, Delta, Echo, Foxtrot, Golf and Hotel. When you add a new waypoint through Waypoint Here the first available beacon will be used.  The symbol on the ASC will be the first letter of the beacon name.

As with other methods of marking a specific locations the waypoints are cleared when you leave the system. Waypoints are not currently saved, so if you save and reload the game any Waypoint Here waypoints you had set will be lost.

Being a software upgrade, Waypoint Here cannot itself take damage in combat. It will however stop working if the ASC is damaged.

If the waypoints do not show up on your screen you may need to adjust your HUD settings to include a drawWaypoints dial or switch to a HUD that already includes it. This dial was introduced in Oolite version 1.79 so older HUDs probably won't include it unless they have been recently updated.

Requirements
============
This OXP needs Oolite v1.80.

Licence/Author
==============
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.

Version History
===============
0.8
- Better handling of ejecting in interstellar space.

0.7
- Bug fixes.

0.6
- Auto-deployment of waypoint in interstellar space now dependant on having the Waypoint Here equipment item installed.

0.5
- Added a auto-deployment of a waypoint at the witchspace entry point when entering interstellar space.

0.4
- Corrected flagging set for debugging. Directional helpers should now appear in interstellar space.

0.3
- Increased the number of deployable beacons from 5 to 8.
- Added an MFD window which displays the first 9 waypoints defined in the current system.
- If a waypoint is deployed in Interstellar space, the MFD will include basic directional markers to aid in finding the waypoint again, as the Advanced Space Compass is deactivated when in Interstellar space.
- Added "readme.txt" file to package.

0.2 
- Fixed issue with waypoints not resetting after a hyperspace jump.

0.1
- Initial Release

Equipment

Name Visible Cost [deci-credits] Tech-Level
Waypoint Here yes 25000 10+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/waypoint_here_eq.js
"use strict";
this.author			= "Neelix"; 
this.copyright		= "© 2014 Neelix."; 
this.licence		= "CC-BY-NC-SA 4.0";
this.name			= "tlxn_waypointHere_eq";
this.description	= "Waypoint Here Equipment Script";

// setup internal waypoint identifiers
this.$wph_waypoints = [
	{key: "wph_alpha", wname: "Waypoint Alpha", code: "A", wpset: false},
	{key: "wph_bravo", wname: "Waypoint Bravo", code: "B", wpset: false},
	{key: "wph_charlie", wname: "Waypoint Charlie", code: "C", wpset: false},
	{key: "wph_delta", wname: "Waypoint Delta", code: "D", wpset: false},
	{key: "wph_echo", wname: "Waypoint Echo", code: "E", wpset: false},
	{key: "wph_foxtrot", wname: "Waypoint Foxtrot", code: "F", wpset: false},
	{key: "wph_golf", wname: "Waypoint Golf", code: "G", wpset: false},
	{key: "wph_hotel", wname: "Waypoint Hotel", code: "H", wpset: false},
];


// Add waypoint at current location
this.activated = function() {
	var wph = worldScripts["tlxn_waypointHere_eq"];
	// look for an unused waypoint identifier
	for (var i = 0; i < wph.$wph_waypoints.length; i++) {
		if (!wph.$wph_waypoints[i].wpset) {
			//unused identifier found - use it and exit function
			system.setWaypoint(
				wph.$wph_waypoints[i].key, player.ship.position, player.ship.orientation,
				{size: 100, beaconCode: wph.$wph_waypoints[i].code, beaconLabel: wph.$wph_waypoints[i].wname}
			);
			wph.$wph_waypoints[i].wpset = true;
			player.consoleMessage(wph.$wph_waypoints[i].wname + " set.", 5);
			worldScripts.Waypoint_Here_MFD.$updateWaypointMFD();
			return;
		}
	}
	//if we get this far then all waypoint identifiers are in use.
	player.consoleMessage("Waypoint Here Memory Full. Please clear a waypoint before attempting to set another",5);
}

// Clear waypoint currently selected on ASC
this.mode = function() {
	var $ct = player.ship.compassTarget;
	var $sw = system.waypoints;
	var wph = worldScripts["tlxn_waypointHere_eq"];
	
	// check position of each waypoint against the postion of the compass target
	for (var i = 0; i < wph.$wph_waypoints.length; i ++) {
		if ($ct && $sw && $sw[wph.$wph_waypoints[i].key] && $ct.position.distanceTo($sw[wph.$wph_waypoints[i].key].position) == 0) {
			//match found - clear the waypoint and exit function
			system.setWaypoint(wph.$wph_waypoints[i].key);
			wph.$wph_waypoints[i].wpset = false;
			player.consoleMessage(wph.$wph_waypoints[i].wname + " cleared",5);
			worldScripts.Waypoint_Here_MFD.$updateWaypointMFD();
			return;
		}
	}
	//if we get this far the compass target did not match one of our waypoints
	player.consoleMessage("No waypoint selected");
}

// reset waypoints on entering a new system
this.shipWillExitWitchspace = function() {
	var wph = worldScripts["tlxn_waypointHere_eq"];
	for (var i = 0; i < wph.$wph_waypoints.length; i ++) {
		if (wph.$wph_waypoints[i].wpset === true) {
			wph.$wph_waypoints[i].wpset = false;
		}
	}	
}

this.shipExitedWitchspace = function() {
	if (system.isInterstellarSpace === true && player.ship.equipmentStatus("EQ_WPH_ASC_UPGRADE") === "EQUIPMENT_OK") {
		// auto-deploy a waypoint at 0, 0, 0
		var wph = worldScripts["tlxn_waypointHere_eq"];
		// always use the "Alpha" waypoint - it should always be free whenever we first arrive in a system
		system.setWaypoint(
			wph.$wph_waypoints[0].key, [0, 0, 0], player.ship.orientation,
			{size: 100, beaconCode: wph.$wph_waypoints[0].code, beaconLabel: wph.$wph_waypoints[0].wname}
		);
		wph.$wph_waypoints[0].wpset = true;
		worldScripts.Waypoint_Here_MFD.$updateWaypointMFD();
		player.consoleMessage("Auto-deploying waypoint for witchspace exit point", 5);
	}
}
Scripts/waypoint_here_mfd.js
"use strict";
this.author			= "phkb"; 
this.copyright		= "© 2017 phkb"; 
this.licence		= "CC-BY-NC-SA 4.0";
this.name			= "Waypoint_Here_MFD";
this.description	= "Waypoint Here MFD Script";

//-------------------------------------------------------------------------------------------------------------
this.startUpComplete = function() {
	// add interface to HUD selector
	var h = worldScripts.hudselector;
	if (h) h.$HUDSelectorAddMFD(this.name, this.name);
	h = null;
}

//-------------------------------------------------------------------------------------------------------------
this.shipWillLaunchFromStation = function(station) {
    // only start the waypoint timer if we have the equipment installed
    if (player.ship.equipmentStatus("EQ_WPH_ASC_UPGRADE") === "EQUIPMENT_OK")
        this._updateWaypointMFD = new Timer(this, this.$updateWaypointMFD, 5, 0.5);
}

//-------------------------------------------------------------------------------------------------------------
this.shipDied = function(whom, why) {
	this.$stopTimer();
}

//-------------------------------------------------------------------------------------------------------------
this.shipWillDockWithStation = function(station) {
    this.$stopTimer();
}

//-------------------------------------------------------------------------------------------------------------
this.$stopTimer = function() {
    if (this._updateWaypointMFD && this._updateWaypointMFD.isRunning) this._updateWaypointMFD.stop();
}

//-------------------------------------------------------------------------------------------------------------
// updates the text of the damage report MFD
this.$updateWaypointMFD = function $updateWaypointMFD() {
    var p = player.ship;
    var output = "SYSTEM WAYPOINTS:\n";
    var keys = [];
    if (system.waypoints) keys = Object.keys(system.waypoints);
    if (keys.length === 0) {
        output += "\n  No waypoints set";
    } else {
        for (var i = 0; i < keys.length; i++) {
            if (i > 8) break;
			var wp = system.waypoints[keys[i]];
            output += this.$padTextRight(
				(p.compassTarget && p.compassTarget == wp ? "•" : "") + 
				(wp.beaconLabel !== "" ? wp.beaconLabel : "(Unlabelled)"), 
				(system.isInterstellarSpace === true ? 7.5 : 8.5)
				) +	(wp.position.distanceTo(p) / 1000).toFixed(1) + "kms";
			// give the player some waypoint direction information in interstellar space
			// because the space compass doesn't work
			if (system.isInterstellarSpace === true && p && p.vectorForward) {
				var f_dev = p.vectorForward.angleTo(wp.position.subtract(p));
				var r_dev = p.vectorRight.angleTo(wp.position.subtract(p));
				var u_dev = p.vectorUp.angleTo(wp.position.subtract(p));
				var s = "";
				// > 1.56 means oppposite side (3.12 exact opposite)
				// so, f_dev < 0.01, r_dev = 1.57, u_dev = 1.57  -- aligned
				if (f_dev < 0.25) {
					if (f_dev < 0.25) s = "O";
					if (f_dev < 0.12) s = "o";
					if (f_dev < 0.05) s = "X";
				}
				if (f_dev >= 0.25) {
					if (r_dev > 1.69) {
						s += "<";
					}
					if (u_dev < 1.45) {
						s += "^";
					} else if(u_dev > 1.69) {
						s += "v";
					}
					if (r_dev < 1.45) {
						s += ">";
					}
					if (f_dev > 1.57) s+= "A";
				}
				output += "  " + s;
			}
			output += "\n";
        }
    }
	// set the text in the MFD
	p.setMultiFunctionText(this.name, output, false);
}

//-------------------------------------------------------------------------------------------------------------
// appends space to currentText to the specified length in 'em'
this.$padTextRight = function(currentText, desiredLength, leftSwitch) {
	if (currentText == null) currentText = "";
	var hairSpace = String.fromCharCode(31);
	var ellip = "…";
	var currentLength = defaultFont.measureString(currentText.toString().replace(/%%/g, "%"));
	var hairSpaceLength = defaultFont.measureString(hairSpace);
	// calculate number needed to fill remaining length
	var padsNeeded = Math.floor((desiredLength - currentLength) / hairSpaceLength);
	if (padsNeeded < 1)	{
		// text is too long for column, so start pulling characters off
		var tmp = currentText;
		do {
			tmp = tmp.substring(0, tmp.length - 2) + ellip;
			if (tmp == ellip) break;
		} while (defaultFont.measureString(tmp.replace(/%%/g, "%")) > desiredLength);
		currentLength = defaultFont.measureString(tmp);
		padsNeeded = Math.floor((desiredLength - currentLength) / hairSpaceLength);
		currentText = tmp;
	}
	// quick way of generating a repeated string of that number
	if (!leftSwitch || leftSwitch == false) {
		return currentText + new Array(padsNeeded).join(hairSpace);
	} else {
		return new Array(padsNeeded).join(hairSpace) + currentText;
	}
}