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

Expansion gsagostinho's Cobra Mk. IV

Content

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description The Cobra Mk. IV is the successor of the extremely popular Cobra Mk. III. This is the heavier of all Cobra ships, and a fine choice for a trader due to its increased cargo capacity, larger energy banks as well as faster energy recharge rate, all of which should make up for its somewhat slower velocity and manoeuvring speeds. This ship is available for both the player and the NPCs. This work is based on Griff's Cobra Mk. III Alternative model. The Cobra Mk. IV is the successor of the extremely popular Cobra Mk. III. This is the heavier of all Cobra ships, and a fine choice for a trader due to its increased cargo capacity, larger energy banks as well as faster energy recharge rate, all of which should make up for its somewhat slower velocity and manoeuvring speeds. This ship is available for both the player and the NPCs. This work is based on Griff's Cobra Mk. III Alternative model.
Identifier gsagostinho.CobraMkIV gsagostinho.CobraMkIV
Title gsagostinho's Cobra Mk. IV gsagostinho's Cobra Mk. IV
Category Ships Ships
Author gsagostinho, Griff gsagostinho, Griff
Version 1.5 1.5
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
  • oolite.oxp.Griff_alloys_and_wreckage:1.0
  • oolite.oxp.Griff_alloys_and_wreckage:1.0
  • Optional Expansions
    Conflict Expansions
    Information URL http://wiki.alioth.net/index.php/Cobra_Mk.4_(Oolite) n/a
    Download URL https://wiki.alioth.net/img_auth.php/6/66/Gsagostinho.CobraMkIV.oxz n/a
    License CC-BY-NC-SA 4.0 CC-BY-NC-SA 4.0
    File Size n/a
    Upload date 1610873321

    Documentation

    Also read http://wiki.alioth.net/index.php/gsagostinho's%20Cobra%20Mk.%20IV

    README.txt

    gsagostinho's Cobra Mk. IV
    ==========================
    
    Version: 1.5
    Required Oolite Version: 1.80
    Author: Gilberto Agostinho (gsagostinho), Griff
    Credits: based on Griff's Cobra Mk. III Alternative model. See Griff's original credits below.
    License: CC-BY-NC-SA 4.0
    
    About
    =====
    
    The Cobra Mk. IV is the successor of the extremely popular Cobra Mk. III. This is the heavier of all Cobra ships, and a fine choice for a trader due to its increased cargo capacity, larger energy banks as well as faster energy recharge rate, all of which should make up for its somewhat slower velocity and manoeuvring speeds. This ship is available for both the player and the NPCs. This work is based on Griff's Cobra Mk. III Alternative model.
    
    I recommend NOT using Griff's original Cobra Mk. III Alt OXP, so that this alternative model is only used as the Cobra Mk. IV, making this ship visually different than any Mk. III (though there is of course no conflict between these two OXPs).
    
    Credits for the original Cobra Mk. III Alt
    ==========================================
    
    Detachable subentity missile concept & script - Thargoid
    Bugfixing and scripting technical help - Eric Walch
    OXP testing & feedback - Cody
    Models & Textures - Griff
    
    Version history
    ===============
    
    22/07/2018 = Version 1.5: small code improvement (thanks, phkb!).
    02/12/2017 - Version 1.4: tweaked the ship roles.
                              reformatting of shipdata.plist (thanks, Rustem!).
    22/08/2017 - Version 1.3: added ship library entry.
    09/08/2017 - Version 1.2: enlarged the model to 1.2x.
    09/08/2017 - Version 1.1: fixed some typos in the README and manifest files.
                              improved all textures.
                              improved specular lightning.
                              diminished cargo bay size to 45t (and 60t with extension).
                              lowered base price to 190000 Cr.
    08/08/2017 - Version 1.0: initial release.
    

    Equipment

    This expansion declares no equipment.

    Ships

    Name
    gsagostinho_cobra_mk4_black-PLAYER
    gsagostinho_cobra_mk4_black_green-PLAYER
    gsagostinho_cobra_mk4_black_green_pirate-NPC
    gsagostinho_cobra_mk4_black_green_trader-NPC
    gsagostinho_cobra_mk4_black_pirate-NPC
    gsagostinho_cobra_mk4_black_trader-NPC
    gsagostinho_cobra_mk4_blue-PLAYER
    gsagostinho_cobra_mk4_blue_pirate-NPC
    gsagostinho_cobra_mk4_blue_trader-NPC
    gsagostinho_cobra_mk4_cream_blue-PLAYER
    gsagostinho_cobra_mk4_cream_blue_pirate-NPC
    gsagostinho_cobra_mk4_cream_blue_trader-NPC
    gsagostinho_cobra_mk4_grey_orange-PLAYER
    gsagostinho_cobra_mk4_grey_orange_pirate-NPC
    gsagostinho_cobra_mk4_grey_orange_trader-NPC
    gsagostinho_cobra_mk4_orange_black-PLAYER
    gsagostinho_cobra_mk4_orange_black_pirate-NPC
    gsagostinho_cobra_mk4_orange_black_trader-NPC
    Cobra Mark IV
    gsagostinho_cobra_mk4_red_black-PLAYER
    gsagostinho_cobra_mk4_red_black_pirate-NPC
    gsagostinho_cobra_mk4_red_black_trader-NPC
    Cobra Mark IV
    Cobra Mark IV
    Missile
    gsagostinho_cobra_mk4_white_blue-PLAYER
    gsagostinho_cobra_mk4_white_blue_pirate-NPC
    gsagostinho_cobra_mk4_white_blue_trader-NPC

    Models

    This expansion declares no models.

    Scripts

    Path
    Scripts/gsagostinho_cobra_mk4_externalMissiles.js
    "use strict";
    this.name				= "gsagostinho_cobra_mk4_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 || 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
    
    		}
    
    	}