Scripters cove

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

Moderators: winston, another_commander

User avatar
RyanHoots
---- E L I T E ----
---- E L I T E ----
Posts: 958
Joined: Fri May 20, 2011 8:10 pm
Location: Nowhere
Contact:

Re: Scripters cove

Post by RyanHoots »

Thanks. :)

I've modified it a little, and it doesn't work (nothing in the latest.log):

borg.js

Code: Select all

this.name			= "borg"
this.author			= "Ryan Hoots";
this.copyright		= "This script is in the public domain.";
this.version		= "1.0";


this.shipTargetAcquired = this.shipBeingAttacked = function ()
{
this.ship.commsMessage(expandDescription("We are Borg. [RH-borg-banter]"));
};
descriptions.plist

Code: Select all

{

RH-borg-banter = (

"You will be assimilated. Resistance is futile.",
"Your tehcnological and biological distinctiveness will be added to our own.",
"You will be assimilated. Resistance is useless."

);

}
Image
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Re: Scripters cove

Post by Kaks »

Everything seems to work ok here.

All I can think of is that old chestnut: did you press shift while starting up Oolite?
When making changes inside an OXP you need to press shift at startup to force Oolite to refresh its internal cache with the new data...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
RyanHoots
---- E L I T E ----
---- E L I T E ----
Posts: 958
Joined: Fri May 20, 2011 8:10 pm
Location: Nowhere
Contact:

Re: Scripters cove

Post by RyanHoots »

I did... even though I've set my GNUstep defaults to always flush the cache. I may need to check my shipdata.plist. But if that file didn't work, how would the Borg appear in the first place? :?
Image
User avatar
RyanHoots
---- E L I T E ----
---- E L I T E ----
Posts: 958
Joined: Fri May 20, 2011 8:10 pm
Location: Nowhere
Contact:

Re: Scripters cove

Post by RyanHoots »

:oops:
It was the shipdata.plist... take a look at this line:

Code: Select all

//		script = "borg.js";
Yep, I added // so I could test the shipdata without worrying about the script (which, at the time, I had not yet started to write). I forgot to remove it. :roll:

Edit: One more problem. Whenever I shoot the cube, it responds with the same set of remarks. I may have to tweak the script, it's annoying with a Mil laser... :wink:
Image
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

I've got a fairly simple mission put together. Follow a rescue ship (plus two escorts) to another system, protect them from pirate attacks as they repair a freighter, then follow the rescue ship (Moray), the freighter (any large trader), and other surviving escorts (standard 'escort') back to the original system.

All working fairly well.

The only problem is that I'm losing *far* more ships to witchspace accidents than to hostile fire. Quite often the mission will go perfectly smoothly - all four ships will jump back to the home system (using the same wormhole), I follow them - and at that point I lose at least one ship about half the time. Since two of the four ships (rescue and freighter) are mission critical, that usually fails the mission too and there's nothing you can do to stop it. (happens occasionally on the jump in, too - one of the escorts goes missing with a shipDied() event...)

Any ideas on what's going wrong and how to fix it?
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Re: Scripters cove

Post by Kaks »

No idea so far, but a PM with the WIP would be appreciated. It might be a bug in Oolite, and if that's the case your oxp should help fix it.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Kaks wrote:
No idea so far, but a PM with the WIP would be appreciated. It might be a bug in Oolite, and if that's the case your oxp should help fix it.
Ah - tracked it down, I think. Setting the ships to print their cause of death found it: scrape damage from the witchspace beacon. (Entering the wormhole between the leader and its escorts seems to trigger this fairly reliably on one of the escorts)
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Re: Scripters cove

Post by Kaks »

Confirmed! It's an Oolite bug, and a fix is on its way, after some proper testing! :)
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Gimi
---- E L I T E ----
---- E L I T E ----
Posts: 2073
Joined: Tue Aug 29, 2006 5:02 pm
Location: Norway

Re: Scripters cove

Post by Gimi »

Could anyone give me an example of an info.plist script written in openstep, or do they have to be in XML?
"A brilliant game of blasting and trading... Truly a mega-game... The game of a lifetime."
(Gold Medal Award, Zzap!64 May 1985).
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Scripters cove

Post by Eric Walch »

Gimi wrote:
Could anyone give me an example of an info.plist script written in openstep, or do they have to be in XML?
The one inside Oolite itself should be openstep.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Kaks wrote:
Confirmed! It's an Oolite bug, and a fix is on its way, after some proper testing! :)
And the fix in r4675 deals with it. Thank you.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Re: Scripters cove

Post by Kaks »

Sometimes an oxp would like to make an NPC jump to another system. However, the NPC might well be blocked by a nearby mass, since it's not always obvious how far away from the station you can safely jump, here's a way to find the minimum distance from any station in order to hopefully jump successfully at the first attempt. It's a combination of AI.plist and ship script, I'm afraid...

NB: I'm using squared distance because it's faster to calculate than distance.

Code: Select all

this.minimumJumpSquaredDistance = function(other) {
   // internal Oolite constants used: K = 0.1, SCANNER_MAX_RANGE = 25600
   let dist=other.mass * 0.1;
   return (dist > 655360000 ? 655360000 : dist); // 25600 * 25600
}
We can now select the nearest safe jump coordinates:

Code: Select all

this.selectNearestJumpPoint = function() {
   let other = system.filteredEntities(this,function(e){return e.isStation;}, this.ship)[0]; // select closest station!
   let A = this.ship.position.subtract(other.position);
   let min2 = this.minimumJumpSquaredDistance(other));

   if (min2 > A.squaredDistanceTo(other.position)){
      let dir = A.magnitude() > 0 ? A.direction() : Vector3D(1,0,0);
      this.ship.savedCoordinates=other.position.add(dir.multiply(Math.sqrt(min2)));
   } else
      reactToAIMessage("DESIRED_RANGE_ACHIEVED");
}
On the AI side you'll have to have something like this:

Code: Select all

	"JUMP_AWAY" =
	{
		ENTER = ("sendScriptMessage: selectNearestJumpPoint",setDestinationFromCoordinates, "setDesiredRangeTo:0.5");
		"COURSE_OK" = ("setSpeedFactorTo: 1.0", performFlyToRangeFromDestination);
		"DESIRED_RANGE_ACHIEVED" = (performHyperSpaceExit);
		UPDATE = ("sendScriptMessage: selectNearestJumpPoint",checkCourseToDestination, "pauseAI: 10.0");
	};
	"NEW_WAYPOINT" =
	{
		ENTER = ("setSpeedFactorTo: 1.0", setDesiredRangeForWaypoint, checkCourseToDestination, "pauseAI: 2.0");
		"WAYPOINT_SET" = ("setStateTo: NEW_WAYPOINT");
		"COURSE_OK" = ("setStateTo: JUMP_AWAY");
		"DESIRED_RANGE_ACHIEVED" = ("setStateTo:JUMP_AWAY");
	};
That should get your ship to go to the nearest available jump spot, then jump. If your ship is already in the clear, it should jump away immediately...

Of course, assuming that the nearest station is the mass of a coriolis station, all you have to do is set coordinates to a random spot about 5-6 km from the station, and your ship should be good to go!

Still, these chunks of code might give an idea or two to some enterprising OXP makers, so I thought I'd share! :D

PS & NB: I haven't tested the code above too rigorously, so there might well be a couple of bugs lurking in there... :P
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

It'll be incorprated to escort contracts for sure. Thanks Kaks.
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
User avatar
Fatleaf
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 1988
Joined: Tue Jun 08, 2010 5:11 am
Location: In analysis mode on Phaelon
Contact:

Re: Scripters cove

Post by Fatleaf »

Can a ship be armed with multiple railguns?

EDIT: I have my answer. NPC's can't have them :( RUBBISH!
Find out about the early influences of Fatleaf here. Also his OXP's!
Holds the Ooniversal record for "Thread Necromancy"
User avatar
Cmdr. Maegil
Sword-toting nut-job
Sword-toting nut-job
Posts: 1294
Joined: Tue Feb 27, 2007 10:28 pm
Location: On the mend in Western Africa

Re: Scripters cove

Post by Cmdr. Maegil »

Feasibility study:

a) can a NPC be formed of several spatially fixed, but otherwise independent entities?
I'm thinking of large sized ships composed by different (possibly frangible) main entities, each a section of the hull, capable of independently and automatically ordering its turrets to target enemies inside their field of fire.
If the target is lost, out of their field of fire or destroyed, it'd automatically look for new targets.

b) can a PC be likewise composed, with NPC "parasites" embedded?
You know those who, having been mugged and stabbed, fired, dog run over, house burned down, wife eloped with best friend, daughters becoming prostitutes and their countries invaded - still say that "all is well"?
I'm obviously not one of them.
Post Reply