Oolite Bulletins

For information and discussion about Oolite.
It is currently Fri Nov 24, 2017 10:26 pm

All times are UTC




Post new topic  Reply to topic  [ 1403 posts ]  Go to page Previous 189 90 91 92 93 94 Next
Author Message
 Post subject: Re: Scripters cove
PostPosted: Fri Dec 02, 2016 11:44 am 
Offline
Competent
Competent

Joined: Mon May 30, 2016 3:54 am
Posts: 34
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 ?

_________________
Trying to survive behind the controls of a Caduceus Psi XT in Alpha test :lol:


Top
   
 Post subject: Re: Scripters cove
PostPosted: Fri Dec 02, 2016 12:29 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2427
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Quote:
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:
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);

_________________
OXPs by Norby


Top
   
 Post subject: Re: Scripters cove
PostPosted: Fri Dec 02, 2016 12:49 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2427
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Quote:
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.

_________________
OXPs by Norby


Top
   
 Post subject: Re: Scripters cove
PostPosted: Fri Dec 02, 2016 2:16 pm 
Offline
Competent
Competent

Joined: Mon May 30, 2016 3:54 am
Posts: 34
Quote:
Quote:
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:

_________________
Trying to survive behind the controls of a Caduceus Psi XT in Alpha test :lol:


Top
   
 Post subject: Re: Scripters cove
PostPosted: Thu Dec 08, 2016 1:15 pm 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral

Joined: Wed Feb 28, 2007 7:54 am
Posts: 5018
Quote:
Quote:
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.


Top
   
 Post subject: Re: Scripters cove
PostPosted: Sun Dec 18, 2016 9:45 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Thu Jun 20, 2013 10:22 pm
Posts: 1113
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?

_________________
"With our thoughts, we make the world" :-)


Top
   
 Post subject: Re: Scripters cove
PostPosted: Sun Dec 18, 2016 10:02 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2427
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
The player.ship.equipment is an array so player.ship.equipment.length contain the number of items.

_________________
OXPs by Norby


Top
   
 Post subject: Re: Scripters cove
PostPosted: Sun Dec 18, 2016 10:55 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Thu Jun 20, 2013 10:22 pm
Posts: 1113
Ahhh, now I know...

Thanks Norby :)

_________________
"With our thoughts, we make the world" :-)


Top
   
 Post subject: Re: Scripters cove
PostPosted: Wed Dec 21, 2016 2:38 pm 
Offline
Dangerous
Dangerous

Joined: Mon May 25, 2015 5:23 pm
Posts: 96
Location: Russia
Hi, how can change the ship script after it appeared(spawn) in the system (like for example AI).

I am trying as:
Code:
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?


Top
   
 Post subject: Re: Scripters cove
PostPosted: Wed Dec 21, 2016 2:45 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2427
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Quote:
how can change the ship script
escapepod.[url=http://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_Ship#setScript]setScript[/url]("stealth_escapepod.js");
Quote:
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].

_________________
OXPs by Norby


Top
   
 Post subject: Re: Scripters cove
PostPosted: Sat Apr 01, 2017 9:58 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Thu Jun 20, 2013 10:22 pm
Posts: 1113
Quote:
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?

_________________
"With our thoughts, we make the world" :-)


Top
   
 Post subject: Re: Scripters cove
PostPosted: Sat Apr 01, 2017 10:12 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2427
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
My guess is if destination.distanceTo(system.mainStaion.position) < a few km.

_________________
OXPs by Norby


Top
   
 Post subject: Re: Scripters cove
PostPosted: Sun Apr 02, 2017 9:07 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Thu Jun 20, 2013 10:22 pm
Posts: 1113
That looks like it could work.
Thanks Norby :)

_________________
"With our thoughts, we make the world" :-)


Top
   
 Post subject: Re: Scripters cove
PostPosted: Sun Apr 02, 2017 10:43 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1806
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
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:
// 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.

_________________
My OXP's


Top
   
 Post subject: Re: Scripters cove
PostPosted: Sun Apr 02, 2017 5:42 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Thu Jun 20, 2013 10:22 pm
Posts: 1113
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.

_________________
"With our thoughts, we make the world" :-)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1403 posts ]  Go to page Previous 189 90 91 92 93 94 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Limited