Scripts/adck_snark.js |
this.name = "adck_snark";
this.author = "Montana05";
this.description = "event handler for the ADCK Snark OXP";
this.version = "1.11";
this.copyright = "2022 Montana05";
this.licence = "CC BY-NC-SA 4.0";
"use strict";
this.shipSpawned = function(ship)
{
if(ship.dataKey.search(/adck_snark/i) < 0 || ship.hasRole("cargopod") || ship.isSubEntity || ship.isPlayer)
{
return;
}
else
{
var shipType = ship.dataKey;
var shipRole = ship.primaryRole;
// setup escape pods
if(ship.hasRole("escape-capsule"))
{
let crewName = expandDescription("[nom]");
let crewDescription = "a fighter pilot";
let crewRole = "hunter"; // the role is not particular important anymore, all data will be added by the script
let crewRace = expandDescription("[adck_snark_races_scientific]"); // add a race to the crew members
let crewRank = "Commander";
let bhgRank = "Hunter"; // middle rank
let crewInsurance = this.$getRndInteger(90, 450);
let crewBounty = 0;
// 1 crew member
const adck_snark_crew_ranks_array = ["Pilot", "Commander"];
crewRank =
adck_snark_crew_ranks_array[Math.floor(Math.random() * adck_snark_crew_ranks_array.length)];
// ranks for Bounty Hunter Guild taken from Random Hits OXP, all credits to LittleBear
const adck_snark_bhg_ranks_array =
["Outsider", "Recruit", "Vigilante", "Bailiff", "Deputy", "Tracker", "Hunter", "Sheriff", "Provost", "Marshal", "Enforcer", "Executioner", "Judge"];
bhgRank =
adck_snark_bhg_ranks_array[Math.floor(Math.random() * adck_snark_bhg_ranks_array.length)];
switch(shipType)
{
case "adck_snark_escape_suit":
crewName = ("the " + crewRace + " " + crewRank + " " + expandDescription("[nom]"));
crewDescription = "a fighter pilot";
crewRole = "hunter";
crewInsurance = this.$getRndInteger(90, 450);
break;
case "adck_snark_escape_suit_criminal":
crewName = ("the " + crewRace + " " + expandDescription("[nom]"));
crewDescription = "a " + expandDescription("[adck_snark_criminals]") + "wanted by GalCop police";
crewRole = "pirate";
crewBounty = crewInsurance + (15 * system.government); // stable governments pay extra bonus
crewInsurance = 0;
break;
case "adck_snark_escape_suit_pirate":
crewName = ("the " + crewRace + " " + expandDescription("[adck_snark_pirate_nicknames]") + expandDescription("[nom]"));
crewDescription = "a " + expandDescription("[adck_snark_criminals]") + "wanted by GalCop police";
crewRole = "pirate";
crewBounty = (crewInsurance * 1.25) + (25 * system.government); // stable governments pay extra bonus
crewInsurance = 0;
break;
case "adck_snark_escape_suit_ssg":
crewName = ("the " + crewRace + " " + crewRank + " " + expandDescription("[nom]"));
crewDescription = "a SSG ship crew member";
crewRole = "hunter";
crewInsurance = (crewInsurance * 1.25); // SSG got better insurance conditions
break;
case "adck_snark_escape_suit_ssg_criminal":
crewName = ("the " + crewRace + " " + crewRank + " " + expandDescription("[nom]"));
crewDescription = "a rogue SSG ship crew member";
crewRole = "pirate";
crewBounty = (crewInsurance * 1.25) + (15 * system.government); // stable governments pay extra bonus
crewInsurance = 0;
break;
case "adck_snark_escape_suit_bhg":
crewName = ("the " + crewRace + " " + bhgRank + " " + expandDescription("[nom]"));
crewDescription = "a member of the Bounty Hunter Guild";
crewRole = "hunter";
crewInsurance = (crewInsurance * 1.10); // BHG got better insurance conditions
break;
case "adck_snark_escape_suit_bhg_criminal":
crewName = ("the " + crewRace + " " + bhgRank + " " + expandDescription("[nom]"));
crewDescription = "a rogue member of the Bounty Hunter Guild";
crewRole = "pirate";
crewBounty = (crewInsurance * 1.10) + (15 * system.government); // stable governments pay extra bonus
crewInsurance = 0;
break;
case "adck_snark_escape_suit_police":
const adck_snark_police_ranks_array = ["Space Junior Lieutenant", "Space Lieutenant"]; // 1 crew member
crewRank =
adck_snark_police_ranks_array[Math.floor(Math.random() * adck_snark_police_ranks_array.length)];
crewName = ("the " + crewRace + " " + crewRank + " " + expandDescription("[nom]"));
crewDescription = "an officer of GalCop Space Police";
crewRole = "police";
crewInsurance = (this.$getRndInteger(90, 450) + (15 * system.government)); // stable governments pay additional reward
break;
default:
break;
};
ship.setCrew
(
{
name: crewName,
short_description: crewDescription,
role: crewRole,
species: crewRace,
insurance: crewInsurance,
bounty: crewBounty
}
);
// removes individual roles
ship.primaryRole = "escape-capsule";
}
else
{
switch(shipRole)
{
case "adck_snark":
case "adck_snark_ssg":
ship.primaryRole = "escort-medium";
break;
case "adck_snark_hunter":
case "adck_snark_bhg":
case "adck_snark_ssg_team_01":
case "adck_snark_bhg_team_01":
if(ship.primaryRole != "escort")
{
ship.primaryRole = "hunter-medium";
};
break;
case "adck_snark_police":
ship.primaryRole = "police";
break;
case "adck_snark_pirate":
ship.primaryRole = "pirate";
break;
default:
break;
};
};
// if there is an existing script in shipDied time to move it
ship.script.$adck_snark_shipDied_old = ship.script.shipDied;
ship.script.shipDied = this.$adck_snark_shipDied;
};
};
this.$adck_snark_shipDied = function $adck_snark_shipDied(whom, why)
{
if(this.ship.dataKey.search(/adck_snark/i) < 0 ||
this.ship.hasRole("escape-capsule") || this.ship.hasRole("cargopod") || this.ship.isSubEntity || this.ship.isPlayer)
{
return;
}
else
{
this.name = "adck_snark";
let shipType = this.ship.dataKey;
let shipBounty = this.ship.bounty;
let shipPos = this.ship.position;
let criminalCrew = 0;
let pirateCrew = 0;
if(shipBounty > 7 && shipBounty < 15)
{
criminalCrew = 1;
};
if(shipBounty > 14 || this.ship.isPirate)
{
pirateCrew = 1;
};
switch(shipType)
{
case "adck_snark_ssg":
case "adck_snark_ssg_team_01":
if(criminalCrew == 1 || pirateCrew == 1)
{
system.addShips("adck_snark_escape_suit_ssg_criminal", 1, shipPos);
}
else
{
system.addShips("adck_snark_escape_suit_ssg", 1, shipPos);
};
break;
case "adck_snark_bhg":
case "adck_snark_bhg_team_01":
if(criminalCrew == 1 || pirateCrew == 1)
{
system.addShips("adck_snark_escape_suit_bhg_criminal", 1, shipPos);
}
else
{
system.addShips("adck_snark_escape_suit_bhg", 1, shipPos);
};
break;
case "adck_snark_police":
system.addShips("adck_snark_escape_suit_police", 1, shipPos);
break;
case "adck_snark_pirate":
system.addShips("adck_snark_escape_suit_pirate", 1, shipPos);
break;
default:
if(criminalCrew == 1)
{
system.addShips("adck_snark_escape_suit_criminal", 1, shipPos);
}
else if(pirateCrew == 1)
{
system.addShips("adck_snark_escape_suit_pirate", 1, shipPos);
}
else
{
system.addShips("adck_snark_escape_suit", 1, shipPos);
};
break;
};
};
if(this.ship.script.$adck_snark_shipDied_old)
{
this.ship.script.$adck_snark_shipDied_old(whom, why);
};
};
this.$getRndInteger = function(min, max)
{
return (Math.floor(Math.random() * (max - min + 1) ) + min);
};
|