overriding standard ships

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

Moderators: winston, another_commander

User avatar
jh145
Dangerous
Dangerous
Posts: 94
Joined: Thu Dec 25, 2014 8:39 pm

overriding standard ships

Post by jh145 »

Hi.

For testing purposes, I'd like to override the three vipers with ships that have associated scripts (Scripts/foo.js) of my own design. I picked on the vipers because they are so readily available, so I don't have to wait more than a couple of seconds before testing out my new functions.

In my OXP (if you can call it that), I've got for example

Code: Select all

  viper = {
    like_ship = "oolite_template_viper";
    script = "whatever.js";
  };
which seems correct, as deliberately mis-spelling "whatever.js" causes a load error.

In whatever.js, I have boilerplate code plus:

Code: Select all

this.shipSpawned = function() {
  log( this.name, "shipSpawned" );
}

this.shipBeingAttacked = function(whom) {
  log( this.name, this+" shipBeingAttacked by "+whom);
}
Neither function is being called. Why not?
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: overriding standard ships

Post by spara »

Hmmm. Are you using Griff's suppressor oxp? That would prevent core ships being spawned.
User avatar
jh145
Dangerous
Dangerous
Posts: 94
Joined: Thu Dec 25, 2014 8:39 pm

Re: overriding standard ships

Post by jh145 »

Hi, spara. No, I'm not using that OXP. Ships are spawning just fine; I can provoke vipers from the station to my heart's content. I can get shipSpawned to report to the log when registered as a world-script (linked-to from scripts.plist), but I can't seem to get shipSpawned or any other function to be called in a ship script (linked-to from shipdata.plist).
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: overriding standard ships

Post by spara »

Something strange going on there.

I created a test oxp with this in shipdata.plist:

Code: Select all

{
  viper = {
    like_ship = "oolite_template_viper";
    script = "whatever.js";
  };
}
Then I created a whatever.js that looked like this:

Code: Select all

this.name = "spawn_test";

this.shipSpawned = function() {
  log( this.name, "shipSpawned" );
}

this.shipBeingAttacked = function(whom) {
  log( this.name, this+" shipBeingAttacked by "+whom);
}
Then I spawned some vipers with this:

Code: Select all

system.addShips("[viper]",10,player.ship.position,10000);
And log says this:

Code: Select all

15:40:20.211 [spawn_test]: shipSpawned
15:40:20.212 [spawn_test]: shipSpawned
15:40:20.212 [spawn_test]: shipSpawned
15:40:20.212 [spawn_test]: shipSpawned
15:40:20.213 [spawn_test]: shipSpawned
15:40:20.213 [spawn_test]: shipSpawned
15:40:20.214 [spawn_test]: shipSpawned
15:40:20.214 [spawn_test]: shipSpawned
15:40:20.214 [spawn_test]: shipSpawned
15:40:20.215 [spawn_test]: shipSpawned
Looks like your code is correct. Any oxps running?
User avatar
jh145
Dangerous
Dangerous
Posts: 94
Joined: Thu Dec 25, 2014 8:39 pm

Re: overriding standard ships

Post by jh145 »

I've got a few OXPs running: rescue stations, random hits, a couple of neolite and griff things. I'll grep through them looking for viper-related badness and report back later.

Meanwhile: how/where did you do this?

Code: Select all

system.addShips("[viper]",10,player.ship.position,10000);
Is that a debug console command or did you put it in a script somewhere?
User avatar
jh145
Dangerous
Dangerous
Posts: 94
Joined: Thu Dec 25, 2014 8:39 pm

Re: overriding standard ships

Post by jh145 »

Ah, you did mention Griff's suppressor OXP, didn't you. I didn't recognise it by that name, but commenting out some lines ...

Code: Select all

/*
"viper" =
   {
   roles = "unused";
   };

"viper-interceptor" =
   {
   roles = "unused";
   };

"viper-pursuit" =
   {
   roles = "unused";
   };
*/
in AddOns/Griff_Shipset_Addition_v1.23.oxp/Config/shipdata-overrides.plist seems to have done the trick. I was confused because I was still seeing police and only occasionally getting the logging messages that I expected, but I guess I must just have been seeing logs from the core vipers and not from the Griff ones.

OK, so if I want my OXP to have the last word (for testing ...) on which ships are registered to which names, what do I have to do? Be last alphabetically and define my overrides in shipdata-overrides.plist?
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: overriding standard ships

Post by Cody »

jh145 wrote:
... Griff_Shipset_Addition_v1.23.oxp...
That OXP, and its companion OXP (Shipset_Replace), are a little bit broken in Oolite 1.80. You could use Griff's individual OXPs for 1.80 instead - see here.
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: overriding standard ships

Post by Smivs »

jh145 wrote:
OK, so if I want my OXP to have the last word (for testing ...) on which ships are registered to which names, what do I have to do? Be last alphabetically and define my overrides in shipdata-overrides.plist?
It might be better to give your new ship? a unique role (eg 'jhTestViper' or somesuch) and spawn them by role, then you will just spawn the ship you want when you want it.
The debug console is ultimately the way to go, but a simple worldscript (named as 'script.js' and placed in AddOns) will do. I use this quite often

Code: Select all

// Standard attributes 
this.name           = "general_test_script"; 
this.author         = "Smivs"; 
this.copyright      = "This script is hereby placed in the public domain."; 
this.version        = "1.0"; 
this.description    = "Script to add entities." 

// Configuration
this.role1 = "classicFerdelance"; 
this.count1 = 5;
this.role2 = ""; 
this.count2 = 2;
this.role3 = ""; 
this.count3 = 1;
this.role4 = ""; 
this.count4 = 1;

this.shipWillLaunchFromStation = function()
// this.shipWillExitWitchspace = function() 
{
    system.addShips(this.role1, this.count1, player.ship.position, 10000)
    system.addShips(this.role2, this.count2, player.ship.position, 10000)
    system.addShips(this.role3, this.count3, player.ship.position, 10000)
    system.addShips(this.role4, this.count4, player.ship.position, 10000)
    log("testscript.spawn", "Generated " + this.count1 + " " + this.role1 + " for testing purposes.");
};
The example above is the one I am currently using to fine-tune the texture on the FerDeLance for the Classic Ships WIP. This has

Code: Select all

roles = "classicFerdelance";
in shipdata, so is completely unique. I have the AI set to dumbAI.plist, so the result is five of them gently tumbling when I launch and this makes visual inspection very easy.
This script allows you to spawn up to four different ships at the same time. The commented-out section gives you the option to spawn after a witchjump rather than by the station - useful if you don't want any other ships around.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: overriding standard ships

Post by spara »

Cody wrote:
jh145 wrote:
... Griff_Shipset_Addition_v1.23.oxp...
That OXP, and its companion OXP (Shipset_Replace), are a little bit broken in Oolite 1.80. You could use Griff's individual OXPs for 1.80 instead - see here.
Not only little broken :shock: . The additional shipset overrides core ships with roles = "unused". Then it defines new ships to be used in core roles. And here things break as this old oxp does not define new roles (assassins etc).

I understand that Griff's current ships are constantly wip, but something should be done to the wiki page. Old links should be moved away from sight and only link to the working individual ships should be offered. Or maybe a new all_in_one, but from what I have gathered, Griff seems to oppose that due updating difficulties.
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: overriding standard ships

Post by Cody »

spara wrote:
I understand that Griff's current ships are constantly wip, but something should be done to the wiki page.
Aye, true enough - if Griff hasn't popped-in by tomorrow, I'll PM him.
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: overriding standard ships

Post by spara »

Cody wrote:
spara wrote:
I understand that Griff's current ships are constantly wip, but something should be done to the wiki page.
Aye, true enough - if Griff hasn't popped-in by tomorrow, I'll PM him.
Hermit in station bundle produces null market in 1.81. It needs little tweaking too.
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: overriding standard ships

Post by Cody »

spara wrote:
Hermit in station bundle produces null market in 1.81.
Would you know how to fix that, spara? I'd rather like to use that bundle again, you see.
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: overriding standard ships

Post by spara »

Cody wrote:
spara wrote:
Hermit in station bundle produces null market in 1.81.
Would you know how to fix that, spara? I'd rather like to use that bundle again, you see.
Sure. Replace shipdata.plist in griff_station_bundle_fullsize_tex_v.1.1 with this one: https://app.box.com/s/8y870smgeg9np5ax5iva. Usual disclaimer of course, not very thoroughly tested :) .
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: overriding standard ships

Post by Cody »

spara wrote:
Replace shipdata.plist in griff_station_bundle_fullsize_tex_v.1.1 with this one:
Sweet - thanks!
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
jh145
Dangerous
Dangerous
Posts: 94
Joined: Thu Dec 25, 2014 8:39 pm

Re: overriding standard ships

Post by jh145 »

Smivs wrote:
It might be better to give your new ship? a unique role (eg 'jhTestViper' or somesuch) and spawn them by role, ...
I'll try that, thanks.

Can we only ever spawn by role, not by ship name? So if I wanted to spawn a bunch of Cobra Mk IIIs, I'd have to define my own jhCobra3 that is like_ship oolite_template_cobra3 but has its own unique role?
Post Reply