Page 1 of 2

Escort Probs Again

Posted: Sun Feb 20, 2011 5:24 pm
by Killer Wolf
trying to use the new formation stuff for the Scorpius. Scorp shipdata has

Code: Select all

	escorts = 8;
	escort-ship = "reduxvampescort";
	script = "scorp-escort.js";
i've likeshipped the reduxed Vamp, giving it escortAI and a role of escort.

scorp-escort.js is

Code: Select all

"use strict";

this.name = "scorp-escort.js";

(function () {
const escortPositions =
[
    
    new Vector3D(-1, 0, -1),
    new Vector3D(-2, 0, 1),
    new Vector3D(-3, 0, -1),
    new Vector3D(-4, 0, -2),

    new Vector3D(1, 0, -1),
    new Vector3D(2, 0, 1),
    new Vector3D(3, 0, -1),
    new Vector3D(4, 0, -2)

];

this.coordinatesForEscortPosition = function (index)
{
    var highPart = 1 + (index >> 2);  // Equivalent to 1 + Math.floor(position / 4)
    var lowPart = index % 4;
   
    var spacing = this.ship.collisionRadius * 1.5 * highPart;
   
    return escortPositions[lowPart].multiply(spacing);
}
}).call(this);
basically just cut/pasted from the Progress thread (unless i buggered it up) ~ i lowered the spacing calc to see if that made a difference but it didn't. it should give a vaguely bat-wing formation : the ships spawn immediate (the new 1.75exe seeems pretty fast), but the escorts just fk off in random directions. some turn loop-the-loops a few times before deciding to go.

owt obvious??

cheers!

Re: Escort Probs Again

Posted: Mon Feb 21, 2011 11:49 am
by Killer Wolf
oh well.

Re: Escort Probs Again

Posted: Mon Feb 21, 2011 11:57 am
by Commander McLane
Sorry, can't help you here. Specifically, I don't yet understand the JS syntax here:

Code: Select all

this.coordinatesForEscortPosition = function (index)
{
    var highPart = 1 + (index >> 2);  // Equivalent to 1 + Math.floor(position / 4)
    var lowPart = index % 4;
   
    var spacing = this.ship.collisionRadius * 1.5 * highPart;
   
    return escortPositions[lowPart].multiply(spacing);
}
}).call(this);
As you say: oh well.

Still much to learn about JS.

Re: Escort Probs Again

Posted: Mon Feb 21, 2011 1:00 pm
by Eric Walch
Killer Wolf wrote:
basically just cut/pasted from the Progress thread (unless i buggered it up) ~ i lowered the spacing calc to see if that made a difference but it didn't. it should give a vaguely bat-wing formation : the ships spawn immediate (the new 1.75exe seeems pretty fast), but the escorts just fk off in random directions. some turn loop-the-loops a few times before deciding to go.

owt obvious??

cheers!
I don't think the above code is wrong. Oolite uses your above code already for the initial addition of the escorts. Than the position is cached and not used anymore. The problem must lie elsewhere. You don't accidentally use ships of police scan_class ? Because that never really worked with custom escorts. Since Oolite 1.75 however it does work, and your code suggest you are using 1.75.

I have no clue but still think the problem is not in above code.

Re: Escort Probs Again

Posted: Mon Feb 21, 2011 1:21 pm
by Killer Wolf
yeah, i'm using the 1.75exe beta i think it is. the code was basically just a pasting of Ahruman's examples w/ my own coordinates in but for some reason the escorts just don't seem to want to join the mother and line up.

Re: Escort Probs Again

Posted: Tue Feb 22, 2011 11:26 pm
by JensAyton
The obvious follow-up question is: do the escorts form up if you comment out the custom script? If so, do they work if you change the factor 1.5 to something higher?

Here’s an updated (and verified) version of the example using the exact same code as the 1.75 release, but with different escort coordinates:

Code: Select all

"use strict";

this.name = "ahruman-escort-test-mother.js";


(function () {

const escortPositions =
[
    // X-shape escort pattern
    new Vector3D(-2, 0,  2),
    new Vector3D( 2, 0,  2),
    new Vector3D(-3, 0, -3),
    new Vector3D( 3, 0, -3)
];

const escortPositionCount = escortPositions.length;
const escortSpacingFactor = 3;


this.coordinatesForEscortPosition = function (index, count)
{
    var highPart = Math.floor(index / escortPositionCount) + 1;
    var lowPart = index % escortPositionCount;
    
    var spacing = this.ship.collisionRadius * escortSpacingFactor * highPart;
    
    return escortPositions[lowPart].multiply(spacing);
}

}).call(this);
The major benefit of this, other than using less obscure arithmetic, is that it works with any number of entries in the escortPositions array, while the code you’re using assumes four.

Re: Escort Probs Again

Posted: Wed Feb 23, 2011 7:29 am
by Killer Wolf
"The obvious follow-up question is: do the escorts form up if you comment out the custom script?"
no :-(
i was testing (read : fumbling about ineptly) different stuff last night, and nothing would get them to hook up. i dropped it to 2 escorts, no scripts, and they still just buggered off. i was trying to find out how to see what state the escorts were in but i wasn't on the net and couldn't work it out.
the only thing i could think of is the escort AI : if i'm reading it right (which i probably aren't, given the Wasps etc seem to tun up w/ escorts ok), it looked as though when spawning up they were getting into the BEGIN_BUSINESS state and hitting the CLEAR_STATION as they would head off to a point then stop : at least one of them then did dock ~ i didn't watch them most of the time as i usually binned the sesh to try something else as soon as it was obvious they weren't hooking up w/ the Scorpius, so i don't know how common that is.

cheers for the code, i'll try it tonight.

Re: Escort Probs Again

Posted: Wed Feb 23, 2011 8:33 am
by Eric Walch
Killer Wolf wrote:
"The obvious follow-up question is: do the escorts form up if you comment out the custom script?"
no :-(
i was testing (read : fumbling about ineptly) different stuff last night, and nothing would get them to hook up. i dropped it to 2 escorts, no scripts, and they still just buggered off. i was trying to find out how to see what state the escorts were in but i wasn't on the net and couldn't work it out.
the only thing i could think of is the escort AI : if i'm reading it right (which i probably aren't, given the Wasps etc seem to tun up w/ escorts ok), it looked as though when spawning up they were getting into the BEGIN_BUSINESS state and hitting the CLEAR_STATION as they would head off to a point then stop : at least one of them then did dock ~ i didn't watch them most of the time as i usually binned the sesh to try something else as soon as it was obvious they weren't hooking up w/ the Scorpius, so i don't know how common that is.

cheers for the code, i'll try it tonight.
Better post the part of the shipdata.plist for both mother and escort. Maybe there is the clue. When adding escorts with escort-ship the escort not even needs escort in its role list. Oolite will add it on spawning. Advantage of that is that the escorts won't be used as escorts for other ships. Also will Oolite give it an escortAI by default and a custom AI will only be used when you explicit set auto_ai to false. One thing that could have happened that you added keys to the escorts that belong to a mother by using a like_ship. e.g. when the original has escorts, you must explicit define zero escorts for a like_ship copy. However such mistakes should show up in the log.
In my experience escorts always work from the start, so I don't really have a clue what could go wrong here.

Re: Escort Probs Again

Posted: Wed Feb 23, 2011 7:59 pm
by Killer Wolf
still can't get this to work :-(
shipdata ;

Code: Select all

//  *************************************************
//  *               S C O R P I U S                 *
//  *************************************************
{
"scorpius" = 
	{
	ai_type = "route1traderAI.plist";
// ai_type = "dumbAI.plist";
	beacon = "G - Scorpius";
	auto_ai = yes;
	exhaust = ("0.0 -15.0 -251.0 16.0 5.0 200.0","71.0 -16.7 36.0 6.0 4.0 20.0","-71.0 -16.7 36.0 6.0 4.0 20.0");
	energy_recharge_rate = 100;	
	forward_weapon_type = "WEAPON_NONE";
	max_flight_pitch = 0.7;
	max_flight_roll = 0.7;
	max_flight_speed = 300;
	max_energy = 25000;
	frangible = "false";
	has_ecm = "true";
	has_escape_pod = "true";
	name = "Scorpius";
	model = "hull.dat"; 
	roles = "scavenger sunskim-trader trader"; 
	escorts = 4;
	escort-ship = "scorpescort";
	script = "scorp-escort.js";
 	thrust = 50;	
	smooth = "false";	
	max_missiles = 12;	
	missiles = 12;	
	missile_launch_position = "0.0 -24.0 258.0";

	subentities = ( 
		"scorpcabins   0 0 0 1 0 0 0",
		"scorpLcannon   0 0 0 1 0 0 0",
		"scorpRcannon   0 0 0 1 0 0 0"

		   );
	shaders = 
		{ 
            "hulloartex.png" = 
			{ 
                vertex_shader = "scorpshaderv.vertex"; 
                fragment_shader = "scorpshaderf.fragment"; 
                textures = 
						(
							"hulloartex.png", 
							"hulloartex-normals.png",
							"hulloartex-effects.png",
							"hulloartex-lites.png"
						);
				uniforms =
						{
						uColorMap = { type = texture; value = 0; }; 
						uNormalMap = { type = texture; value = 1; }; 
						uEffectsMap = { type = texture; value = 2; };
						uGlowMap = { type = texture; value = 3; };	
						uTime = "universalTime";
						nearly_dead = "throwingSparks";	
						hull_heat_level = "hullHeatLevel";	 				
						engine_power = "speedFactor"; 
						}; 	
			}; 
		};
	};	
		
	"scorpcabins" =  
	{
	ai_type = "nullAI.plist";
	name = "Scorpius";
	model = "cabrigs.dat"; 
	roles = "scorpsubent"; 
	shaders = 
		{ 
            "cabrigtex.png" = 
			{ 
                vertex_shader = "scorpshaderv.vertex"; 
                fragment_shader = "scorpshaderf.fragment"; 
                textures = 
						(
							"cabrigtex.png",  
							"cabrigtex-normals.png",
							"cabrigtex-effects.png",
							"cabrigtex-lites.png"
						);
				uniforms =
						{
						uColorMap = { type = texture; value = 0; }; // don't change the order of the textures, the order  
						uNormalMap = { type = texture; value = 1; }; // of the other uniforms in this list (eg 'uTime', 'nearly_dead_')
						uEffectsMap = { type = texture; value = 2; }; // doesn't matter
						uGlowMap = { type = texture; value = 3; };	
						uTime = "universalTime";
						nearly_dead = "throwingSparks";	
						hull_heat_level = "hullHeatLevel";	 				
						engine_power = "speedFactor"; 
						}; 	
			}; 
		};

	};	


	"scorpRcannon" =  
	{
	ai_type = "nullAI.plist";
	name = "Scorpius";
	model = "scorprgun.dat"; 
	roles = "scorpsubent"; 
	forward_weapon_type = "WEAPON_MILITARY_LASER";
	weapon_position_forward = "73.0 17.2 179.0";
	shaders = 
		{ 
            "cabrigtex.png" = 
			{ 
                vertex_shader = "scorpshaderv.vertex"; 
                fragment_shader = "scorpshaderf.fragment"; 
                textures = 
						(
							"cabrigtex.png",  
							"cabrigtex-normals.png",
							"cabrigtex-effects.png",
							"cabrigtex-lites.png"
						);
				uniforms =
						{
						uColorMap = { type = texture; value = 0; }; // don't change the order of the textures, the order  
						uNormalMap = { type = texture; value = 1; }; // of the other uniforms in this list (eg 'uTime', 'nearly_dead_')
						uEffectsMap = { type = texture; value = 2; }; // doesn't matter
						uGlowMap = { type = texture; value = 3; };	
						uTime = "universalTime";
						nearly_dead = "throwingSparks";	
						hull_heat_level = "hullHeatLevel";	 				
						engine_power = "speedFactor"; 
						}; 	
			}; 
		};

	};	

	
	"scorpLcannon" =  
	{
	ai_type = "nullAI.plist";
	name = "Scorpius";
	model = "scorplgun.dat"; 
	roles = "scorpsubent"; 
	forward_weapon_type = "WEAPON_MILITARY_LASER";
	weapon_position_forward = "-73.0 17.2 179.0";
	shaders = 
		{ 
            "cabrigtex.png" = 
			{ 
                vertex_shader = "scorpshaderv.vertex"; 
                fragment_shader = "scorpshaderf.fragment"; 
                textures = 
						(
							"cabrigtex.png",  
							"cabrigtex-normals.png",
							"cabrigtex-effects.png",
							"cabrigtex-lites.png"
						);
				uniforms =
						{
						uColorMap = { type = texture; value = 0; }; // don't change the order of the textures, the order  
						uNormalMap = { type = texture; value = 1; }; // of the other uniforms in this list (eg 'uTime', 'nearly_dead_')
						uEffectsMap = { type = texture; value = 2; }; // doesn't matter
						uGlowMap = { type = texture; value = 3; };	
						uTime = "universalTime";
						nearly_dead = "throwingSparks";	
						hull_heat_level = "hullHeatLevel";	 				
						engine_power = "speedFactor"; 
						}; 	
			}; 
		};

	};	

//  *************************************************
//  *            SCORP ESCORT                       *
//  *************************************************
"scorpescort" = 
	{
	ai_type = "escortAI.plist";
	auto_ai = yes;
	aft_eject_position = "0.0 11.1 47.69";
	energy_recharge_rate = 4.25;	
	exhaust = ("-7.54 2.69 -47.94 6.0 4.0 150.0", "7.54 2.69 -47.94 6.0 4.0 150.0");
	forward_weapon_type = "WEAPON_BEAM_LASER";
	weapon_position_forward = "0.0 -2.76 83.46";
	weapon_position_aft = "0.0 2.54 -49.34";
	laser_color = "blueColor";
	max_cargo = 31;
	likely_cargo = 7;
	max_energy = 520;
	max_flight_pitch = 2;
	max_flight_roll = 4;
	max_flight_speed = 375;
	fuel = 70;
	has_fuel_injection = 0.9;
	has_shield_booster = 0.78;
	has_ecm = "true";
	has_escape_pod = "true";
	heat_insulation = 1.0;
	has_scoop = "true";
	max_missiles = 6;	
	missiles = 6;	
	name = "Scorpius Escort";
	missile_launch_position = "0.0 -5.3 22.1";
	model = "scorpesc.dat"; 
	roles = "escort"; 
 	thrust = 55;	
	scoop_position = "0.0 -5.3 22.1";	
	smooth = "false";	
	shaders = 
		{ 
            "scorpescskin.png" = 
			{ 
                vertex_shader = "scorpshaderv.vertex"; 
                fragment_shader = "scorpshaderf.fragment"; 
                textures = 
						(
							"scorpescskin.png", 
							"scorpescnormals.png",
							"scorpesceffects.png",
							"scorpesclites.png"
						);
				uniforms =
						{
						uColorMap = { type = texture; value = 0; }; 
						uNormalMap = { type = texture; value = 1; }; 
						uEffectsMap = { type = texture; value = 2; };
						uGlowMap = { type = texture; value = 3; };	
						uTime = "universalTime";
						nearly_dead = "throwingSparks";	
						hull_heat_level = "hullHeatLevel";	 				
						engine_power = "speedFactor"; 
						}; 	
			}; 
		};
	};	

	
}
- to prevent likeshipping probs, i copied a Vamp model etc and created a new ship, scorpescort.
- originally, Scorp was genned up w/ a role of "scorpius" - not sure it that would have affected things?
- originally put pirate as a role - i did see a Scorp w/ escort ships, but of course they were mid combat so i can't tell if the script ran fine regards the formation thingy.
- one time i came across the four escorts outside a station, they were all pointing nose out in a + shape, it looked cool, but there was no Scorp in sight.
- have uses my populating script to dump 5 Scorps on launching, and then tried on WS exit. buggered if i can find them - i thought they'd mainly hang around the main corridor. i came across one lone one out in the depths but there were no escorts. [edit] : yeah, i'm a moron - i've just remembered that my script uses Role to populate, and it tries to populate a role of "scorpius" that i have since changed X-( would there be any benefits (testing-wise) to genning up scorps and then putting in their script a change of role to Trader or whatever?
- the beacon worked no prob w/ the Scorpius role, now it's very hit and miss. Log says 5 Scorps were genned, but no beacon symbol appears a lot of the time. i got the one above locked on, and i locked one outside a Sothis : sadly, it was running a trading AI i guess cos it tried to dock :-( again, no escorts around for this one.

might try sticking a death action thing in, in case things are getting genned but killed immediately; i had that prob w/ teh Sothis.

Re: Escort Probs Again

Posted: Fri Feb 25, 2011 7:37 am
by Killer Wolf
flat out doesn't work for me. spawned up a load of sun-skimmers and put the Scorp as that role, so i ended up w/ a few in the system when i jumped in. i have some nifty screengrabs of loads of escorts loitering outside the station (strangely, they all form lines, it looks quite cool) but none are hooking up w/ the Scorps. i've seen literally ONE w/ escorts, and that only had 2, not the 4 specified in the shipdata.

Re: Escort Probs Again

Posted: Fri Feb 25, 2011 9:04 am
by Switeck
"Safer" systems, such as Corporate States may remove escorts that it considers unnecessary.
Even Anacondas sometimes travel alone there.

Re: Escort Probs Again

Posted: Fri Feb 25, 2011 9:27 am
by Eric Walch
Switeck wrote:
"Safer" systems, such as Corporate States may remove escorts that it considers unnecessary.
Even Anacondas sometimes travel alone there.
Yes but escort reduction only happens for ships added in a trader role, not for custom roles.

Re: Escort Probs Again

Posted: Fri Feb 25, 2011 10:17 am
by Killer Wolf
Eric Walch wrote:
Switeck wrote:
"Safer" systems, such as Corporate States may remove escorts that it considers unnecessary.
Even Anacondas sometimes travel alone there.
Yes but escort reduction only happens for ships added in a trader role, not for custom roles.
like i said i spawned them under sunskim-trader in case the custom role was causing probs, so i take it the auto number reduction doesn't apply? it seems a bit odd having a specific shipdata entry for escort numbers if the game itself is then going to alter it, potentially removing them all together. wouldn't it be better to have it the other way around, ie if you specify escort ships the game gens up a random number unless you also put in a number-of-escorts value as an override?

so how's the game engine working for me then : is my Scorp genning saying "give me four escort ships per Scorp", which are then genned, but the game is then saying "you don't need any" and the escorts are then left to sit aimlessly until they decide to dock etc?

Re: Escort Probs Again

Posted: Fri Feb 25, 2011 10:33 am
by Commander McLane
No. If the engine decides to reduce the number of escorts in safe systems, it doesn't generate them in the first place.

Can you wrap up the current state of your OXP and put in on the box? It's really hard to say anything from the script and shipdata alone. I'd like to see what actually happens.

Re: Escort Probs Again

Posted: Fri Feb 25, 2011 11:37 am
by Killer Wolf
aye, cheers, i'll send you a link tonight.