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

Expansion SniperLock

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description SniperLock software allows for more accurate targetting by enabling longer dwell times on targets. SniperLock software allows for more accurate targetting by enabling longer dwell times on targets.
Identifier oolite.oxp.CommonSenseOTB.SniperLock oolite.oxp.CommonSenseOTB.SniperLock
Title SniperLock SniperLock
Category Equipment Equipment
Author CommonSenseOTB CommonSenseOTB
Version 1.0.0 1.0.0
Tags Equipment Equipment
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/SniperLock n/a
Download URL https://wiki.alioth.net/img_auth.php/b/b1/Oolite.oxp.CommonSenseOTB.SniperLock.oxz n/a
License CC BY-NC-SA 3.0 CC BY-NC-SA 3.0
File Size n/a
Upload date 1610873445

Documentation

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

README.md

# SniperLock
SniperLock software allows for  more accurate targeting by enabling longer dwell times on targets.

README.txt

CommonSense 'Outside-the-Box' Design Studios Ltd. is happy to announce the latest design in 
software upgrades for use in all ranges of space vessels. SniperLock software allows for 
more accurate targetting by enabling longer dwell times on targets. The new control system 
will be in effect when the software upgrade known as "SniperLockv1.oxp" is placed in the 
space vessels' computer's AddOns folder. We hope you will find the 500 credit price to be a 
real bargain. Available at all shipyards tech level 12+. Thank you for your patronage. 

THIS OXP IS A PRODUCTION OF COMMONSENSE 'OUTSIDE-THE-BOX' DESIGN STUDIOS LTD.
Author: CommonSenseOTB


USER CUSTOMIZABILITY:

For those with drifting joysticks, disabilities, unnaturally poor aim, and for other reasons, 
you now have the option of adjusting how accurate you have to aim to get a lock, how much 
force you have to apply to the controls to force an unlock, and how long the lock will last.
You may go to the startup function of the sniperlock script and set your own adjusted values.


COMPATIBILITY:
Oolite version 1.75.3 due to CTD frame callback issues in previous oolite versions.
Sniperlock software requires scanner targetting enhancement to be installed to operate.
Can be used with most heads-up-display systems.
Compatible with target tracker.
No dependancies.
					   

Author: CommonSenseOTB(thinking outside-the-box for your playing enjoyment and the improvement of oolite)
Completed: Dec. 17, 2011

SniperLock.oxp.

SniperLock software acts as an intermediary between you and your ship. When you have a great 
shot lined up on your currently selected target, the software temporarily takes micro-control 
over the ships attitude thrusters to keep the ship lined up on target. The override lasts for 
a fraction of a second and provided the pilot continues to aim, the software can then re-lock 
again and again. The pilot may override the lock-on by simply pushing slightly on the pitch 
or yaw controls. The best way to use this software upgrade is not to think about it. Fly and 
aim normally and the system will automatically micro-correct any minor misalignment in your 
aim. Fire a laser burst at the beginning of each lock-on for most effective results.
SniperLock software is not perfect and there may be a slight lag as the target is tracked. 
Sudden evasive movements and fuel injecting by the target may break the lock-on. Also, due to 
liability issues, the software will only initiate lock-on with targets over 5km distant to 
avoid the possibility of collisions.
SniperLock software and control interface works with most other targetting systems and 
heads-up-displays. Any odd behaviour should be reported to the software arm of 
CommonSense 'Outside-the-Box' Design Studios Ltd., of which SniperLock is a wholly owned 
subsidiary.

When you want to keep the bad guys out of arms reach, get SniperLock. Legal in all 8 sectors.


THANX AND RECOGNITION: Okti for the example of basic code to orient the ship contained in his
                       oxp target tracker. I learn best by seeing examples of code that works, 
					   many of which are already being used in my hud concepts. Much thanks.
					   THANK YOU ALL FOR YOUR SUPPORT AND HELP!   -Sincerely, CommonSenseOTB.

ABOUT THIS PRODUCT: SniperLockv1.oxp requires oolite 1.75.3 or better. The frame callbacks used 
                    may occasionally cause a CTD when you die in versions of oolite earlier 
					than 1.75.3.					

TO USE THIS OXP: Unzip and drag or move the SniperLockv1.oxp folder into your addons folder.


License:

This OXP is released under the Creative Commons Attribution - Non-Commercial -
Share Alike 3.0 license with the following clauses:

* Attribution to the author CommonSenseOTB
* Whilst you are free (and encouraged) to re-use any of the scripting in this OXP, the 
  usage must be distinct from that within this OXP. Unique identifiers such as 
  (but not limited to) unique shipdata.plist entity keys, mission variables, script names 
  (this.name), equipment identity strings (EQ_), description list arrays and entity roles 
  must not be re-used without prior agreement. Basically if it's unique or would identify or 
  overwrite anything in the original OXP, then you may not re-use it (for obvious compatibility
  reasons).
* rebundling of this OXP within another distribution is permitted as long as it is unchanged.
  The following derivates however are permitted and except from the above:
  * the conversion of files between XML and openStep.
  * the merging of files with other files of the same type from other OXPs.
* The license information (either as this file or merged into a larger one) must be included 
  in the OXP.
* Even though it is not compulsory, if you are re-using any sizable or recognisable piece of 
  this OXP, please let me know :)

Equipment

Name Visible Cost [deci-credits] Tech-Level
SniperLock Software & Control Interface yes 5000 12+
Sell SniperLock yes 0 12+

Ships

This expansion declares no ships.

Models

This expansion declares no models.

Scripts

Path
Scripts/sniperlock.js
this.name               = "sniperlock";
this.author               = "CommonSenseOTB";
this.copyright            = "Copyright Dec. 17, 2011 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description         = "Sniperlock Script";
this.version            = "1.0";

this.startUp = function()
   {
   // You may toggle the difficulty to lock and unlock, and duration. This has applications for compensating for joysticks that drift slightly, persons with disabilities, and persons who find it difficult to keep a constant aim at a target.
   // It is possible to tweak these to suit your own capability to aim and constantly maintain that aim.
   //
   // The current settings are quite balanced and should not prove too uber.
   //
   // YOU MAY TOUCH THESE
   //
   this.sniperlockdifficultylock = 0.002;// default is 0.002, this determines how accurate you have to aim to get a lock, set lower to make it harder to get a lock, higher to make it easier to get a lock.
   this.sniperlockdifficultyunlock = 0.06;// default is 0.06, this determines how much force you have to apply to the controls to force an unlock and how large a movement the target has to make to break the lock, set lower to make it easier to unlock, higher to make it harder to unlock.
   this.sniperlockduration = 12;// default is 12, this determines how long the lock will last, set lower to make the lock time shorter, higher to make the lock time longer.
   //
   //
   //
   // DO NOT TOUCH THESE PLEASE
   //
   // OXP DEVELOPERS: deactivation switch provided for remote access by other oxps
   //
   this.deactivate = "FALSE";// default is "FALSE", scripters can deactivate this oxp by setting to "TRUE";
   //
   this.sniperlockchangeflag = "OFF";// flag to engage sniperlock control software
   this.sniperlockcounter = 0;//counter to control sniperlock time
   this.sniperlocktargetlastposition1 = "";// aim is 1 frame behind true target position
   this.sniperlocktargetlastposition2 = "";// aim is 2 frames behind true target position
   this.sniperlocktargetlastposition3 = "";// aim is 3 frames behind true target position
   }  

this.playerBoughtEquipment = function(equipmentKey)
   {     
   if(equipmentKey === ("EQ_SNIPERLOCK_REMOVAL"))
      {
      player.ship.removeEquipment("EQ_SNIPERLOCK");
      player.ship.removeEquipment("EQ_SNIPERLOCK_REMOVAL");
      player.credits += 250;
      }
   }
   
this.shipWillLaunchFromStation = function()
   {
   this.sl = addFrameCallback(this.sniperLock.bind(this));//----------   
   }

this.shipDockedWithStation = function()
   {
   removeFrameCallback(this.sl);//----------
   }
   
this.shipWillEnterWitchspace = function()
   {
   removeFrameCallback(this.sl);//----------
   }
   
this.shipExitedWitchspace = function()
   {
   this.sl = addFrameCallback(this.sniperLock.bind(this));//----------   
   }
   
this.sniperLock = function()
   {
   if((!player.ship.target) || (player.ship.equipmentStatus("EQ_SNIPERLOCK") !== "EQUIPMENT_OK") || (player.ship.equipmentStatus("EQ_SCANNER_SHOW_MISSILE_TARGET") !== "EQUIPMENT_OK") || (this.deactivate === "TRUE"))
      {
	  if(this.sniperlockchangeflag !== "OFF")
         {
	     this.sniperlocktargetlastposition1 = "";
	     this.sniperlocktargetlastposition2 = "";
	     this.sniperlocktargetlastposition3 = "";
	     this.sniperlockchangeflag = "OFF";
	     this.sniperlockcounter = 0;
		 return;
	     }
      return;
      }
   if(player.ship.target.isValid)
      {
      this.sniperlocktargetrangevalue = ((player.ship.position.distanceTo(player.ship.target.position) - player.ship.target.collisionRadius) / 1000);
	  }
   else
      {
	  this.sniperlocktargetrangevalue = 0;
	  }
   if((this.sniperlockchangeflag === "READY") && (this.sniperlocktargetrangevalue > 5.0) && (this.sniperlocktargetrangevalue < 25.6))
      {
	  if(player.ship.viewDirection === "VIEW_FORWARD")
	     {
	     let readytv = player.ship.target.position.subtract(player.ship.position).direction();
         let readya = player.ship.heading.angleTo(readytv);
	        {
		    if(readya <= this.sniperlockdifficultylock)
	           {
               this.sniperlocktargetlastposition1 = player.ship.target.position;
               this.sniperlocktargetlastposition2 = player.ship.target.position;
               this.sniperlocktargetlastposition3 = player.ship.target.position;
               this.sniperlockchangeflag = "ON";
			   }
            }
         }
      if(player.ship.viewDirection === "VIEW_AFT")
	     {
	     let readytv = player.ship.target.position.subtract(player.ship.position).direction();
         let readya = player.ship.heading.multiply(-1).angleTo(readytv);
	        {
		    if(readya <= this.sniperlockdifficultylock)
	           {
               this.sniperlocktargetlastposition1 = player.ship.target.position;
               this.sniperlocktargetlastposition2 = player.ship.target.position;
               this.sniperlocktargetlastposition3 = player.ship.target.position;
               this.sniperlockchangeflag = "ON";
			   }
            }
         }
      }
   if((this.sniperlockchangeflag === "ON") && (this.sniperlocktargetrangevalue > 5.0) && (this.sniperlocktargetrangevalue < 25.6))
      {
	  if(player.ship.viewDirection === "VIEW_FORWARD")
	     {
	     this.sniperlockcounter += 1;
	     let disengagetv = player.ship.target.position.subtract(player.ship.position).direction();
         let disengagea = player.ship.heading.angleTo(disengagetv);
		 if((disengagea > this.sniperlockdifficultyunlock) || (this.sniperlockcounter > this.sniperlockduration))
	        {
			this.sniperlocktargetlastposition1 = "";
            this.sniperlocktargetlastposition2 = "";
            this.sniperlocktargetlastposition3 = "";
            this.sniperlockchangeflag = "READY";
			this.sniperlockcounter = 0;
			return;
            }
         let tv = this.sniperlocktargetlastposition3.subtract(player.ship.position).direction();
         let a = player.ship.heading.angleTo(tv);
         let cr = player.ship.heading.cross(tv).direction();
         player.ship.orientation = player.ship.orientation.rotate(cr,-a);
         this.sniperlocktargetlastposition3 = this.sniperlocktargetlastposition2;
         this.sniperlocktargetlastposition2 = this.sniperlocktargetlastposition1;
	     this.sniperlocktargetlastposition1 = player.ship.target.position;
		 }
      if(player.ship.viewDirection === "VIEW_AFT")
	     {
	     this.sniperlockcounter += 1;
	     let disengagetv = player.ship.target.position.subtract(player.ship.position).direction();
         let disengagea = player.ship.heading.multiply(-1).angleTo(disengagetv);
		 if((disengagea > this.sniperlockdifficultyunlock) || (this.sniperlockcounter > this.sniperlockduration))
	        {
			this.sniperlocktargetlastposition1 = "";
            this.sniperlocktargetlastposition2 = "";
            this.sniperlocktargetlastposition3 = "";
            this.sniperlockchangeflag = "READY";
			this.sniperlockcounter = 0;
			return;
            }
         let tv = this.sniperlocktargetlastposition3.subtract(player.ship.position).direction();
         let a = player.ship.heading.multiply(-1).angleTo(tv);
         let cr = player.ship.heading.multiply(-1).cross(tv).direction();
         player.ship.orientation = player.ship.orientation.rotate(cr,-a);
         this.sniperlocktargetlastposition3 = this.sniperlocktargetlastposition2;
         this.sniperlocktargetlastposition2 = this.sniperlocktargetlastposition1;
	     this.sniperlocktargetlastposition1 = player.ship.target.position;
		 }
      }
   if((this.sniperlockchangeflag === "ON") && (this.sniperlocktargetrangevalue <= 5.0))
      {
	  this.sniperlocktargetlastposition1 = "";
      this.sniperlocktargetlastposition2 = "";
      this.sniperlocktargetlastposition3 = "";
      this.sniperlockchangeflag = "READY";
	  this.sniperlockcounter = 0;
      }
   }
   
this.shipTargetAcquired = function()
   {
   if(this.deactivate === "FALSE")
      {
      this.sniperlocktargetlastposition1 = "";
      this.sniperlocktargetlastposition2 = "";
      this.sniperlocktargetlastposition3 = "";
      this.sniperlockchangeflag = "READY";
      this.sniperlockcounter = 0;
	  }
   }

this.shipDied = function()
   {
   removeFrameCallback(this.sl);//----------
   }