Scripters cove

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: Scripters cove

Post 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 ?
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Scripters cove

Post 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);
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Scripters cove

Post 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.
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: Scripters cove

Post 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:
Scars remind us where we've been. They don't have to dictate where we're going.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6682
Joined: Wed Feb 28, 2007 7:54 am

Re: Scripters cove

Post 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.
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Scripters cove

Post 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?
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Scripters cove

Post by Norby »

The player.ship.equipment is an array so player.ship.equipment.length contain the number of items.
Rustem
Deadly
Deadly
Posts: 170
Joined: Mon May 25, 2015 5:23 pm
Location: Russia

Re: Scripters cove

Post 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?
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Scripters cove

Post 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].
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Scripters cove

Post 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?
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Scripters cove

Post by Norby »

My guess is if destination.distanceTo(system.mainStaion.position) < a few km.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post 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.
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Scripters cove

Post 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.
Post Reply