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

Expansion CustomShields

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Shield flasher and damage effects, forward/aft shield simulation for the NPCs. Shield flasher and damage effects, forward/aft shield simulation for the NPCs.
Identifier oolite.oxp.CommonSenseOTB.CustomShields oolite.oxp.CommonSenseOTB.CustomShields
Title CustomShields CustomShields
Category Ambience Ambience
Author CommonSenseOTB CommonSenseOTB
Version 0.83 0.83
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL http://wiki.alioth.net/index.php/CustomShields n/a
Download URL https://wiki.alioth.net/img_auth.php/e/e0/CustomShields_0.83.oxz n/a
License CC BY-NC-SA 3 with clauses, see in the readme.txt CC BY-NC-SA 3 with clauses, see in the readme.txt
File Size n/a
Upload date 1610873489

Documentation

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

CustomShieldsv0.83 Readme.txt

CommonSense 'Outside-the-Box' Design Studios Ltd. is happy to bring you the long awaited 
realization of shield flasher and damage effects to Oolite. As well, in this oxp is the 
first realistic forward/aft shield simulation for the npcs that works nearly identical 
to that found on the players own ship and which offers a new mix of balance and strategy 
to player ship combat, dogfighting in particular. The oxp is customizable for both game 
effects and mechanics. Compatibility and balance with other oxps is therefore insured. 
Have it your way and enjoy.

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



USER CUSTOMIZABILITY:

You have the option of going to the startUp function of the customshields script
and setting the defaults to fit with your type of game.

this.customshieldsshieldtype = "advanced";//choices: "basic" , "advanced" , "off"

   -referring to npcs, the current default is advanced which is a simulation of the player's 
    forward/aft shield setup. While a touch more difficult to destroy basic ships, it is 
	actually easier to destroy the tough ships when you fly smart and concentrate your fire 
	on one of the two shields. Overall a very balanced simulation that even lets npcs use 
	shield equalizers and capacitors and shield cyclers if those oxps are installed as well.
	
   -basic is just the effects and no game mechanic changes. The npc's energy level is used to 
    determine the shield effects and if a damage effect is displayed. This is provided just 
	for mission compatibility reasons if you find advanced is too difficult and it may be 
	too difficult if you are not able to target a ships weakest shield consistantly.
	
   -off is just that, off. No shield effects or damage effects for most npcs. The effects 
    from inside the player ship of having your shields or unshielded hull hit will still be 
	in effect.
	
this.customshieldsshieldtypethargoid = "basic";//choices: "basic" , "off"

   -referring to thargoids, the current default is basic, which is just the effects and 
    no game mechanic changes. The thargoid's energy level is used to determine the shield 
	effects displayed. Thargoids are already quite tough and while they don't have the 
	same technology as other vessels, it seems reasonable that some kind of shielding 
	energy is involved. In addition, it would be difficult sometimes to determine which 
	side of a warship is forward or aft so for now only a basic effects mode is available. 
	The shields color changes all the way down the color scale until destruction 
	with no damage effects, for now at least.
	
   -off is just that, off. No shield effects for thargoids.
   
this.customshieldsshieldcolor = "multicolor";//choices: "multicolor" , "blue" , "pink"(haha!)

   -referring to the color or style of shields for the player and most npcs, the current 
    default is multicolor. The color of shield and shield penetration effects goes down the 
	scale from blue to green to yellow to orange to red just before shield collapse.
	
   -blue uses bright blues for full shields to barely visible blue when the shields are near 
    collapse. Shield penetration colors are still the same as in multicolor, from blue to 
	red.
	
   -pink uses bright pink for full shields to barely visible pink when the shields are near 
    collapse. Shield penetration colors go from yellow to orange. Together it reminds me of 
	bubblegum or strawberries, bananas and oranges whipped up into some kind of shield 
	smoothee. I was just messing around but girlies or kids or those young at heart with a 
	fun attitude might like it, hehe!
	
this.customshieldsshieldcolorthargoid = "green";//choices: "green"

   -referring to the color or style of shields for thargoids, the current default is 
    green. The color of shield is green and uses bright green for full shields to barely 
	visible green when the shields are near collapse and shield penetration effects go 
	down the scale from green to yellow to orange to red just before the shield collapses 
	and the ship is destroyed. This is currently the only option for thargoid shield color.

this.customshieldsdamageeffects = "damage";//choices: "damage" , "blownpanels" , "sparks" , "off"

   -referring to the type of damage effects allowed, the current default is damage which is 
    a small chance that an unshielded hit will cause a hull breach with some type of specific 
	damage to equipment or ship and is quite serious, perhaps even more so than random damage 
	to cargo and equipment occasionally caused by an unshielded hit, and this applies 
	equally to players and npcs alike. There is currently only one type of damage caused by a 
	hull breach, a fuel leak with a visual effect of the fuel leaking that is scoopable by 
	player and npc alike. There will be more types of damage in a future version. This 
	selection also includes the cosmetic damage effects sparks and blownpanels to be in 
	effect also.
	
   -blownpanels will on the occasional unshielded hit cause a scarred alloy panel to be blown off 
    of the attacked vessel amidst a shower of sparks. These may be scooped the same as any 
	alloy panel. As they are debris and smoldering at the corner, they will disintegrate after 
	a period of time. It is cosmetic damage only. This selection also includes the cosmetic 
	damage effect sparks to be in effect also.
	
   -sparks will on the majority of unshielded hits cause an eruption of sparks from the 
    hit location on the attacked vessel. It is cosmetic damage only.

   -off is just that, off. No real or cosmetic damage will be added as a result of unshielded 
    hits to either the player or the npc.

this.customshieldsmissilemineexplosioneffects = "on";//choices: "on" , "off" 

   -referring to explosion effects for missiles or mines, the current default is on which 
    causes an enhanced explosion effect to appear when a missile or mine explodes.

   -off is just that, off. Additional explosion effects will not appear when a missile or 
    mine explodes.   
	
These are currently the only available options but should allow most players to tweek both 
eye candy and game mechanics to suit individual needs and playstyles.



COMPATIBILITY:
Oolite version 1.76+
Future versions for 1.77 will take advantage of many new features.
Advanced shield mode can utilize shieldequalizer+capacitors.oxp and shieldcycler.oxp for npcs.
Not compatible with NPC shields.oxp as they will probably conflict.
Uses the existing scriptinfo npcshields = "no" for compatibility with oxps that use it.
SHADERS CAPABLE COMPUTER NOT NEEDED-->works with ALL computers, uses flashers, NOT shaders.
No dependancies.

					   
Changelog:
version 0.81-removed zero poly marker and replaced with a regular poly model
            -script tweaks related to the regular model compatibility
			-selectability for damage effects added
			-selectability for missile and mine explosion effects added
			-attempts to squash the whom is null error, mostly resolved, still a few errors

version 0.82-one poly model now in use for the markers with a small black texture
            -a few script tweaks to try to ensure most markers aren't destroyed prematurely
			-changes on shipTakingDamage routines to eliminate whom is null and also the-->
			-variable speedcollisionradiusadjustment added to prevent shield 
			 flashers from colliding with ship while under injector power
			-transferred velocity to missile/mine explosion effects and adjusted effect size
			-made standard one poly model really small to eliminate core game white explosion
             flare to restore sparks to just like it was before and added larger models for 
			 a white flare effect for blown panels and damage
            -added velocity for blown panels and the accompanying sparks as they are blown off 
			 the hull in the direction of the impact

version 0.83-blown panels redone as a separate scripted cargo entity to resolve many issues
            -shield effects now work for the victim of any cloaked attacker, including the player
			 
Author: CommonSenseOTB(thinking outside-the-box for your playing enjoyment and the improvement of oolite)
Completed: Sept. 10, 2012 first release of version 0.8
CustomShieldsv083.oxp is the current version released Sept. 24, 2012.



Shield flasher effects at last!!!

A brainstorm happened to me in the first week of august and after taking a modified NPCshields.oxp 
and attaching some code as a test I realized that it would be possible to use flashers as 
shield effects without modifying any ships and would be 100% compatible with most oxps. The 
real challenge was using vectors, as I used to suck at them, but now I have a little understanding.
The other thing I realized only 2 weeks ago was how to give a more 3-D feel to the effect by 
adding flashers to represent the tunneling of lasers through the shield. It adds a lot to the 
effect and feel of it. Currently I use vectors to plot the impact point of the attackers laser 
with the shield and this will improve in 1.77 for accuracy and speed with all the new JS commands.
The direction from the player's ship to the impact on the player's ship is used to position 
a shield flash effect so one can see the flash of impact as well as the normal tunneling effect.
When the shields are down, hits on the hull produce sparks and even blown panels occasionally.
Rarely, an unprotected hit can produce a visible ship damage effect to both player and npc. 
This part is still a work-in-progress with 5 or 6 effects still to be completed. Still, one is 
included that works reasonably well. This is a fuel leak caused by a hull breach with a visible 
venting of a dull blue gas from the ship of which some can be scooped by player or npcs. This was 
created with flashers as well. Anyway, this is something to play with until all the other 
damage effects are finished.

I know a lot of people have been wanting this for a long time and I was tired of waiting so 
here you go, enjoy, and have fun!



THANX AND RECOGNITION: Commander McLane for the NPCshields.oxp to use as an experimental template.
                       cim for providing a link to a one-poly model.
					   spara, JazHaz, Shipbuilder and Commander McLane for playtesting, comments 
					   and posting results on potential bugs and other issues, many thanks.
					   Thargoid for suggesting to use the shipAttackedByCloaked event.
					   Eric Walch for a good scripted cargo example in Cargo Wrecks and teasers.
                       All the viewtopics and people that talked about this and gave me ideas.
                       Everyone that said it could not be done, which made me go ahead and do it.
                       
					                                           -Sincerely, CommonSenseOTB.
															   

															   
															   
ABOUT THIS PRODUCT: This oxp provides eye candy as well as some game mechanic changes. It is 
                    up to you, the player, to customize your experience	by taking an 
                    appropriate oxp-safe text editor like Notepad++ and changing the 
                    defaults, only if you so desire, which are in the startUp function of the 
                    script labelled "customshields". After making changes to the defaults, 
					be sure to hold down the Shift key until you see the spinning cobra 
					when you restart your game in order for the changes to take effect. 
					Your playing enjoyment is totally up to you, which is why options are 
					provided for customization. Enjoy this product and help make it better
					by posting your thoughts at the appropriate viewtopic.					

TO USE THIS OXP: Unzip and drag or move the CustomShieldsv083.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

This expansion declares no equipment.

Ships

Name
Hull plating
Hull plating
customshieldsdamage
customshieldsfuelvapor
customshieldsfuelvapor
customshieldsfuelvapor
customshieldsfuelleaksscoopoverride
customshieldsexplosion
customshieldsexplosion
customshieldsexplosion
customshieldsexplosion
customshieldsexplosion
customshieldsexplosion
customshieldsexplosion
customshieldsexplosion
customshieldsexplosion
customshieldsexplosion
customshieldsshieldflasherblueA1
customshieldsshieldflasherblueA2
customshieldsshieldflasherblueA3
customshieldsshieldflasherblueA4
customshieldsshieldflasherblueA5
customshieldsshieldflasherblueAplayer
customshieldsshieldflasherblueB1
customshieldsshieldflasherblueB2
customshieldsshieldflasherblueB3
customshieldsshieldflasherblueB4
customshieldsshieldflasherblueB5
customshieldsshieldflasherblueBplayer
customshieldsshieldflasherblueC1
customshieldsshieldflasherblueC2
customshieldsshieldflasherblueC3
customshieldsshieldflasherblueC4
customshieldsshieldflasherblueC5
customshieldsshieldflasherblueCplayer
customshieldsshieldflasherblueD1
customshieldsshieldflasherblueD2
customshieldsshieldflasherblueD3
customshieldsshieldflasherblueD4
customshieldsshieldflasherblueD5
customshieldsshieldflasherblueDplayer
customshieldsshieldflasherblueE1
customshieldsshieldflasherblueE2
customshieldsshieldflasherblueE3
customshieldsshieldflasherblueE4
customshieldsshieldflasherblueE5
customshieldsshieldflasherblueEplayer
customshieldsshieldflasherblueF1
customshieldsshieldflasherblueF2
customshieldsshieldflasherblueF3
customshieldsshieldflasherblueF4
customshieldsshieldflasherblueF5
customshieldsshieldflasherblueFplayer
customshieldsshieldflasherblueG1
customshieldsshieldflasherblueG2
customshieldsshieldflasherblueG3
customshieldsshieldflasherblueG4
customshieldsshieldflasherblueG5
customshieldsshieldflasherblueGplayer
customshieldsshieldflasherblueH1
customshieldsshieldflasherblueH2
customshieldsshieldflasherblueH3
customshieldsshieldflasherblueH4
customshieldsshieldflasherblueH5
customshieldsshieldflasherblueHplayer
customshieldsshieldflasherblueI1
customshieldsshieldflasherblueI2
customshieldsshieldflasherblueI3
customshieldsshieldflasherblueI4
customshieldsshieldflasherblueI5
customshieldsshieldflasherblueIplayer
customshieldsshieldflasherblueJ1
customshieldsshieldflasherblueJ2
customshieldsshieldflasherblueJ3
customshieldsshieldflasherblueJ4
customshieldsshieldflasherblueJ5
customshieldsshieldflasherblueJplayer
customshieldsshieldflasherflareupA1
customshieldsshieldflasherflareupA2
customshieldsshieldflasherflareupA3
customshieldsshieldflasherflareupA4
customshieldsshieldflasherflareupA5
customshieldsshieldflasherflareupAplayer
customshieldsshieldflasherflareupB1
customshieldsshieldflasherflareupB2
customshieldsshieldflasherflareupB3
customshieldsshieldflasherflareupB4
customshieldsshieldflasherflareupB5
customshieldsshieldflasherflareupBplayer
customshieldsshieldflasherflareupC1
customshieldsshieldflasherflareupC2
customshieldsshieldflasherflareupC3
customshieldsshieldflasherflareupC4
customshieldsshieldflasherflareupC5
customshieldsshieldflasherflareupCplayer
customshieldsshieldflasherflareupD1
customshieldsshieldflasherflareupD2
customshieldsshieldflasherflareupD3
customshieldsshieldflasherflareupD4
customshieldsshieldflasherflareupD5
customshieldsshieldflasherflareupDplayer
customshieldsshieldflasherflareupE1
customshieldsshieldflasherflareupE2
customshieldsshieldflasherflareupE3
customshieldsshieldflasherflareupE4
customshieldsshieldflasherflareupE5
customshieldsshieldflasherflareupEplayer
customshieldsshieldflasherflareupF1
customshieldsshieldflasherflareupF2
customshieldsshieldflasherflareupF3
customshieldsshieldflasherflareupF4
customshieldsshieldflasherflareupF5
customshieldsshieldflasherflareupFplayer
customshieldsshieldflasherflareupG1
customshieldsshieldflasherflareupG2
customshieldsshieldflasherflareupG3
customshieldsshieldflasherflareupG4
customshieldsshieldflasherflareupG5
customshieldsshieldflasherflareupGplayer
customshieldsshieldflasherflareupH1
customshieldsshieldflasherflareupH2
customshieldsshieldflasherflareupH3
customshieldsshieldflasherflareupH4
customshieldsshieldflasherflareupH5
customshieldsshieldflasherflareupHplayer
customshieldsshieldflasherflareupI1
customshieldsshieldflasherflareupI2
customshieldsshieldflasherflareupI3
customshieldsshieldflasherflareupI4
customshieldsshieldflasherflareupI5
customshieldsshieldflasherflareupIplayer
customshieldsshieldflasherflareupJ1
customshieldsshieldflasherflareupJ2
customshieldsshieldflasherflareupJ3
customshieldsshieldflasherflareupJ4
customshieldsshieldflasherflareupJ5
customshieldsshieldflasherflareupJplayer
customshieldsshieldflashermulticolorA1
customshieldsshieldflashermulticolorA2
customshieldsshieldflashermulticolorA3
customshieldsshieldflashermulticolorA4
customshieldsshieldflashermulticolorA5
customshieldsshieldflashermulticolorAplayer
customshieldsshieldflashermulticolorB1
customshieldsshieldflashermulticolorB2
customshieldsshieldflashermulticolorB3
customshieldsshieldflashermulticolorB4
customshieldsshieldflashermulticolorB5
customshieldsshieldflashermulticolorBplayer
customshieldsshieldflashermulticolorC1
customshieldsshieldflashermulticolorC2
customshieldsshieldflashermulticolorC3
customshieldsshieldflashermulticolorC4
customshieldsshieldflashermulticolorC5
customshieldsshieldflashermulticolorCplayer
customshieldsshieldflashermulticolorD1
customshieldsshieldflashermulticolorD2
customshieldsshieldflashermulticolorD3
customshieldsshieldflashermulticolorD4
customshieldsshieldflashermulticolorD5
customshieldsshieldflashermulticolorDplayer
customshieldsshieldflashermulticolorE1
customshieldsshieldflashermulticolorE2
customshieldsshieldflashermulticolorE3
customshieldsshieldflashermulticolorE4
customshieldsshieldflashermulticolorE5
customshieldsshieldflashermulticolorEplayer
customshieldsshieldflashermulticolorF1
customshieldsshieldflashermulticolorF2
customshieldsshieldflashermulticolorF3
customshieldsshieldflashermulticolorF4
customshieldsshieldflashermulticolorF5
customshieldsshieldflashermulticolorFplayer
customshieldsshieldflashermulticolorG1
customshieldsshieldflashermulticolorG2
customshieldsshieldflashermulticolorG3
customshieldsshieldflashermulticolorG4
customshieldsshieldflashermulticolorG5
customshieldsshieldflashermulticolorGplayer
customshieldsshieldflashermulticolorH1
customshieldsshieldflashermulticolorH2
customshieldsshieldflashermulticolorH3
customshieldsshieldflashermulticolorH4
customshieldsshieldflashermulticolorH5
customshieldsshieldflashermulticolorHplayer
customshieldsshieldflashermulticolorI1
customshieldsshieldflashermulticolorI2
customshieldsshieldflashermulticolorI3
customshieldsshieldflashermulticolorI4
customshieldsshieldflashermulticolorI5
customshieldsshieldflashermulticolorIplayer
customshieldsshieldflashermulticolorJ1
customshieldsshieldflashermulticolorJ2
customshieldsshieldflashermulticolorJ3
customshieldsshieldflashermulticolorJ4
customshieldsshieldflashermulticolorJ5
customshieldsshieldflashermulticolorJplayer
customshieldsshieldflasherpinkA1
customshieldsshieldflasherpinkA2
customshieldsshieldflasherpinkA3
customshieldsshieldflasherpinkA4
customshieldsshieldflasherpinkA5
customshieldsshieldflasherpinkAplayer
customshieldsshieldflasherpinkB1
customshieldsshieldflasherpinkB2
customshieldsshieldflasherpinkB3
customshieldsshieldflasherpinkB4
customshieldsshieldflasherpinkB5
customshieldsshieldflasherpinkBplayer
customshieldsshieldflasherpinkC1
customshieldsshieldflasherpinkC2
customshieldsshieldflasherpinkC3
customshieldsshieldflasherpinkC4
customshieldsshieldflasherpinkC5
customshieldsshieldflasherpinkCplayer
customshieldsshieldflasherpinkD1
customshieldsshieldflasherpinkD2
customshieldsshieldflasherpinkD3
customshieldsshieldflasherpinkD4
customshieldsshieldflasherpinkD5
customshieldsshieldflasherpinkDplayer
customshieldsshieldflasherpinkE1
customshieldsshieldflasherpinkE2
customshieldsshieldflasherpinkE3
customshieldsshieldflasherpinkE4
customshieldsshieldflasherpinkE5
customshieldsshieldflasherpinkEplayer
customshieldsshieldflasherpinkF1
customshieldsshieldflasherpinkF2
customshieldsshieldflasherpinkF3
customshieldsshieldflasherpinkF4
customshieldsshieldflasherpinkF5
customshieldsshieldflasherpinkFplayer
customshieldsshieldflasherpinkG1
customshieldsshieldflasherpinkG2
customshieldsshieldflasherpinkG3
customshieldsshieldflasherpinkG4
customshieldsshieldflasherpinkG5
customshieldsshieldflasherpinkGplayer
customshieldsshieldflasherpinkH1
customshieldsshieldflasherpinkH2
customshieldsshieldflasherpinkH3
customshieldsshieldflasherpinkH4
customshieldsshieldflasherpinkH5
customshieldsshieldflasherpinkHplayer
customshieldsshieldflasherpinkI1
customshieldsshieldflasherpinkI2
customshieldsshieldflasherpinkI3
customshieldsshieldflasherpinkI4
customshieldsshieldflasherpinkI5
customshieldsshieldflasherpinkIplayer
customshieldsshieldflasherpinkJ1
customshieldsshieldflasherpinkJ2
customshieldsshieldflasherpinkJ3
customshieldsshieldflasherpinkJ4
customshieldsshieldflasherpinkJ5
customshieldsshieldflasherpinkJplayer
customshieldsshieldflasherthargoidgreenA1
customshieldsshieldflasherthargoidgreenA2
customshieldsshieldflasherthargoidgreenA3
customshieldsshieldflasherthargoidgreenA4
customshieldsshieldflasherthargoidgreenA5
customshieldsshieldflasherthargoidgreenB1
customshieldsshieldflasherthargoidgreenB2
customshieldsshieldflasherthargoidgreenB3
customshieldsshieldflasherthargoidgreenB4
customshieldsshieldflasherthargoidgreenB5
customshieldsshieldflasherthargoidgreenC1
customshieldsshieldflasherthargoidgreenC2
customshieldsshieldflasherthargoidgreenC3
customshieldsshieldflasherthargoidgreenC4
customshieldsshieldflasherthargoidgreenC5
customshieldsshieldflasherthargoidgreenD1
customshieldsshieldflasherthargoidgreenD2
customshieldsshieldflasherthargoidgreenD3
customshieldsshieldflasherthargoidgreenD4
customshieldsshieldflasherthargoidgreenD5
customshieldsshieldflasherthargoidgreenE1
customshieldsshieldflasherthargoidgreenE2
customshieldsshieldflasherthargoidgreenE3
customshieldsshieldflasherthargoidgreenE4
customshieldsshieldflasherthargoidgreenE5
customshieldsshieldflasherthargoidgreenF1
customshieldsshieldflasherthargoidgreenF2
customshieldsshieldflasherthargoidgreenF3
customshieldsshieldflasherthargoidgreenF4
customshieldsshieldflasherthargoidgreenF5
customshieldsshieldflasherthargoidgreenG1
customshieldsshieldflasherthargoidgreenG2
customshieldsshieldflasherthargoidgreenG3
customshieldsshieldflasherthargoidgreenG4
customshieldsshieldflasherthargoidgreenG5
customshieldsshieldflasherthargoidgreenH1
customshieldsshieldflasherthargoidgreenH2
customshieldsshieldflasherthargoidgreenH3
customshieldsshieldflasherthargoidgreenH4
customshieldsshieldflasherthargoidgreenH5
customshieldsshieldflasherthargoidgreenI1
customshieldsshieldflasherthargoidgreenI2
customshieldsshieldflasherthargoidgreenI3
customshieldsshieldflasherthargoidgreenI4
customshieldsshieldflasherthargoidgreenI5
customshieldsshieldflasherthargoidgreenJ1
customshieldsshieldflasherthargoidgreenJ2
customshieldsshieldflasherthargoidgreenJ3
customshieldsshieldflasherthargoidgreenJ4
customshieldsshieldflasherthargoidgreenJ5
customshieldssparks
customshieldssparksblownpanels
customshieldssparksfuelleaks

Models

This expansion declares no models.

Scripts

Path
Scripts/customshields.js
"use strict";

this.name           = "customshields";
this.author         = "CommonSenseOTB";
this.copyright		= "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description    = "Simulated shields, shields effects, damage effects";
this.version        = "0.83";

this.startUp = this.playerBoughtNewShip = function()
   {
   //
   //------------------YOU MAY CHANGE THESE DEFAULTS--------------
   //
   //----------------------------------------------------------------------------------------------------
   this.customshieldsshieldtype = "advanced";     //choices: "advanced" , "basic" , "off"
   //----------------------------------------------------------------------------------------------------
   this.customshieldsshieldtypethargoid = "basic";     //choices: "basic" , "off"
   //----------------------------------------------------------------------------------------------------
   this.customshieldsshieldcolor = "multicolor";     //choices: "multicolor" , "blue" , "pink"
   //----------------------------------------------------------------------------------------------------
   this.customshieldsshieldcolorthargoid = "green";     //choices: "green"
   //----------------------------------------------------------------------------------------------------
   this.customshieldsdamageeffects = "sparks";     //choices: "damage" , "blownpanels" , "sparks" , "off"
   //----------------------------------------------------------------------------------------------------
   this.customshieldsmissilemineexplosioneffects = "on";     //choices: "on" , "off" 
   //----------------------------------------------------------------------------------------------------
   //
   //-------------DO NOT CHANGE ANYTHING BELOW THIS POINT---------
   //
   //
   //
   //----------------------------------------------------------------
   //Note:draw distance maximum for effects is currently set at 51200
   //----------------------------------------------------------------
   //
   if(player.ship.mass > 0 && player.ship.mass <= 5000)
      {
      this.customshieldsplayershieldflashersize = 1;
      }
   if(player.ship.mass > 5000 && player.ship.mass <= 50000)
      {
      this.customshieldsplayershieldflashersize = 2;
      }    
   if(player.ship.mass > 50000 && player.ship.mass <= 150000)
      {
      this.customshieldsplayershieldflashersize = 3;
      }  
   if(player.ship.mass > 150000 && player.ship.mass <= 500000)
      {
      this.customshieldsplayershieldflashersize = 4;
      }
   if(player.ship.mass > 500000)
      {
      this.customshieldsplayershieldflashersize = 5;
      }
   this.customshieldshitrange = 50;//default if string different from below
   if(this.customshieldsdamageeffects === "damage")
      {
	  this.customshieldshitrange = 50;
	  }
   if(this.customshieldsdamageeffects === "blownpanels")
      {
	  this.customshieldshitrange = 45;
	  }
   if(this.customshieldsdamageeffects === "sparks")
      {
	  this.customshieldshitrange = 35;
	  }
   if(this.customshieldsdamageeffects === "off")
      {
	  this.customshieldshitrange = 1;
	  }
   this.customshieldsspeedcollisionradiusadjustment = (player.ship.maxSpeed / 350) * 8;     
   }
this.shipTakingDamage = function(amount, whom, type)
   {
   if(whom && whom.position !== undefined)//added for whom is null issue
      {
      if(player.ship.speed > player.ship.maxSpeed)//added for shield collision issue caused by using solid models which are needed to work correctly in 1.76, applies to advanced and basic npcs also
         {
         var speedcollisionradiusadjustment = (player.ship.speed / player.ship.maxSpeed) * this.customshieldsspeedcollisionradiusadjustment;
	     }
      else
         {
	     var speedcollisionradiusadjustment = 0;
	     }
      var impactradiusfactor = ((3 * (1500 / (player.ship.position.distanceTo(whom.position)))) + 16);	 
      var impactlocation = whom.position.add(whom.vectorForward.multiply((whom.position.distanceTo(player.ship.position)) - (player.ship.collisionRadius + 1 + speedcollisionradiusadjustment)));//determine possible forward weapon hit location
      if((player.ship.position.distanceTo(impactlocation)) > (player.ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
         {
         impactlocation = whom.position.add(whom.vectorForward.multiply(-((whom.position.distanceTo(player.ship.position)) - (player.ship.collisionRadius + 1 + speedcollisionradiusadjustment))));//determine possible aft weapon hit location
         if((player.ship.position.distanceTo(impactlocation)) > (player.ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
            {
            impactlocation = whom.position.add(whom.vectorRight.multiply((whom.position.distanceTo(player.ship.position)) - (player.ship.collisionRadius + 1 + speedcollisionradiusadjustment)));//determine possible starboard weapon hit location
            if((player.ship.position.distanceTo(impactlocation)) > (player.ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
               {
               impactlocation = whom.position.add(whom.vectorRight.multiply(-((whom.position.distanceTo(player.ship.position)) - (player.ship.collisionRadius + 1 + speedcollisionradiusadjustment))));//determine possible port weapon hit location
               if((player.ship.position.distanceTo(impactlocation)) > (player.ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                  {			   
                  var impactinterpolation = ((player.ship.collisionRadius + 1 + speedcollisionradiusadjustment) / (player.ship.position.distanceTo(whom.position)));  
                  impactlocation = Vector3D.interpolate(player.ship.position, whom.position, impactinterpolation);//interpolate weapon hit directly between ship and attacker as a fallback position
                  }
               }
            }
         }
      var attackerdirection = whom.position.subtract(impactlocation).direction();
      var playerdirection = player.ship.position.subtract(impactlocation).direction();
      var impactdirection = impactlocation.subtract(player.ship.position).direction();
      var impactrelativeposition = impactlocation.subtract(player.ship.position);
      var impactangle = player.ship.heading.angleTo(impactdirection);
      this.customshieldsattackerdirection = attackerdirection;
      this.customshieldsplayerdirection = playerdirection;
      this.customshieldsimpactdirection = impactdirection;
      this.customshieldsimpactrelativeposition = impactrelativeposition;
      this.customshieldsimpactlocation = impactlocation;
      if(impactangle <= 1.57)
         {
	     if(player.ship.forwardShield === 0)
            {
		    this.$customshieldsplayerunshieldedhits();	
		    }
         else
	        {
		    this.customshieldsplayershieldflashers = (player.ship.forwardShield / player.ship.maxForwardShield);
            if((type === "scrape damage") && (whom.mass > 10000 || whom.velocity.magnitude > 500))//might take closing speed into account in the future
		       {
			   if(player.ship.viewDirection === "VIEW_CUSTOM")
			      {
			      this.$customshieldsplayershieldflareupcustom();
			      }
               else
			      {
			      this.$customshieldsplayershieldflareup();
			      }
			   }
            else
		       {
			   if(player.ship.viewDirection === "VIEW_CUSTOM")
			      {
		          this.$customshieldsplayershieldflasherscustom();
			      }
               else
			      {
			      this.$customshieldsplayershieldflashers();
			      }
			   }
		    }
         }
      else
         {
	     if(player.ship.aftShield === 0)
            {
            this.$customshieldsplayerunshieldedhits();		 
		    }
         else
	        {
		    this.customshieldsplayershieldflashers = (player.ship.aftShield / player.ship.maxAftShield);
		    if((type === "scrape damage") && (whom.mass > 10000 || whom.velocity.magnitude > 500))
		       {
			   if(player.ship.viewDirection === "VIEW_CUSTOM")
			      {
			      this.$customshieldsplayershieldflareupcustom();
			      }
               else
			      {
			      this.$customshieldsplayershieldflareup();
			      }
			   }
            else
		       {
			   if(player.ship.viewDirection === "VIEW_CUSTOM")
			      {
		          this.$customshieldsplayershieldflasherscustom();
			      }
               else
			      {
			      this.$customshieldsplayershieldflashers();
			      }
			   }
		    }
         }
      }
   }
this.$customshieldsplayerunshieldedhits = function()
   {
   var hitrange = this.customshieldshitrange;
   var hitchance = Math.ceil(Math.random() * hitrange);
   switch(hitchance)
      {   
      case 1://10% nothing
	  case 2:
	  case 3:
	  case 4:
	  case 5:
	     {
		 break;
		 }
	  case 6://60% sparks
	  case 7:
	  case 8:
	  case 9:
	  case 10:
	  case 11:
	  case 12:
	  case 13:
	  case 14:
	  case 15:
	  case 16:
	  case 17:
	  case 18:
	  case 19:
	  case 20:
	  case 21:
	  case 22:
	  case 23:
	  case 24:
	  case 25:
	  case 26:
	  case 27:
	  case 28:
	  case 29:
	  case 30:
	  case 31:
	  case 32:
	  case 33:
	  case 34:
	  case 35:
         {
         var sparks = system.addShips("customshieldssparks", 1, this.customshieldsimpactlocation, 0);
         break;
         }
      case 36://20% blown panels
      case 37:
	  case 38:
	  case 39:
	  case 40:
	  case 41:
	  case 42:
	  case 43:
	  case 44:
	  case 45:
         {
		 var il = this.customshieldsimpactlocation;
         var id = this.customshieldsimpactdirection;
		 var sparksblownpanels = player.ship.spawnOne("customshieldssparksblownpanels");
         sparksblownpanels.position = il;
		 sparksblownpanels.orientation = id.rotationTo([0, 0, 1]);
		 sparksblownpanels.velocity = player.ship.velocity.add(sparksblownpanels.vectorForward.multiply((Math.ceil(Math.random() * 150)) + 50));
         break;
         }
      case 46://currently nothing, future expansion
	  case 47:
	  case 48:
	  case 49:
	     {
		 break;
		 }
      case 50://fuel leak caused by hull rupture
         {
		 if(this.customshieldsfuelleakflag === 1.0)
            {
            break;
            }
         this.customshieldsfuelleakflag = 1.0;
		 this.customshieldsfuelleakrepairTimer = new Timer(this, this.$customshieldsfuelleakrepair, 60, -1);	
		 var il = this.customshieldsimpactlocation;
         var id = this.customshieldsimpactdirection;
		 var sparksfuelleaks = player.ship.spawnOne("customshieldssparksfuelleaks");
         sparksfuelleaks.position = il;
		 sparksfuelleaks.orientation = id.rotationTo([0, 0, 1]);
         sparksfuelleaks.target = player.ship;
         break;
         }
      }
   }
this.$customshieldsfuelleakrepair = function()
   {
   this.customshieldsfuelleakflag = 0.0;
   player.consoleMessage("Fuel leak sealed", 4);
   if(this.customshieldsfuelleakrepairTimer && this.customshieldsfuelleakrepairTimer.isRunning)
      {
      this.customshieldsfuelleakrepairTimer.stop();
	  delete this.customshieldsfuelleakrepairTimer;
      }
   }
this.shipDied = function()
   {
   if(this.customshieldsfuelleakrepairTimer && this.customshieldsfuelleakrepairTimer.isRunning)
      {
      this.customshieldsfuelleakrepairTimer.stop();
	  delete this.customshieldsfuelleakrepairTimer;
      }
   }   
this.$customshieldsplayershieldflareupcustom = function()
   {
   var psf = this.customshieldsplayershieldflashers;
   var psfs = this.customshieldsplayershieldflashersize;
   var il = this.customshieldsimpactlocation;
   psf = Math.floor(psf * 10);
   psf = (psf / 10);
   switch(psf)
      {   
      case 0.9:
         {
		 var playershieldflareupcustom = player.ship.spawnOne("customshieldsshieldflasherflareupA" + psfs);
         playershieldflareupcustom.position = il;
         playershieldflareupcustom.target = player.ship;
         break;
         }
      case 0.8:
         {
		 var playershieldflareupcustom = player.ship.spawnOne("customshieldsshieldflasherflareupB" + psfs);
         playershieldflareupcustom.position = il;
         playershieldflareupcustom.target = player.ship;
         break;
         }
      case 0.7:
         {
		 var playershieldflareupcustom = player.ship.spawnOne("customshieldsshieldflasherflareupC" + psfs);
         playershieldflareupcustom.position = il;
         playershieldflareupcustom.target = player.ship;
         break;
         }
      case 0.6:
         {
		 var playershieldflareupcustom = player.ship.spawnOne("customshieldsshieldflasherflareupD" + psfs);
         playershieldflareupcustom.position = il;
         playershieldflareupcustom.target = player.ship;
         break;
         }
      case 0.5:
         {
		 var playershieldflareupcustom = player.ship.spawnOne("customshieldsshieldflasherflareupE" + psfs);
         playershieldflareupcustom.position = il;
         playershieldflareupcustom.target = player.ship;
         break;
         }
      case 0.4:
         {
		 var playershieldflareupcustom = player.ship.spawnOne("customshieldsshieldflasherflareupF" + psfs);
         playershieldflareupcustom.position = il;
         playershieldflareupcustom.target = player.ship;
         break;
         }
      case 0.3:
         {
		 var playershieldflareupcustom = player.ship.spawnOne("customshieldsshieldflasherflareupG" + psfs);
         playershieldflareupcustom.position = il;
         playershieldflareupcustom.target = player.ship;
         break;
         }
      case 0.2:
         {
		 var playershieldflareupcustom = player.ship.spawnOne("customshieldsshieldflasherflareupH" + psfs);
         playershieldflareupcustom.position = il;
         playershieldflareupcustom.target = player.ship;
         break;
         }
      case 0.1:
         {
		 var playershieldflareupcustom = player.ship.spawnOne("customshieldsshieldflasherflareupI" + psfs);
         playershieldflareupcustom.position = il;
         playershieldflareupcustom.target = player.ship;
         break;
         }
      case 0.0:
         {
		 var playershieldflareupcustom = player.ship.spawnOne("customshieldsshieldflasherflareupJ" + psfs);
         playershieldflareupcustom.position = il;
         playershieldflareupcustom.target = player.ship;
         break;
         }
      }
   }            
this.$customshieldsplayershieldflareup = function()
   {
   var psf = this.customshieldsplayershieldflashers;
   var il = this.customshieldsimpactlocation;
   var pd = this.customshieldsplayerdirection;
   psf = Math.floor(psf * 10);
   psf = (psf / 10);
   switch(psf)
      {   
      case 0.9:
         {
		 var playershieldflareup = player.ship.spawnOne("customshieldsshieldflasherflareupAplayer");
         playershieldflareup.position = il;
		 playershieldflareup.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflareup.target = player.ship;
         break;
         }
      case 0.8:
         {
		 var playershieldflareup = player.ship.spawnOne("customshieldsshieldflasherflareupBplayer");
         playershieldflareup.position = il;
		 playershieldflareup.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflareup.target = player.ship;
         break;
         }
      case 0.7:
         {
		 var playershieldflareup = player.ship.spawnOne("customshieldsshieldflasherflareupCplayer");
         playershieldflareup.position = il;
		 playershieldflareup.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflareup.target = player.ship;
         break;
         }
      case 0.6:
         {
		 var playershieldflareup = player.ship.spawnOne("customshieldsshieldflasherflareupDplayer");
         playershieldflareup.position = il;
		 playershieldflareup.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflareup.target = player.ship;
         break;
         }
      case 0.5:
         {
		 var playershieldflareup = player.ship.spawnOne("customshieldsshieldflasherflareupEplayer");
         playershieldflareup.position = il;
		 playershieldflareup.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflareup.target = player.ship;
         break;
         }
      case 0.4:
         {
		 var playershieldflareup = player.ship.spawnOne("customshieldsshieldflasherflareupFplayer");
         playershieldflareup.position = il;
		 playershieldflareup.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflareup.target = player.ship;
         break;
         }
      case 0.3:
         {
		 var playershieldflareup = player.ship.spawnOne("customshieldsshieldflasherflareupGplayer");
         playershieldflareup.position = il;
		 playershieldflareup.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflareup.target = player.ship;
         break;
         }
      case 0.2:
         {
		 var playershieldflareup = player.ship.spawnOne("customshieldsshieldflasherflareupHplayer");
         playershieldflareup.position = il;
		 playershieldflareup.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflareup.target = player.ship;
         break;
         }
      case 0.1:
         {
		 var playershieldflareup = player.ship.spawnOne("customshieldsshieldflasherflareupIplayer");
         playershieldflareup.position = il;
		 playershieldflareup.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflareup.target = player.ship;
         break;
         }
      case 0.0:
         {
		 var playershieldflareup = player.ship.spawnOne("customshieldsshieldflasherflareupJplayer");
         playershieldflareup.position = il;
		 playershieldflareup.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflareup.target = player.ship;
         break;
         }
      }
   }      
this.$customshieldsplayershieldflasherscustom = function()
   {
   var customshieldsshieldcolor = this.customshieldsshieldcolor;
   var psf = this.customshieldsplayershieldflashers;
   var psfs = this.customshieldsplayershieldflashersize;
   var il = this.customshieldsimpactlocation;
   var ad = this.customshieldsattackerdirection;
   psf = Math.floor(psf * 10);
   psf = (psf / 10);
   switch(psf)
      {   
      case 0.9:
         {
         var playershieldflasherscustom = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "A" + psfs);
         playershieldflasherscustom.position = il;
		 playershieldflasherscustom.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflasherscustom.target = player.ship;
         break;
         }
      case 0.8:
         {
         var playershieldflasherscustom = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "B" + psfs);
         playershieldflasherscustom.position = il;
		 playershieldflasherscustom.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflasherscustom.target = player.ship;
         break;
         }
      case 0.7:
         {
         var playershieldflasherscustom = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "C" + psfs);
         playershieldflasherscustom.position = il;
		 playershieldflasherscustom.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflasherscustom.target = player.ship;
         break;
         }
      case 0.6:
         {
         var playershieldflasherscustom = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "D" + psfs);
         playershieldflasherscustom.position = il;
		 playershieldflasherscustom.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflasherscustom.target = player.ship;
         break;
         }
      case 0.5:
         {
         var playershieldflasherscustom = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "E" + psfs);
         playershieldflasherscustom.position = il;
		 playershieldflasherscustom.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflasherscustom.target = player.ship;
         break;
         }
      case 0.4:
         {
         var playershieldflasherscustom = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "F" + psfs);
         playershieldflasherscustom.position = il;
		 playershieldflasherscustom.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflasherscustom.target = player.ship;
         break;
         }
      case 0.3:
         {
         var playershieldflasherscustom = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "G" + psfs);
         playershieldflasherscustom.position = il;
		 playershieldflasherscustom.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflasherscustom.target = player.ship;
         break;
         }
      case 0.2:
         {
         var playershieldflasherscustom = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "H" + psfs);
         playershieldflasherscustom.position = il;
		 playershieldflasherscustom.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflasherscustom.target = player.ship;
         break;
         }
      case 0.1:
         {
         var playershieldflasherscustom = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "I" + psfs);
         playershieldflasherscustom.position = il;
		 playershieldflasherscustom.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflasherscustom.target = player.ship;
         break;
         }
      case 0.0:
         {
         var playershieldflasherscustom = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "J" + psfs);
         playershieldflasherscustom.position = il;
		 playershieldflasherscustom.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflasherscustom.target = player.ship;
         break;
         }
      }
   }      
this.$customshieldsplayershieldflashers = function()//v0.81correction made to use a normal entity instead of a zero poly entity, spawn flash slightly farther out rather than at the same position as the tunneling effect
   {
   var customshieldsshieldcolor = this.customshieldsshieldcolor;
   var psf = this.customshieldsplayershieldflashers;
   var psfs = this.customshieldsplayershieldflashersize;
   var il = this.customshieldsimpactlocation;
   var ad = this.customshieldsattackerdirection;
   var pd = this.customshieldsplayerdirection;
   var interpolation = ((player.ship.collisionRadius + 2) / (player.ship.collisionRadius + 1));
   var ilinterpolation = Vector3D.interpolate(player.ship.position, il, interpolation);
   this.customshieldsimpactrelativepositioninterpolation = ilinterpolation.subtract(player.ship.position);
   psf = Math.floor(psf * 10);
   psf = (psf / 10);
   switch(psf)
      {   
      case 0.9:
         {
         var playershieldflashersmain = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "A" + psfs);
         playershieldflashersmain.position = il;
		 playershieldflashersmain.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflashersmain.target = player.ship;
		 var playershieldflashersflash = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "Aplayer");
         playershieldflashersflash.position = ilinterpolation;
		 playershieldflashersflash.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflashersflash.target = player.ship;
         break;
         }
      case 0.8:
         {
         var playershieldflashersmain = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "B" + psfs);
         playershieldflashersmain.position = il;
		 playershieldflashersmain.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflashersmain.target = player.ship;
		 var playershieldflashersflash = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "Bplayer");
         playershieldflashersflash.position = ilinterpolation;
		 playershieldflashersflash.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflashersflash.target = player.ship;
         break;
         }
      case 0.7:
         {
         var playershieldflashersmain = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "C" + psfs);
         playershieldflashersmain.position = il;
		 playershieldflashersmain.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflashersmain.target = player.ship;
		 var playershieldflashersflash = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "Cplayer");
         playershieldflashersflash.position = ilinterpolation;
		 playershieldflashersflash.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflashersflash.target = player.ship;
         break;
         }
      case 0.6:
         {
         var playershieldflashersmain = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "D" + psfs);
         playershieldflashersmain.position = il;
		 playershieldflashersmain.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflashersmain.target = player.ship;
		 var playershieldflashersflash = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "Dplayer");
         playershieldflashersflash.position = ilinterpolation;
		 playershieldflashersflash.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflashersflash.target = player.ship;
         break;
         }
      case 0.5:
         {
         var playershieldflashersmain = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "E" + psfs);
         playershieldflashersmain.position = il;
		 playershieldflashersmain.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflashersmain.target = player.ship;
		 var playershieldflashersflash = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "Eplayer");
         playershieldflashersflash.position = ilinterpolation;
		 playershieldflashersflash.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflashersflash.target = player.ship;
         break;
         }
      case 0.4:
         {
         var playershieldflashersmain = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "F" + psfs);
         playershieldflashersmain.position = il;
		 playershieldflashersmain.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflashersmain.target = player.ship;
		 var playershieldflashersflash = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "Fplayer");
         playershieldflashersflash.position = ilinterpolation;
		 playershieldflashersflash.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflashersflash.target = player.ship;
         break;
         }
      case 0.3:
         {
         var playershieldflashersmain = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "G" + psfs);
         playershieldflashersmain.position = il;
		 playershieldflashersmain.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflashersmain.target = player.ship;
		 var playershieldflashersflash = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "Gplayer");
         playershieldflashersflash.position = ilinterpolation;
		 playershieldflashersflash.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflashersflash.target = player.ship;
         break;
         }
      case 0.2:
         {
         var playershieldflashersmain = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "H" + psfs);
         playershieldflashersmain.position = il;
		 playershieldflashersmain.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflashersmain.target = player.ship;
		 var playershieldflashersflash = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "Hplayer");
         playershieldflashersflash.position = ilinterpolation;
		 playershieldflashersflash.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflashersflash.target = player.ship;
         break;
         }
      case 0.1:
         {
         var playershieldflashersmain = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "I" + psfs);
         playershieldflashersmain.position = il;
		 playershieldflashersmain.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflashersmain.target = player.ship;
		 var playershieldflashersflash = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "Iplayer");
         playershieldflashersflash.position = ilinterpolation;
		 playershieldflashersflash.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflashersflash.target = player.ship;
         break;
         }
      case 0.0:
         {
         var playershieldflashersmain = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "J" + psfs);
         playershieldflashersmain.position = il;
		 playershieldflashersmain.orientation = ad.rotationTo([0, 0, 1]);
         playershieldflashersmain.target = player.ship;
		 var playershieldflashersflash = player.ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "Jplayer");
         playershieldflashersflash.position = ilinterpolation;
		 playershieldflashersflash.orientation = pd.rotationTo([0, 0, 1]);
         playershieldflashersflash.target = player.ship;
         break;
         }
      }
   }   
this.shipSpawned = function(ship)
   {
   if((ship.isMissile || ship.isMine) && (this.customshieldsmissilemineexplosioneffects === "on"))
      {
	  if(ship.scriptInfo.npc_shields && ship.scriptInfo.npc_shields === "no")
         {
		 return;
		 }
      else
	     {
	     ship.script.$customshieldsmissilemineshipdied = ship.script.shipDied;
         ship.script.shipDied = function(whom, why)
            {
            if(why !== "removed" && why !== "hit a planet" && (player.ship.isValid && player.ship.position.distanceTo(ship.position) < 51200))//determine if effect should be drawn, use "isVisible" in 1.77
               {
               ship.script.customshieldsmissilemineexplosion = ship.spawnOne("customshieldsmissilemineflareupA");
			   ship.script.customshieldsmissilemineexplosion.position = ship.position;
		       ship.script.customshieldsmissilemineexplosion.orientation = ship.orientation;
			   ship.script.customshieldsmissilemineexplosion.velocity = ship.velocity;
               }
            if(ship.script.$customshieldsmissilemineshipdied)
	           {
               ship.script.$customshieldsmissilemineshipdied.apply(this, arguments);
		       }
            }
	     }
      }
   if((ship.isThargoid) && (this.customshieldsshieldtypethargoid === "basic"))//main thargoid shield effects routines using only energy level to control the shield and damage effects
      {
	  if(ship.scriptInfo.npc_shields && ship.scriptInfo.npc_shields === "no")
         {
		 return;
		 }
      else
	     {
         if(ship.mass > 0 && ship.mass <= 5000)
            {
            ship.script.customshieldsshieldflashersize = 1;
            }
         if(ship.mass > 5000 && ship.mass <= 50000)
            {
            ship.script.customshieldsshieldflashersize = 2;
            }    
         if(ship.mass > 50000 && ship.mass <= 150000)
            {
            ship.script.customshieldsshieldflashersize = 3;
            }  
         if(ship.mass > 150000 && ship.mass <= 500000)
            {
            ship.script.customshieldsshieldflashersize = 4;
            }
         if(ship.mass > 500000)
            {
            ship.script.customshieldsshieldflashersize = 5;
            }
         ship.script.customshieldsshieldcolorthargoid = worldScripts["customshields"].customshieldsshieldcolorthargoid;
	     //----------------------------------------------------begin cloaked attacker code
	     ship.script.$customshieldsthargoidsshipbeingattackedbycloaked = ship.script.shipBeingAttackedByCloaked;
	     ship.script.shipBeingAttackedByCloaked = function()
            {
	        if(player.ship.isCloaked === true)//if the player ship is cloaked it is likely to be the attacker
		       {
		       ship.script.customshieldscloakedattacker = player.ship;//tell the target who attacked
			   }
            if(ship.script.$customshieldsthargoidsshipbeingattackedbycloaked)
		       {
               ship.script.$customshieldsthargoidsshipbeingattackedbycloaked.apply(this, arguments);
               }
            }
	     ship.script.$customshieldsthargoidsshipattackedother = ship.script.shipAttackedOther;
	     ship.script.shipAttackedOther = function(other)
            {
	        if(ship.isCloaked === true)//a cloaked thargoid(is there such a thing?) attacking another npc will override the player as the cloaked attacker when the player is also cloaked
		       {
		       other.script.customshieldscloakedattacker = ship;//tell the target who attacked
			   }
            if(ship.script.$customshieldsthargoidsshipattackedother)
		       {
               ship.script.$customshieldsthargoidsshipattackedother.apply(this, arguments);
               }
           }
         ship.script.$customshieldsthargoidsshiptakingdamage = ship.script.shipTakingDamage;
         ship.script.shipTakingDamage = function(amount, whom, type)
            {
		    if(ship.script.customshieldscloakedattacker)//if this key exists the attacker is cloaked
               {
	           whom = ship.script.customshieldscloakedattacker;//whom must be the cloaked attacker, make it so
	           delete ship.script.customshieldscloakedattacker;//reset this key
	           }//---------------------------------------------end cloaked attacker code
			if(whom && whom.position !== undefined)
               {
	           var impactradiusfactor = ((3 * (1500 / (ship.position.distanceTo(whom.position)))) + 16);	 
               var impactlocation = whom.position.add(whom.vectorForward.multiply((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1)));//determine possible forward weapon hit location
               if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                  {
                  impactlocation = whom.position.add(whom.vectorForward.multiply(-((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1))));//determine possible aft weapon hit location
                  if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                     {
                     impactlocation = whom.position.add(whom.vectorRight.multiply((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1)));//determine possible starboard weapon hit location
                     if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                        {
                        impactlocation = whom.position.add(whom.vectorRight.multiply(-((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1))));//determine possible port weapon hit location
                        if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                           {			   
                           var impactinterpolation = ((ship.collisionRadius + 1) / (ship.position.distanceTo(whom.position)));  
                           impactlocation = Vector3D.interpolate(ship.position, whom.position, impactinterpolation);//interpolate weapon hit directly between ship and attacker as a fallback position
                           }
                        }
                     }
                  }
               var attackerdirection = whom.position.subtract(impactlocation).direction();
               var impactdirection = impactlocation.subtract(ship.position).direction();
               var impactrelativeposition = impactlocation.subtract(ship.position);
               var impactangle = ship.heading.angleTo(impactdirection);
	           ship.script.customshieldsattackerdirection = attackerdirection;
	           ship.script.customshieldsimpactdirection = impactdirection;
               ship.script.customshieldsimpactrelativeposition = impactrelativeposition;
               ship.script.customshieldsimpactlocation = impactlocation;			
               if(player.ship.isValid && player.ship.position.distanceTo(ship.position) < 51200)//determine if effect should be drawn, use "isVisible" in 1.77
                  {
			      ship.script.customshieldsdrawthargoidshieldflashers = (ship.energy / ship.maxEnergy);
		          if((type === "scrape damage") && (whom.mass > 10000 || whom.velocity.magnitude > 500))
		             {
			         ship.script.$customshieldsdrawthargoidshieldflareup();
			         }
                  else
			         {
			         ship.script.$customshieldsdrawthargoidshieldflashers();
			         }
			      }
               if(ship.script.$customshieldsthargoidsshiptakingdamage)
		          {
                  ship.script.$customshieldsthargoidsshiptakingdamage.apply(this, arguments);
                  }
               }
			}
         ship.script.$customshieldsdrawthargoidshieldflareup = function()
            {
            var dsf = ship.script.customshieldsdrawthargoidshieldflashers;
	        var sfs = ship.script.customshieldsshieldflashersize;
            var il = ship.script.customshieldsimpactlocation;
            dsf = Math.floor(dsf * 10);
            dsf = (dsf / 10);
            switch(dsf)
               {   
               case 0.9:
                  {
		          var thargoidshieldflareup = ship.spawnOne("customshieldsshieldflasherflareupA" + sfs);
                  thargoidshieldflareup.position = il;
                  thargoidshieldflareup.target = ship;
                  break;
                  }
               case 0.8:
                  {
		          var thargoidshieldflareup = ship.spawnOne("customshieldsshieldflasherflareupB" + sfs);
                  thargoidshieldflareup.position = il;
                  thargoidshieldflareup.target = ship;
                  break;
                  }
               case 0.7:
                  {
		          var thargoidshieldflareup = ship.spawnOne("customshieldsshieldflasherflareupC" + sfs);
                  thargoidshieldflareup.position = il;
                  thargoidshieldflareup.target = ship;
                  break;
                  }
               case 0.6:
                  {
		          var thargoidshieldflareup = ship.spawnOne("customshieldsshieldflasherflareupD" + sfs);
                  thargoidshieldflareup.position = il;
                  thargoidshieldflareup.target = ship;
                  break;
                  }
               case 0.5:
                  {
		          var thargoidshieldflareup = ship.spawnOne("customshieldsshieldflasherflareupE" + sfs);
                  thargoidshieldflareup.position = il;
                  thargoidshieldflareup.target = ship;
                  break;
                  }
               case 0.4:
                  {
		          var thargoidshieldflareup = ship.spawnOne("customshieldsshieldflasherflareupF" + sfs);
                  thargoidshieldflareup.position = il;
                  thargoidshieldflareup.target = ship;
                  break;
                  }
               case 0.3:
                  {
		          var thargoidshieldflareup = ship.spawnOne("customshieldsshieldflasherflareupG" + sfs);
                  thargoidshieldflareup.position = il;
                  thargoidshieldflareup.target = ship;
                  break;
                  }
               case 0.2:
                  {
		          var thargoidshieldflareup = ship.spawnOne("customshieldsshieldflasherflareupH" + sfs);
                  thargoidshieldflareup.position = il;
                  thargoidshieldflareup.target = ship;
                  break;
                  }
               case 0.1:
                  {
		          var thargoidshieldflareup = ship.spawnOne("customshieldsshieldflasherflareupI" + sfs);
                  thargoidshieldflareup.position = il;
                  thargoidshieldflareup.target = ship;
                  break;
                  }
               case 0.0:
                  {
		          var thargoidshieldflareup = ship.spawnOne("customshieldsshieldflasherflareupJ" + sfs);
                  thargoidshieldflareup.position = il;
                  thargoidshieldflareup.target = ship;
                  break;
                  }
               }
            }        
         ship.script.$customshieldsdrawthargoidshieldflashers = function()
            {
	        var customshieldsshieldcolorthargoid = ship.script.customshieldsshieldcolorthargoid;
	        var dsf = ship.script.customshieldsdrawthargoidshieldflashers;
	        var sfs = ship.script.customshieldsshieldflashersize;
	        var il = ship.script.customshieldsimpactlocation;
	        var ad = ship.script.customshieldsattackerdirection;
	        dsf = Math.floor(dsf * 10);
            dsf = (dsf / 10);
	        switch(dsf)
               {   
               case 0.9:
                  {
			      var thargoidshieldflashers = ship.spawnOne("customshieldsshieldflasherthargoid" + customshieldsshieldcolorthargoid + "A" + sfs);
			      thargoidshieldflashers.position = il;
			      thargoidshieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			      thargoidshieldflashers.target = ship;
			      break;
			      }
               case 0.8:
                  {
			      var thargoidshieldflashers = ship.spawnOne("customshieldsshieldflasherthargoid" + customshieldsshieldcolorthargoid + "B" + sfs);
			      thargoidshieldflashers.position = il;
			      thargoidshieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			      thargoidshieldflashers.target = ship;
			      break;
			      }
               case 0.7:
                  {
			      var thargoidshieldflashers = ship.spawnOne("customshieldsshieldflasherthargoid" + customshieldsshieldcolorthargoid + "C" + sfs);
			      thargoidshieldflashers.position = il;
			      thargoidshieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			      thargoidshieldflashers.target = ship;
			      break;
			      }
               case 0.6:
                  {
			      var thargoidshieldflashers = ship.spawnOne("customshieldsshieldflasherthargoid" + customshieldsshieldcolorthargoid + "D" + sfs);
			      thargoidshieldflashers.position = il;
			      thargoidshieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			      thargoidshieldflashers.target = ship;
			      break;
			      }
               case 0.5:
                  {
		          var thargoidshieldflashers = ship.spawnOne("customshieldsshieldflasherthargoid" + customshieldsshieldcolorthargoid + "E" + sfs);
			      thargoidshieldflashers.position = il;
			      thargoidshieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			      thargoidshieldflashers.target = ship;
			      break;
			      }
               case 0.4:
                  {
			      var thargoidshieldflashers = ship.spawnOne("customshieldsshieldflasherthargoid" + customshieldsshieldcolorthargoid + "F" + sfs);
			      thargoidshieldflashers.position = il;
			      thargoidshieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			      thargoidshieldflashers.target = ship;
			      break;
			      }
               case 0.3:
                  {
			      var thargoidshieldflashers = ship.spawnOne("customshieldsshieldflasherthargoid" + customshieldsshieldcolorthargoid + "G" + sfs);
			      thargoidshieldflashers.position = il;
			      thargoidshieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			      thargoidshieldflashers.target = ship;
			      break;
			      }
               case 0.2:
                  {
			      var thargoidshieldflashers = ship.spawnOne("customshieldsshieldflasherthargoid" + customshieldsshieldcolorthargoid + "H" + sfs);
			      thargoidshieldflashers.position = il;
			      thargoidshieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			      thargoidshieldflashers.target = ship;
			      break;
			      }
               case 0.1:
                  {
			      var thargoidshieldflashers = ship.spawnOne("customshieldsshieldflasherthargoid" + customshieldsshieldcolorthargoid + "I" + sfs);
			      thargoidshieldflashers.position = il;
			      thargoidshieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			      thargoidshieldflashers.target = ship;
			      break;
			      }
               case 0.0:
                  {
			      var thargoidshieldflashers = ship.spawnOne("customshieldsshieldflasherthargoid" + customshieldsshieldcolorthargoid + "J" + sfs);
			      thargoidshieldflashers.position = il;
			      thargoidshieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			      thargoidshieldflashers.target = ship;
			      break;
			      }
               }
            }
		 }
      }
   if(ship.isPlayer || ship.isSubEntity || ship.isStation || ship.isThargoid || ship.isRock || ship.isCargo || ship.isWeapon || ship.isDerelict || ship.primaryRole === "wreckage" || ship.scanClass === "CLASS_BUOY" || (ship.scriptInfo.npc_shields && ship.scriptInfo.npc_shields === "no"))
      {
      return;
	  }	  
   if(this.customshieldsshieldtype === "basic")//main npc shielding routines using only energy level to control the shield and damage effects
      {
      if(ship.mass > 0 && ship.mass <= 5000)
         {
         ship.script.customshieldsshieldflashersize = 1;
         }
      if(ship.mass > 5000 && ship.mass <= 50000)
         {
         ship.script.customshieldsshieldflashersize = 2;
         }    
      if(ship.mass > 50000 && ship.mass <= 150000)
         {
         ship.script.customshieldsshieldflashersize = 3;
         }  
      if(ship.mass > 150000 && ship.mass <= 500000)
         {
         ship.script.customshieldsshieldflashersize = 4;
         }
      if(ship.mass > 500000)
         {
         ship.script.customshieldsshieldflashersize = 5;
         }
      ship.script.customshieldsspeedcollisionradiusadjustment = (ship.maxSpeed / 350) * 8;	
      ship.script.customshieldsshieldcolor = worldScripts["customshields"].customshieldsshieldcolor;
	  ship.script.customshieldshitrange = worldScripts["customshields"].customshieldshitrange;
	  //----------------------------------------------------begin cloaked attacker code
	  ship.script.$customshieldsshipbeingattackedbycloaked = ship.script.shipBeingAttackedByCloaked;
	  ship.script.shipBeingAttackedByCloaked = function()
         {
	     if(player.ship.isCloaked === true)//if the player ship is cloaked it is likely to be the attacker
		    {
		    ship.script.customshieldscloakedattacker = player.ship;//tell the target who attacked
			}
         if(ship.script.$customshieldsshipbeingattackedbycloaked)
		    {
            ship.script.$customshieldsshipbeingattackedbycloaked.apply(this, arguments);
            }
         }
	  ship.script.$customshieldsshipattackedother = ship.script.shipAttackedOther;
	  ship.script.shipAttackedOther = function(other)
         {
	     if(ship.isCloaked === true)//a cloaked npc attacking another npc will override the player as the cloaked attacker when the player is also cloaked
		    {
		    other.script.customshieldscloakedattacker = ship;//tell the target who attacked
			}
         if(ship.script.$customshieldsshipattackedother)
		    {
            ship.script.$customshieldsshipattackedother.apply(this, arguments);
            }
        }
      ship.script.$customshieldsshiptakingdamage = ship.script.shipTakingDamage;
      ship.script.shipTakingDamage = function(amount, whom, type)
         {
		 if(ship.script.customshieldscloakedattacker)//if this key exists the attacker is cloaked
            {
	        whom = ship.script.customshieldscloakedattacker;//whom must be the cloaked attacker, make it so
	        delete ship.script.customshieldscloakedattacker;//reset this key
	        }//---------------------------------------------end cloaked attacker code
		 if(whom && whom.position !== undefined)
            {
			if(ship.speed > ship.maxSpeed)//added for shield collision issue
               {
               var speedcollisionradiusadjustment = (ship.speed / ship.maxSpeed) * ship.script.customshieldsspeedcollisionradiusadjustment;
	           }
            else
               {
	           var speedcollisionradiusadjustment = 0;
	           }
	        var impactradiusfactor = ((3 * (1500 / (ship.position.distanceTo(whom.position)))) + 16);	 
            var impactlocation = whom.position.add(whom.vectorForward.multiply((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1 + speedcollisionradiusadjustment)));//determine possible forward weapon hit location
            if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
               {
               impactlocation = whom.position.add(whom.vectorForward.multiply(-((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1 + speedcollisionradiusadjustment))));//determine possible aft weapon hit location
               if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                  {
                  impactlocation = whom.position.add(whom.vectorRight.multiply((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1 + speedcollisionradiusadjustment)));//determine possible starboard weapon hit location
                  if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                     {
                     impactlocation = whom.position.add(whom.vectorRight.multiply(-((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1 + speedcollisionradiusadjustment))));//determine possible port weapon hit location
                     if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                        {			   
                        var impactinterpolation = ((ship.collisionRadius + 1 + speedcollisionradiusadjustment) / (ship.position.distanceTo(whom.position)));  
                        impactlocation = Vector3D.interpolate(ship.position, whom.position, impactinterpolation);//interpolate weapon hit directly between ship and attacker as a fallback position
                        }
                     }
                  }
               }
            var attackerdirection = whom.position.subtract(impactlocation).direction();
            var impactdirection = impactlocation.subtract(ship.position).direction();
            var impactrelativeposition = impactlocation.subtract(ship.position);
            var impactangle = ship.heading.angleTo(impactdirection);
	        ship.script.customshieldsattackerdirection = attackerdirection;
	        ship.script.customshieldsimpactdirection = impactdirection;
            ship.script.customshieldsimpactrelativeposition = impactrelativeposition;
            ship.script.customshieldsimpactlocation = impactlocation;
            if((ship.energy > (ship.maxEnergy * 0.2)) && (player.ship.isValid && player.ship.position.distanceTo(ship.position) < 51200))//determine if effect should be drawn, use "isVisible" in 1.77
               {
			   ship.script.customshieldsdrawshieldflashers = ((((ship.energy / ship.maxEnergy) - 0.2) / 4) * 5);
		       if((type === "scrape damage") && (whom.mass > 10000 || whom.velocity.magnitude > 500))
		          {
			      ship.script.$customshieldsdrawshieldflareup();
			      }
               else
			      {
			      ship.script.$customshieldsdrawshieldflashers();
			      }
			   }
            if((ship.energy <= (ship.maxEnergy * 0.2)) && (player.ship.isValid && player.ship.position.distanceTo(ship.position) < 51200))//determine if effect should be drawn, use "isVisible" in 1.77
               {
		       ship.script.$customshieldsdrawunshieldedhits();
		       }
            if(ship.script.$customshieldsshiptakingdamage)
		       {
               ship.script.$customshieldsshiptakingdamage.apply(this, arguments);
               }
            }
		 }
      ship.script.$customshieldsdrawunshieldedhits = function()
         {
		 var hitrange = ship.script.customshieldshitrange;
         var hitchance = Math.ceil(Math.random() * hitrange);
         switch(hitchance)
            {   
            case 1://10% nothing
	        case 2:
	        case 3:
	        case 4:
	        case 5:
	           {
		       break;
		       }
	        case 6://60% sparks
	        case 7:
	        case 8:
	        case 9:
	        case 10:
	        case 11:
	        case 12:
	        case 13:
	        case 14:
	        case 15:
	        case 16:
	        case 17:
	        case 18:
	        case 19:
	        case 20:
	        case 21:
	        case 22:
	        case 23:
	        case 24:
	        case 25:
	        case 26:
	        case 27:
	        case 28:
	        case 29:
	        case 30:
	        case 31:
	        case 32:
	        case 33:
	        case 34:
	        case 35:
               {
               var sparks = system.addShips("customshieldssparks", 1, ship.script.customshieldsimpactlocation, 0);
               break;
               }
            case 36://20% blown panels
            case 37:
	        case 38:
	        case 39:
	        case 40:
	        case 41:
	        case 42:
	        case 43:
	        case 44:
	        case 45:
               {
               var il = ship.script.customshieldsimpactlocation;
               var id = ship.script.customshieldsimpactdirection;
		       var sparksblownpanels = ship.spawnOne("customshieldssparksblownpanels");
               sparksblownpanels.position = il;
		       sparksblownpanels.orientation = id.rotationTo([0, 0, 1]);
		       sparksblownpanels.velocity = ship.velocity.add(sparksblownpanels.vectorForward.multiply((Math.ceil(Math.random() * 150)) + 50));
               break;
               }
            case 46://currently nothing, future expansion
            case 47:
	        case 48:
	        case 49:
	           {
		       break;
		       }
            case 50://fuel leak caused by hull rupture
               {
			   if(ship.script.customshieldsfuelleakflag === 1.0)
			      {
			      break;
			      }
               this.customshieldsfuelleakflag = 1.0;
			   var il = ship.script.customshieldsimpactlocation;
               var id = ship.script.customshieldsimpactdirection;
		       var sparksfuelleaks = ship.spawnOne("customshieldssparksfuelleaks");
               sparksfuelleaks.position = il;
		       sparksfuelleaks.orientation = id.rotationTo([0, 0, 1]);
               sparksfuelleaks.target = ship;
               break;
               }
            }
         }  
      ship.script.$customshieldsdrawshieldflareup = function()
         {
         var dsf = ship.script.customshieldsdrawshieldflashers;
	     var sfs = ship.script.customshieldsshieldflashersize;
         var il = ship.script.customshieldsimpactlocation;
         dsf = Math.floor(dsf * 10);
         dsf = (dsf / 10);
         switch(dsf)
            {   
            case 0.9:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupA" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.8:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupB" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.7:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupC" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.6:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupD" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.5:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupE" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.4:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupF" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.3:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupG" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.2:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupH" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.1:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupI" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.0:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupJ" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            }
         }        
      ship.script.$customshieldsdrawshieldflashers = function()
         {
	     var customshieldsshieldcolor = ship.script.customshieldsshieldcolor;
	     var dsf = ship.script.customshieldsdrawshieldflashers;
	     var sfs = ship.script.customshieldsshieldflashersize;
	     var il = ship.script.customshieldsimpactlocation;
	     var ad = ship.script.customshieldsattackerdirection;
	     dsf = Math.floor(dsf * 10);
         dsf = (dsf / 10);
	     switch(dsf)
            {   
            case 0.9:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "A" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.8:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "B" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.7:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "C" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.6:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "D" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.5:
               {
		       var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "E" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.4:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "F" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.3:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "G" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.2:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "H" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.1:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "I" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.0:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "J" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            }
         }
      }
   if(this.customshieldsshieldtype === "advanced")//main npc shielding routines using realistic forward and aft virtual shields to control the shield and damage effects and equipment
      {   	  
      ship.script.customshieldsmaxforwardshieldlevel = 128;
      ship.script.customshieldsmaxaftshieldlevel = 128;
      ship.script.customshieldsshieldrechargingrate = 1.0;
      ship.script.customshieldsshieldrechargingratemultiplier = 0.0;
      ship.script.customshieldslastenergylevel = ship.energy;
      if(ship.equipmentStatus("EQ_SHIELD_BOOSTER") === "EQUIPMENT_OK")
         {
	     ship.removeEquipment("EQ_SHIELD_BOOSTER");
         ship.script.customshieldsmaxforwardshieldlevel += 128;
         ship.script.customshieldsmaxaftshieldlevel += 128;
         }
      if(ship.equipmentStatus("EQ_SHIELD_ENHANCER") === "EQUIPMENT_OK")
         {
	     ship.removeEquipment("EQ_SHIELD_ENHANCER");
         ship.script.customshieldsmaxforwardshieldlevel += 128;
         ship.script.customshieldsmaxaftshieldlevel += 128;
	     ship.script.customshieldsshieldrechargingrate = 1.5;
	     ship.script.customshieldsshieldrechargingratemultiplier = 0.5;
         }
      if(worldScripts["shieldequalizercapacitors"])
         {
	     if(Math.random() <= 0.10)
	        {
		    if(Math.random() <= 0.50)
		       {
			   ship.awardEquipment("EQ_SHIELD_EQUALIZER");
			   }
            if(Math.random() <= 0.50)
		       {
			   ship.awardEquipment("EQ_FORWARD_SHIELD_CAPACITOR");
			   ship.script.customshieldsmaxforwardshieldlevel += 64;
			   }
            if(Math.random() <= 0.50)
		       {
			   ship.awardEquipment("EQ_AFT_SHIELD_CAPACITOR");
			   ship.script.customshieldsmaxaftshieldlevel += 64;
			   }
		    }
	     }
      if(worldScripts["Shield Cycler"])
         {
	     if(Math.random() <= 0.10)
	        {
		    if((Math.random() <= 0.50) && (ship.equipmentStatus("EQ_SHIELD_EQUALIZER") !== "EQUIPMENT_OK"))
		       {
			   ship.awardEquipment("EQ_SC_SHIELD_CYCLER_INTERNAL");
			   }
            }
         }
      if(ship.mass > 0 && ship.mass <= 5000)
         {
         ship.script.customshieldsshieldflashersize = 1;
         }
      if(ship.mass > 5000 && ship.mass <= 50000)
         {
         ship.script.customshieldsshieldflashersize = 2;
         }    
      if(ship.mass > 50000 && ship.mass <= 150000)
         {
         ship.script.customshieldsshieldflashersize = 3;
         }  
      if(ship.mass > 150000 && ship.mass <= 500000)
         {
         ship.script.customshieldsshieldflashersize = 4;
         }
      if(ship.mass > 500000)
         {
         ship.script.customshieldsshieldflashersize = 5;
         }
      ship.script.customshieldsspeedcollisionradiusadjustment = (ship.maxSpeed / 350) * 8;
      ship.script.customshieldsshieldcolor = worldScripts["customshields"].customshieldsshieldcolor;
	  ship.script.customshieldshitrange = worldScripts["customshields"].customshieldshitrange;
      ship.script.customshieldsforwardshieldlevel = ship.script.customshieldsmaxforwardshieldlevel;
      ship.script.customshieldsaftshieldlevel = ship.script.customshieldsmaxaftshieldlevel;
	  //----------------------------------------------------begin cloaked attacker code
	  ship.script.$customshieldsshipbeingattackedbycloaked = ship.script.shipBeingAttackedByCloaked;
	  ship.script.shipBeingAttackedByCloaked = function()
         {
	     if(player.ship.isCloaked === true)//if the player ship is cloaked it is likely to be the attacker
		    {
		    ship.script.customshieldscloakedattacker = player.ship;//tell the target who attacked
			}
         if(ship.script.$customshieldsshipbeingattackedbycloaked)
		    {
            ship.script.$customshieldsshipbeingattackedbycloaked.apply(this, arguments);
            }
         }
	  ship.script.$customshieldsshipattackedother = ship.script.shipAttackedOther;
	  ship.script.shipAttackedOther = function(other)
         {
	     if(ship.isCloaked === true)//a cloaked npc attacking another npc will override the player as the cloaked attacker when the player is also cloaked
		    {
		    other.script.customshieldscloakedattacker = ship;//tell the target who attacked
			}
         if(ship.script.$customshieldsshipattackedother)
		    {
            ship.script.$customshieldsshipattackedother.apply(this, arguments);
            }
        }
      ship.script.$customshieldsshiptakingdamage = ship.script.shipTakingDamage;
      ship.script.shipTakingDamage = function(amount, whom, type)
         {
		 if(ship.script.customshieldscloakedattacker)//if this key exists the attacker is cloaked
            {
	        whom = ship.script.customshieldscloakedattacker;//whom must be the cloaked attacker, make it so
	        delete ship.script.customshieldscloakedattacker;//reset this key
	        }//---------------------------------------------end cloaked attacker code
		 if(whom && whom.position !== undefined)
            {
			if(ship.speed > ship.maxSpeed)//added for shield collision issue
               {
               var speedcollisionradiusadjustment = (ship.speed / ship.maxSpeed) * ship.script.customshieldsspeedcollisionradiusadjustment;
	           }
            else
               {
	           var speedcollisionradiusadjustment = 0;
	           }
	        var impactradiusfactor = ((3 * (1500 / (ship.position.distanceTo(whom.position)))) + 16);	 
            var impactlocation = whom.position.add(whom.vectorForward.multiply((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1 + speedcollisionradiusadjustment)));//determine possible forward weapon hit location
            if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
               {
               impactlocation = whom.position.add(whom.vectorForward.multiply(-((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1 + speedcollisionradiusadjustment))));//determine possible aft weapon hit location
               if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                  {
                  impactlocation = whom.position.add(whom.vectorRight.multiply((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1 + speedcollisionradiusadjustment)));//determine possible starboard weapon hit location
                  if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                     {
                     impactlocation = whom.position.add(whom.vectorRight.multiply(-((whom.position.distanceTo(ship.position)) - (ship.collisionRadius + 1 + speedcollisionradiusadjustment))));//determine possible port weapon hit location
                     if((ship.position.distanceTo(impactlocation)) > (ship.collisionRadius + speedcollisionradiusadjustment + impactradiusfactor))//too far from ship because of delay to hit from plasma weapon or off vector angle because of thargoid laser
                        {			   
                        var impactinterpolation = ((ship.collisionRadius + 1 + speedcollisionradiusadjustment) / (ship.position.distanceTo(whom.position)));  
                        impactlocation = Vector3D.interpolate(ship.position, whom.position, impactinterpolation);//interpolate weapon hit directly between ship and attacker as a fallback position
                        }
                     }
                  }
               }
            var attackerdirection = whom.position.subtract(impactlocation).direction();
            var impactdirection = impactlocation.subtract(ship.position).direction();
            var impactrelativeposition = impactlocation.subtract(ship.position);
            var impactangle = ship.heading.angleTo(impactdirection);
	        ship.script.customshieldsattackerdirection = attackerdirection;
	        ship.script.customshieldsimpactdirection = impactdirection;
            ship.script.customshieldsimpactrelativeposition = impactrelativeposition;
            ship.script.customshieldsimpactlocation = impactlocation;
            if((ship.script.customshieldsforwardshieldlevel > 0) && (impactangle <= 1.57))//choose the shield that was hit
               {
               ship.script.customshieldsforwardshieldlevel -= amount;//subtract from shield
               var forwardshieldrecovery = amount;
               if(ship.script.customshieldsforwardshieldlevel < 0)//shield minimum is 0, give overflow damage to energy
                  {
                  forwardshieldrecovery += ship.script.customshieldsforwardshieldlevel;
			      var transferredamount = (ship.script.customshieldsforwardshieldlevel * -1);
                  ship.script.customshieldsforwardshieldlevel = 0;
			      if(((ship.equipmentStatus("EQ_SHIELD_EQUALIZER") === "EQUIPMENT_OK") || (ship.equipmentStatus("EQ_SC_SHIELD_CYCLER_INTERNAL") === "EQUIPMENT_OK")) && (ship.script.customshieldsaftshieldlevel > 0))//take from the opposite shield before energy adjustment
                     {
			         ship.script.customshieldsaftshieldlevel -= transferredamount;
                     var aftshieldrecovery = transferredamount;
                     if(ship.script.customshieldsaftshieldlevel < 0)//shield minimum is 0, give overflow damage to energy
                        {
                        aftshieldrecovery += ship.script.customshieldsaftshieldlevel;
                        ship.script.customshieldsaftshieldlevel = 0;
				        forwardshieldrecovery = aftshieldrecovery;
                        }
			         }
                  }
               if((ship.equipmentStatus("EQ_SHIELD_EQUALIZER") === "EQUIPMENT_OK") || (ship.equipmentStatus("EQ_SC_SHIELD_CYCLER_INTERNAL") === "EQUIPMENT_OK"))//final division of shield energy between shields
                  {
			      if((ship.equipmentStatus("EQ_SC_SHIELD_CYCLER_INTERNAL") === "EQUIPMENT_OK") && (ship.energy > 5))
			         {
			         ship.energy -= 4.0;//shield cycler transfer energy loss(minimum)
			         }
                  var shieldtransfer = ((ship.script.customshieldsforwardshieldlevel + ship.script.customshieldsaftshieldlevel) / 2);
                  ship.script.customshieldsforwardshieldlevel = shieldtransfer;
                  ship.script.customshieldsaftshieldlevel = shieldtransfer;
			      }
               ship.energy += forwardshieldrecovery;//restore energy	 
               if(player.ship.isValid && player.ship.position.distanceTo(ship.position) < 51200)//determine if effect should be drawn, use "isVisible" in 1.77
                  {
			      ship.script.customshieldsdrawshieldflashers = (ship.script.customshieldsforwardshieldlevel / ship.script.customshieldsmaxforwardshieldlevel);
		          if((type === "scrape damage") && (whom.mass > 10000 || whom.velocity.magnitude > 500))
		             {
			         ship.script.$customshieldsdrawshieldflareup();
			         }
                  else
			         {
			         ship.script.$customshieldsdrawshieldflashers();
			         }
			      }
               }
            if((ship.script.customshieldsforwardshieldlevel === 0) && (impactangle <= 1.57) && (player.ship.isValid && player.ship.position.distanceTo(ship.position) < 51200))//determine if effect should be drawn, use "isVisible" in 1.77
               {
		       ship.script.$customshieldsdrawunshieldedhits();
		       }
            if((ship.script.customshieldsaftshieldlevel > 0) && (impactangle > 1.57))//choose the shield that was hit
               {// the shield is depleted
               ship.script.customshieldsaftshieldlevel -= amount;//subtract from shield
               var aftshieldrecovery = amount;
               if(ship.script.customshieldsaftshieldlevel < 0)//shield minimum is 0, give overflow damage to energy
                  {
                  aftshieldrecovery += ship.script.customshieldsaftshieldlevel;
			      var transferredamount = (ship.script.customshieldsaftshieldlevel * -1);
                  ship.script.customshieldsaftshieldlevel = 0;
			      if(((ship.equipmentStatus("EQ_SHIELD_EQUALIZER") === "EQUIPMENT_OK") || (ship.equipmentStatus("EQ_SC_SHIELD_CYCLER_INTERNAL") === "EQUIPMENT_OK")) && (ship.script.customshieldsforwardshieldlevel > 0))//take from the opposite shield before energy adjustment
                     {
			         ship.script.customshieldsforwardshieldlevel -= transferredamount;
                     var forwardshieldrecovery = transferredamount;
                     if(ship.script.customshieldsforwardshieldlevel < 0)//shield minimum is 0, give overflow damage to energy
                        {
                        forwardshieldrecovery += ship.script.customshieldsforwardshieldlevel;
                        ship.script.customshieldsforwardshieldlevel = 0;
				        aftshieldrecovery = forwardshieldrecovery;
                        }
			         }
                  }
               if((ship.equipmentStatus("EQ_SHIELD_EQUALIZER") === "EQUIPMENT_OK") || (ship.equipmentStatus("EQ_SC_SHIELD_CYCLER_INTERNAL") === "EQUIPMENT_OK"))//final division of shield energy between shields
                  {
			      if((ship.equipmentStatus("EQ_SC_SHIELD_CYCLER_INTERNAL") === "EQUIPMENT_OK") && (ship.energy > 5))
			         {
			         ship.energy -= 4.0;//shield cycler transfer energy loss(minimum)
			         }
                  var shieldtransfer = ((ship.script.customshieldsforwardshieldlevel + ship.script.customshieldsaftshieldlevel) / 2);
                  ship.script.customshieldsforwardshieldlevel = shieldtransfer;
                  ship.script.customshieldsaftshieldlevel = shieldtransfer;
			      }
               ship.energy += aftshieldrecovery;//restore energy	 		 
               if(player.ship.isValid && player.ship.position.distanceTo(ship.position) < 51200)//determine if effect should be drawn, use "isVisible" in 1.77
		          {
			      ship.script.customshieldsdrawshieldflashers = (ship.script.customshieldsaftshieldlevel / ship.script.customshieldsmaxaftshieldlevel);
			      if((type === "scrape damage") && (whom.mass > 10000 || whom.velocity.magnitude > 500))
		             {
			         ship.script.$customshieldsdrawshieldflareup();
			         }
                  else
			         {
			         ship.script.$customshieldsdrawshieldflashers();
			         }
			      }
               }
            if((ship.script.customshieldsaftshieldlevel === 0) && (impactangle > 1.57) && (player.ship.isValid && player.ship.position.distanceTo(ship.position) < 51200))//determine if effect should be drawn, use "isVisible" in 1.77
               {
		       ship.script.$customshieldsdrawunshieldedhits();
		       }		 
            if(ship.script.customshieldsshieldrechargeTimer)//start shield recharge
		       {
		       ship.script.customshieldsshieldrechargeTimer.start();
               }
            else
		       {
		       ship.script.customshieldsshieldrechargeTimer = new Timer(ship.script, ship.script.$customshieldsshieldrecharge, 0.5, 0.5);
               }		 
            if(ship.script.$customshieldsshiptakingdamage)
		       {
               ship.script.$customshieldsshiptakingdamage.apply(this, arguments);
               }
            }
		 }
      ship.script.$customshieldsdrawunshieldedhits = function()
         {
		 var hitrange = ship.script.customshieldshitrange;
         var hitchance = Math.ceil(Math.random() * hitrange);
         switch(hitchance)
            {   
            case 1://10% nothing
	        case 2:
	        case 3:
	        case 4:
	        case 5:
	           {
		       break;
		       }
	        case 6://60% sparks
	        case 7:
	        case 8:
	        case 9:
	        case 10:
	        case 11:
	        case 12:
	        case 13:
	        case 14:
	        case 15:
	        case 16:
	        case 17:
	        case 18:
	        case 19:
	        case 20:
	        case 21:
	        case 22:
	        case 23:
	        case 24:
	        case 25:
	        case 26:
	        case 27:
	        case 28:
	        case 29:
	        case 30:
	        case 31:
	        case 32:
	        case 33:
	        case 34:
	        case 35:
               {
               var sparks = system.addShips("customshieldssparks", 1, ship.script.customshieldsimpactlocation, 0);
               break;
               }
            case 36://20% blown panels
            case 37:
	        case 38:
	        case 39:
	        case 40:
	        case 41:
	        case 42:
	        case 43:
	        case 44:
	        case 45:
               {
               var il = ship.script.customshieldsimpactlocation;
               var id = ship.script.customshieldsimpactdirection;
		       var sparksblownpanels = ship.spawnOne("customshieldssparksblownpanels");
               sparksblownpanels.position = il;
		       sparksblownpanels.orientation = id.rotationTo([0, 0, 1]);
		       sparksblownpanels.velocity = ship.velocity.add(sparksblownpanels.vectorForward.multiply((Math.ceil(Math.random() * 150)) + 50));
               break;
               }
            case 46://currently nothing, future expansion
            case 47:
	        case 48:
	        case 49:
	           {
		       break;
		       }
            case 50://fuel leak caused by hull rupture
               {
			   if(ship.script.customshieldsfuelleakflag === 1.0)
			      {
			      break;
			      }
               this.customshieldsfuelleakflag = 1.0;
			   var il = ship.script.customshieldsimpactlocation;
               var id = ship.script.customshieldsimpactdirection;
		       var sparksfuelleaks = ship.spawnOne("customshieldssparksfuelleaks");
               sparksfuelleaks.position = il;
		       sparksfuelleaks.orientation = id.rotationTo([0, 0, 1]);
               sparksfuelleaks.target = ship;
               break;
               }
            }
         }  	  
      ship.script.$customshieldsdrawshieldflareup = function()
         {
         var dsf = ship.script.customshieldsdrawshieldflashers;
	     var sfs = ship.script.customshieldsshieldflashersize;
         var il = ship.script.customshieldsimpactlocation;
         dsf = Math.floor(dsf * 10);
         dsf = (dsf / 10);
         switch(dsf)
            {   
            case 0.9:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupA" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.8:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupB" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.7:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupC" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.6:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupD" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.5:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupE" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.4:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupF" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.3:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupG" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.2:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupH" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.1:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupI" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            case 0.0:
               {
		       var shieldflareup = ship.spawnOne("customshieldsshieldflasherflareupJ" + sfs);
               shieldflareup.position = il;
               shieldflareup.target = ship;
               break;
               }
            }
         }   
      ship.script.$customshieldsdrawshieldflashers = function()
         {
	     var customshieldsshieldcolor = ship.script.customshieldsshieldcolor;
	     var dsf = ship.script.customshieldsdrawshieldflashers;
	     var sfs = ship.script.customshieldsshieldflashersize;
	     var il = ship.script.customshieldsimpactlocation;
	     var ad = ship.script.customshieldsattackerdirection;
	     dsf = Math.floor(dsf * 10);
         dsf = (dsf / 10);
	     switch(dsf)
            {   
            case 0.9:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "A" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.8:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "B" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.7:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "C" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.6:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "D" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.5:
               {
		       var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "E" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.4:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "F" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.3:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "G" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.2:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "H" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.1:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "I" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            case 0.0:
               {
			   var shieldflashers = ship.spawnOne("customshieldsshieldflasher" + customshieldsshieldcolor + "J" + sfs);
			   shieldflashers.position = il;
			   shieldflashers.orientation = ad.rotationTo([0, 0, 1]);
			   shieldflashers.target = ship;
			   break;
			   }
            }
         }
      ship.script.$customshieldsshieldrecharge = function()
         {
         if(ship.energy < ship.maxEnergy || ship.isDerelict)// recharge shields after energy has been recharged and derelicts have no shields to recharge
            {
		    if((ship.energy > ship.script.customshieldslastenergylevel) && ((ship.energy - ship.script.customshieldslastenergylevel) <= 10.0))//level went up but not much indicates charging rather than a one shot oxp energy replacement
		       {
			   ship.script.customshieldsenergyrecharged = ((ship.energy - ship.script.customshieldslastenergylevel) * ship.script.customshieldsshieldrechargingratemultiplier);
			   ship.energy += ship.script.customshieldsenergyrecharged;//add any multiplier of the ships built-in energy recharge rate to the ship's energy
			   ship.script.customshieldslastenergylevel = ship.energy;
			   }
            return;
            }
         ship.script.customshieldsforwardshieldlevel += ship.script.customshieldsshieldrechargingrate;
	     ship.script.customshieldsaftshieldlevel += ship.script.customshieldsshieldrechargingrate;
         if(ship.script.customshieldsforwardshieldlevel >= ship.script.customshieldsmaxforwardshieldlevel)
            {
            ship.script.customshieldsforwardshieldlevel = ship.script.customshieldsmaxforwardshieldlevel;//forward shield fully charged
            if(ship.script.customshieldsaftshieldlevel >= ship.script.customshieldsmaxaftshieldlevel)
               {
               ship.script.customshieldsaftshieldlevel = ship.script.customshieldsmaxaftshieldlevel;//aft shield fully charged
               ship.script.customshieldsshieldrechargeTimer.stop();//stop timer when both shields fully charged
			   return;
               }
            return;
            }
         if(ship.script.customshieldsaftshieldlevel >= ship.script.customshieldsmaxaftshieldlevel)
            {
            ship.script.customshieldsaftshieldlevel = ship.script.customshieldsmaxaftshieldlevel;//aft shield fully charged
            return;
		    }     
         }	  
      ship.script.$customshieldsshipdied = ship.script.shipDied;
      ship.script.shipDied = function(whom, why)
         {
         if(ship.script.customshieldsshieldrechargeTimer)// recharge timer is stopped and removed if the ship dies
            {
            ship.script.customshieldsshieldrechargeTimer.stop();
            delete ship.script.customshieldsshieldrechargeTimer;
            }
         if(ship.script.$customshieldsshipdied)
	        {
            ship.script.$customshieldsshipdied.apply(this, arguments);
		    }
         }
      }
   }
Scripts/customshieldsblownpanels.js
this.name        = "customshieldsblownpanels"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept.24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Blown Panels"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsblownpaneldestruction = Math.ceil(Math.random() * 30);   
      this.customshieldsblownpanelTimer = new Timer(this, this.customshieldsblownpanel, this.customshieldsblownpaneldestruction, -1);
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.customshieldsblownpanel = function()
   {
   this.ship.explode();
   return;
   }

this.shipRemoved = this.entityDestroyed = function()//remove timers that are not needed
   {
   if(this.customshieldsblownpanelTimer && this.customshieldsblownpanelTimer.isRunning)
      {
      this.customshieldsblownpanelTimer.stop();
	  delete this.customshieldsblownpanelTimer;
      }
   }
   
this.shipWasScooped = function(scooper)
   {
   this.cargotype = "Alloys";
   this.quantity = parseInt(1);
   this.ship.setCargo(this.cargotype, this.quantity);
   this.message = this.quantity + " ton Alloys";
   if(scooper.isPlayer)
      {
      player.consoleMessage(this.message);
      }
   }
Scripts/customshieldsdamage.js
this.name        = "customshieldsdamage"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Damage"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.ship.explode();
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   } 
Scripts/customshieldsfuelleaks.js
this.name        = "customshieldsfuelleaks"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Fuel Leaks"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
      {
	  this.customshieldsframetime = 0.0;
	  this.customshieldsframetimelimit = this.ship.target.fuel;
	  this.ship.velocity = this.ship.velocity.add(this.ship.vectorForward.multiply(10 + (this.customshieldsframetimelimit * 3)));
	  this.csfl = addFrameCallback(this.customshieldsfuelleaks.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   if(this.customshieldsframetimelimit > (this.customshieldsframetime + 1.0))
      {
	  this.customshieldsframetimelimit = (this.customshieldsframetime + 1.0);//1 second left to exist, collision dissipates vapor cloud
	  }
   }   
   
this.customshieldsfuelleaks = function(delta)
   {
   if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
      {
	  this.customshieldsframetime += delta;
	  this.customshieldsfuelscooperpossibilities = system.filteredEntities(this, function (entity){return ((entity.fuel < 7.0) && (entity.equipmentStatus("EQ_FUEL_SCOOPS") === "EQUIPMENT_OK") && (entity !== this.ship.target))}, this.ship, 25);//must have space for fuel, working fuel scoops, and not be the one leaking the fuel to begin with 
      if(this.customshieldsfuelscooperpossibilities.length > 0)
	     {
		 if(this.customshieldsfuelscooperpossibilities[0].isPlayer)
		    {
			player.consoleMessage("Fuel vapor detected, scooping...", 4);
			if(player.ship.scoopOverride === false)//if effect is not currently active
			   {
			   player.ship.scoopOverride = true;//activate the effect
			   this.ship.spawnOne("customshieldsfuelleaksscoopoverride");//spawn marker timer for effect control
			   }
			}
		 var fuelchance = Math.ceil(Math.random() * 10);
		 if(fuelchance === 1)//1 in 10 clouds scooped results in 0.1 ly of fuel and 3 clouds spawned for every 0.1 ly of fuel a ship has results in an average max recovery of 30% of the fuel if you scoop every cloud
		    {
		    this.customshieldsfuelscooperpossibilities[0].fuel += 0.1;//contains 0.1ly fuel
			}
         removeFrameCallback(this.csfl);//----------
		 this.ship.remove();//each vapor cloud piece can be scooped only once so remove it		 
         return;
		 }	  
	  if(this.customshieldsframetime >= this.customshieldsframetimelimit)//length of time fuel vapor exists
	     {
		 removeFrameCallback(this.csfl);//----------
		 this.ship.remove();		 
         return;
		 }
      return;
      }
   else
      {
	  removeFrameCallback(this.csfl);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsfuelleaksscoopoverride.js
this.name        = "customshieldsfuelleaksscoopoverride"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Fuel Leaks Scoop Override"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csflso = addFrameCallback(this.customshieldsfuelleaksscoopoverride.bind(this));//----------
      return;
	  }
   else
      {
	  player.ship.scoopOverride = false;
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }     
   
this.customshieldsfuelleaksscoopoverride = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 2.0)//length of time scoop override effect lasts
	     {
		 player.ship.scoopOverride = false;
		 removeFrameCallback(this.csflso);//----------
		 this.ship.remove();		 
         return;
		 }
      }
   else
      {
	  player.ship.scoopOverride = false;
	  removeFrameCallback(this.csflso);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsmissilemineflareupA.js
this.name        = "customshieldsmissilemineflareupA"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Missile Mine Explosions"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csmmfu = addFrameCallback(this.customshieldsmissilemineflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }
 
this.customshieldsmissilemineflareup = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.1)//interval between to the next animation frame
	     {
		 this.customshieldsmissilemineexplosion = this.ship.spawnOne("customshieldsmissilemineflareupB");
         this.customshieldsmissilemineexplosion.position = this.ship.position;
		 this.customshieldsmissilemineexplosion.orientation = this.ship.orientation;
		 this.customshieldsmissilemineexplosion.velocity = this.ship.velocity;
		 removeFrameCallback(this.csmmfu);//----------
         this.ship.explode();		
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.csmmfu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsmissilemineflareupB.js
this.name        = "customshieldsmissilemineflareupB"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Missile Mine Explosions"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csmmfu = addFrameCallback(this.customshieldsmissilemineflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }
 
this.customshieldsmissilemineflareup = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.1)//interval between to the next animation frame
	     {
		 this.customshieldsmissilemineexplosion = this.ship.spawnOne("customshieldsmissilemineflareupC");
         this.customshieldsmissilemineexplosion.position = this.ship.position;
		 this.customshieldsmissilemineexplosion.orientation = this.ship.orientation;
		 this.customshieldsmissilemineexplosion.velocity = this.ship.velocity;
		 removeFrameCallback(this.csmmfu);//----------
         this.ship.explode();			 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.csmmfu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsmissilemineflareupC.js
this.name        = "customshieldsmissilemineflareupC"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Missile Mine Explosions"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csmmfu = addFrameCallback(this.customshieldsmissilemineflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.customshieldsmissilemineflareup = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.1)//interval between to the next animation frame
	     {
		 this.customshieldsmissilemineexplosion = this.ship.spawnOne("customshieldsmissilemineflareupD");
         this.customshieldsmissilemineexplosion.position = this.ship.position;
		 this.customshieldsmissilemineexplosion.orientation = this.ship.orientation;
		 this.customshieldsmissilemineexplosion.velocity = this.ship.velocity;
		 removeFrameCallback(this.csmmfu);//----------
         this.ship.explode();			 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.csmmfu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsmissilemineflareupD.js
this.name        = "customshieldsmissilemineflareupD"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Missile Mine Explosions"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csmmfu = addFrameCallback(this.customshieldsmissilemineflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.customshieldsmissilemineflareup = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.1)//interval between to the next animation frame
	     {
		 this.customshieldsmissilemineexplosion = this.ship.spawnOne("customshieldsmissilemineflareupE");
         this.customshieldsmissilemineexplosion.position = this.ship.position;
		 this.customshieldsmissilemineexplosion.orientation = this.ship.orientation;
		 removeFrameCallback(this.csmmfu);//----------
		 this.ship.explode();		 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.csmmfu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsmissilemineflareupE.js
this.name        = "customshieldsmissilemineflareupE"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Missile Mine Explosions"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csmmfu = addFrameCallback(this.customshieldsmissilemineflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }    
   
this.customshieldsmissilemineflareup = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.1)//interval between to the next animation frame
	     {
		 this.customshieldsmissilemineexplosion = this.ship.spawnOne("customshieldsmissilemineflareupF");
         this.customshieldsmissilemineexplosion.position = this.ship.position;
		 this.customshieldsmissilemineexplosion.orientation = this.ship.orientation;
		 removeFrameCallback(this.csmmfu);//----------
		 this.ship.remove();		 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.csmmfu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsmissilemineflareupF.js
this.name        = "customshieldsmissilemineflareupF"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Missile Mine Explosions"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csmmfu = addFrameCallback(this.customshieldsmissilemineflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }     
   
this.customshieldsmissilemineflareup = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.1)//interval between to the next animation frame
	     {
		 this.customshieldsmissilemineexplosion = this.ship.spawnOne("customshieldsmissilemineflareupG");
         this.customshieldsmissilemineexplosion.position = this.ship.position;
		 this.customshieldsmissilemineexplosion.orientation = this.ship.orientation;
		 removeFrameCallback(this.csmmfu);//----------
		 this.ship.remove();		 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.csmmfu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsmissilemineflareupG.js
this.name        = "customshieldsmissilemineflareupG"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Missile Mine Explosions"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csmmfu = addFrameCallback(this.customshieldsmissilemineflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }     
   
this.customshieldsmissilemineflareup = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.1)//interval between to the next animation frame
	     {
		 this.customshieldsmissilemineexplosion = this.ship.spawnOne("customshieldsmissilemineflareupH");
         this.customshieldsmissilemineexplosion.position = this.ship.position;
		 this.customshieldsmissilemineexplosion.orientation = this.ship.orientation;
		 removeFrameCallback(this.csmmfu);//----------
		 this.ship.remove();		 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.csmmfu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsmissilemineflareupH.js
this.name        = "customshieldsmissilemineflareupH"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Missile Mine Explosions"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csmmfu = addFrameCallback(this.customshieldsmissilemineflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }     
   
this.customshieldsmissilemineflareup = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.1)//interval between to the next animation frame
	     {
		 this.customshieldsmissilemineexplosion = this.ship.spawnOne("customshieldsmissilemineflareupI");
         this.customshieldsmissilemineexplosion.position = this.ship.position;
		 this.customshieldsmissilemineexplosion.orientation = this.ship.orientation;
		 removeFrameCallback(this.csmmfu);//----------
		 this.ship.remove();		 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.csmmfu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsmissilemineflareupI.js
this.name        = "customshieldsmissilemineflareupI"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Missile Mine Explosions"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csmmfu = addFrameCallback(this.customshieldsmissilemineflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }     
   
this.customshieldsmissilemineflareup = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.1)//interval between to the next animation frame
	     {
		 this.customshieldsmissilemineexplosion = this.ship.spawnOne("customshieldsmissilemineflareupJ");
         this.customshieldsmissilemineexplosion.position = this.ship.position;
		 this.customshieldsmissilemineexplosion.orientation = this.ship.orientation;
		 removeFrameCallback(this.csmmfu);//----------
		 this.ship.remove();		 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.csmmfu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsmissilemineflareupJ.js
this.name        = "customshieldsmissilemineflareupJ"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Missile Mine Explosions"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.customshieldsframetime = 0.0;
      this.csmmfu = addFrameCallback(this.customshieldsmissilemineflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }     
   
this.customshieldsmissilemineflareup = function(delta)
   {
   if(this.ship && this.ship.isValid)
      {
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.1)//interval between to the next animation frame
	     {
		 removeFrameCallback(this.csmmfu);//----------
		 this.ship.remove();		 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.csmmfu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsplayershieldflash.js
this.name        = "customshieldsplayershieldflash"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Player Shield Flash"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
      {
      this.customshieldsimpactrelativepositioninterpolation = worldScripts["customshields"].customshieldsimpactrelativepositioninterpolation;
	  this.ship.position = this.ship.target.position.add(this.customshieldsimpactrelativepositioninterpolation);
	  this.customshieldsframetime = 0.0;
	  this.cspsf = addFrameCallback(this.customshieldsplayershieldflash.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }  
   
this.customshieldsplayershieldflash = function(delta)
   {
   if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
      {
	  this.ship.position = this.ship.target.position.add(this.customshieldsimpactrelativepositioninterpolation); 
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.15)//length of time shield effect lasts
	     {
		 removeFrameCallback(this.cspsf);//----------
		 this.ship.remove();		 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.cspsf);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsshieldflasher.js
this.name        = "customshieldsshieldflasher"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Shield Flashers"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
      {
	  if(this.ship.target.isPlayer)
	     {
		 this.customshieldsimpactrelativeposition = worldScripts["customshields"].customshieldsimpactrelativeposition;
		 }
      else
	     {
	     this.customshieldsimpactrelativeposition = this.ship.target.script.customshieldsimpactrelativeposition;
		 }
	  this.ship.position = this.ship.target.position.add(this.customshieldsimpactrelativeposition);
	  this.customshieldsframetime = 0.0;
	  this.cssf = addFrameCallback(this.customshieldsshieldflasher.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }     
   
this.customshieldsshieldflasher = function(delta)
   {
   if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
      {
	  this.ship.position = this.ship.target.position.add(this.customshieldsimpactrelativeposition); 
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.15)//length of time shield effect lasts
	     {
		 removeFrameCallback(this.cssf);//----------
		 this.ship.remove();		 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.cssf);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldsshieldflasherflareup.js
this.name        = "customshieldsshieldflasherflareup"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Shield Flasher Flare Ups"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
      {
	  if(this.ship.target.isPlayer)
	     {
		 this.customshieldsimpactrelativeposition = worldScripts["customshields"].customshieldsimpactrelativeposition;
		 }
      else
	     {
	     this.customshieldsimpactrelativeposition = this.ship.target.script.customshieldsimpactrelativeposition;
		 }
	  this.ship.position = this.ship.target.position.add(this.customshieldsimpactrelativeposition);
	  this.customshieldsframetime = 0.0;
	  this.cssffu = addFrameCallback(this.customshieldsshieldflasherflareup.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }  
   
this.customshieldsshieldflasherflareup = function(delta)
   {
   if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
      {
	  this.ship.position = this.ship.target.position.add(this.customshieldsimpactrelativeposition); 
	  this.customshieldsframetime += delta;
	  if(this.customshieldsframetime >= 0.45)//length of time shield effect lasts
	     {
		 removeFrameCallback(this.cssffu);//----------
		 this.ship.remove();		 
         return;
		 }
      }
   else
      {
	  removeFrameCallback(this.cssffu);//----------
      this.ship.remove();   
      return;
	  }
   }
Scripts/customshieldssparks.js
this.name        = "customshieldssparks"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Sparks"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      this.ship.explode();
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   } 
Scripts/customshieldssparksblownpanels.js
this.name        = "customshieldssparksblownpanels"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Sparks and Blown Panels"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid)
      {
      var blownpanels = this.ship.spawnOne("customshieldsblownpanels");
      blownpanels.orientation = this.ship.orientation;
      blownpanels.velocity = this.ship.velocity;
      var sparks1 = this.ship.spawnOne("customshieldssparks");
	  sparks1.orientation = this.ship.orientation;
      sparks1.velocity = this.ship.velocity.add(sparks1.vectorForward.multiply(-25));
	  var sparks2 = this.ship.spawnOne("customshieldssparks");
	  sparks2.orientation = this.ship.orientation;
      sparks2.velocity = this.ship.velocity.add(sparks2.vectorForward.multiply(-25));
	  var sparks3 = this.ship.spawnOne("customshieldssparks");
	  sparks3.orientation = this.ship.orientation;
      sparks3.velocity = this.ship.velocity.add(sparks3.vectorForward.multiply(-25));
      this.ship.explode();
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }	  
   }
Scripts/customshieldssparksfuelleaks.js
this.name        = "customshieldssparksfuelleaks"; 
this.author      = "CommonSenseOTB"; 
this.copyright   = "Copyright Sept. 24, 2012 by CommonSenseOTB, licensed under Creative Commons: attribution, non-commercial, sharealike with clauses - see readme.txt";
this.description = "Script For Spawning Fuel Leaks"; 
this.version     = "0.83";

this.shipSpawned = function()
   {
   if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
      {
	  if(this.ship.target.isPlayer)
	     {
		 //message fuel leak here for player
		 //might have to use the player fuel leak command here instead to activate the built in warnings
		 player.consoleMessage("HULL BREACH! Fuel leak detected", 4);
		 this.customshieldsimpactrelativeposition = worldScripts["customshields"].customshieldsimpactrelativeposition;
		 }
      else
	     {
	     this.customshieldsimpactrelativeposition = this.ship.target.script.customshieldsimpactrelativeposition;
		 }
	  this.ship.position = this.ship.target.position.add(this.customshieldsimpactrelativeposition);	  
      this.customshieldsdirectionfuelleak = this.ship.position.subtract(this.ship.target.position).direction();
	  this.ship.orientation = this.customshieldsdirectionfuelleak.rotationTo([0, 0, 1]);
	  this.customshieldsframetime = 0.0;
	  this.customshieldsframetimefuelcounter = 1.0;
	  this.ship.spawnOne("customshieldsdamage");
	  this.ship.spawnOne("customshieldssparks");
      this.ship.spawnOne("customshieldssparks");
      this.ship.spawnOne("customshieldsblownpanels");
      this.ship.spawnOne("customshieldssparks");
      this.ship.spawnOne("customshieldssparks");
      this.ship.spawnOne("customshieldsblownpanels");
	  this.cssfl = addFrameCallback(this.customshieldssparksfuelleaks.bind(this));//----------
      return;
	  }
   else
      {
	  this.ship.remove();
	  return;
	  }
   }

this.shipTakingDamage = function()
   {
   this.ship.energy = this.ship.maxEnergy;//restore energy
   }     
   
this.customshieldssparksfuelleaks = function(delta)
   {
   if(this.ship && this.ship.isValid && this.ship.target && this.ship.target.isValid)
      {
	  this.ship.position = this.ship.target.position.add(this.customshieldsimpactrelativeposition);
	  this.customshieldsdirectionfuelleak = this.ship.position.subtract(this.ship.target.position).direction();
	  this.ship.orientation = this.customshieldsdirectionfuelleak.rotationTo([0, 0, 1]);
	  this.customshieldsframetime += delta;
	  if(this.ship.target.fuel < 0.1)//when out of fuel stop spawning it
	     {
		 removeFrameCallback(this.cssfl);//----------
		 this.ship.remove();		 
         return;
		 }
	  if(this.customshieldsframetime >= 0.1)//length of time between spawning fuel
	     {
		 this.customshieldsframetime = 0.0;//reset for next spawning
		 this.customshieldsframetimefuelcounter += 1.0;
		 if(this.customshieldsframetimefuelcounter >= 4.0)//3 clouds for every 0.1 ly of fuel
		    {
			this.customshieldsframetimefuelcounter = 1.0;
			this.ship.target.fuel -= 0.1;//remove fuel from leaking ship
			}
		 if(this.ship.target.fuel > 5.0)
		    {
			this.customshieldshighfuel = this.ship.spawnOne("customshieldsfuelleakshigh");
			this.customshieldshighfuel.orientation = this.ship.orientation;
            this.customshieldshighfuel.target = this.ship.target;
			return;
			}
         if(this.ship.target.fuel > 2.0)
		    {
			this.customshieldsmediumfuel = this.ship.spawnOne("customshieldsfuelleaksmedium");
			this.customshieldsmediumfuel.orientation = this.ship.orientation;
            this.customshieldsmediumfuel.target = this.ship.target;
			return;
			}
         if(this.ship.target.fuel > 0.1)
		    {
			this.customshieldslowfuel = this.ship.spawnOne("customshieldsfuelleakslow");
			this.customshieldslowfuel.orientation = this.ship.orientation;
            this.customshieldslowfuel.target = this.ship.target;
			return;
			}
         return;
		 }
      return;
      }
   else
      {
	  removeFrameCallback(this.cssfl);//----------
      this.ship.remove();   
      return;
	  }
   }