Page 1 of 1

Strange problem with unresponsive ships

Posted: Wed Jul 12, 2017 3:14 pm
by UK_Eliter
If I may ask for help again . .

I've got a ship type, the name and role of which is IST_thargoidDefenceShip. This ship type has a plist ai and a script. And ships of this type are launched from a - huge - ship. The problem is, these defence ships won't do anything when they go into performAttack. They come up red on the scanner, and my player ship's turrets fire on them when they are red, but they do not actually attack but rather sail on off into the void.

Here is some more detail. My ai checks for the LAUNCHED OKAY message, and the problem occurs after that message has been received. Moreover, while the ship script decides what the ships should attack, I've tried replacing that functionality with a 'scanForNonThargoid' and same attacking-without-attacking behavour occurs. I've even tried removing the huge launch ship - once the defence ships find a target - and still the defence ships won't attack. (I had thought that perhaps that some sort of misfiring anti-collision routine was stopping the shifts from attacking.) Any tharglets launched by the defence ships attack fine.

Now I'm completely stumped.

Here's the relevant part of the AI.

Code: Select all

	GLOBAL =
	{
		"LAUNCHED OKAY" = ("setStateTo: SCAN");
	};

	SCAN = 
	{
		ENTER = (performIdle, "randomPauseAI: 0.5 3.0");
		UPDATE = ("sendScriptMessage: $_findTarget", "pauseAI: 4.0");
			TARGET_FOUND = (setTargetToFoundTarget, "setStateTo: ATTACK_SHIP");
			[ . . code omitted . .]
	};

	ATTACK_SHIP =
	{
		ENTER = (performAttack);
		INCOMING_MISSILE = (fightOrFleeMissile, setTargetToPrimaryAggressor, "setStateTo: CONSIDER_RETALIATION");
		TARGET_DESTROYED = ("setStateTo: SCAN"); // I tried removing this line; doing so made no difference.
		TARGET_LOST = ("setStateTo: SCAN");  // I tried removing this line; doing so made no difference.
	};

Re: Strange problem with unresponsive ships

Posted: Wed Jul 12, 2017 4:55 pm
by Smivs
Do they have scan_class 'CLASS_THARGOID'?

Re: Strange problem with unresponsive ships

Posted: Wed Jul 12, 2017 5:36 pm
by UK_Eliter
They do, Smivs, yes.

Re: Strange problem with unresponsive ships

Posted: Wed Jul 12, 2017 6:04 pm
by Smivs
Good. That's usually enough to make anything seriously anti-social!. :twisted:
Interesting problem - be good to know what it is then.

Re: Strange problem with unresponsive ships

Posted: Wed Jul 12, 2017 10:49 pm
by UK_Eliter
Smivs, you're toying with me! I thought you had a lead!

Re: Strange problem with unresponsive ships

Posted: Wed Jul 12, 2017 10:51 pm
by UK_Eliter
To diagnose this problem, I need a serious dump of information about these wayward thargoids. How can I do that? Perhaps I could use the recovery console - that hitherto I've fought shy of.

Re: Strange problem with unresponsive ships

Posted: Wed Jul 12, 2017 11:14 pm
by UK_Eliter
I suspect that the size of the launching ship - it's a generation ship, from the OXP of that name (which I've adapted in my OXP) - has something to do with it. If I get my player ship sufficiently far from the launching ship then the bugs attack (though, complicating things, if the player is far away, the bugs follow a different routine to reach it . .).

I'd really like to get this sorted out. For, I've rewritten my OXP in much better coding style, and (/partly for that reason) optimisations and bug fixes, and this is the one thing I need to get done before I can release it and escape the massive time sink that is Oolite OXPing!

Re: Strange problem with unresponsive ships

Posted: Thu Jul 13, 2017 1:24 am
by phkb
UK_Eliter wrote:
escape the massive time sink that is Oolite OXPing!
Hmm. Unlikely! Here, have another cookie. :D

Re: Strange problem with unresponsive ships

Posted: Thu Jul 13, 2017 2:11 am
by UK_Eliter
Might any of the main Oolite's programmers shed some light? Who are they these days? I've lost track. another_commander?

Re: Strange problem with unresponsive ships

Posted: Thu Jul 13, 2017 2:58 am
by phkb
One way to debug what's going on with the AI is to turn on different parts of "logcontrol.plist". In particular, these items:

Code: Select all

	ai							= yes; // AI messages are shown if a ship's reportAIMessages property is set, for instance through the JavaScript console.
	ai.message.receive					= inherit;
	ai.takeAction						= inherit;
	ai.takeAction.noAction					= inherit;
	ai.takeAction.orphaned					= $aiError;
	ai.takeAction.debugMessage				= inherit;
	ai.takeAction.badSelector				= inherit;
	ai.error						= $aiError;
	ai.error.recursion					= inherit;
	ai.error.recursion.stackTrace				= inherit;
	ai.error.stackOverflow					= inherit;
	ai.error.stackOverflow.dump				= inherit;
	ai.setTakeOffFromPlanet.noPlanet			= $aiError;
	ai.suggestEscort					= inherit;
	ai.suggestEscort.refused				= inherit;
	ai.rollD.invalidValue					= $aiError;
	ai.syntax.setCoordinates				= $aiError;
	ai.scanForNearestShipMatchingPredicate.compile.failed	= $aiError;
	ai.invalidFormat					= $aiError;
	ai.invalidFormat.state					= inherit;
	ai.invalidFormat.handler				= inherit;
	ai.invalidFormat.action					= inherit;
	ai.unpermittedMethod					= $aiError;
	ai.load							= no;
	ai.load.failed.unknownAI				= $aiError;
	ai.invalid.notAStation					= $aiError; // Warning when station AI message is used on non-station.
And as the comment says, make sure reportAIMessages is set to true on the ship.

Re: Strange problem with unresponsive ships

Posted: Thu Jul 13, 2017 3:00 am
by phkb
And the Javascript console is invaluable. It makes it far easier to debug things while they are in motion.

Re: Strange problem with unresponsive ships

Posted: Thu Jul 13, 2017 6:10 am
by Smivs
UK_Eliter wrote: Wed Jul 12, 2017 10:49 pm
Smivs, you're toying with me! I thought you had a lead!
No, sorry. I've had 'fun' in the past with Thargoids and I know the scan_class is a big deal in how they behave. It just seemed like a good place to start.

Re: Strange problem with unresponsive ships

Posted: Thu Jul 13, 2017 9:03 am
by Griff
I don't know if it's any help (i'm totally AI clueless), but Eric Walch fixed a problem i had with some ships launching from a black monk station which would just pootle about the place non agressivley here: https://bb.oolite.space/viewtopic.ph ... 68#p176568
fatleaf's post just below eric's also might be usefull, weapon range seems to play a part in hw agressive the ships might be

Re: Strange problem with unresponsive ships

Posted: Fri Jul 14, 2017 12:45 am
by UK_Eliter
Thanks everyone. I think that, with your help, I am making progress. My launched ships now attack, though they do have a tendency, even when attacking, to try to be twiching off in the direction that they were flying in when they launched!

At one point I thought I might be able to solve problems by fiddling with the length of the dock from which the ships were launched. (It turned out the dock was very short, even though the ships containing the lock are very long.) Here's a picture, for your amusement, of an experiment that didn't really work out . . They grey snout/tube is the dock, extending, er, out of the ship.