Back to Index | Page generated: Nov 12, 2024, 11:02:04 PM |
from Expansion Manager's OXP list | from Expansion Manifest | |
---|---|---|
Description | Once the equipment is purchased, the cross-hairs change shape to alert the pilot to the precise moment a target is centred. Please use responsibly - Wildefire Systems does not endorse or condone hostility between spacefarers. The equipment can be bought at space ports with a technological level of 11 or above, for 1750 credits. | Once the equipment is purchased, the cross-hairs change shape to alert the pilot to the precise moment a target is centred. Please use responsibly - Wildefire Systems does not endorse or condone hostility between spacefarers. The equipment can be bought at space ports with a technological level of 11 or above, for 1750 credits. |
Identifier | oolite.oxp.Wildeblood.AutoCrosshairs | oolite.oxp.Wildeblood.AutoCrosshairs |
Title | Auto Crosshairs | Auto Crosshairs |
Category | Equipment | Equipment |
Author | Wildeblood | Wildeblood |
Version | 1.1.1 | 1.1.1 |
Tags | crosshairs | crosshairs |
Required Oolite Version | ||
Maximum Oolite Version | ||
Required Expansions | ||
Optional Expansions | ||
Conflict Expansions | ||
Information URL | http://wiki.alioth.net/index.php/Auto_Crosshairs | n/a |
Download URL | https://wiki.alioth.net/img_auth.php/5/5a/AutoCrosshairs_1.1.1.oxz | AutoCrosshairs_1.1.1.oxz |
License | ||
File Size | n/a | |
Upload date | 1610873303 |
Also read http://wiki.alioth.net/index.php/Auto%20Crosshairs
------------------------------ Auto Crosshairs OXP ver. 1.1.1 ------------------------------ Date: October 5th, 2014 Author: Wildeblood --------------------- Installation and use: --------------------- This OXP adds an equipment item which changes the way the gun-sight cross-hairs behave in Oolite. In standard Oolite the cross-hairs are static, and only differ in appearance depending on the type of weapons installed. With this OXP installed, once the equipment (the Wildefire Systems Type 4 Gunsight) is purchased, the cross-hairs change shape to alert the pilot to the precise moment a target is centred. Please use responsibly - Wildefire Systems does not endorse or condone hostility between spacefarers. Simply place the Auto Crosshairs OXP into your "AddOns" folder. The equipment can be bought at space ports with a technological level of 11 or above, for 1750 credits. Only usable with Oolite 1.77 or later. No configuration is needed or normally possible. For players who can't resist tinkering inside OXPs, there is a parameter at the top of the javascript file (this.$precision = 2; // Whole number 1-5), you could experiment with. ---------------------------------- Customizing the cross-hair design: ---------------------------------- To use a different cross-hairs file to the included one there is no need to modify this OXP; Auto Crosshairs can automatically detect and use patches for it in other OXPs. Create a file with the design of cross-hairs you want to use when on target. In any world script (script.js file): this.name = "Any name will work"; this.version = "1.0"; Define an object called $autoCrosshairs, and within it an object with the same name as your HUD file: this.$autoCrosshairs = {}; this.$autoCrosshairs["hud.plist"] = {}; Then define two properties called off and on with the names of the cross-hair files you want to use when the target is off-centre or on-centre: this.$autoCrosshairs["hud.plist"].off = "crosshairs.plist"; this.$autoCrosshairs["hud.plist"].on = "my_fancy_on_target_crosshairs.plist"; You can declare the whole $autoCrosshairs object simply like this:- this.$autoCrosshairs = { "hud.plist": { off: "crosshairs.plist", on: "my_fancy_on_target_crosshairs.plist" } } That example will associate your fancy on-target crosshairs with the default HUD and crosshairs. You can also associate crosshair files with a specific HUD file, e.g.: this.$autoCrosshairs = { "coluber_hud_ch01.plist": { off: "coluber_hud_ch01_off_target_crosshairs.plist", on: "coluber_hud_ch01_on_target_crosshairs.plist" } } It does not matter whether these patches for Auto Crosshairs are in the same OXP as their associated HUD or another OXP. ----------- Change Log: ----------- 1.1.1 (October 5th, 2014) Discard HUD settings if HUD file changes. 1.1 (October 2nd, 2014) Same as version 1.0.88. 1.0.88 (October 2nd, 2014) Ver 1.1 beta: because a crosshair reset causes a HUD reset, this now saves and routinely restores reticleTargetSensitive, scannerNonLinear, and scannerUltraZoom settings. (I think this is wrong, but the commoonity seem to think it is right. Too bad if another script is actually trying to change these settings on the fly.) A backup copy of the version 1.0.77 script remains inside. 1.0.77 (October 1st, 2014) Ver 1.1 beta: enhanced patchability. 1.0.66 (September 30th, 2014) Ver 1.1 beta: automatically detects patch files at start-up. 1.0.5 (September 29th, 2014) Bug fix: check that on-target crosshairs file isn't accidentally recorded as off-target file. 1.0.4 (May 23rd, 2013) Bug introduced in 1.0.3 fixed, and new on-target cross-hair design. 1.0.3 (May 22nd, 2013) Added alternative cross-hair for mining laser. 1.0.2 (May 20th, 2013) Better compatibility with other cross-hair switching OXPs. 1.0.1 (May 20th, 2013) Bug fix: stop frame callback if equipment is damaged. 1.0 (May 20th, 2013) First published.
Name | Visible | Cost [deci-credits] | Tech-Level |
---|---|---|---|
Auto Crosshairs | yes | 17500 | 11+ |
Path | |
---|---|
Config/script.js | "use strict"; this.name = "Auto Crosshairs"; this.version = "1.1.1"; /* ==================================================================================== OTHER SCRIPTS CAN SAFELY TWIDDLE THIS AT ANY TIME... ======================================================================================= */ this.$precision = 2; // Whole number 1-5 /* ==================================================================================== STARTING & STOPPING FRAME CALLBACK ======================================================================================= */ this.shipTargetAcquired = function (target) { "use strict"; if (player.ship.equipmentStatus("EQ_AUTO_CROSSHAIRS") === "EQUIPMENT_OK") { if (this.$crosshairs[player.ship.hud]) { this.$onTargetCrosshairs = this.$crosshairs[player.ship.hud].on; this.$offTargetCrosshairs = this.$crosshairs[player.ship.hud].off; } else { this.$onTargetCrosshairs = this.$crosshairs.default.on; this.$offTargetCrosshairs = this.$crosshairs.default.off; // if (player.ship.crosshairs != this.$onTargetCrosshairs) { // this.$offTargetCrosshairs = player.ship.crosshairs; // } } if (this.$offTargetCrosshairs === null) { this.$ooliteQuirk = [ player.ship.hud, player.ship.reticleTargetSensitive, player.ship.scannerNonLinear, player.ship.scannerUltraZoom ]; } this.$runningFCB = addFrameCallback(this._targetAlert.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._removeFCB(); } this.equipmentDamaged = this.equipmentDestroyed = function (equipment) { "use strict"; if (equipment === "EQ_AUTO_CROSSHAIRS") { this._removeFCB(); } } this._removeFCB = function () { "use strict"; if (this.$runningFCB) { removeFrameCallback(this.$runningFCB); delete this.$runningFCB; delete this.$currentState; player.ship.crosshairs = this.$offTargetCrosshairs; if (this.$ooliteQuirk) { this._ooliteQuirk(); delete this.$ooliteQuirk; } } } /* ==================================================================================== TARGET SENSITIVITY (FRAME CALLBACK) ======================================================================================= */ this._targetAlert = function () { "use strict"; var self = player.ship; if (self.target) { var target = self.target; var range = target.position.distanceTo(self.position) - target.collisionRadius; var deviation; switch (self.viewDirection) { case "VIEW_FORWARD": deviation = self.vectorForward.angleTo(target.position.subtract(self.position)) * range; break; case "VIEW_AFT": deviation = self.vectorForward.angleTo(self.position.subtract(target.position)) * range; break; case "VIEW_PORT": deviation = self.vectorRight.angleTo(self.position.subtract(target.position)) * range; break; case "VIEW_STARBOARD": deviation = self.vectorRight.angleTo(target.position.subtract(self.position)) * range; break; default: deviation = self.vectorForward.angleTo(target.position.subtract(self.position)) * range; // forward } if (deviation < target.collisionRadius / this.$precision) { if (this.$currentState === "ON_TARGET") { return; } player.ship.crosshairs = this.$onTargetCrosshairs; this.$currentState = "ON_TARGET"; return; } else { if (this.$currentState === "OFF_TARGET") { return; } player.ship.crosshairs = this.$offTargetCrosshairs; if (this.$ooliteQuirk) { this._ooliteQuirk(); } this.$currentState = "OFF_TARGET"; return; } } else { // If player.ship.target is gone. this._removeFCB(); } } /* ==================================================================================== SCAN FOR SPECIAL HUDs AT STARTUP... ======================================================================================= */ this.startUpComplete = function () { "use strict"; if (!this.$crosshairs) { this.$crosshairs = {default: {off: null, on: "auto-crosshairs-on-target.plist"}}; } var scriptName; var arrayLength = worldScriptNames.length; for (var i = 0; i < arrayLength; i++) { scriptName = worldScriptNames[i]; if (worldScripts[scriptName].$autoCrosshairs) { var definition = worldScripts[scriptName].$autoCrosshairs; for (prop in definition) { this.$crosshairs[prop] = {}; this.$crosshairs[prop].off = definition[prop].off; this.$crosshairs[prop].on = definition[prop].on; } } } delete this.startUpComplete; } /* ==================================================================================== 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. ======================================================================================= */ |