Scripts/illegal_goods_missions.js |
"use strict";
this.name = "illegal_goods_missions";
this.author = "capt murphy";
this.copyright = "2011 capt murphy";
this.licence = "CC BY-NC-SA 3.0";
this.description = "Missions worldscript for illegal_goods_tweak.";
// "my son" must always be in array position 1 for a particular mission
this._rescueeArray = ["me", "my son", "my daughter", "my partner", "my spouse", "my brother", "my sister", "my father", "my mother"];
//======================================================================================================================
// clears up missionVariables from previous versions,
this.startUp = function() {
if (missionVariables.ig_pendingmission === "no") {delete missionVariables.ig_pendingmission; delete missionVariables.ig_rescuetime; delete missionVariables.ig_missionlaunchtime; delete missionVariables.ig_rescuelocation;}
if (missionVariables.ig_currentmission === "no"){this.$ig_cleanupmissionvariables();}
delete missionVariables.ig_rescuelocation1;
if (!worldScripts.snoopers && !worldScripts.GNN) {
delete this.shipExitedWitchSpace;
}
}
//======================================================================================================================
// existing missions cleared on galactic jump
this.playerEnteredNewGalaxy = function() {
delete missionVariables.ig_pendingmission;
delete missionVariables.ig_rescuelocation;
delete missionVariables.ig_rescuetime;
delete missionVariables.ig_missionlaunchtime;
this.$ig_cleanupmissionvariables();
mission.setInstructionsKey (null, "illegal_goods_missions");
}
//======================================================================================================================
// used at startUp to clean old missionVariables and at the end of a mission.
this.$ig_cleanupmissionvariables = function() {
delete missionVariables.ig_currentmission;
delete missionVariables.ig_contactname;
delete missionVariables.ig_rescuee;
delete missionVariables.ig_rescuedwhen;
delete missionVariables.ig_missionsystem;
delete missionVariables.ig_missionsystemname;
delete missionVariables.ig_rescuelocationcurrent;
delete missionVariables.ig_missionreward;
delete missionVariables.ig_slaverbasedestroyed;
delete missionVariables.ig_special5end;
delete missionVariables.ig_special5slavecount;
}
//======================================================================================================================
this.missionScreenOpportunity = function() { // don't run if save anywhere scripted dock.
if (player.ship.docked && player.ship.dockedStation.isMainStation) {
this.$igmissionsetup();
this.$igmissionfinish();
delete missionVariables.ig_special5end; // needed to allow mission screen to run after handing over slaves at end of this mission.
}
}
// send a news item out after the slaver base is destroyed
this.shipExitedWitchspace = function() {
if (missionVariables.ig_slaverbasenewsitem && global.clock.seconds > parseInt(missionVariables.ig_slaverbasenewsitem)) {
var news = {ID:this.name,
Message:expandMissionText("special5_newsitem"),
Agency:1,
Priority:1
};
var g = worldScripts.GNN;
if (g) g._insertNews(news);
if (!g) {
var w = worldScripts.snoopers;
if (w) w.insertNews(news);
}
delete missionVariables.ig_slaverbasenewsitem;
delete missionVariables.ig_slaverbasesystem;
}
}
//======================================================================================================================
// if pending mission is true, mission launch time has passed and no current mission set up new mission,
this.$igmissionsetup = function() {
if (missionVariables.ig_pendingmission && !missionVariables.ig_currentmission && clock.days >= missionVariables.ig_missionlaunchtime) {
if (Math.random() < 0.4) {
this.$igspecialmissionsetup(); // set up one of 4 special missions
} else {
this.$igstandardmissionsetup(); // set up standard mission.
}
if (missionVariables.ig_currentmission) { // possible that no mission results from set-up
mission.runScreen({screenID: "igt_aimission", title: "Message from Amnesty Intergalactic", messageKey: "offer_mission"});
if (missionVariables.ig_currentmission == "standard") {
// email system interface
var w = worldScripts.EmailSystem;
if (w) {
w.$createEmail({sender:"Amnesty Intergalactic",
subject:"Meeting request",
date:global.clock.seconds,
message:expandMissionText("offer_mission"),
isRead:true
});
}
}
delete missionVariables.ig_pendingmission;
delete missionVariables.ig_missionlaunchtime;
delete missionVariables.ig_rescuedwhen;
delete missionVariables.ig_rescuetime;
delete missionVariables.ig_rescuelocation;
}
}
}
//======================================================================================================================
// sets up standard mission.
this.$igstandardmissionsetup = function() {
missionVariables.ig_contactname = (randomName() + " " + randomName());
var rescuee = (Math.floor(Math.random() * this._rescueeArray.length));
missionVariables.ig_rescuee = this._rescueeArray[rescuee];
missionVariables.ig_rescuedwhen = (clock.days - missionVariables.ig_rescuetime);
var targetsystemsID = new Array;
var targetsystems = SystemInfo.systemsInRange(35);
var potentialmissionsystem;
if (targetsystems.length > 0) {
var counter = 0;
for (counter = 0; counter < targetsystems.length; counter++) {
targetsystemsID[counter] = targetsystems[counter].systemID;
}
var thisGalaxy = system.info.galaxyID;
var thisSystem = system.ID;
// selects a system at random from systems within 35 light years of current system. If selected system is within 7 light years, or is post nova, or there is no possible route to the system will try and select another. If fails to find a suitable system within 100 iterations, mission is cancelled.
counter = 0
while (counter < 100) {
potentialmissionsystem = targetsystemsID[(Math.floor(Math.random() * targetsystemsID.length))];
if (!System.infoForSystem(thisGalaxy, thisSystem).routeToSystem(System.infoForSystem(thisGalaxy, potentialmissionsystem)) ||
System.infoForSystem(thisGalaxy, potentialmissionsystem).sun_gone_nova ||
System.infoForSystem(thisGalaxy, thisSystem).distanceToSystem(System.infoForSystem(thisGalaxy, potentialmissionsystem)) < 7) {
potentialmissionsystem = -1;
}
counter++;
if (potentialmissionsystem !== -1) {break;}
}
}
if (potentialmissionsystem === -1) {return;}
missionVariables.ig_missionsystem = potentialmissionsystem;
missionVariables.ig_missionsystemname = System.infoForSystem(thisGalaxy, potentialmissionsystem).name;
var distance = System.infoForSystem(thisGalaxy, thisSystem).routeToSystem(System.infoForSystem(system.info.galaxyID, potentialmissionsystem)).distance;
missionVariables.ig_missionreward = (500 + (Math.floor(distance / 7) * 250));
mission.markSystem({system:potentialmissionsystem, name:"ig_mission"});
mission.setInstructionsKey ("mission_summary", "illegal_goods_missions");
missionVariables.ig_currentmission = "standard";
missionVariables.ig_rescuelocationcurrent = missionVariables.ig_rescuelocation;
}
//======================================================================================================================
// sets up special mission - runs standard mission set-up then overwrites some missionvariables.
this.$igspecialmissionsetup = function() {
this.$igstandardmissionsetup();
if (!missionVariables.ig_currentmission) {return;}
var ig_switchvar = (Math.floor(Math.random() * 4));
switch(ig_switchvar) {
case 0:
missionVariables.ig_currentmission = "special1";
missionVariables.ig_rescuee = this._rescueeArray[1];
break;
case 1:
if (player.ship.equipmentStatus("EQ_IG_INSURANCE") !== "EQUIPMENT_OK") {
missionVariables.ig_currentmission = "special2";
}
break;
case 2:
if (player.ship.equipmentStatus("EQ_IG_LEGAL_HACK") !== "EQUIPMENT_OK") {
missionVariables.ig_currentmission = "special3";
}
break;
case 3:
missionVariables.ig_currentmission = "special4";
}
}
//======================================================================================================================
// checks for current mission and correct system before running mission success screens.
this.$igmissionfinish = function () {
if (missionVariables.ig_currentmission && system.info.systemID === missionVariables.ig_missionsystem) {
switch (missionVariables.ig_currentmission) {
case "standard":
player.credits += missionVariables.ig_missionreward;
mission.unmarkSystem({system:system.info.systemID, name:"ig_mission"});
mission.setInstructionsKey (null, "illegal_goods_missions");
var w = worldScripts.EmailSystem;
if (!w) {
mission.runScreen({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_noemail"});
} else {
mission.runScreen({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_withemail"});
w.$createEmail({sender:missionVariables.ig_contactname,
subject:"Eternal Gratitude",
date:global.clock.seconds,
message:expandMissionText("end_mission_email")
});
}
clock.addSeconds (43200);
this.$ig_cleanupmissionvariables();
break;
case "special1":
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special1", choicesKey: "ship_visit_agree"}, this.$ig_shipvisitchoice);
break;
case "special2":
player.ship.awardEquipment("EQ_IG_INSURANCE");
mission.setInstructionsKey (null, "illegal_goods_missions");
mission.unmarkSystem({system:system.info.systemID, name:"ig_mission"});
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special2"});
this.$ig_cleanupmissionvariables();
break;
case "special3":
player.ship.awardEquipment("EQ_IG_LEGAL_HACK");
mission.setInstructionsKey (null, "illegal_goods_missions");
mission.unmarkSystem({system:system.info.systemID, name:"ig_mission"});
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special3"});
this.$ig_cleanupmissionvariables();
break;
case "special4":
player.credits += missionVariables.ig_missionreward;
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special4", choicesKey: "special4_mission_agree"}, this.$ig_special4choice);
break;
case "special5":
if (missionVariables.ig_slaverbasedestroyed && missionVariables.ig_special5end !== "not yet") {
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special5", choicesKey: "special5_slaves_left"}, this.$ig_special5choice);
}
}
}
}
//======================================================================================================================
this.$ig_shipvisitchoice = function(choice) {
if (choice === "1_VISITAGREE") {
player.credits += missionVariables.ig_missionreward;
mission.setInstructionsKey (null, "illegal_goods_missions");
mission.unmarkSystem({system:system.info.systemID, name:"ig_mission"});
clock.addSeconds (43200);
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special1a"});
player.ship.awardEquipment("EQ_TRUMBLE");
} else {
missionVariables.ig_missionreward = (missionVariables.ig_missionreward / 2);
player.credits += missionVariables.ig_missionreward;
mission.setInstructionsKey (null, "illegal_goods_missions");
mission.unmarkSystem({system:system.info.systemID, name:"ig_mission"});
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special1b"});
}
this.$ig_cleanupmissionvariables();
}
//======================================================================================================================
this.$ig_special4choice = function(choice) {
if (choice === "1_AGREESPECIAL5") {
missionVariables.ig_currentmission = "special5"
mission.setInstructionsKey ("special5_instructions", "illegal_goods_missions");
missionVariables.ig_special5slavecount = 0;
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special4b"});
} else {
mission.setInstructionsKey (null, "illegal_goods_missions");
mission.unmarkSystem({system:system.info.systemID, name:"ig_mission"});
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special4a"});
this.$ig_cleanupmissionvariables();
}
}
//======================================================================================================================
this.$ig_special5choice = function(choice) {
if(choice === "1_YESSLAVES") {
missionVariables.ig_special5end = "not yet";
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special5b"});
} else {
mission.setInstructionsKey (null, "illegal_goods_missions");
mission.unmarkSystem({system:system.info.systemID, name:"ig_mission"});
missionVariables.ig_missionreward = (1000 + (missionVariables.ig_special5slavecount * 50));
mission.runScreen ({screenID:"igt_endmission", title: "Eternal Gratitude.", messageKey: "end_mission_special5a"});
player.credits += missionVariables.ig_missionreward;
this.$ig_cleanupmissionvariables();
}
}
//======================================================================================================================
// used in special5 mission
this.systemWillPopulate = function() {
// we put the slaver base in regardless of whether the player chooses to access the mission
// it's on the other side of the sun, so they are unlikely to find it without notification
// if they do, well, that's just a bonus for the player
if ((missionVariables.ig_currentmission === "special4" || missionVariables.ig_currentmission === "special5") &&
system.info.systemID === missionVariables.ig_missionsystem &&
system.countShipsWithRole("slaver_base") === 0 &&
!missionVariables.ig_slaverbasedestroyed) {
// set the position of the base
//log(this.name, "Adding slaver base to system");
var position = Vector3D(0, 0, 1.2 + Math.random() * 0.2).fromCoordinateSystem("psu");
// add base with populator
system.setPopulator("slaver base", {
callback: function(pos) {
//log(this.name, "adding...");
var sb = system.addShips("slaver_base", 1, pos);
//log(this.name, "result: " + sb);
// adjust properties of slaver base
if (sb.length > 0) sb[0].suppressArrivalReports = true;
if (!sb || sb.length == 0) log(this.name, "ERROR - slaser base not created!");
}.bind(this),
location:"COORDINATES",
coordinates:position});
// add some asteroids around the base
system.setPopulator("sb_asteroid", {
callback: function(pos) {
system.addShips("asteroid", 8, pos, player.ship.scannerRange);
}.bind(this),
location:"COORDINATES",
coordinates:position});
}
}
//======================================================================================================================
// used for free maintenace equipment.
this.guiScreenChanged = function(to, from) {
if(to === "GUI_SCREEN_EQUIP_SHIP" && player.ship.equipmentStatus("EQ_IG_INSURANCE") === "EQUIPMENT_OK") {
this._ig_playercredits = player.credits;
}
}
//======================================================================================================================
this.playerBoughtEquipment = function(equipment) {
if(player.ship.equipmentStatus("EQ_IG_INSURANCE") === "EQUIPMENT_OK") {
if(equipment === "EQ_RENOVATION") {
player.credits = this._ig_playercredits;
player.ship.removeEquipment("EQ_IG_INSURANCE");
player.consoleMessage("TianveDirect Insurance Policy redeemed - No charge for Maintenance Overhaul",5);
} else {
this._ig_playercredits = player.credits;
}
}
}
|
Scripts/illegal_goods_tweak.js |
"use strict";
this.name = "illegal_goods_tweak";
this.author = "Capt. Murphy";
this.copyright = "2012 Capt. Murphy";
this.licence = "CC BY-NC-SA 3.0";
this.description = "Introduces interaction with GalCop customs when docking at a main station with contraband in the hold.";
this._alwaysDetect = true; // Change this to false if you want a chance that Galcop customs don't notice your Contraband.
this._loggingEnabled = false; // enables log entries
this._ncOXPStations = true; // if true and New Cargoes installed docking penalties will apply at some OXP stations (as defined by New Cargoes)
this._cargoNameArray = ["food", "textiles", "radioactives", "slaves", "liquor_wines", "luxuries", "narcotics", "computers", "machinery", "alloys", "firearms", "furs", "minerals", "alien_items"]; // used by Hypercargo/Vortex code
this._cargoType = ["food", "textiles", "radioactives", "slaves", "liquor_Wines", "luxuries", "narcotics", "computers", "machinery", "alloys", "firearms", "furs", "minerals", "gold", "platinum", "gem_stones", "alien_items"]; // used by New Cargoes code.
this._smugglers = false;
this._runContrabandCheck = false;
//======================================================================================================================
// OXPConfig2 attributes
this.oxpcSettings =
{
Info: {Name:"illegal_goods_tweak",Display:"Illegal Goods Tweak",Notify:false,InfoB:"Note _ncOXPStations ignored if New Cargoes OXP is not installed. Default is main stations only."},
Bool0: {Name:"_alwaysDetect",Def:true,Desc:"100% contraband detection rate."},
Bool1: {Name:"_loggingEnabled",Def:false,Desc:"Enable Log Messages."},
Bool2: {Name:"_ncOXPStations",Def:true,Desc:"Contraband checks at OXP stations."}
}
// configuration settings for use in Lib_Config
this._igtConfig = {Name:this.name, Alias:"Illegal Goods Tweak", Display:"Config", Alive:"_igtConfig",
Bool:{
B0:{Name:"_alwaysDetect", Def:true, Desc:"100% detection rate"},
B1:{Name:"_loggingEnabled", Def:false, Desc:"Enable log messages"},
B2:{Name:"_ncOXPStations", Def:true, Desc:"Check at OXP stations"},
Info:"0 - 100% contraband detection rate.\n1 - Output debug messages to the log.\n2 - Enable contraband check at OXP stations."},
};
//======================================================================================================================
this.startUp = function() { // clean up old missionVariable from previous versions.
if (missionVariables.ig_always_detect){
if (missionVariables.ig_always_detect === "no"){this._alwaysDetect = false;}
delete missionVariables.ig_always_detect;
}
delete missionVariables.ig_amnestyreward;
delete missionVariables.ig_bribe;
// compatibility checks....
if (worldScripts["CargoTypeExtension"]) {
this._compatibilityMessage = "";
var version = worldScripts["CargoTypeExtension"].version;
if (version.localeCompare("1.2.3") < 0) {this._compatibilityMessage += "Illegal Goods Tweak is not compatible with New Cargoes version "+version+". Please upgrade to New Cargoes verson 1.2.3 or later.\n\n";}
if (worldScripts["HyperCargo"]) {
version = worldScripts["HyperCargo"].version;
if (Number(version) < 1.07) {this._compatibilityMessage += "Illegal Goods Tweak and New Cargoes not compatible with HyperCargo version "+version+". Please upgrade to HyperCargo version 1.07 or later.\n\n";}
}
if (worldScripts["vortex_player.js"]) {
version = worldScripts["vortex_player.js"].version;
if (Number(version) < 1.23) {this._compatibilityMessage += "Illegal Goods Tweak and New Cargoes not compatible with Vortex version "+version+". Please upgrade to Vortex version 1.23 or later.";}
}
}
if (worldScripts.Smugglers_Illegal) this._smugglers = true;
// register our settings, if Lib_Config is present
if (worldScripts.Lib_Config) worldScripts.Lib_Config._registerSet(this._igtConfig);
}
//======================================================================================================================
this.shipDockedWithStation = function() { // will check for contraband if just docked
this._runContrabandCheck = true;
}
//======================================================================================================================
this.missionScreenOpportunity = function() {
if (this._compatibilityMessage) {
mission.runScreen ({screenID:"igt_compatibility", title: "Warning"});
mission.addMessageText(this._compatibilityMessage);
delete this._compatibilityMessage;
}
if (this._runContrabandCheck && player.ship.docked &&
(player.ship.dockedStation.allegiance == "galcop" || (this._ncOXPStations && worldScripts["CargoTypeExtension"] && worldScripts["CargoTypeExtension"].checkImports(player.ship.dockedStation)))) {
delete this._runContrabandCheck;
this.$contrabandCheck();
}
}
//======================================================================================================================
this.$contrabandCheck = function () {
//reset persistent variables.
this._manNCSlavesIgnore = 0;
this._manNCNarcsIgnore = 0;
this._manNCArmsIgnore = 0;
this._hcNCSlavesIgnore = 0;
this._hcNCNarcsIgnore = 0;
this._hcNCArmsIgnore = 0;
this._mbNCSlavesIgnore = new Array;
this._mbNCNarcsIgnore = new Array;
this._mbNCArmsIgnore = new Array;
this._mBSlavesIgnored = 0;
this._mBNarcsIgnored = 0;
this._mBArmsIgnored = 0;
this._hcSlaves = 0;
this._hcNarcs = 0;
this._hcArms = 0;
this._slavesNoPermit = new Array;
this._narcsNoPermit = new Array;
this._armsNoPermit = new Array;
this._slavesTypeNoPermit = new Array;
this._narcsTypeNoPermit = new Array;
this._armsTypeNoPermit = new Array;
// detect contraband in normal hold
this._manSlaves = player.ship.manifest.slaves;
this._manNarcs = player.ship.manifest.narcotics;
this._manArms = player.ship.manifest.firearms;
// check for special cargos and permits from New Cargoes OXP in manifest
this._ncStatus = new Array;
if (worldScripts["CargoTypeExtension"]){this.$checkNC("manifest");}
if (this._ncStatus.length > 0) {this.$checkNCPermits("manifest","checkManifest");}
if (this._smugglers == false) {
var illegals = this._manSlaves - this._manNCSlavesIgnore + this._manNarcs - this._manNCNarcsIgnore + this._manArms - this._manNCArmsIgnore;
} else {
var illegals = this._manSlaves - this._manNCSlavesIgnore;
this._manNarcs = 0;
this._manNCNarcsIgnore = 0;
this._manArms = 0;
this._manNCArmsIgnore;
}
// detect contraband in hypercargo if fitted.
if(player.ship.equipmentStatus("EQ_HYPERCARGO") === "EQUIPMENT_OK" && worldScripts["HyperCargo"]) {
this._hcUsed = this.$checkHyperCargo();
if (worldScripts["CargoTypeExtension"] && missionVariables.hyperCargoNewCargoes) {
var tempCurrentManifest = worldScripts["CargoTypeExtension"].suspendPlayerManifest();
worldScripts["CargoTypeExtension"].restorePlayerManifest(missionVariables.hyperCargoNewCargoes);
this.$checkNC("hypercargo");
if (this._ncStatus.length > 0) {this.$checkNCPermits("hypercargo","checkHyperCargo");}
missionVariables.hyperCargoNewCargoes = worldScripts["CargoTypeExtension"].suspendPlayerManifest();
worldScripts["CargoTypeExtension"].restorePlayerManifest(tempCurrentManifest);
}
if (this._hcUsed) {
if (this._smugglers == false) {
var illegalsHC = this._hcSlaves - this._hcNCSlavesIgnore + this._hcNarcs - this._hcNCNarcsIgnore + this._hcArms - this._hcNCArmsIgnore;
} else {
var illegalsHC = this._hcSlaves - this._hcNCSlavesIgnore;
}
// if hypercargo is hacked, has contraband and no contraband in main hold go to slipped past customs.
if (missionVariables.hyperCargoFailChance === 0.05 && illegalsHC > 0 && illegals === 0){this.$slippedPastCustoms();}
// other wise include hypercargo contraband in total count
else if (missionVariables.hyperCargoFailChance !== 0.05){illegals += illegalsHC;}
}
}
if (illegals > 0) { // if contraband is present...
if (!this._alwaysDetect) { // if false random chance of detection
if((Math.floor(Math.random() * 100) + 1) > ((system.techLevel + (system.government * 2) + 4)*3)){
this.$slippedPastCustoms();
} else {
this.$warningScreen();
}
} else {
this.$warningScreen();
}
} else {// if no illegals in main hold and no hypercargo check for vortex/maelstrom/multiBay and call multiBay code.
if(player.ship.equipmentStatus("EQ_MULTIBAY") === "EQUIPMENT_OK") {
this._manNarcs = 0;
this._manSlaves = 0;
this._manArms = 0;
if(player.ship.name === "Maelstrom") {this._multiBayNo = 3;}
if(player.ship.name === "Vortex") {this._multiBayNo = 5;}
this.$suspendCurrentManifest();
var bayCounter;
for (bayCounter = 0; bayCounter < this._multiBayNo; bayCounter++) {
if (bayCounter === missionVariables.multiBay_currentCargo) {continue;}
this.$unloadMB(bayCounter);
if (worldScripts["CargoTypeExtension"]) {this.$checkNC("multibay"+bayCounter);}
if (this._ncStatus.length > 0) {this.$checkNCPermits("multibay"+bayCounter,"checkMultiBay",bayCounter);}
if (this._smugglers == false) {
this._manNarcs += player.ship.manifest.narcotics;
this._manArms +=player.ship.manifest.firearms;
this._mBNarcsIgnored += this._mbNCNarcsIgnore[bayCounter];
this._mBArmsIgnored += this._mbNCArmsIgnore[bayCounter];
}
this._manSlaves += player.ship.manifest.slaves;
if (this._smugglers == false) {
illegals += player.ship.manifest.narcotics + player.ship.manifest.slaves + player.ship.manifest.firearms - this._mbNCNarcsIgnore[bayCounter]- this._mbNCSlavesIgnore[bayCounter]- this._mbNCArmsIgnore[bayCounter];
} else {
illegals += player.ship.manifest.slaves - this._mbNCSlavesIgnore[bayCounter];
}
this._mBSlavesIgnored += this._mbNCSlavesIgnore[bayCounter];
this.$loadMB(bayCounter);
}
this.$restoreCurrentManifest();
if (illegals > 0) {
this._mbUsed = true;
this.$slippedPastCustoms();
}
}
}
}
//======================================================================================================================
// function to check if any contraband is a New Cargoes special cargo. Results are stored in this._ncStatus
this.$checkNC = function (location) {
var counter;
var arrayLength;
var genericType;
var quantity;
var permitLevel;
var tempArray = new Array;
var index;
var specificType;
var specialCargoCarried = worldScripts["CargoTypeExtension"].specialCargoesCarried();
if (specialCargoCarried.length > 0) {
arrayLength = specialCargoCarried.length;
for (counter = 0; counter < arrayLength; counter++) {
genericType = worldScripts["CargoTypeExtension"].cargoDefinition(specialCargoCarried[counter],"genericType");
if (genericType !== "slaves" && genericType !== "narcotics" && genericType !== "firearms") {continue;}
specificType = worldScripts["CargoTypeExtension"].cargoDefinition(specialCargoCarried[counter],"specificType");
quantity = worldScripts["CargoTypeExtension"].hasSpecialCargo(specialCargoCarried[counter]);
permitLevel = worldScripts["CargoTypeExtension"].importPermitDetails(specialCargoCarried[counter],quantity);
tempArray = [location,specialCargoCarried[counter],genericType,quantity,permitLevel,specificType];
index = this._ncStatus.length;
this._ncStatus[index] = tempArray;
if (this._loggingEnabled) {log (this.name,"checkNC output: " + this._ncStatus);}
}
}
}
//======================================================================================================================
// function that checks this._ncStatus for contraband Special Cargo with a valid permit.
this.$checkNCPermits = function(location,context,bayCounter) {
var counter;
var arrayLength = this._ncStatus.length;
var slaveCount = 0;
var narcCount = 0;
var armCount = 0;
for (counter = 0; counter < arrayLength; counter++) {
if (this._ncStatus[counter][0] !== location) {continue;}
if (this._ncStatus[counter][2] === "slaves") {
if (this._ncStatus[counter][4][0] !== 0 ||
this._ncStatus[counter][4][1] !== 0 ||
this._ncStatus[counter][4][2] !== 0) {
slaveCount += this._ncStatus[counter][3];
continue;
} else {
this._slavesNoPermit.push(this._ncStatus[counter][3]);
this._slavesTypeNoPermit.push(this._ncStatus[counter][5]);
continue;
}
}
if (this._ncStatus[counter][2] === "narcotics") {
if (this._ncStatus[counter][4][0] !== 0 ||
this._ncStatus[counter][4][1] !== 0 ||
this._ncStatus[counter][4][2] !== 0) {
narcCount += this._ncStatus[counter][3];
continue;
} else {
this._narcsNoPermit.push(this._ncStatus[counter][3]);
this._narcsTypeNoPermit.push(this._ncStatus[counter][5]);
continue;
}
}
if (this._ncStatus[counter][2] === "firearms") {
if (this._ncStatus[counter][4][0] !== 0 ||
this._ncStatus[counter][4][1] !== 0 ||
this._ncStatus[counter][4][2] !== 0) {
armCount += this._ncStatus[counter][3];
} else {
this._armsNoPermit.push(this._ncStatus[counter][3]);
this._armsTypeNoPermit.push(this._ncStatus[counter][5]);
continue;
}
}
}
if (this._loggingEnabled) {log (this.name,"checkNCPermits context: "+context+", location: "+location+", Slaves Ignored: "+ slaveCount+ ", Narcs Ignored: "+narcCount+", Firearms ignored: "+armCount);}
if (context === "checkManifest") {
this._manNCSlavesIgnore = slaveCount;
this._manNCNarcsIgnore = narcCount;
this._manNCArmsIgnore = armCount;
return;
}
if (context === "checkHyperCargo") {
this._hcNCSlavesIgnore= slaveCount;
this._hcNCNarcsIgnore = narcCount;
this._hcNCArmsIgnore = armCount;
return;
}
if (context === "checkMultiBay") {
this._mbNCSlavesIgnore[bayCounter] = slaveCount;
this._mbNCNarcsIgnore[bayCounter] = narcCount;
this._mbNCArmsIgnore[bayCounter] = armCount;
return;
}
}
//======================================================================================================================
// function called when removing contraband to update New Cargoes records when necessary.
this.$updateNCStatus = function(location) {
if (this._loggingEnabled) {log(this.name,"updateNCStatus called with param.: "+location);}
var counter;
var arrayLength = this._ncStatus.length;
var iterations;
for (counter = 0; counter < arrayLength; counter++) {
if (this._ncStatus[counter][0] !== location) {continue;}
if (location === "hypercargo") {
var tempCurrentManifest = worldScripts["CargoTypeExtension"].suspendPlayerManifest();
worldScripts["CargoTypeExtension"].restorePlayerManifest(missionVariables.hyperCargoNewCargoes);
}
if (this._ncStatus[counter][4][0] === 0 && this._ncStatus[counter][4][1] === 0 && this._ncStatus[counter][4][2] === 0) {
iterations = this._ncStatus[counter][3];
var counter1;
for (counter1 = 0; counter1 < iterations; counter1++) {
worldScripts["CargoTypeExtension"].removeSpecialCargo(this._ncStatus[counter][1])
};
}
if (location === "hypercargo") {
missionVariables.hyperCargoNewCargoes = worldScripts["CargoTypeExtension"].suspendPlayerManifest();
worldScripts["CargoTypeExtension"].restorePlayerManifest(tempCurrentManifest);
}
if (this._loggingEnabled) {log(this.name,"tempCurrentmainifest: "+tempCurrentManifest+"missionVariables.hyperCargoNewCargoes: " +missionVariables.hyperCargoNewCargoes);}
}
}
//======================================================================================================================
this.$checkHyperCargo = function() {
var returnFlag = false;
if (missionVariables.hyperCargoMemory === "EMPTY") {return returnFlag;}
if (worldScripts["HyperCargo"].storedArray[3] > 0) {this._hcSlaves = worldScripts["HyperCargo"].storedArray[3]; returnFlag = true;}
if (worldScripts["HyperCargo"].storedArray[6] > 0) {this._hcNarcs = worldScripts["HyperCargo"].storedArray[6]; returnFlag = true;}
if (worldScripts["HyperCargo"].storedArray[10] > 0) {this._hcArms = worldScripts["HyperCargo"].storedArray[10]; returnFlag = true;}
return returnFlag;
}
//======================================================================================================================
this.$updateHyperCargo = function() {
worldScripts["HyperCargo"].storedArray[3] = this._hcNCSlavesIgnore;
worldScripts["HyperCargo"].storedArray[6] = this._hcNCNarcsIgnore;
worldScripts["HyperCargo"].storedArray[10] = this._hcNCArmsIgnore;
var counter;
var contents = 0;
missionVariables.hyperCargoMemory = "";
for(counter = 0; counter < 14; counter++) {
contents += worldScripts["HyperCargo"].storedArray[counter];
missionVariables.hyperCargoMemory = missionVariables.hyperCargoMemory + worldScripts["HyperCargo"].storedArray[counter] + ":";
}
if (contents === 0) {missionVariables.hyperCargoMemory = "EMPTY";}
}
//======================================================================================================================
this.$suspendCurrentManifest = function() {
if (worldScripts["CargoTypeExtension"]) {this._tempNCManifest = worldScripts["CargoTypeExtension"].suspendPlayerManifest();}
this._tempManifestArray = new Array(17);
var counter;
for (counter = 0; counter < 17; counter++) {
this._tempManifestArray[counter] = manifest[this._cargoType[counter]];
manifest[this._cargoType[counter]] = 0;
}
}
//======================================================================================================================
this.$restoreCurrentManifest = function() {
var counter;
for(counter = 0; counter < 17; counter++) {
manifest[this._cargoType[counter]] = this._tempManifestArray[counter];
}
delete this._tempManifestArray;
if (worldScripts["CargoTypeExtension"]) {worldScripts["CargoTypeExtension"].restorePlayerManifest(this._tempNCManifest);}
}
//======================================================================================================================
this.$unloadMB = function(bay) {
if (worldScripts["CargoTypeExtension"] && missionVariables["multiBay_ncBay" + bay]) {
worldScripts["CargoTypeExtension"].restorePlayerManifest(missionVariables["multiBay_ncBay" + bay]);
}
var tempArray = missionVariables["multiBay_cargoBay" + bay].split(":");
var cargoCounter;
for (cargoCounter = 0; cargoCounter < 14; cargoCounter++) {
manifest[this._cargoNameArray[cargoCounter]] = tempArray[cargoCounter];
}
}
//======================================================================================================================
this.$loadMB = function(bay) {
var tempArray = new Array(14);
var loadCounter;
for(loadCounter = 0; loadCounter < 14; loadCounter++) {
tempArray[loadCounter] = manifest[this._cargoNameArray[loadCounter]];
manifest[this._cargoNameArray[loadCounter]] = 0;
}
missionVariables["multiBay_cargoBay" + bay] = tempArray.join(":");
if(worldScripts["CargoTypeExtension"]) {
missionVariables["multiBay_ncBay" + bay] = worldScripts["CargoTypeExtension"].suspendPlayerManifest();
}
}
//======================================================================================================================
this.$detectedChoice = function(choice) {
if (choice === "1_YES") {// handover contraband
this.$commonHandover();
}
if (choice === "2_NO") {// ignore warning
this.$commonPenalty();
}
if (choice === "4_NO") {// switch to smugglers
worldScripts.Smugglers_Equipment._doCargoCheck = true;
}
if (choice === "3_BRIBE") { // attempt bribe
if((Math.floor(Math.random() * 100) + 1) < (system.government + (7 - system.economy) + 5 * 5)) {
missionVariables.ig_legalpenalty = 25;
player.ship.setBounty(player.bounty + missionVariables.ig_legalpenalty, "attempted bribe");
mission.runScreen ({screenID:"igt_bribe", title: "Bribery Is An Offence!", messageKey: "failed_bribe", model: "police", choicesKey: "failedbribe_handover_yesno"}, this.$failedBribeChoice);
// email system interface
var w = worldScripts.EmailSystem;
if (w) {
var ga = worldScripts.GalCopAdminServices;
w.$createEmail({sender:"GalCop Customs",
subject:"Attempt to bribe official",
date:global.clock.seconds,
message:expandMissionText("failed_bribe_email", {stationname:player.ship.dockedStation.displayName, systemname:System.systemNameForID(global.system.ID)}),
expiryDays:ga._defaultExpiryDays
});
}
delete missionVariables.ig_legalpenalty;
} else {
missionVariables.ig_bribe = Math.round(((this._manArms - this._manNCArmsIgnore + this._hcArms - this._hcNCArmsIgnore) * (49.6 +(Math.random() * 39.2))) + ((this._manNarcs - this._manNCNarcsIgnore + this._hcNarcs - this._hcNCNarcsIgnore) * (0.4 +(Math.random() * 101.2))) + ((this._manSlaves - this._manNCSlavesIgnore + this._hcSlaves - this._hcNCSlavesIgnore) * (2 +(Math.random() * 26.4))));
if(missionVariables.ig_bribe > player.credits) {
missionVariables.ig_bribe = player.credits;
}
mission.runScreen({screenID:"igt_bribe", title: "Interesting...", messageKey: "offered_bribe", model: "police", choicesKey: "bribe_accept_yesno"}, this.$bribeChoice);
}
}
}
//======================================================================================================================
this.$failedBribeChoice = function(choice) {
if (choice === "1_YES") { // handover after failed bribe attempt
this.$commonHandover();
} else { // ignore warnings
this.$commonPenalty();
}
}
//======================================================================================================================
this.$bribeChoice = function(choice) {
if (choice === "1_PAY") { // pay bribe
player.credits -= missionVariables.ig_bribe;
mission.runScreen ({screenID:"igt_bribe", title: "All Clear.", messageKey: "paid_bribe", model: "police"});
delete missionVariables.ig_bribe;
}
if (choice === "2_NO") { // don't pay bribe and accept legal penalty
delete missionVariables.ig_bribe;
this.$commonPenalty();
}
if (choice === "3_YES") { // don't pay bribe and handover contraband
delete missionVariables.ig_bribe;
this.$commonHandover();
}
}
//======================================================================================================================
this.$warningScreen = function() {
if (this._smugglers == false) {
mission.runScreen({
screenID:"igt_warning",
title: "GalCop Customs Warning",
messageKey: "contraband_warning",
model: "police",
choicesKey: "detected_yesnobribe"},
this.$detectedChoice);
} else {
mission.runScreen({
screenID:"igt_warning",
title: "Amnesty Intergalactic",
messageKey: "contraband_warning_alt",
overlay:{name:"stgu-candle.png", height:546},
choicesKey: "detected_yesno"},
this.$detectedChoice);
}
this.$appendDetectedContraband();
}
//======================================================================================================================
this.$appendDetectedContraband = function() {
mission.addMessageText("Contraband Detected:\n");
var counter;
this._detectedContraband = "";
var slavesDetected = this._manSlaves - this._manNCSlavesIgnore + this._hcSlaves - this._hcNCSlavesIgnore - this._mBSlavesIgnored;
if (slavesDetected > 0) {
var slavesMessage = "Slaves : "+slavesDetected+" units";
if (this._slavesNoPermit.length > 0) {
slavesMessage += " including ";
for (counter = 0; counter < this._slavesNoPermit.length; counter++) {
slavesMessage += this._slavesNoPermit[counter] + " ";
if ((this._slavesNoPermit.length - counter) === 1){
slavesMessage += this._slavesTypeNoPermit[counter]+".";
} else {
slavesMessage += this._slavesTypeNoPermit[counter]+", ";
}
}
} else {
slavesMessage += ".";
}
mission.addMessageText(slavesMessage);
this._detectedContraband += slavesMessage + "\n";
}
if (this._smugglers == false) {
var narcsDetected = this._manNarcs - this._manNCNarcsIgnore + this._hcNarcs - this._hcNCNarcsIgnore - this._mBNarcsIgnored;
if (narcsDetected > 0) {
var narcsMessage = "Narcotics : "+narcsDetected+" tons";
if (this._narcsNoPermit.length > 0) {
narcsMessage += " including ";
for (counter = 0; counter < this._narcsNoPermit.length; counter++) {
narcsMessage += this._narcsNoPermit[counter]+" ";
if ((this._narcsNoPermit.length - counter) === 1) {
narcsMessage += this._narcsTypeNoPermit[counter]+".";
} else {
narcsMessage = narcsMessage +this._narcsTypeNoPermit[counter]+", ";
}
}
} else {
narcsMessage += ".";
}
mission.addMessageText(narcsMessage);
this._detectedContraband += narcsMessage + "\n";
}
var armsDetected = this._manArms - this._manNCArmsIgnore + this._hcArms - this._hcNCArmsIgnore - this._mBArmsIgnored;
if (armsDetected > 0) {
var armsMessage = "Firearms : "+armsDetected+" tons";
if (this._armsNoPermit.length > 0) {
armsMessage += " including ";
for (counter = 0; counter < this._armsNoPermit.length; counter++) {
armsMessage += this._armsNoPermit[counter]+" ";
if ((this._armsNoPermit.length - counter) === 1) {
armsMessage += this._armsTypeNoPermit[counter]+".";
} else {
armsMessage = armsMessage +this._armsTypeNoPermit[counter]+", ";
}
}
} else {
armsMessage += ".";
}
mission.addMessageText(armsMessage);
this._detectedContraband += armsMessage + "\n";
}
}
}
//======================================================================================================================
this.$slippedPastCustoms = function() {
mission.runScreen ({screenID:"igt_slipcustoms", title: "You Slipped Past Customs.", messageKey: "handover_voluntary", choicesKey: "handover_vol_yesno"}, this.$volHandoverChoice);
this.$appendDetectedContraband();
}
//======================================================================================================================
this.$volHandoverChoice = function (choice) {
if(choice === "1_YES") { // if slipped past customs handover voluntarily.
this.$commonHandover();
} else {
delete this._hcUsed;
delete this._mbUsed;
}
}
//======================================================================================================================
this.$commonHandover = function() {
if (this._ncStatus.length > 0) {this.$updateNCStatus("manifest");}
player.ship.manifest.slaves = this._manNCSlavesIgnore;
if (this._smugglers == false) {
player.ship.manifest.narcotics = this._manNCNarcsIgnore;
player.ship.manifest.firearms = this._manNCArmsIgnore;
}
if (this._hcUsed) {
this.$updateHyperCargo();
if (this._ncStatus.length > 0){this.$updateNCStatus("hypercargo");}
delete this._hcUsed;
}
if (this._mbUsed) {
delete this._mbUsed;
this.$suspendCurrentManifest();
var bayCounter = 0;
for (bayCounter = 0; bayCounter < this._multiBayNo; bayCounter++) {
if (bayCounter === missionVariables.multiBay_currentCargo) {continue;}
this.$unloadMB(bayCounter);
if (this._ncStatus.length > 0) {this.$updateNCStatus("multibay"+bayCounter);}
player.ship.manifest.slaves = this._mbNCSlavesIgnore[bayCounter];
if (this._smugglers == false) {
player.ship.manifest.narcotics = this._mbNCNarcsIgnore[bayCounter];
player.ship.manifest.firearms = this._mbNCArmsIgnore[bayCounter];
}
this.$loadMB(bayCounter);
}
this.$restoreCurrentManifest();
}
// keep track of how many slaves rescued, for use externally
if ((this._manSlaves - this._manNCSlavesIgnore - this._mBSlavesIgnored + this._hcSlaves - this._hcNCSlavesIgnore) > 0) {
missionVariables.ig_rescued_slaves += (this._manSlaves - this._manNCSlavesIgnore - this._mBSlavesIgnored + this._hcSlaves - this._hcNCSlavesIgnore);
}
// set the reward amount
if (this._smugglers == false) {
missionVariables.ig_amnestyreward = this._manNarcs - this._manNCNarcsIgnore - this._mBNarcsIgnored + this._hcNarcs - this._hcNCNarcsIgnore + this._manArms - this._manNCArmsIgnore - this._mBArmsIgnored + this._hcArms - this._hcNCArmsIgnore + ((this._manSlaves - this._manNCSlavesIgnore - this._mBSlavesIgnored + this._hcSlaves - this._hcNCSlavesIgnore) * 5);
} else {
missionVariables.ig_amnestyreward = ((this._manSlaves - this._manNCSlavesIgnore - this._mBSlavesIgnored + this._hcSlaves - this._hcNCSlavesIgnore) * 5);
}
// add the reward to the player's account
player.credits += missionVariables.ig_amnestyreward;
// determine how to display the amount (either "credits" or "credit")
missionVariables.ig_credittype = "credits";
if (missionVariables.ig_amnestyreward == 1) missionVariables.ig_credittype = "credit";
// show the mission screen
if (this._smugglers == false) {
mission.runScreen ({screenID:"igt_contraband", title: "Contraband Removed", messageKey: "amnesty_reward", model: "police"});
} else {
mission.runScreen ({screenID:"igt_contraband", title: "Slaves Rescued", messageKey: "amnesty_reward_alt", overlay:{name:"stgu-candle.png", height:546}});
worldScripts.Smugglers_Equipment._doCargoCheck = true;
}
// email system interface
var w = worldScripts.EmailSystem;
if (w) {
var ga = worldScripts.GalCopAdminServices;
if (this._smugglers == false) {
w.$createEmail({sender:"GalCop Customs",
subject:"Contraband removal",
date:global.clock.seconds,
message:expandMissionText("amnesty_reward_email", {contraband:this._detectedContraband, stationname:player.ship.dockedStation.displayName, systemname:System.systemNameForID(global.system.ID)}),
expiryDays:ga._defaultExpiryDays
});
} else {
w.$createEmail({sender:"Amnesty Intergalactic",
subject:"Slaves Rescued",
date:global.clock.seconds,
message:expandMissionText("amnesty_reward_email_alt", {contraband:this._detectedContraband, stationname:player.ship.dockedStation.displayName, systemname:System.systemNameForID(global.system.ID)}),
expiryDays:ga._defaultExpiryDays
});
}
}
delete missionVariables.ig_credittype;
delete missionVariables.ig_amnestyreward;
if ((this._manSlaves - this._manNCSlavesIgnore - this._mBSlavesIgnored + this._hcSlaves - this._hcNCSlavesIgnore) > 0) {
this.$missionInitialise();
}
}
//======================================================================================================================
this.$commonPenalty = function() {
missionVariables.ig_legalpenalty = this._manArms - this._manNCArmsIgnore + this._hcArms - this._hcNCArmsIgnore + this._manSlaves - this._manNCSlavesIgnore + this._hcSlaves - this._hcNCSlavesIgnore + ((this._manNarcs - this._manNCNarcsIgnore + this._hcNarcs - this._hcNCNarcsIgnore) * 2);
player.ship.setBounty(player.bounty + missionVariables.ig_legalpenalty, "illegal imports");
mission.runScreen ({screenID:"igt_penalised", title: "You Have Been Penalised!", messageKey: "legal_penalty", model: "police"});
// email system interface
var w = worldScripts.EmailSystem;
if (w) {
var ga = worldScripts.GalCopAdminServices;
w.$createEmail({sender:"GalCop Customs",
subject:"Contraband Penalty",
date:global.clock.seconds,
message:expandMissionText("legal_penalty_email", {stationname:player.ship.dockedStation.displayName, systemname:System.systemNameForID(global.system.ID)}),
expiryDays:ga._defaultExpiryDays
});
}
delete missionVariables.ig_legalpenalty;
}
//======================================================================================================================
// if slaves are handed over sets up potential mini missions.
this.$missionInitialise = function() {
if (!missionVariables.ig_pendingmission) {
var tempCounter = 0;
var iterations = this._manSlaves - this._manNCSlavesIgnore - this._mBSlavesIgnored + this._hcSlaves - this._hcNCSlavesIgnore;
for(tempCounter =0;tempCounter<iterations;tempCounter++) {
if (Math.random() < 0.1) {
missionVariables.ig_pendingmission = true;
missionVariables.ig_rescuelocation = ("" + system.name);
missionVariables.ig_rescuetime = clock.days;
missionVariables.ig_missionlaunchtime = (clock.days + 7 + Math.floor(Math.random()*8));
break;
}
}
}
// tacked on here - if slaves are handed over at end of special5 mission increment counter for special reward.
if (missionVariables.ig_currentmission === "special5" && missionVariables.ig_missionsystem === system.info.systemID && missionVariables.ig_slaverbasedestroyed) {
missionVariables.ig_special5slavecount += this._manSlaves - this._manNCSlavesIgnore - this._mBSlavesIgnored + this._hcSlaves - this._hcNCSlavesIgnore;
}
}
|
Scripts/slavermarket.js |
"use strict";
this.name = "slaver-market";
this.author = "spara";
this.copyright = "2014 spara";
this.license = "CC BY-NC-SA 4.0";
this.$originalDefs = {
"food" : [0, 0, 20, -1, 0, 0, 1, 0, 0],
"textiles" : [0, 0, 20, -1, 0, 0, 3, 0, 0],
"radioactives" : [0, 0, 42, -3, -3, 0, 7, 3, 0],
"slaves" : [0, 0, 2, 1, 0, 20, 1, 0, 0],
"liquor_wines" : [0, 0, 105, -5, 0, 0, 15, 0, 0],
"luxuries" : [0, 0, 236, 8, 0, 0, 3, 0, 0],
"narcotics" : [0, 0, 10, 1, 0, 20, 120, 0, 0],
"computers" : [0, 0, 150, 14, 0, 0, 3, 0, 0],
"machinery" : [0, 0, 120, 6, 0, 0, 7, 0, 0],
"alloys" : [0, 0, 70, 1, 0, 0, 31, 2, 0],
"firearms" : [0, 0, 50, 1, 0, 29, 7, 0, 0],
"furs" : [0, 0, 160, -9, 0, 0, 63, 0, 0],
"minerals" : [0, 0, 16, -1, -1, 85, 3, 3, 0],
"gold" : [0, 0, 73, -1, -1, 5, 7, 3, 1],
"platinum" : [0, 0, 145, -2, -2, 6, 31, 7, 1],
"gem_stones" : [0, 0, 25, -1, -1, 250, 15, 15, 2],
"alien_items" : [0, 0, 140, 1, 0, 0, 3, 0, 0]
};
this.updateLocalCommodityDefinition = function(goodDefinition) {
var commodity = goodDefinition.key;
var oldDefs = this.$originalDefs[commodity];
//old style definition found for the good. calculate it the old way
if (oldDefs) {
var market_base_price = oldDefs[2];
var market_eco_adjust_price = oldDefs[3];
var market_eco_adjust_quantity = oldDefs[4];
var market_base_quantity = oldDefs[5];
var market_mask_price = oldDefs[6];
var market_mask_quantity = oldDefs[7];
var market_rnd = Math.floor(Math.random() * 256);
var economy = system.economy;
var price = (market_base_price + (market_rnd & market_mask_price) + (economy * market_eco_adjust_price)) & 255;
price *= 0.4;
var quantity = (market_base_quantity + (market_rnd & market_mask_quantity) - (economy * market_eco_adjust_quantity)) & 255;
if (quantity > 127) quantity = 0;
quantity &= 63;
goodDefinition.price = price * 10;
goodDefinition.quantity = quantity;
}
//no definition found. nullify the goods.
else {
goodDefinition.price = 0;
goodDefinition.quantity = 0;
}
return goodDefinition;
};
|