Scripters cove
Moderators: winston, another_commander
- montana05
- ---- 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
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 ?
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.
- Norby
- ---- 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
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.phkb wrote:Is it possible to check whether a particular ship can fit through the docking port of a station?
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);
- Norby
- ---- 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
[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.montana05 wrote:how I could return the old ship plus all the equipment in case the ship didn't feel comfortable with the commander?
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.- montana05
- ---- 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
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.Norby wrote:[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.montana05 wrote:how I could return the old ship plus all the equipment in case the ship didn't feel comfortable with the commander?
Another way if you setchance=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.
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
Scars remind us where we've been. They don't have to dictate where we're going.
-
- Quite Grand Sub-Admiral
- Posts: 6683
- Joined: Wed Feb 28, 2007 7:54 am
Re: Scripters cove
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 classNorby wrote: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.phkb wrote:Is it possible to check whether a particular ship can fit through the docking port of a station?
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.- Redspear
- ---- E L I T E ----
- Posts: 2689
- Joined: Thu Jun 20, 2013 10:22 pm
- Location: On the moon Thought, orbiting the planet Ignorance.
Re: Scripters cove
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?
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?
- Redspear
- ---- E L I T E ----
- Posts: 2689
- Joined: Thu Jun 20, 2013 10:22 pm
- Location: On the moon Thought, orbiting the planet Ignorance.
Re: Scripters cove
Ahhh, now I know...
Thanks Norby
Thanks Norby
Re: Scripters cove
Hi, how can change the ship script after it appeared(spawn) in the system (like for example AI).
I am trying as:
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?
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
}
}
It is impossible to assign a other script to EscapePod?
- Norby
- ---- 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
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");
It isRustem wrote:EscapePod d't have shipdata.plist
"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].- Redspear
- ---- E L I T E ----
- Posts: 2689
- Joined: Thu Jun 20, 2013 10:22 pm
- Location: On the moon Thought, orbiting the planet Ignorance.
Re: Scripters cove
My traffic redistributer oxp address the second of the above factors but I'd also like to include the first.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
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?
- Norby
- ---- 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
My guess is if
destination.distanceTo(system.mainStaion.position) <
a few km.- Redspear
- ---- E L I T E ----
- Posts: 2689
- Joined: Thu Jun 20, 2013 10:22 pm
- Location: On the moon Thought, orbiting the planet Ignorance.
Re: Scripters cove
That looks like it could work.
Thanks Norby
Thanks Norby
- phkb
- 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
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:
I suspect in most scenarios the last item will be interchangeable with
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");
ship.destinationSystem
.- Redspear
- ---- E L I T E ----
- Posts: 2689
- Joined: Thu Jun 20, 2013 10:22 pm
- Location: On the moon Thought, orbiting the planet Ignorance.
Re: Scripters cove
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.
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.