| Scripts/dmd_trade.js | "use strict";
this.author      = "Morgan Orr"; 
this.copyright   = "� 2011-2016 Morgan Orr."; 
this.licence 	 = "CC-BY-SA 4.0";
this.version     = "0.8";
 /*			~~~I STRONGLY encourage the modification and development of this free software by anyone to meet your needs, I only ask that you give me credit for the original work. Thanks and enjoy.~~~*/
this.name			= "dmd_trade";
this.description	= "Finds distance to dmd production systems so dmd_trademarket can apply a price multiple based on distance.";
// this script is really a modification of phkb's smugglers code
//I STRONGLY encourage the modification and development of this free software by all to meet your needs, I only ask that you give me credit for the original work. Thanks and enjoy!
this.$witchlogging = false;
this.$sysId = -1;
this.$priceMultiple = 0;
this.$witchfireLoaded = false;
this.$witchspaceDestination = -1;
this.startUp = function() {
	this.$sysId = system.ID;
}
this.$sysDistance = function() {
	//production centers
	var sys = [];
		if(galaxyNumber == 0) {
		var sys = 223;		
	}
		if(galaxyNumber == 1) {
		var sys = 135;		
	}
		if(galaxyNumber == 2) {
		var sys = 210;		
	}
		if(galaxyNumber == 3) {
		var sys = 96;	
	}
		if(galaxyNumber == 4) {
		var sys = 44;		
	}
		if(galaxyNumber == 5) {
		var sys = 242;	
	}
		if(galaxyNumber == 6) {
		var sys = 27;
	}
		if(galaxyNumber == 7) {
		var sys = 134;	
	}
	
	var sysInfo = System.infoForSystem(galaxyNumber,sys);
	var way = system.info.routeToSystem(sysInfo);
   	if (way) {
    	this.$priceMultiple = way.route.length * 0.025;
	} else {
      	this.$priceMultiple = 99 * 0.025; // if the system is unreachable, then prices will be really high
   }
	if(this.$witchlogging) log(this.name,this.name+"  waylong = "+way.route.length);
	if(this.$witchlogging) log(this.name,this.name+":  system = " +this.$sysId+ " Galsys = "+sysInfo+" sys = "+sys);
	if(this.$witchlogging) log(this.name,this.name+":  $priceMultiple 1 = " +this.$priceMultiple);
	return this.$priceMultiple;
}
this.shipWillEnterWitchspace = function(cause, destination) {
    this.$witchfireDestination = destination;
}
this.shipWillExitWitchspace = function() {
	this.$witchfireLoaded = false;
}
this.shipExitedWitchspace = function() {
	this.$sysId = system.ID;
}
this.$witchfireData = function() {
	this.$witchfireLoaded = true;
	this.$sysDistance();
}
 | 
                
                    | Scripts/dmd_trademarket.js | "use strict";
this.author      = "Morgan Orr"; 
this.copyright   = "� 2011-2016 Morgan Orr."; 
this.licence 	 = "CC-BY-SA 4.0";
this.version     = "0.8";
 /*			~~~I STRONGLY encourage the modification and development of this free software by anyone to meet your needs, I only ask that you give me credit for the original work. Thanks and enjoy.~~~*/
this.name        = "dmd_trademarket";
this.description = "Applies witchfire_whiskey data to GalCop and DMD stations.";
// this script is really a modification of phkb's smugglers code
//I STRONGLY encourage the modification and development of this free software by all to meet your needs, I only ask that you give me credit for the original work. Thanks and enjoy!
this.$witchlogging = false;
this.$quanMulti = function () {
	var multi = [];
	if (Math.random > 0.85) {
		var multi = 96;
	} else {
		var multi = 24
	}
	return multi;
}
this.updateGeneralCommodityDefinition = function(goodDefinition, station, systemID) {
	var dt = worldScripts.dmd_trade;
	if (dt) {
		if (station && station.name === "Darkside Moonshine Distillery") {
			goodDefinition.quantity = Math.round(Math.random() * this.$quanMulti());
		} else {
			goodDefinition.quantity = 0;
			if (dt.$witchfireLoaded == false && parseInt((clock.seconds % 1) * 10000) != 0) {
				dt.$witchfireData();
			
			}
			if(this.$witchlogging) log(this.name,this.name+": quantity"+goodDefinition.quantity+" mulit = "+this.$quanMulti());
			if (dt.$witchfireLoaded == true) {
			
				var priceMulti = 2620 * dt.$priceMultiple;
				goodDefinition.price = 2620 + priceMulti;
				var sysId = systemID;
				if(this.$witchlogging) log(this.name,this.name+": system"+sysId);
				if (sysId == -1) {
					// get the players witchspace destination
					if (dt.$witchspaceDestination != -1) {
						sysId = dt.$witchspaceDestination;
						if(this.$witchlogging) log(this.name,this.name+": destination"+dt.$witchfireDestination);
					} else {
						// work out the next system from the players route
						var p = player.ship;
						var target = p.targetSystem;
						var myRoute = System.infoForSystem(global.galaxyNumber, dt.$sysId).routeToSystem(System.infoForSystem(global.galaxyNumber, target), p.routeMode);
						sysId = myRoute.route[1];
						if(this.$witchlogging) log(this.name,this.name+": sysId :"+sysId);
						p = null;
						myRoute = null;
					}
				}	
			}
		}	
	}		
	return goodDefinition;	
}
 | 
                
                    | Scripts/witchfire-populator.js | "use strict";
this.author      = "Morgan Orr"; 
this.copyright   = "� 2011-2016 Morgan Orr."; 
this.licence 	 = "CC-BY-SA 4.0";
this.version     = "0.8";
 /*			~~~I STRONGLY encourage the modification and development of this free software by anyone to meet your needs, I only ask that you give me credit for the original work. Thanks and enjoy.~~~*/
//I STRONGLY encourage the modification and development of this free software by all to meet your needs, I only ask that you give me credit for the original work. Thanks and enjoy!
this.name           = "witchfire-populator";
this.description    = "Witchfire Whiskey bases";
this.systemWillPopulate = function() {
  	if(system.isInterstellarSpace || system.government === !5 || system.sun.hasGoneNova || system.sun.isGoingNova || system.countShipsWithRole("darkside-moonshine-distillery") > 0 || system.countShipsWithRole("darkside-moonshine-saloon") > 0 )
	{ return; }
	this.addedCount = 0;
	if
	(
	galaxyNumber == 0 && system.ID == 59 ||
	galaxyNumber == 0 && system.ID == 142 ||
	galaxyNumber == 0 && system.ID == 173 ||
	galaxyNumber == 0 && system.ID == 213 ||
	galaxyNumber == 0 && system.ID == 223 ||
	galaxyNumber == 0 && system.ID == 238 ||
	galaxyNumber == 1 && system.ID == 0 ||
	galaxyNumber == 1 && system.ID == 30 ||
	galaxyNumber == 1 && system.ID == 47 ||
	galaxyNumber == 1 && system.ID == 64 ||
	galaxyNumber == 1 && system.ID == 110 ||
	galaxyNumber == 1 && system.ID == 135 ||
	galaxyNumber == 1 && system.ID == 137 ||
	galaxyNumber == 1 && system.ID == 190 ||
	galaxyNumber == 1 && system.ID == 213 ||
	galaxyNumber == 1 && system.ID == 217 ||
	galaxyNumber == 1 && system.ID == 225 ||
	galaxyNumber == 1 && system.ID == 254 ||
	galaxyNumber == 2 && system.ID == 36 ||
	galaxyNumber == 2 && system.ID == 40 ||
	galaxyNumber == 2 && system.ID == 99 ||
	galaxyNumber == 2 && system.ID == 184 ||
	galaxyNumber == 2 && system.ID == 210 ||
	galaxyNumber == 3 && system.ID == 96 ||
	galaxyNumber == 3 && system.ID == 240 ||
	galaxyNumber == 4 && system.ID == 31 ||
	galaxyNumber == 4 && system.ID == 37 ||
	galaxyNumber == 4 && system.ID == 44 ||
	galaxyNumber == 4 && system.ID == 63 ||
	galaxyNumber == 4 && system.ID == 95 ||
	galaxyNumber == 4 && system.ID == 127 ||
	galaxyNumber == 4 && system.ID == 134 ||
	galaxyNumber == 4 && system.ID == 198 ||
	galaxyNumber == 5 && system.ID == 12 ||
	galaxyNumber == 5 && system.ID == 32 ||
	galaxyNumber == 5 && system.ID == 47 ||
	galaxyNumber == 5 && system.ID == 56 ||
	galaxyNumber == 5 && system.ID == 129 ||
	galaxyNumber == 5 && system.ID == 160 ||
	galaxyNumber == 5 && system.ID == 167 ||
	galaxyNumber == 5 && system.ID == 242 ||
	galaxyNumber == 6 && system.ID == 27 ||
	galaxyNumber == 6 && system.ID == 137 ||
	galaxyNumber == 6 && system.ID == 139 ||
	galaxyNumber == 6 && system.ID == 153 ||
	galaxyNumber == 6 && system.ID == 228 ||
	galaxyNumber == 7 && system.ID == 11 ||
	galaxyNumber == 7 && system.ID == 62 ||
	galaxyNumber == 7 && system.ID == 134 ||
	galaxyNumber == 7 && system.ID == 166 ||
	galaxyNumber == 7 && system.ID == 170 ||
	galaxyNumber == 7 && system.ID == 185 ||
	galaxyNumber == 7 && system.ID == 186 ||
	galaxyNumber == 7 && system.ID == 196 ||
	galaxyNumber == 7 && system.ID == 240 ||
	galaxyNumber == 7 && system.ID == 242 ||
	galaxyNumber == 7 && system.ID == 253
	)
	{
		system.setPopulator("darkside-moonshine-distillery",
		{
			location: "TRIANGLE",
			locationSeed: 21541,
			deterministic: true,
			callback: function(pos)
			{
				var DMD = system.addShips("darkside-moonshine-distillery",1,pos,0);
				//system.addShips("witchfire-beacon", 1, DMD.position.add(DMD.heading.multiply(10E3)), 1);
			}
		});
	}
	if(system.economy < 4 && system.scrambledPseudoRandomNumber() > (0.32 * system.government)) {
		if
		(
		galaxyNumber == 0 && system.ID == 59 ||
		galaxyNumber == 0 && system.ID == 142 ||
		galaxyNumber == 0 && system.ID == 173 ||
		galaxyNumber == 0 && system.ID == 213 ||
		galaxyNumber == 0 && system.ID == 223 ||
		galaxyNumber == 0 && system.ID == 238 ||
		galaxyNumber == 1 && system.ID == 0 ||
		galaxyNumber == 1 && system.ID == 30 ||
		galaxyNumber == 1 && system.ID == 47 ||
		galaxyNumber == 1 && system.ID == 64 ||
		galaxyNumber == 1 && system.ID == 110 ||
		galaxyNumber == 1 && system.ID == 135 ||
		galaxyNumber == 1 && system.ID == 137 ||
		galaxyNumber == 1 && system.ID == 190 ||
		galaxyNumber == 1 && system.ID == 213 ||
		galaxyNumber == 1 && system.ID == 217 ||
		galaxyNumber == 1 && system.ID == 225 ||
		galaxyNumber == 1 && system.ID == 254 ||
		galaxyNumber == 2 && system.ID == 36 ||
		galaxyNumber == 2 && system.ID == 40 ||
		galaxyNumber == 2 && system.ID == 99 ||
		galaxyNumber == 2 && system.ID == 184 ||
		galaxyNumber == 2 && system.ID == 210 ||
		galaxyNumber == 3 && system.ID == 96 ||
		galaxyNumber == 3 && system.ID == 240 ||
		galaxyNumber == 4 && system.ID == 31 ||
		galaxyNumber == 4 && system.ID == 37 ||
		galaxyNumber == 4 && system.ID == 44 ||
		galaxyNumber == 4 && system.ID == 63 ||
		galaxyNumber == 4 && system.ID == 95 ||
		galaxyNumber == 4 && system.ID == 127 ||
		galaxyNumber == 4 && system.ID == 134 ||
		galaxyNumber == 4 && system.ID == 198 ||
		galaxyNumber == 5 && system.ID == 12 ||
		galaxyNumber == 5 && system.ID == 32 ||
		galaxyNumber == 5 && system.ID == 47 ||
		galaxyNumber == 5 && system.ID == 56 ||
		galaxyNumber == 5 && system.ID == 129 ||
		galaxyNumber == 5 && system.ID == 160 ||
		galaxyNumber == 5 && system.ID == 167 ||
		galaxyNumber == 5 && system.ID == 242 ||
		galaxyNumber == 6 && system.ID == 27 ||
		galaxyNumber == 6 && system.ID == 137 ||
		galaxyNumber == 6 && system.ID == 139 ||
		galaxyNumber == 6 && system.ID == 153 ||
		galaxyNumber == 6 && system.ID == 228 ||
		galaxyNumber == 7 && system.ID == 11 ||
		galaxyNumber == 7 && system.ID == 62 ||
		galaxyNumber == 7 && system.ID == 134 ||
		galaxyNumber == 7 && system.ID == 166 ||
		galaxyNumber == 7 && system.ID == 170 ||
		galaxyNumber == 7 && system.ID == 185 ||
		galaxyNumber == 7 && system.ID == 186 ||
		galaxyNumber == 7 && system.ID == 196 ||
		galaxyNumber == 7 && system.ID == 240 ||
		galaxyNumber == 7 && system.ID == 242 ||
		galaxyNumber == 7 && system.ID == 253
		)
		{ return; }
		this.addedCount = 0;
		
		system.setPopulator("darkside-moonshine-saloon",
		{
			location: "TRIANGLE",
			locationSeed: 27641,
			deterministic: true,
			callback: function(pos)
			{
				var DMS = system.addShips("darkside-moonshine-saloon",1,pos,0);
				//system.addShips("witchfire-beacon", 1, DMD.position.add(DMD.heading.multiply(10E3)), 1);
			}
		});
	}
}
 |