Page 91 of 115

Re: Scripters cove

Posted: Fri Dec 02, 2016 11:44 am
by montana05
I am developing another version of the bio-ship Caduceus, this time a Navy creation with a soul. My current problem is the idea that the ship could actually deny you as a owner when you try to buy it.

this.playerBoughtNewShip works after the deal so how I could return the old ship plus all the equipment in case the ship didn't feel comfortable with the commander ?

Re: Scripters cove

Posted: Fri Dec 02, 2016 12:29 pm
by Norby
phkb wrote:
Is it possible to check whether a particular ship can fit through the docking port of a station?
There are some check in the core, I remember to lines in the log when an NPC is too large to launch from a dock.

In ILS I made a check just for the width, if you apply it to the height also then you will be something for the most case but probably will be exceptions. Here are the relevant lines:

Code: Select all

var p = player.ship;
var s = this.$S; //station
var u = s.subEntities;
var i = 0;
if( u ) while( u[i] && !u[i].isDock ) i++;
var dr = s.vectorRight; //save for wide npc
var dz = s.boundingBox.z;
if( u && u[i] && u[i].isDock ) {
	var x = u[i].boundingBox.x, y = u[i].boundingBox.y;
	if( x < y ) {
		maxw = x; //rotated dock model (coriolis, ico)
		dr = s.vectorUp;
	} else {
		maxw = y; //dodo, etc.
		var o = u[i].orientation; //normal orientation mean no Torus Station
		if( o.w != 1 || o.x != 0 || o.y != 0 || o.z != 0 ) dr = s.vectorUp;
	}
	dz = u[i].boundingBox.z; //save for wide npc
}
if( p.boundingBox.x < maxw )
	player.consoleMessage("You can dock without roll", 5);

Re: Scripters cove

Posted: Fri Dec 02, 2016 12:49 pm
by Norby
montana05 wrote:
how I could return the old ship plus all the equipment in case the ship didn't feel comfortable with the commander?
[wiki]ShipStorageHelper[/wiki] is a way as [wiki]Combat Simulator[/wiki] use it to restore your ship at landing. You should save the ship when the gui is changed to the shipyard and restore if bought without permission. Although it could not handle future oxp ships with scripted tricks until somebody not make support for it into SSH.

Another way if you set chance=0; in shipyard.plist so never appear in shipyard and make alternative access like missionScreen popup or a line in F4 Interfaces if the ship is available.

Re: Scripters cove

Posted: Fri Dec 02, 2016 2:16 pm
by montana05
Norby wrote:
montana05 wrote:
how I could return the old ship plus all the equipment in case the ship didn't feel comfortable with the commander?
[wiki]ShipStorageHelper[/wiki] is a way as [wiki]Combat Simulator[/wiki] use it to restore your ship at landing. You should save the ship when the gui is changed to the shipyard and restore if bought without permission. Although it could not handle future oxp ships with scripted tricks until somebody not make support for it into SSH.

Another way if you set chance=0; in shipyard.plist so never appear in shipyard and make alternative access like missionScreen popup or a line in F4 Interfaces if the ship is available.
Thanks a lot, I will have a look tomorrow. I still got about 3 month to get used to the languages here and hopefully finish my entire mission(s), including bio-ships and weapons. I always liked Galactic Navy so I decided to improve it as, I guess, it was originally planed. Unfortunately, thanks to the CR, I am forced to code from scratch so probably it will be named Navy Reserve with an additional mission named Navy Intelligence. This is where powerful ships and weapons will be offered if your kill count and number of missions fit.

After 1 week I got a lot ideas day per day and my scripts change accordingly. I used a lot of ideas from the gurus here, so right now my ships are Mega-Ueber :lol:

Re: Scripters cove

Posted: Thu Dec 08, 2016 1:15 pm
by another_commander
Norby wrote:
phkb wrote:
Is it possible to check whether a particular ship can fit through the docking port of a station?
There are some check in the core, I remember to lines in the log when an NPC is too large to launch from a dock.
Thanks to a new contribution by phkb (see, this is what I like, you ask for a feature, it's not in, you go ahead and implement it), we now have the JS Station class canDockShip(shipEntity) function, which returns true or false, depending on whether the station can dock the ship entity passed as parameter or not. It uses the core code mentioned by Norby above.

Re: Scripters cove

Posted: Sun Dec 18, 2016 9:45 pm
by Redspear
The wiki gives a method for listing the equipment for a ship but I couldn't find a simple method for counting the number of equipment items.

I'd like to be able to count the number of equipment items installed on the player ship via script. Should be simple enough, right? So what am I missing?

Re: Scripters cove

Posted: Sun Dec 18, 2016 10:02 pm
by Norby
The player.ship.equipment is an array so player.ship.equipment.length contain the number of items.

Re: Scripters cove

Posted: Sun Dec 18, 2016 10:55 pm
by Redspear
Ahhh, now I know...

Thanks Norby :)

Re: Scripters cove

Posted: Wed Dec 21, 2016 2:38 pm
by Rustem
Hi, how can change the ship script after it appeared(spawn) in the system (like for example AI).

I am trying as:

Code: Select all

this.shipLaunchedEscapePod = function(escapepod)
{
	if (escapepod)
	{
		escapepod.script = "stealth_escapepod.js"; 		// not work - script, Script, read-only
		// escapepod.switchAI("DSR_epodAI.plist");		// alternative variant
	}
}
Or there is only one option to specify the shipdata.plist. But the EscapePod d't have shipdata.plist.

It is impossible to assign a other script to EscapePod?

Re: Scripters cove

Posted: Wed Dec 21, 2016 2:45 pm
by Norby
Rustem wrote:
how can change the ship script
escapepod.[url=http://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_Ship#setScript]setScript[/url]("stealth_escapepod.js");
Rustem wrote:
EscapePod d't have shipdata.plist
It is "oolite_template_escape-capsule" in oolite.app/Resources/Config/shipdata.plist . Another way is if you add a script line to this dataKey in your [wiki]shipdata-overrides.plist[/wiki].

Re: Scripters cove

Posted: Sat Apr 01, 2017 9:58 pm
by Redspear
Redspear wrote:
Three major determnants in terms of mass-lock duration are
  • Heading of mass-locking ships relative to the player
  • Speed Difference between player and mass-locking ship (with a large difference in the player's favour being the most desirable)
  • Scanner Range with a larger reach taking longer to clear
My traffic redistributer oxp address the second of the above factors but I'd also like to include the first.
The idea is that if a ship were travelling to either the main station or the sun then I could slow it (were it not in combat) in order to make overtaking easier without also making combat easier

There's are the property cruiseSpeed which I'd like to use in relation to destination.

Unfortunately, the latter seems to accept only vectors when what I really want is "main station", "planet" or "sun", the common player destinations where mass lock is most frustrating.

Is there an easy way around this (i.e. to identify ships headed in those directions) or a simple way to calculate the vectors I might need to know?

Re: Scripters cove

Posted: Sat Apr 01, 2017 10:12 pm
by Norby
My guess is if destination.distanceTo(system.mainStaion.position) < a few km.

Re: Scripters cove

Posted: Sun Apr 02, 2017 9:07 am
by Redspear
That looks like it could work.
Thanks Norby :)

Re: Scripters cove

Posted: Sun Apr 02, 2017 10:43 am
by phkb
I'm not sure if I've understood the question properly, but you can get the current destination of a ship with the Priority AI, like this:

Code: Select all

// if the destination is a planet...
var planet = ship.AIScript.oolite_priorityai.getParameter("oolite_selectedPlanet");
// if the destination is a station...
var station = ship.AIScript.oolite_priorityai.getParameter("oolite_selectedStation");
// if the destination is a witchspace jump destination...
var systemID = ship.AIScript.oolite_priorityai.getParameter("oolite_witchspaceDestination");
I suspect in most scenarios the last item will be interchangeable with ship.destinationSystem.

Re: Scripters cove

Posted: Sun Apr 02, 2017 5:42 pm
by Redspear
Thanks phkb.

I wanted to check their heading and then slow them down if it was similar to that of the player.

Looks like cruiseSpeed is read only anyway but I've found it in shipEntity.m so (for myself at least) I can set it there instead.