| Scripts/BUS_gecko_dragon_ship_script.js | this.name			= "BUS_gecko_dragon_ship_script";
this.author			= "Montana05";
this.description	= "ship script for Gecko 'Dragon Class'";
this.version		= "0.52";
this.copyright		= "2021 Montana05";
this.licence   		= "CC BY-NC-SA 4.0";
"use strict";
this.shipSpawned = function(ship)
{
	this.$BUSgdc_shipType = this.ship.dataKey;
	var shipRole = this.ship.primaryRole;
	
	if(this.ship.hasRole("escape-capsule"))
	{
		// neutral inits first
		var crewName = expandDescription("[nom]");
		var crewDescription = "a crew member of an evacuated ship";
		var crewRole = "hunter";  // not perfect but somewhere in the middle
		var crewRank = "Commander";
		var bhgRank = "Hunter";  // middle rank
		var crewRace = expandDescription("[MRP01_GalCop_races_scientific]");  // add a race to the crew members
		var crewBounty = 0;
		var crewInsurance = 0;
		
		this.$BUSgdc_crew_ranks_array = ["Gunner", "Co-Pilot", "Pilot", "Commander"];  // based on an crew of 1 to 2 person
		crewRank = 
		$BUSgdc_crew_ranks_array[Math.floor(Math.random() * $BUSgdc_crew_ranks_array.length)];
		// ranks for Bounty Hunter Guild taken from Random Hits OXP, all credits to LittleBear
		this.$BUSgdc_bhg_ranks_array = 
		["Outsider", "Recruit", "Vigilante", "Bailiff", "Deputy", "Tracker", "Hunter", "Sheriff", "Provost", "Marshal", "Enforcer", "Executioner", "Judge"];
		bhgRank = 
		$BUSgdc_bhg_ranks_array[Math.floor(Math.random() * $BUSgdc_bhg_ranks_array.length)];
		switch(this.$BUSgdc_shipType) 
		{
			case "BUS_gecko_dragon_escape_capsule":
				crewName = ("the " + crewRace + " " + crewRank + " " + expandDescription("[nom]"));
				crewDescription = "a ship crew member";
				crewInsurance = this.$getRndInteger(90, 450);
				crewRole = "hunter";
				break;
			case "BUS_gecko_dragon_escape_capsule_bhg":
				crewName = ("the " + crewRace + " " + bhgRank + " " + expandDescription("[nom]"));
				crewDescription = "a member of the Bounty Hunter Guild";
				crewInsurance = (this.$getRndInteger(90, 450) * 1.10);  // BHG got better insurance conditions
				crewRole = "hunter";
				break;
			case "BUS_gecko_dragon_escape_capsule_ssg":	
		
				crewName = ("the " + crewRace + " " + crewRank + " " + expandDescription("[nom]"));
				crewDescription = "a SSG ship crew member";
				crewInsurance = (this.$getRndInteger(90, 450) * 1.25);  // SSG got better insurance conditions
				crewRole = "hunter";
				break;
			
			case "BUS_gecko_dragon_escape_capsule_bhg_pirate":
				
				crewName = ("the " + crewRace + " " + bhgRank + " " + expandDescription("[nom]"));
				crewDescription = "a rouge member of the Bounty Hunter Guild";
				crewBounty = (this.$getRndInteger(90, 450) * 1.10) + (15 * system.government);  // stable governments pay extra bonus
				crewRole = "hunter";
				break;
			
			case "BUS_gecko_dragon_escape_capsule_ssg_pirate":
				
				crewName = ("the " + crewRace + " " + crewRank + " " + expandDescription("[nom]"));
				crewDescription = "a rouge SSG ship crew member";
				crewBounty = (this.$getRndInteger(90, 450) * 1.25) + (15 * system.government);  // stable governments pay extra bonus
				crewRole = "hunter";
				break;
									
			case "BUS_gecko_dragon_escape_capsule_pirate":
				crewName = ("the " + crewRace + " " + expandDescription("[MRP01_pirate_nicknames]") + expandDescription("[nom]"));
				crewDescription = "a criminal wanted by GalCop police";
				crewRole = "pirate";
				crewBounty = this.$getRndInteger(90, 450) + (15 * system.government);  // stable governments pay extra bonus
				break;	
				
			default: 
				break;		
		};
		this.ship.setCrew
		(
			{
				name: crewName,
				short_description: crewDescription,
				role: crewRole,
				species: crewRace,
				insurance: crewInsurance,
				bounty: crewBounty
			}
		);
		// remove individual roles
		this.ship.primaryRole = "escape-capsule";
	}
	else
	{
		// individual role of the ship, will only be called from other OXP's 
		switch(shipRole) 
		{
			case "BUS_gecko_dragon_01":
			case "BUS_gecko_dragon_02":
			case "BUS_gecko_dragon_ssg":
			
				this.ship.primaryRole = "escort-heavy";
				break;
				
			case "BUS_gecko_dragon_hunt_01":
			case "BUS_gecko_dragon_hunt_02":
			case "BUS_gecko_dragon_hunt_02_team_01":
			case "BUS_gecko_dragon_ssg_team_01":
				
				this.ship.switchAI("oolite-bountyHunterAI.js");
				this.ship.primaryRole = "hunter";
				break;
			case "BUS_gecko_dragon_pirate_01":
			case "BUS_gecko_dragon_pirate_02":
				
				this.ship.primaryRole = "pirate";
				break;
			
			default: 
				break;		
		};		
		
		switch(this.$BUSgdc_shipType) 
		{
			case "BUS_gecko_dragon_01":
			case "BUS_gecko_dragon_02":
			case "BUS_gecko_dragon_hunt_01":
			case "BUS_gecko_dragon_hunt_02":
			case "BUS_gecko_dragon_ssg":
			case "BUS_gecko_dragon_hunt_02_team_01":
			case "BUS_gecko_dragon_ssg_team_01":
						
				if(this.ship.cargoSpaceUsed <= 1)
				{
					this.ship.adjustCargo(this.$BUSgdc_space_jockeyCargo(), 1);
					this.ship.adjustCargo(this.$BUSgdc_space_jockeyCargo(), 1);
				};
				break;
			case "BUS_gecko_dragon_pirate_01":
			case "BUS_gecko_dragon_pirate_02":
				
				this.ship.setCargoType("PLENTIFUL_GOODS");
				break;		
			default: 
				break;		
		};	
	};
};
this.shipDied = function(whom, why)
{
	if(this.ship.hasRole("escape-capsule"))
	{
		return;
	}
	else
	{
		// neutral inits first
		var podType = "escape-capsule";
		var criminalCrew = 0;
		var debrisCount = 0;
		var cargoType = "";
		var cargoPod = "cargopod";
		var cargoLoad = this.ship.cargoSpaceUsed;
		var cargoCount = 0;
				
		if(this.ship.bounty > 7 || 
		   this.$BUSgdc_shipType == "BUS_gecko_dragon_pirate_01" || 
		   this.$BUSgdc_shipType == "BUS_gecko_dragon_pirate_02")
				criminalCrew = 1;
		
		switch(this.$BUSgdc_shipType) 
		{
			case "BUS_gecko_dragon_01":
			case "BUS_gecko_dragon_02":
			case "BUS_gecko_dragon_hunt_01":	
			
				if(criminalCrew == 1)
					podType = "BUS_gecko_dragon_escape_capsule_pirate";	
				else
				{
					podType = "BUS_gecko_dragon_escape_capsule";
				};
				break;
			case "BUS_gecko_dragon_hunt_02":
			case "BUS_gecko_dragon_hunt_02_team_01":
						
				if(criminalCrew == 1)
					podType = "BUS_gecko_dragon_escape_capsule_bhg_pirate";	
				else
				{
					podType = "BUS_gecko_dragon_escape_capsule_bhg";
				};
				break;
			case "BUS_gecko_dragon_ssg":
			case "BUS_gecko_dragon_ssg_team_01":
						
				if(criminalCrew == 1)
					podType = "BUS_gecko_dragon_escape_capsule_ssg_pirate";	
				else
				{
					podType = "BUS_gecko_dragon_escape_capsule_ssg";
				};
				break;
			case "BUS_gecko_dragon_pirate_01":
			case "BUS_gecko_dragon_pirate_02":	
				
				podType = "BUS_gecko_dragon_escape_capsule_pirate";
				break;
			default: 
				break;	
		};	
		
		// emergency crafts
		system.addShips(podType, 1, this.ship.position);
		// cargopods
		if(cargoLoad > 0)
		{
			for(var i = this.ship.cargoList.length - 1 ; i >= 0 ; --i)
			{
				cargoType = this.ship.cargoList[i].commodity;
				cargoPod = ("MRP01_container_" + cargoType);
				cargoCount = this.ship.cargoList[i].quantity;
							
				system.addShips(cargoPod, cargoCount, this.ship.position);
			};
		};
		
		/*
		// outsourced to Montanas Ressource Pack 01 V 0.54
		debrisCount = this.$getRndInteger(3, 6);
		// explosive shrapnels
		system.addShips("MRP01_effects_explosive_shrapnel", debrisCount, this.ship.position);
		// various depris
		system.addShips("MRP01_ship_debris", debrisCount, this.ship.position);
		// burning fuel
		debrisCount = (this.ship.fuel.toFixed(0));	
		system.addShips("MRP01_effects_burningFuel", debrisCount, this.ship.position);
		*/
	};
};
// food, booze and guns, what else you need for your trip ? :P
this.$BUSgdc_space_jockeyCargo = function()
{
	this.$BUSgdc_space_jockey_cargo_array = ["firearms", "food", "liquor_wines"];
	if(worldScripts["witchfire-populator"])  // Darkside Moonshine Distillery OXP
		this.$BUSgdc_space_jockey_cargo_array.push("witchfire_whiskey");
	var space_jockey_cargo = 
	$BUSgdc_space_jockey_cargo_array[Math.floor(Math.random() * $BUSgdc_space_jockey_cargo_array.length)];
	return (space_jockey_cargo);
};
this.$getRndInteger = function(min, max)
{
	return Math.floor(Math.random() * (max - min + 1) ) + min;
};
 |