A plea for cloaking to affect missiles . .

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Post Reply
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

A plea for cloaking to affect missiles . .

Post by UK_Eliter »

. . to some at least easily noticeable degree. At present (well, on my system anyway: Oolite PC version 1.83.0.6559) that is not the case, and I feel it is (too) unrealistic and a bit unfair!
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: A plea for cloaking to affect missiles . .

Post by another_commander »

This is something you can easily do by editing the oolite-cloaking-device-equipment.js script, found in Resources/Scripts. Make the this.activated function look as follows:

Code: Select all

this.activated = function()
{
	player.ship.isCloaked = !player.ship.isCloaked;
	
	if (player.ship.isCloaked)
	{
		// find missiles targeting player
		var missilesTargetingPlayer =	system.filteredEntities(this, function(ent)
										{
											return (ent.isMissile && ent.target == player.ship);
										},	player.ship, 25600);
		for (var i = 0; i < missilesTargetingPlayer.length; i++)
		{
			missilesTargetingPlayer[i].target = null; // target lost -> missile detonates
		}
	}
}
Shift-restart and off you go.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: A plea for cloaking to affect missiles . .

Post by UK_Eliter »

Thanks, Commander.

I think I'd like to use a modified version of that code - modified such that only certain types of missiles are affected, and perhaps with some randomisation (if that wouldldn't slow the game down). *However*, what I'd like to do with it, would be to put it in an expansion pack which overwrites Oolite's own oolite-cloaking-device-equipment.js. If it would be alright to do that, could you tell me how to, please? Thanks.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: A plea for cloaking to affect missiles . .

Post by another_commander »

To make it into an OXP:
1. Save the above script in the Scripts subfolder of your OXP folder, say under the nane mycloak.js.
2. Copy/paste the entry for the Cloaking Device to an empty equipment.plist file, save it under the Config subfolder.
3. In your equipment.plist, edit the script= [...] line to make it refer to mycloak.js.

The game will now use your Cloaking Device, rather than the core one.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: A plea for cloaking to affect missiles . .

Post by UK_Eliter »

Thanks a lot, another_commander. I've implemented all that, and it works. However, I was wondering about:

(1) whether ships will still be able to lock missiles on the player, when the player is cloaked (which may mean that, with my code as it stands, the missile is liable to detonate as soon as launched);

(2) implementing the same behaviour but for when the target is *not the player*. Would that be hard to do? What routine would I have to hack?

Thanks.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: A plea for cloaking to affect missiles . .

Post by another_commander »

UK_Eliter wrote:
(1) whether ships will still be able to lock missiles on the player, when the player is cloaked (which may mean that, with my code as it stands, the missile is liable to detonate as soon as launched);
I don't think that missiles will be launched while the player is cloaked. Try spawning a few Cobra pirates and shot them until they fire a missile, then cloak and wait. If they don't fire any more missiles while you are cloaked, then it's all good.
(2) implementing the same behaviour but for when the target is *not the player*. Would that be hard to do? What routine would I have to hack?
Try removing the check for player in the earlier script I posted. That should do.Probably it shouldn't. That may require some more careful scripting. It should be doable by tapping the shipCloakActivated handler, but I can't dedicate time to work that out right now. Maybe one of our OXP scripter gurus can jump in at this point.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: A plea for cloaking to affect missiles . .

Post by cim »

Updating the missile AI so that it checks if the current target is cloaked may be the more reliable approach.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: A plea for cloaking to affect missiles . .

Post by another_commander »

After cim's reply, I decided to go in and check what's going on, because I was certain that the AI for the missiles was already taking into account cloaking. And it does indeed.

On a standard core install, the missiles will just go towards the direction the last kown position of the cloaked ship. In case of the ship decloaking, they resume their chase. I tested it quickly and it was very obvious to me that this works as intended. I don't think there is anything to fix here.

@UK_Eliter: Are you by any chance using an older version of Griff's ships? If yes, please check the shipdata.plist and see what AI is assigned to the missiles. If it's not a JS AI, then maybe that's the problem.

Edit: Aaarrrrgghhhhh! It was working only because of a local AI mod I had done some time ago. Ouch. OK, committing the fix to trunk in a while.


Edit #2: Done and you can test the fix without having to wait for the nightly, since it's an edit of the oolite-priorityai.js file in Resources/Scripts. In the behaviourMissileInterceptTarget function, replace the last line from

Code: Select all

this.ship.performIntercept();
to

Code: Select all

if (this.ship.target && !this.ship.target.isCloaked)
{
	this.ship.performIntercept();
}
else
{
	this.ship.performIdle();
}
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: A plea for cloaking to affect missiles . .

Post by UK_Eliter »

Dear another_commander

How long until this fix makes it into a stable release, please? If it will be a while, I will release an expansion pack that plugs the gap.

PS: Cim - thanks.
PPS: @another_commander - no, I'm not using any Griff shipsets. I have 'anarchies_facelift_0.5.oxp', but I don't think that counts.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: A plea for cloaking to affect missiles . .

Post by another_commander »

UK_Eliter wrote:
How long until this fix makes it into a stable release, please? If it will be a while, I will release an expansion pack that plugs the gap.
You are essentially asking when the next version of the game will be released and there is no answer to that question. Consider it will be a while, just to be on the safe side.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: A plea for cloaking to affect missiles . .

Post by UK_Eliter »

another_commander wrote:
You are essentially asking when the next version of the game will be released and there is no answer to that question. Consider it will be a while, just to be on the safe side.
Right. Thanks. I'll see what I can do, expansion pack-wise.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: A plea for cloaking to affect missiles . .

Post by UK_Eliter »

another_commander,

The javascript fix you supplied seems to work. However: does it interfere with custom AIs for missiles (as in the AIs for my Nexus missiles, for example)? Such an AI might intend to respond in a certain way to TARGET_CLOAKED, but before it can get that message it may, by dint of having done performIntercept, get told to performIdle.

PS: I thought for a moment that the fix had ended up making a ship (namely a Boa that was attacking the player ship) performIdle(it was still red on the scanner, but it was rotating on its axis). Yet, on examining the log, I find:

Code: Select all

Entity "Boa" position: (27741.3, 2026.58, 341680) scanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT range: 1992.99 (visible: yes) mass 181789 AI: armoury_stunnedAI.plist:STUNNED / oolite-nullAI.js
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: A plea for cloaking to affect missiles . .

Post by another_commander »

I don't know anything about the Nexus missile, so I can't say. Why don't you give it a try and see what happens? If there is interference, then you may want to provide a specific AI for your missile that overrides core.

As far as the Boa is concerned,message is not related to the missile AI change and it does not appear to be originating from core either.
User avatar
Zark Montor
Competent
Competent
Posts: 42
Joined: Thu Jan 02, 2014 1:06 am
Location: Sevenoaks, Kent, UK

Re: A plea for cloaking to affect missiles . .

Post by Zark Montor »

Under normal conditions, if you fire whilst cloaking, bang, you de cloak. someone locks a missile onto you, it would lock onto a heat signature or electronic system ping (i'm trying to over elaborate on purpose) so cloaking might not solve the issue of getting hit etc. i think you would have to have a whole system dedicated to chaff/ecm, cloak and emergency maneuver within a short space of time for you to even think about a 50/50 chance of losing any missile TBH and practical. Also, you end up with a missile that might look for another target, depending on which type of missile has been used.. Could have some amusing consequences, space junk, scooping a live warhead.....
Last edited by Zark Montor on Thu Dec 10, 2015 6:52 pm, edited 1 time in total.
I have returned! Less annoying and still enjoying the mighty Oo!
1.86 on self reconned dell studio xps thru Pep 8/64. Runs very well.
Nice to see its still well supported. Oo, Suits you, Sir!
User avatar
Zark Montor
Competent
Competent
Posts: 42
Joined: Thu Jan 02, 2014 1:06 am
Location: Sevenoaks, Kent, UK

Re: A plea for cloaking to affect missiles . .

Post by Zark Montor »

Perhaps rather than just an OXP for this, you could look at a key sequencer or hot key for all sorts of things, such as cargo scooping, ship towing etc etc, there are some tasks that require activation of various systems that would be made easier by way of hot key sequencing.
I have returned! Less annoying and still enjoying the mighty Oo!
1.86 on self reconned dell studio xps thru Pep 8/64. Runs very well.
Nice to see its still well supported. Oo, Suits you, Sir!
Post Reply