Config/script.js |
"use strict";
this.name = "Feudal_PlanetFall2";
this.author = "phkb";
this.copyright = "CC-BY-SA-NC 4.0";
this.description = "Allows for full customisations of Feudal systems";
this.debug = true;
this.rsnInUse = false;
this.nameStore = null;
//-------------------------------------------------------------------------------------------------------------
this.startUp = function () {
var pf = worldScripts.PlanetFall2;
pf._locationOverrides["0 96"] = {
main: [
{
roles: ["planetFall2_mainSurface_FSRoyalCourt", "capitalCity", "planetFall2_mainSurface_FSCathedral", "capitalCity"],
names: ["Sir Ffoliot Cary Port, Lesser Walsingham (Royal Court)", "Lesser Walsingham (Capital City)", "Greater Walsingham (Cathedral)", "Lancaster (City)"],
}
],
};
pf._landingImages["feudalCourt"] = [
{ name: "feudalCourt_1.png", height: 568 }, { name: "feudalCourt_2.png", height: 568 }, { name: "feudalCourt_3.png", height: 568 },
{ name: "feudalCourt_4.png", height: 568 }, { name: "feudalCourt_5.png", height: 568 }, { name: "feudalCourt_6.png", height: 568 },
{ name: "feudalCourt_7.png", height: 568 }, { name: "feudalCourt_8.png", height: 568 }, { name: "feudalCourt_9.png", height: 568 },
{ name: "feudalCourt_10.png", height: 568 }, { name: "feudalCourt_11.png", height: 568 }, { name: "feudalCourt_12.png", height: 568 },
{ name: "feudalCourt_13.png", height: 568 }, { name: "feudalCourt_14.png", height: 568 }, { name: "feudalCourt_15.png", height: 568 }
];
pf._landingImages["feudalCathedral"] = [
{ name: "feudalCathedral_1.png", height: 568 }, { name: "feudalCathedral_2.png", height: 568 }, { name: "feudalCathedral_3.png", height: 568 },
{ name: "feudalCathedral_4.png", height: 568 }, { name: "feudalCathedral_5.png", height: 568 }
];
if (worldScripts["feudal-planetfall.js"]) {
pf.$addPrepopulationFunction("feudal-planetfall.js", "extraPopulation");
if (this.debug) log(this.name, "Monkey-patching shipWillEnterWitchspace, shipWillLaunchFromStation, and shipWillExitWitchspace functions of Feudal states PlanetFall script");
var f = worldScripts["feudal-planetfall.js"];
delete f.shipWillLaunchFromStation;
delete f.shipWillExitWitchspace;
f.extraPopulation = this.feudalstates_extraPopulation;
f.shipWillEnterWitchspace = this.feudalstates_shipWillEnterWitchspace;
}
this._phraseGen = worldScripts.GNN_PhraseGen;
// link into the PF name store
var ns = worldScripts.PlanetFall2_Names;
// make sure the nameStore dictionary has been populated
if (Object.keys(ns.nameStore).length == 0) {
// if the number of keys in the nameStore object is zero, it means the startUp function in PlanetFall2_Names
// hasn't been run yet (this one has been run first).// so run it now, and delete it so it doesn't get run twice.
ns.startUp();
delete ns.startUp;
}
this.nameStore = ns.nameStore;
if (worldScripts.RandomStationNames) this.rsnInUse = true;
// override the rsn flag if we've specifically turned it off.
if (worldScripts.PlanetFall2._config.useGANames == false) this.rsnInUse = false;
}
//-------------------------------------------------------------------------------------------------------------
this.feudalstates_extraPopulation = function () {
if (system.government == 1 && worldScripts.PlanetFall2) {
if ((galaxyNumber == 0 && system.techLevel >= 7) || (galaxyNumber == 1 && system.techLevel >= 5) || (galaxyNumber == 2 && system.techLevel >= 7) || (galaxyNumber == 4 && system.techLevel >= 7) || (galaxyNumber == 5 && system.techLevel >= 8)) {
var pf = worldScripts.PlanetFall2;
var key = galaxyNumber + " " + system.ID;
// if we have a full custom setup, don't use the override method
if (pf._locationOverrides[key]) return;
worldScripts.PlanetFall2.planetFallOverride = true; // set the override, so only external OXP locations appear
}
}
}
//-------------------------------------------------------------------------------------------------------------
// just pointing this at the correct worldscript name
this.feudalstates_shipWillEnterWitchspace = function (cause, destination) {
if (system.government == 1 && worldScripts.PlanetFall2) {
worldScripts.PlanetFall2.planetFallOverride = false;
}
}
//-------------------------------------------------------------------------------------------------------------
// reproduction of Galactic Almanac's naming method for Royal Courts
this.planetFall_mainSurface_FSRoyalCourt1 = [
"Hall","Castle","Fortress","Bastion","Palace","Chateau","Citadel","Keep"
];
this.planetFall_mainSurface_FSRoyalCourt2 = [
"Honour","Chivalry","Fortitude","Stoicism","Endurance","Fortune","Courage","Nobility","Gallantry",
"Bravery","Heroism","Valour","Daring","Adventure","Enlightenment","Audacity","Temperance",
"Grace","Virtue","Fealty","Honesty","Integrity"
];
this.planetFall_mainSurface_FSRoyalCourt3a = [
"Royal","Regal","Feudal"
];
this.planetFall_mainSurface_FSRoyalCourt3b = [
"Court","Lodge"
];
//-------------------------------------------------------------------------------------------------------------
this.$PF_RoyalCourt = function $PF_RoyalCourt(dataKey) {
if (!this.rsnInUse) return "";
// do we have a stored name for this key
var stored = this.nameStore[galaxyNumber][system.ID][dataKey];
// if not, generate one
if (!stored) {
var def = {
fieldA: [].concat(this.planetFall_mainSurface_FSRoyalCourt1),
fieldB: [].concat(this.planetFall_mainSurface_FSRoyalCourt2),
fieldC: [].concat(this.planetFall_mainSurface_FSRoyalCourt3a),
fieldD: [].concat(this.planetFall_mainSurface_FSRoyalCourt3b),
fieldE: ["[3] [4]"],
fieldF: [],
fieldG: [],
fieldH: [],
fieldI: [],
fieldJ: [],
fieldK: [],
fieldL: [],
fieldM: [],
fieldN: [],
fieldO: [],
fieldP: [],
fieldQ: [],
fieldR: [],
sentences: [
"1 of 2 (5)"
],
};
var text = this._phraseGen._makePhrase(def);
this.nameStore[galaxyNumber][system.ID][dataKey] = text;
} else {
// otherwise, use the stored value
var text = stored;
}
return text;
}
|