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

Expansion Griff Cobra MkIII Alt

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Alternative Highpoly version of the Cobra Mk III. Requires a video card capable of supporting Oolite Shaders Alternative Highpoly version of the Cobra Mk III. Requires a video card capable of supporting Oolite Shaders
Identifier oolite.oxp.Griff.Cobra_MKIII_Alt oolite.oxp.Griff.Cobra_MKIII_Alt
Title Griff Cobra MkIII Alt Griff Cobra MkIII Alt
Category Ships Ships
Author Griff Griff
Version 1.3.4 1.3.4
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
  • oolite.oxp.Griff.Griff_shipset_decals:1.0
  • oolite.oxp.Griff_alloys_and_wreckage:1.0
  • oolite.oxp.Griff.Griff_shipset_decals:1.0
  • oolite.oxp.Griff_alloys_and_wreckage:1.0
  • Optional Expansions
    Conflict Expansions
    Information URL http://wiki.alioth.net/index.php/Griff_Industries n/a
    Download URL https://wiki.alioth.net/img_auth.php/4/45/Oolite.oxp.Griff.Cobra_MKIII_Alt.oxz n/a
    License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
    File Size n/a
    Upload date 1610873286

    Documentation

    Also read http://wiki.alioth.net/index.php/Griff%20Cobra%20MkIII%20Alt

    Equipment

    This expansion declares no equipment.

    Ships

    Name
    Missile
    griff_cobra_Mk3_alt_pirate-NPC_scuffed
    griff_cobra_Mk3_alt_trader-NPC_clean
    griff_cobra_Mk3_alt_trader-NPC_scuffed
    Cobra Mark III
    griff_normalmapped_alt_cobra_mkIII_Multidecal_PLAYER_scuffed
    Cobra Mark III

    Models

    This expansion declares no models.

    Scripts

    Path
    Scripts/griff_cobra_III_(alt)_externalMissiles.js
    "use strict";
    this.name				= "griff_cobra_III_(alt)_externalMissiles.js";
    this.author				= "Thargoid";
    this.copyright			= "Creative Commons: attribution, non-commercial, sharealike.";
    this.description		= "Generic external missile launching script";
    this.version			= "1.01";
    
    this.shipSpawned = function()
    	{ // just to ensure ship is fully loaded with selected missile type and nothing else
    	if(this.ship.scriptInfo.missileRole) // missileRole should be defined in shipdata.plist
    		{ this.missileRole = this.ship.scriptInfo.missileRole; }
    	else
    		{ this.missileRole = "EQ_MISSILE"; } // default to standard missile if not
        
        if (this.ship.scriptInfo.initialMissiles)
            {this.initialMissiles = parseInt(this.ship.scriptInfo.initialMissiles);}
        else
            {this.initialMissiles = this.ship.missileCapacity;};
        
    	if (this.ship.missiles.length > 0) this.ship.awardEquipment("EQ_MISSILE_REMOVAL"); // remove all spawning missiles and restock with selected ones.
    	var addCounter = 0; 
    	for(addCounter = 0; addCounter < this.initialMissiles;addCounter++)
    		{ this.ship.awardEquipment(this.missileRole); }
    	}
    
    this.shipFiredMissile = function(missile, target)
    	{
    	if(!this.ship.subEntities || this.ship.subEntities.length === 0) {return}; // if we've run out of sub-ents before we run out of missiles
    	
    	var subCounter = this.ship.subEntities.length - 1; // Set counter to number of sub-ents minus 1 (as entity array goes up from zero)
    	for(subCounter = this.ship.subEntities.length - 1;subCounter>=0;subCounter--)
    		{
    		if(this.ship.subEntities[subCounter].hasRole(missile.primaryRole)) // if the sub-ent is the same as the missile being fired
    			{
    			missile.position = this.localToGlobal(this.ship.subEntities[subCounter].position); // move the fired missile to the sub-ent position
    			missile.orientation = this.ship.subEntities[subCounter].orientation.multiply(this.ship.orientation); // point the missile in the right direction
    			missile.desiredSpeed = missile.maxSpeed;
    			this.ship.subEntities[subCounter].remove(); // remove the sub-ent version of the missile
    			break; // come out of the loop, as we've done our swap
    			}
    		}
    	}
    
    this.localToGlobal = function(position)
    	{ // sub-ent position is relative to mother, but for swapping we need the absolute global position
    	let orientation = this.ship.orientation;
    	return this.ship.position.add(position.rotateBy(orientation));
    	}
    
    this.shipTakingDamage = function(amount, fromEntity, damageType)
    	{
    	if(this.ship.missiles.length === 0 && this.ship.subEntities.length === 0) // if we're all out of missiles and any sub-entities, bail out.
    		{ return; }
    	
    	this.missileSubs = 0;
    	var subCounter = this.ship.subEntities.length - 1; // Set counter to number of sub-ents minus 1 (as entity array goes up from zero)
    	for(subCounter = this.ship.subEntities.length - 1;subCounter>=0;subCounter--)
    		{
    		if(this.ship.subEntities[subCounter].hasRole(this.missileRole)) // if the sub-ent is a missile, count it
    			{ this.missileSubs++; }
    		}
    	
    	if(this.missileSubs === 0 && this.ship.subEntities.length === 0) // if we're all out of missiles and missile sub-entities, bail out.
    		{ return; }
    	
    	if(this.missileSubs < this.ship.missiles.length) // if we've got more missiles than sub-entity missiles
    		{
    		this.ship.awardEquipment("EQ_MISSILE_REMOVAL"); // get rid of all missiles
    		if(this.missileSubs > 0)
    			{
    			var missileCounter = 0; 
    			for(missileCounter = 0;missileCounter<this.missileSubs;missileCounter++) // restock with the correct number of selected missile
    				{ this.ship.awardEquipment(this.missileRole); }
    			}
    		return;	
    		}
    		
    	if(this.missileSubs > this.ship.missiles.length) // if we've got less missiles than sub-entity missiles
    		{
    		this.difference = this.missileSubs - this.ship.missiles.length;
    		var removeCounter = 0; 
    		for(removeCounter = 0;removeCounter<this.difference;removeCounter++) // loop through however many subs we need to remove
    				{
    				var subCounter = this.ship.subEntities.length - 1; // Set counter to number of sub-ents minus 1 (as entity array goes up from zero)
    				for(subCounter = this.ship.subEntities.length - 1;subCounter>=0;subCounter--)
    					{
    					if(this.ship.subEntities[subCounter].hasRole(this.missileRole)) // if the sub-ent is a missile, remove it
    						{ 
    						this.ship.subEntities[subCounter].remove(); 
    						break;
    						}
    					}
    				}
    		return;		
    		}	
    	}
    	
    this.shipDied = function() // event that occurs when the entity (ship) whose script this is dies
    	{
    
    	if(!this.ship || (player.ship.isValid && this.ship.position.distanceTo(player.ship.position) > 50000)) return; // exit the script if the explosion happens far from the player
    
     		this.largeCount = (Math.ceil(Math.random() * 4)); // between 0-4 pieces of wreckage
    		this.tinyCount =  (Math.ceil(Math.random() * 10) + 5); // between 5-10 tiny spark fragments
    		this.sparkCount =  (Math.ceil(Math.random() * 20) + 10); // between 10-20 spin spark fragments
    		this.ship.spawn("griffspark", this.tinyCount); // spawn the tiny spark fragments
    
    
    	if(this.largeCount > 0) // if there is large wreckage
    		{
    		this.ship.spawn("griffwreckage", this.largeCount); // spawn the larger wreckage
    		this.ship.spawn("spinspark", this.sparkCount); // spawn the spin sparks
    
    		}
    
    	}