[RELEASE] Escort Formations 1.1

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1422
Joined: Thu Aug 27, 2015 4:24 pm

Re: [RELEASE] Escort Formations 1.1

Post by cbr »

For cloud editing purposes

Code: Select all

this.author      = "cim"; 
this.copyright   = "� 2011-2014 cim."; 
this.licence = "CC-BY-SA 3.0";
this.version     = "1.1"; 
this.name = "Escort Formations Randomiser";
this.description = "Randomise escort formations for traders and pirates";

"use strict";

this.startUp = function() {
		this.$escortPatterns = new Object;
		this.$escortPatterns["combat-spread"] = [new Vector3D(1,0,0), 
																							new Vector3D(-1,0,0)];
		this.$escortPatterns["echelon"] = [new Vector3D(1,0,-1)];
		this.$escortPatterns["trail"] = [new Vector3D(1,0,-5),
																		 new Vector3D(-1,0,-6)];
		this.$escortPatterns["vform"] = [new Vector3D(1,0,-1), 
																			new Vector3D(-1,0,-1)];
		this.$escortPatterns["arrowhead"] = [new Vector3D(1,0,-1),
																					new Vector3D(-1,0,-1),
																					new Vector3D(0,1,-1),
																					new Vector3D(0,-1,-1)];
		this.$escortPatterns["convoy"] = [new Vector3D(0,1,7),
																			new Vector3D(0,-1,-7),
																			new Vector3D(1,1,6),
																			new Vector3D(-1,-1,-6),
																			new Vector3D(1,-1,-6),
																			new Vector3D(-1,1,6)];
		this.$escortPatterns["scouting-spread"] = [new Vector3D(5,0,-4),
																							 new Vector3D(-5,0,4)];
		this.$escortPatterns["planebox"] = [new Vector3D(2,0,2),
																				new Vector3D(-2,0,-2),
																				new Vector3D(-2,0,2),
																				new Vector3D(2,0,-2)];
		this.$escortPatterns["twistbox"] = [new Vector3D(2,0,2),
																				new Vector3D(0,2,-2),
																				new Vector3D(0,-2,-2),
																				new Vector3D(-2,0,2)];
		this.$escortPatterns["octahedron"] = [new Vector3D(4,0,0),
																					new Vector3D(-4,0,0),
																					new Vector3D(0,4,0),
																					new Vector3D(0,-4,0),
																					new Vector3D(0,1,4),
																					new Vector3D(0,-1,-4)];
		this.$escortPatterns["pyramid"] = [new Vector3D(0,1,4.5),
																			 new Vector3D(3,3,-3),
																			 new Vector3D(-3,-3,-3),
																			 new Vector3D(-3,3,-3),
																			 new Vector3D(3,-3,-3)];
		this.$escortPatterns["wave"] = [new Vector3D(1,0,-0.5),
																		new Vector3D(-1,0,-0.5),
																		new Vector3D(1,0,-5.5),
																		new Vector3D(-1,0,-5.5),
																		new Vector3D(2,0,-6.5),
																		new Vector3D(-2,0,-6.5)];
		this.$escortPatterns["screen"] = [new Vector3D(1,0,3),
																			 new Vector3D(-1,0,3),
																			 new Vector3D(4,0,2.5),
																			 new Vector3D(-4,0,2.5)];
		this.$escortPatterns["opencolumn"] = [new Vector3D(-0.5,0,-2),
																					new Vector3D(0.5,0,-2),
																					new Vector3D(-0.5,0,-4),
																					new Vector3D(0.5,0,-4),
																					new Vector3D(-0.5,0,-6),
																					new Vector3D(0.5,0,-6)];
		this.$escortPatterns["stack"] = [new Vector3D(0.5,1,0),
																		 new Vector3D(-0.5,-1,0)];
		this.$escortPatterns["flank"] = [new Vector3D(1,0,-1),
																		 new Vector3D(-1,0,-1),
																		 new Vector3D(7,0,-1),
																		 new Vector3D(-7,0,-1)];
		this.$escortPatterns["bulge"] = [new Vector3D(-1,0,-1),
																			new Vector3D(1,0,-1),
																			new Vector3D(0,0.5,7),
																			new Vector3D(0,-0.5,-7)];
		this.$escortPatterns["near-far"] = [new Vector3D(-1,0,-1),
																				new Vector3D(7,0,-1),
																				new Vector3D(1,0,-1),
																				new Vector3D(6,0,-2)];
		this.$escortPatterns["helix"] = [new Vector3D(-3,0,-1),
																		 new Vector3D(0,3,-2),
																		 new Vector3D(3,0,-3),
																		 new Vector3D(0,-3,-4),
																		 new Vector3D(-4,0,-5),
																		 new Vector3D(0,4,-6),
																		 new Vector3D(4,0,-7),
																		 new Vector3D(0,-4,-8)
																		];
		this.$escortPatterns["vwide"] = [new Vector3D(4,0,-4), 
																			new Vector3D(-4,0,-4)];


}

this.shipSpawned = function(ship) {
		if (!ship.script) return; // odd, but seems to happen occasionally
		if (ship.script.coordinatesForEscortPosition != Script.prototype.coordinatesForEscortPosition) { 
				this.$debug(ship.displayName+" has escort coordinates already");
				return; 
		} // already has some custom coordinates
		if (ship.script.$efr_pattern) { 
				this.$debug(ship.displayName+" has $efr_pattern already");
				return; 
		} // variable name conflict
		if (ship.script.$efr_timer) { 
				this.$debug(ship.displayName+" has $efr_pattern already");
				return; 
		} // variable name conflict
		var offensiveChance = 0;
		if (ship.primaryRole == "trader") {
				offensiveChance = 0.15;
		} else if (ship.primaryRole == "bigTrader" && ship.name != "Super Bulk Hauler") {
				offensiveChance = 0.15;
		} else if (ship.primaryRole == "liner" || ship.primaryRole == "coachwhip" || ship.primaryRole == "fuelship") { // from Transports OXP
				offensiveChance = 0.05;
		} else if (ship.primaryRole == "pirate") {
				offensiveChance = 0.75;
		} else if (ship.primaryRole == "police" || ship.primaryRole == "hunter") {
				offensiveChance = 0.9;
		} else {
				this.$debug(ship.displayName+" has no included role");
				return; // stock ships only
		}
		if (Math.random() < 0.10) { 
				this.$debug("No escort change for "+ship.displayName);
				return; 
		} // keep default formation
		
// timer to allow escorts to be set up too
		if (Math.random() < offensiveChance) {
				ship.script.$efr_timer = new Timer(ship,function() { worldScripts["Escort Formations Randomiser"].$setupOffensiveEscorts(ship); },0.25);
		} else {
				ship.script.$efr_timer = new Timer(ship,function() { worldScripts["Escort Formations Randomiser"].$setupDefensiveEscorts(ship); },0.25);
		}
}

this.$setupOffensiveEscorts = function(ship) {
		var formations = new Array();
		if (!ship.escorts) {
				return; // no escorts
		} else if (ship.escorts.length <= 2) {
				formations.push("combat-spread","echelon","vform","trail","near-far","vwide");
		} else if (ship.escorts.length <= 4) {
				formations.push("combat-spread","echelon","arrowhead","vform","wave","stack","flank","near-far","helix","vwide");
		} else {
				formations.push("arrowhead","vform","wave","stack","flank","helix");
		}
		this.$setupEscortFormation(ship,formations[Math.floor(Math.random()*formations.length)]);
}

this.$setupDefensiveEscorts = function(ship) {
		var formations = new Array();
		if (!ship.escorts) {
				return; // no escorts
		} else if (ship.escorts.length <= 2) {
				formations.push("convoy","vform","scouting-spread","screen","near-far","vwide");
		} else if (ship.escorts.length <= 4) {
				formations.push("planebox","twistbox","vform","convoy","screen","opencolumn","bulge","near-far","vwide");
		} else {
				formations.push("octahedron","pyramid","vform","convoy","bulge");
		}
		this.$setupEscortFormation(ship,formations[Math.floor(Math.random()*formations.length)]);
}

this.$setupEscortFormation = function(ship,formation) {
		ship.script.$efr_pattern = formation;
		ship.script.coordinatesForEscortPosition = function(index) {
				var positions = worldScripts["Escort Formations Randomiser"].$getEscortPositions(this.$efr_pattern);
				var layer = 1+Math.floor(index/positions.length);
				var component = index % positions.length;
				
				return positions[component].multiply(this.ship.collisionRadius * 5 * layer).add([0,0,7.5*this.ship.collisionRadius]);
		}
		this.$debug(ship.displayName+" assigned formation: "+formation);
		ship.updateEscortFormation();
}

this.$getEscortPositions = function(pattern) {
		if (this.$escortPatterns[pattern]) {
				return this.$escortPatterns[pattern];
		} else {
				return this.$escortPatterns["vform"];
		}
}

this.$debug = function(msg) {
//		log(this.name,msg);
}
User avatar
Cholmondely
Archivist
Archivist
Posts: 5364
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: [RELEASE] Escort Formations 1.1

Post by Cholmondely »

cbr wrote: Sun Mar 14, 2021 9:41 pm
For cloud editing purposes
Help? What is this?
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: [RELEASE] Escort Formations 1.1

Post by Cody »

Cholmondely wrote: Mon Mar 15, 2021 9:59 am
cbr wrote: Sun Mar 14, 2021 9:41 pm
For cloud editing purposes
Help? What is this?
I've looked at clouds from both sides now
From up and down, and still somehow
It's cloud illusions I recall
I really don't know clouds at all
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Re: [RELEASE] Escort Formations 1.1

Post by maik »

Cody wrote: Mon Mar 15, 2021 4:58 pm
Cholmondely wrote: Mon Mar 15, 2021 9:59 am
cbr wrote: Sun Mar 14, 2021 9:41 pm
For cloud editing purposes
Help? What is this?
I've looked at clouds from both sides now
From up and down, and still somehow
It's cloud illusions I recall
I really don't know clouds at all
How very poetic of you! 😀
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1422
Joined: Thu Aug 27, 2015 4:24 pm

Re: [RELEASE] Escort Formations 1.1

Post by cbr »

Cody wrote: Mon Mar 15, 2021 4:58 pm

I've looked at clouds from both sides now
From up and down, and still somehow
It's cloud illusions I recall
I really don't know clouds at all
aa, very beautiful indeed... :D
User avatar
Cholmondely
Archivist
Archivist
Posts: 5364
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: [RELEASE] Escort Formations 1.1

Post by Cholmondely »

Just to mention,

Rustem came out with a version 1.2; and then a version 1.3 which is here: https://app.box.com/s/lqdwx8wxg1rf2ioeoygnd5k46y8z8t7y

Reference: https://bb.oolite.space/viewtopic.php?p=260769#p260769 (2017)

His "Trigon" is not included in cbr's randomiser script above.
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Cholmondely
Archivist
Archivist
Posts: 5364
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: [RELEASE] Escort Formations 1.1

Post by Cholmondely »

cbr wrote: Sun Mar 14, 2021 9:41 pm
For cloud editing purposes

Code: Select all

this.author      = "cim"; 
this.copyright   = "� 2011-2014 cim."; 
this.licence = "CC-BY-SA 3.0";
this.version     = "1.1"; 
this.name = "Escort Formations Randomiser";
this.description = "Randomise escort formations for traders and pirates";

"use strict";

this.startUp = function() {
		this.$escortPatterns = new Object;
		this.$escortPatterns["combat-spread"] = [new Vector3D(1,0,0), 
																							new Vector3D(-1,0,0)];
		this.$escortPatterns["echelon"] = [new Vector3D(1,0,-1)];
		this.$escortPatterns["trail"] = [new Vector3D(1,0,-5),
																		 new Vector3D(-1,0,-6)];
		this.$escortPatterns["vform"] = [new Vector3D(1,0,-1), 
																			new Vector3D(-1,0,-1)];
		this.$escortPatterns["arrowhead"] = [new Vector3D(1,0,-1),
																					new Vector3D(-1,0,-1),
																					new Vector3D(0,1,-1),
																					new Vector3D(0,-1,-1)];
		this.$escortPatterns["convoy"] = [new Vector3D(0,1,7),
																			new Vector3D(0,-1,-7),
																			new Vector3D(1,1,6),
																			new Vector3D(-1,-1,-6),
																			new Vector3D(1,-1,-6),
																			new Vector3D(-1,1,6)];
		this.$escortPatterns["scouting-spread"] = [new Vector3D(5,0,-4),
																							 new Vector3D(-5,0,4)];
		this.$escortPatterns["planebox"] = [new Vector3D(2,0,2),
																				new Vector3D(-2,0,-2),
																				new Vector3D(-2,0,2),
																				new Vector3D(2,0,-2)];
		this.$escortPatterns["twistbox"] = [new Vector3D(2,0,2),
																				new Vector3D(0,2,-2),
																				new Vector3D(0,-2,-2),
																				new Vector3D(-2,0,2)];
		this.$escortPatterns["octahedron"] = [new Vector3D(4,0,0),
																					new Vector3D(-4,0,0),
																					new Vector3D(0,4,0),
																					new Vector3D(0,-4,0),
																					new Vector3D(0,1,4),
																					new Vector3D(0,-1,-4)];
		this.$escortPatterns["pyramid"] = [new Vector3D(0,1,4.5),
																			 new Vector3D(3,3,-3),
																			 new Vector3D(-3,-3,-3),
																			 new Vector3D(-3,3,-3),
																			 new Vector3D(3,-3,-3)];
		this.$escortPatterns["wave"] = [new Vector3D(1,0,-0.5),
																		new Vector3D(-1,0,-0.5),
																		new Vector3D(1,0,-5.5),
																		new Vector3D(-1,0,-5.5),
																		new Vector3D(2,0,-6.5),
																		new Vector3D(-2,0,-6.5)];
		this.$escortPatterns["screen"] = [new Vector3D(1,0,3),
																			 new Vector3D(-1,0,3),
																			 new Vector3D(4,0,2.5),
																			 new Vector3D(-4,0,2.5)];
		this.$escortPatterns["opencolumn"] = [new Vector3D(-0.5,0,-2),
																					new Vector3D(0.5,0,-2),
																					new Vector3D(-0.5,0,-4),
																					new Vector3D(0.5,0,-4),
																					new Vector3D(-0.5,0,-6),
																					new Vector3D(0.5,0,-6)];
		this.$escortPatterns["stack"] = [new Vector3D(0.5,1,0),
																		 new Vector3D(-0.5,-1,0)];
		this.$escortPatterns["flank"] = [new Vector3D(1,0,-1),
																		 new Vector3D(-1,0,-1),
																		 new Vector3D(7,0,-1),
																		 new Vector3D(-7,0,-1)];
		this.$escortPatterns["bulge"] = [new Vector3D(-1,0,-1),
																			new Vector3D(1,0,-1),
																			new Vector3D(0,0.5,7),
																			new Vector3D(0,-0.5,-7)];
		this.$escortPatterns["near-far"] = [new Vector3D(-1,0,-1),
																				new Vector3D(7,0,-1),
																				new Vector3D(1,0,-1),
																				new Vector3D(6,0,-2)];
		this.$escortPatterns["helix"] = [new Vector3D(-3,0,-1),
																		 new Vector3D(0,3,-2),
																		 new Vector3D(3,0,-3),
																		 new Vector3D(0,-3,-4),
																		 new Vector3D(-4,0,-5),
																		 new Vector3D(0,4,-6),
																		 new Vector3D(4,0,-7),
																		 new Vector3D(0,-4,-8)
																		];
		this.$escortPatterns["vwide"] = [new Vector3D(4,0,-4), 
																			new Vector3D(-4,0,-4)];


}

this.shipSpawned = function(ship) {
		if (!ship.script) return; // odd, but seems to happen occasionally
		if (ship.script.coordinatesForEscortPosition != Script.prototype.coordinatesForEscortPosition) { 
				this.$debug(ship.displayName+" has escort coordinates already");
				return; 
		} // already has some custom coordinates
		if (ship.script.$efr_pattern) { 
				this.$debug(ship.displayName+" has $efr_pattern already");
				return; 
		} // variable name conflict
		if (ship.script.$efr_timer) { 
				this.$debug(ship.displayName+" has $efr_pattern already");
				return; 
		} // variable name conflict
		var offensiveChance = 0;
		if (ship.primaryRole == "trader") {
				offensiveChance = 0.15;
		} else if (ship.primaryRole == "bigTrader" && ship.name != "Super Bulk Hauler") {
				offensiveChance = 0.15;
		} else if (ship.primaryRole == "liner" || ship.primaryRole == "coachwhip" || ship.primaryRole == "fuelship") { // from Transports OXP
				offensiveChance = 0.05;
		} else if (ship.primaryRole == "pirate") {
				offensiveChance = 0.75;
		} else if (ship.primaryRole == "police" || ship.primaryRole == "hunter") {
				offensiveChance = 0.9;
		} else {
				this.$debug(ship.displayName+" has no included role");
				return; // stock ships only
		}
		if (Math.random() < 0.10) { 
				this.$debug("No escort change for "+ship.displayName);
				return; 
		} // keep default formation
		
// timer to allow escorts to be set up too
		if (Math.random() < offensiveChance) {
				ship.script.$efr_timer = new Timer(ship,function() { worldScripts["Escort Formations Randomiser"].$setupOffensiveEscorts(ship); },0.25);
		} else {
				ship.script.$efr_timer = new Timer(ship,function() { worldScripts["Escort Formations Randomiser"].$setupDefensiveEscorts(ship); },0.25);
		}
}

this.$setupOffensiveEscorts = function(ship) {
		var formations = new Array();
		if (!ship.escorts) {
				return; // no escorts
		} else if (ship.escorts.length <= 2) {
				formations.push("combat-spread","echelon","vform","trail","near-far","vwide");
		} else if (ship.escorts.length <= 4) {
				formations.push("combat-spread","echelon","arrowhead","vform","wave","stack","flank","near-far","helix","vwide");
		} else {
				formations.push("arrowhead","vform","wave","stack","flank","helix");
		}
		this.$setupEscortFormation(ship,formations[Math.floor(Math.random()*formations.length)]);
}

this.$setupDefensiveEscorts = function(ship) {
		var formations = new Array();
		if (!ship.escorts) {
				return; // no escorts
		} else if (ship.escorts.length <= 2) {
				formations.push("convoy","vform","scouting-spread","screen","near-far","vwide");
		} else if (ship.escorts.length <= 4) {
				formations.push("planebox","twistbox","vform","convoy","screen","opencolumn","bulge","near-far","vwide");
		} else {
				formations.push("octahedron","pyramid","vform","convoy","bulge");
		}
		this.$setupEscortFormation(ship,formations[Math.floor(Math.random()*formations.length)]);
}

this.$setupEscortFormation = function(ship,formation) {
		ship.script.$efr_pattern = formation;
		ship.script.coordinatesForEscortPosition = function(index) {
				var positions = worldScripts["Escort Formations Randomiser"].$getEscortPositions(this.$efr_pattern);
				var layer = 1+Math.floor(index/positions.length);
				var component = index % positions.length;
				
				return positions[component].multiply(this.ship.collisionRadius * 5 * layer).add([0,0,7.5*this.ship.collisionRadius]);
		}
		this.$debug(ship.displayName+" assigned formation: "+formation);
		ship.updateEscortFormation();
}

this.$getEscortPositions = function(pattern) {
		if (this.$escortPatterns[pattern]) {
				return this.$escortPatterns[pattern];
		} else {
				return this.$escortPatterns["vform"];
		}
}

this.$debug = function(msg) {
//		log(this.name,msg);
}
Does this need updating for Rustem's v.1.3 (trigon formation added)?

And should I include this as a tweak for Escort Formations? Or is it a new oxp? Or is it something else? I have absolutely no idea what "cloud-editing purposes" are supposed to be! It all sounds a bit foggy to me!
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1422
Joined: Thu Aug 27, 2015 4:24 pm

Re: [RELEASE] Escort Formations 1.1

Post by cbr »

It is a mix...

sorry to cloud your vision :oops:

In simple street-speak or town-talk, I just stored it here for me be able to find it again :wink:

Think simple, no hidden layers...
User avatar
Cholmondely
Archivist
Archivist
Posts: 5364
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: [RELEASE] Escort Formations 1.3

Post by Cholmondely »

Cholmondely wrote: Wed Jun 07, 2023 8:13 pm
Just to mention,

Rustem came out with a version 1.2; and then a version 1.3 which is here: https://app.box.com/s/lqdwx8wxg1rf2ioeoygnd5k46y8z8t7y

Reference: https://bb.oolite.space/viewtopic.php?p=260769#p260769 (2017)
Rustem's Version 1.3 is now on the in-game Expansions Manager/Oolite Starter
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
Post Reply