Page 1 of 2

DONE: NPC 's switch on 'Navlights' when in docking Queue

Posted: Sun Feb 09, 2014 12:14 am
by dertien
I would be looking to solve a little thing that I would like to add to the shippack I am making, but could be useful for other shippacks too.

I don't know if this can be accomplished by adding a few well placed entires in the AI files or if it should be done by script, so therefore the question.

- When NPC's enter station aegis to dock to the station, how could we make them switch on nav lights. A red one on the left and a green one on the right. If this could be done with flashers on the "wingtips", that would be cool, noting too fancy in the sense of shaders. A bit like Commander Mc Lane's docking assistant script when activated. They should be able to be positioned per ship like the exhaust plumes (xyz).

Of course, NPC's flying from witchpoint to Station don't want to advertise their whereabouts to pirates, and light up like x-mas trees.
So when they leave the station aegis or entering witchspace, they should turn the flashers off.

Does anybody like this idea, and can someone tell me how to accomplish this ?


SOLVED:

I must admit it was Smivs that gave me the idea with his shippack, but I just wanted the ships to switch them on near the station, not all the time.

Howto:

- open shipdata.plist of ship you would like to add flashers to and add them as subentities (cobra Mk 1 example):

Code: Select all

subentities = (
		
							{
								type = "flasher";
								position = (-30.97, -1.27, -7.62);
								color = redColor;
								initially_on = no;
								frequency = 1;
								size = 12;
							},
							{
								type = "flasher";
								position = (30.97, -1.27, -7.62);
								color = greenColor;
								initially_on = no;
								frequency = 1;
								size = 12;
							}		
				);
This will add isofase blinking flashers (green and red) on both 'wingtips' of the cobra Mk 1. Since the state of the flashers is set to

Code: Select all

 initially_on = no;
this will not do anything however without the file below, so read on.

If you want them to be permanently on (like in Smiv's shipset) change the code from

Code: Select all

frequency = 1;
to

Code: Select all

frequency = 0;
Then download this :https://app.box.com/s/j9nurj03c1ojqa43nmsb and put it in your oxp folder, make sure it is the last file that gets loaded, I put an extra "Z" in the name just in case.

Go camp around a station entrance and do some Cobbie Mk 1 spotting. Please report those that do not use their flashers.

Enjoy!

Some nice screenshots of a Cobra Mk 3 docking at Zaonce with Frontierspace background:

Pic 1 waiting for clearance (no nav lights)
Pic 2 docking (nav lights on)

Image
Image

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 12:17 am
by Pleb
Could this be done similarly to the Police ship's lights? They turn on when engaging hostiles and turn off when finished...perhaps if you take a look at that you can work something out from that?

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 12:35 am
by dertien
Yes; I had something like that in mind, but nothing concrete as of yet.

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 1:01 am
by Redspear
Like the idea :) but I can't improve on Pleb's suggestion...

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 2:17 am
by Diziet Sma
There are a few ships with nav-lights already.. though they don't flash, and are on permanently.. Some of Smiv's ships, IIRC, and Captain Beatniks.. (such as both the Pitviper models)

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 4:04 am
by dertien
Ha! well I did it and yes Pleb, the solution lay in the AI property lists, not too hard, but heck of a lot of time to get it right, and gametesting of course.

- added the entry

Code: Select all

switchLightsOff,
to all relevant AI plists (in the GLOBAL part at the top) exept in the dockingAI.plist GLOBAL where I used

Code: Select all

switchLightsOn,


- In the shipdata property list of every ship added the necessary subentity flashers at the right coordinates and with

Code: Select all

initially_on = yes;
like so:

Code: Select all

{
								type = "flasher";
								position = (-27.76, 0.21, 7.00);
								color = redColor;
								//colors = ({ hue = 61; }, { hue = 61; brightness = 0.0; }, { hue = 61; brightness = 0.0; }, { hue = 61; brightness = 0.0; });
								initially_on = yes;
								frequency = 1;
								size = 12;
							},
							{
								type = "flasher";
								position = (27.76, 0.21, 7.00);
								color = greenColor;
								//colors = ({ hue = 61; }, { hue = 61; brightness = 0.0; }, { hue = 61; brightness = 0.0; }, { hue = 61; brightness = 0.0; });
								initially_on = yes;
								frequency = 1;
								size = 12;
							},
And finally in the same file; changed the line

Code: Select all

 auto_ai = yes;
to

Code: Select all

auto _ai = no;
This might have some implications since the javascript files are no longer spoken for with the auto_ai set to NO. Don't really know what that will mean gameplay wise.

Now when ships are planning on docking they switch their navlights on ! works fine (as far as I've seen ingame) and is indeed similar to the police switching on their lights when attacking.

Great.

example Global part of the DockingAI.plist:

Code: Select all

{
	GLOBAL =
	{
		ENTER =
		(
			switchLightsOn,
			"dropMessages: DOCKING_ABORTED,FACING_DESTINATION",
			"setSpeedTo: 0.0",
			requestDockingCoordinates,
			"setStateTo: AWAIT_COORDS"
		);
	};
Edit: I changed the property of the flasher to initially off instead of on. See post at the top for correct usage, thanks

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 7:56 am
by Pleb
8) I thought it might be something like that, but I've never really played around with the flashers much before. Glad you've cracked it though! :)

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 8:52 am
by Smivs
All my ships feature flashing navigation lights as described, although they are permanently on, except on derelicts of course. :)

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 8:55 am
by Thargoid
That will work, but currently flashers are "all or nothing" in that you can only switch them all on or off by script. Being able to address them individually is a long standing feature request.

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 2:04 pm
by Zireael
Wow, I love this suggestion and how quickly it got coded!

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 2:45 pm
by cim
Thargoid wrote:
That will work, but currently flashers are "all or nothing" in that you can only switch them all on or off by script. Being able to address them individually is a long standing feature request.
Oolite JavaScript Reference: Flasher

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 3:13 pm
by Thargoid
:)

Just for reference, how to we reference them directly (for example if I have two flashers, how to I reference one of them only? Do they now appear as sub-entities, or is there some other similar array?

Re: NPC 's switch on 'Navlights' when entering Station Aegis

Posted: Sun Feb 09, 2014 3:42 pm
by cim
Thargoid wrote:
Just for reference, how to we reference them directly (for example if I have two flashers, how to I reference one of them only? Do they now appear as sub-entities, or is there some other similar array?
ship.flashers

See also: ship.exhausts

Re: DONE: NPC 's switch on 'Navlights' when in docking Queue

Posted: Sun Feb 09, 2014 6:22 pm
by dertien
A little question for people that are more acquainted with Oolite scripting and AI. What is the difference AI wise between a shipdata.plist having

Code: Select all

auto_ai = no;
and

Code: Select all

auto_ai = no;
, I have read upon it in the wiki, but still don't understand. What I seemed to understand was that with the auto ai set to ON that certain javascript AI would be called upon, and that Oolite is merging towards JS instead of using Plists since JS has more nuts and bolts to work with than property lists, or am I wrong here ?

Would someone care to elaborate ?

Re: DONE: NPC 's switch on 'Navlights' when in docking Queue

Posted: Sun Feb 09, 2014 6:51 pm
by Smivs
I don't know the situation regarding the new js AIs, but normally auto_ai is set to 'on' which means the ship would be given an appropriate AI for the role it was spawned with. 'auto_ai=no' means that it will use the AI specified in the shipdata.plist