Oolite Bulletins

For information and discussion about Oolite.
It is currently Mon Oct 23, 2017 7:05 pm

All times are UTC




Post new topic  Reply to topic  [ 1388 posts ]  Go to page Previous 188 89 90 91 92 93 Next
Author Message
 Post subject: Re: Scripters cove
PostPosted: Mon Feb 22, 2016 1:35 pm 
Offline
Commodore
Commodore
User avatar

Joined: Thu Nov 07, 2013 10:21 pm
Posts: 281
Pick a random direction, using randomDirection(). Then work out the direction of the sun / planet by subtracting the position of the entity from the position of the planet, and normalise that using the direction() function. You've now got two vectors which should both have a length of one.

Now take the dot product of the two vectors (using the dot() function, obviously), which should be a number between -1 and 1. A value of 1 means the vectors are in the same direction and -1 means they're pointing in exactly in the opposite directions. So if the dot product is more than, say, 0.95 you're heading roughly towards the planet and need to try a different direction.

Ref: http://wiki.alioth.net/index.php/Oolite ... :_Vector3D


Top
   
 Post subject: Re: Scripters cove
PostPosted: Mon Feb 22, 2016 1:50 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2408
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Quote:
I don't want the random direction to be into the sun or planet.
Here is my untested attempt to exclude the sun from a random direction.
The same should be checked for each items in system.planets array also.
Code:
var pp = player.ship.position;
//heading from the player to the center of the sun
var h = sun.position.subtract(pp);
for(var i=0; i<100; i++) { //max. 100 retry
    var q = Quaternion.random();
    var qf = q.vectorForward();
    //angle from the center of the sun to the border of the disk
    if( Math.tan(qf.angleTo(h)) > sun.radius / pp.distanceTo(sun.position) ) {
        player.ship.orientation = q; //points out of the sun
        break;
    }
}

_________________
OXPs by Norby


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Feb 23, 2016 7:41 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1750
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
Quote:
using the dot() function, obviously
I love the clever use of "obviously"... :wink:

_________________
My OXP's


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Mar 29, 2016 4:05 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1750
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
Is it possible to leverage the built-in assassin system? For instance, could accepting or completing a mission increase the chance of assassins at the witchpoint? Or does it need an entirely separate approach (eg Random Hits)?

_________________
My OXP's


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Mar 29, 2016 5:59 am 
Offline
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
User avatar

Joined: Fri Nov 11, 2011 6:19 pm
Posts: 4013
Quote:
Is it possible to leverage the built-in assassin system? For instance, could accepting or completing a mission increase the chance of assassins at the witchpoint? Or does it need an entirely separate approach (eg Random Hits)?
Give your mission script a custom populator, and have it add extra assassins sometimes. You can either add a separate myoxp-bonus-assassins entry, or override the existing "oolite-assassins" entry to one with a higher group count and/or a tougher callback function.

To get them to attack you have a few options:
- give the player a high-risk parcel or passenger for some parts of the mission
- add trader-courier+ to the player's role set a few times
- (probably better) add myoxp-mission-protagonist+ to the player's role set a few times, and use Role-categories.plist to add it to the oolite-courier role group.
(The plus on the end prevents distance-related decay of roles, which you probably want in this case)

You might also want to add an extra assassin personality to the comms array, conditional on the player having attracted these specific assassins, so that sometimes they can say "there's the pilot who offended the vice-Duke!" or whatever the mission is about.

_________________
OXPs: [EliteWiki] New Cargoes, [EliteWiki] Skilled NPCs, [EliteWiki] Curse of the Black Sunspot, and more


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Apr 05, 2016 3:17 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1750
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
Thanks for the previous response, cim.

Another question: Is it possible to remove a particular system ID as a witchspace destination for NPC's? The idea being to quarantine a system for whatever reason. I realise I can just add a timer or a frame callback and monitor all ships with hyperspace engines and check their destinationSystem property, but I was hoping for something a little more direct.

_________________
My OXP's


Top
   
 Post subject: Re: Scripters cove
PostPosted: Thu Aug 04, 2016 3:57 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1750
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
A question for any Vector experts out there...

How can you work out if a ship is on a particular lane? I can see that "entity" has a "position" vector, and a vector has a "toCoordinateSystem" method. So if I do something like this:
Code:
var vect = myNPCShip.position.toCoordinateSystem("wpu");
log(this.name, "vect = " + vect.x + ", " + vect.y + ", " + vect.z);
and then running something like it over a few ships returns these results:
Quote:
13:51:21.006 [myOXP]: ship = [Ship "Night Adder" position: (-16739.1, -33957.8, 309128) scanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT]
13:51:21.006 [myOXP]: vect = 0.05546399538012031, 0.07352871999922404, 0.7520263813183803
13:51:21.006 [myOXP]: ship = [Ship "Python" position: (5878.13, -45060.9, 34723.5) scanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT]
13:51:21.006 [myOXP]: vect = 0.006470267535101524, 0.11036057068886841, 0.08447313493024122
13:51:21.006 [myOXP]: ship = [Ship "Bug" position: (2346.88, -29148.4, -15840.6) scanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT]
13:51:21.006 [myOXP]: vect = 0.007663652896847149, 0.07072589638477839, -0.038536007153059604
13:51:21.006 [myOXP]: ship = [Ship "Cobra Mark III" position: (-371164, -98700.6, -106782) scanClass: CLASS_NEUTRAL status: STATUS_IN_FLIGHT]
13:51:21.006 [myOXP]: vect = 0.9319277605848015, 0.06686805118676767, -0.2597719691820526
Would any of these numbers indicate a ship on the witchpoint-planet lane?

_________________
My OXP's


Top
   
 Post subject: Re: Scripters cove
PostPosted: Thu Aug 04, 2016 10:38 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2408
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
First you should define what you mean "on lane", for example within 2*scanner range (51200m) from the wp line.

Then use wpm where coords are in meters to be comparable with the selected width of lane. The 3. coordinate mean nothing for you (show the position along the lane) but the first two are two sides of a right triangle where the length of the third side (using Pythagorean theorem) is what you want to compare with the width of lane.

Another way: ............ Ship
PlanetImageWitchpoint

The "b" side is the wp lane (witchpoint is at origo so b is equal with system.mainPlanet.position), "a" is myNPCShip.position, gamma is a.angleTo(b) in radians what Math.sin() need. So you can do something like this (untested):
Code:
var a = myNPCShip.position, p = system.mainPlanet;
if( a && p && a.magnitude() * Math.sin( a.angleTo(p.position) ) < 51200) {
    //myNPCShip is in wp lane
}
The check of "a" could prevent problems with destroyed NPCs, the check of planet is useful in interstellar space.

Usually worth count ships in Witchpoint-Main Station line also.

_________________
OXPs by Norby


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Aug 09, 2016 2:53 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1750
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
Thanks for the previous answer, Norby!

Another question: What would be the best way to reliably determine what alloys and wreckage were created with the destruction of a particular ship?

_________________
My OXP's


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Aug 09, 2016 1:39 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2408
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Quote:
what alloys and wreckage were created with the destruction of a particular ship?
Just an idea:
- in shipDied event save the time and position (could be tricky if ship is not valid anymore),
- in shipSpawned check if it is an alloy/wreckage, then compare the time and position with saved destructions and if it is "enough near" then assume it is crearted by that ship,
- remove old entries from the saved list after a sure timeout in a timer.

_________________
OXPs by Norby


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Aug 09, 2016 3:31 pm 
Offline
Above Average
Above Average

Joined: Fri Jul 22, 2016 3:55 am
Posts: 20
How could one store a set amount of data for each system, and read/write as well as store that data for later use? For example, I want to save the amount of entities in each system for later reference. Would I have to store the data in the system description space? Could I keep this data in a script-generated file?


Top
   
 Post subject: Re: Scripters cove
PostPosted: Tue Aug 09, 2016 4:03 pm 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Mon May 20, 2013 9:53 pm
Posts: 2408
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
The script in SMax's MFDRestoreAfterLoad contain a nice example how to save an array of data into the savegame using JSON to convert it to string and load back in the startUp event.

Your array should be a property of your script so define it as this._YourArray = []; (like this.name at the top of the script) and use as this._YourArray[0] = 123; within your functions.

_________________
OXPs by Norby


Top
   
 Post subject: Re: Scripters cove
PostPosted: Sat Aug 13, 2016 2:39 am 
Offline
Above Average
Above Average

Joined: Fri Jul 22, 2016 3:55 am
Posts: 20
What does cargo_type = "CARGO_THARGOID" in shipdata.plist do exactly?


Top
   
 Post subject: Re: Scripters cove
PostPosted: Sat Aug 13, 2016 3:57 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1750
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
I'm not 100% sure, but I think that makes the item scoopable as Alien Items.

_________________
My OXP's


Top
   
 Post subject: Re: Scripters cove
PostPosted: Fri Dec 02, 2016 2:16 am 
Offline
Commodore
Commodore
User avatar

Joined: Tue Jan 21, 2014 10:37 pm
Posts: 1750
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...
Is it possible to check whether a particular ship can fit through the docking port of a station? Without, you know, actually trying.

_________________
My OXP's


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1388 posts ]  Go to page Previous 188 89 90 91 92 93 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 16 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