Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Scripters cove

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

Moderators: winston, another_commander

User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4740
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post by phkb »

Part of the problem may lie in the function stacking your doing in this line:

Code: Select all

this.startUpComplete = this.equipmentAdded = this.playerBoughtNewShip = function()
This code will run whenever you start up from a save game (as you've noted), and theoretically would run every time any equipment is added, or whenever the player buys a new ship.

I think it would be better to do something like this:

Code: Select all

this.startUpComplete = function()
{	
	this.$adjustSpeed();
}

this.equipmentAdded = function(equipmentKey) 
{
	log(this.name, "adding equipment " + equipmentKey);
	if (equipmentKey == "EQ_TRANSIT_DEFAULT" || equipmentKey == "EQ_TRANSIT_GRADE" || equipmentKey == "EQ_PERFORMANCE_DEFAULT" || equipmentKey == "EQ_PERFORMANCE_GRADE")
		this.$adjustSpeed();
}

this.playerBoughtNewShip = function(ship, price) 
{
	log(this.name, "new ship " + ship);
	this.$adjustSpeed();
}

this.$adjustSpeed = function() 
{
	var p = player.ship;
	var td = p.equipmentStatus("EQ_TRANSIT_DEFAULT");
	var tg = p.equipmentStatus("EQ_TRANSIT_GRADE");
	var pd = p.equipmentStatus("EQ_PERFORMANCE_DEFAULT");
	var pg = p.equipmentStatus("EQ_PERFORMANCE_GRADE");

	log(this.name, "transit def " + td + ", gde " + tg);
	log(this.name, "perform def " + pd + ", gde " + pg);
	log(this.name, "maxspeed pre  = " + p.maxSpeed);
	if(tg == "EQUIPMENT_OK" && td != "EQUIPMENT_OK" && pd != "EQUIPMENT_OK") {p.maxSpeed -= 50;}
	if(pg == "EQUIPMENT_OK" && pd != "EQUIPMENT_OK" && td != "EQUIPMENT_OK") {p.maxSpeed += 50;}
	if(tg == "EQUIPMENT_OK" && pd == "EQUIPMENT_OK") {p.maxSpeed -= 100;}
	if(pg == "EQUIPMENT_OK" && td == "EQUIPMENT_OK") {p.maxSpeed += 100;}
	log(this.name, "maxspeed post = " + p.maxSpeed);
}
This way you can see which of the events is not firing, plus the equipmentAdded function won't keep adjusting your speed when non-related equipment items are added.
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2657
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Scripters cove

Post by Redspear »

Thanks so much phkb! :D

I knew about the 'any' equipment issue (planning to add conditions later), so that was to come.
I didn't know that 'this.' statements could be nested however, so that opens up some new possibilities :-)

I'll try out the script and report back.
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2657
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Scripters cove

Post by Redspear »

Tried the above script. Same problem, namely this.equipmentAdded isn't firing (no log entries and no speed change using numeric hud).

The equipment is definitely being added (listed on the in game equipment list).
The way it is added may be unsual however...
Player buys transit re-fit which in turn grants (amongst other things) transit grade via script (working).

The fact that desired behaviour occurs from this.startUpComplete but not from this.equipmentAdded (with any of the three scripts so far) is curious.

I've tried swapping 'grades' for 're-fits' but to no avail.
I'll try this.playerBoughtEquipment else I might have to go down the replaceShip route...
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4740
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post by phkb »

Can you send me the entire script file?
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2657
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Scripters cove

Post by Redspear »

I could but I think I've just solved it...

There were two seperate checks for equipment added which were somehow interfering (I wasn't aware that one might prevent another). I've just tried combining them and suddenly there are log entries...

It's currently applying the adjustment twice but I think I might know why that is:
this.equipmentAdded = this.playerBoughtEquipment = function(equipment)
As refits are both purchased and added then that's potentially two triggers.

this.playerBoughtEquipment should be unnecessary in the presence of this.equipmentAdded

Thanks for all your help phkb :)
...and apologies for the wild goose chase :oops:
User avatar
montana05
---- E L I T E ----
---- 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

Post by montana05 »

Some noob questions of mine:

If I use scan class="CLASS_BUOY" is the player rewarded a kill and a bounty if defined ? From my first observation it seems not to be the case.

In which OXP I could find the tanker anaconda ? Once in a while it shows up on my scanner but I really dont remember anymore where this ship belong to.
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
Norby
---- E L I T E ----
---- 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

Post by Norby »

montana05 wrote: Tue Nov 07, 2017 3:04 am
If I use scan class="CLASS_BUOY" is the player rewarded a kill and a bounty if defined ? From my first observation it seems not to be the case.
If you tested then it is true. Sounds logical.
montana05 wrote: Tue Nov 07, 2017 3:04 am
In which OXP I could find the tanker anaconda ?
I think this:

Code: Select all

wildShips_anaconda = {
                like_ship = "anaconda";
                name = "Anaconda Tanker";
                roles = "wildShips_tanker wildShips_anaconda";
};
User avatar
montana05
---- E L I T E ----
---- 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

Post by montana05 »

Norby wrote: Tue Nov 07, 2017 10:10 am
montana05 wrote: Tue Nov 07, 2017 3:04 am
If I use scan class="CLASS_BUOY" is the player rewarded a kill and a bounty if defined ? From my first observation it seems not to be the case.
If you tested then it is true. Sounds logical.
Actually I first faced the problem while adapting the Star Destroyer, the escorts are defined as buoy and therefore no kills or bounties are rewarded even if they are fugitives. Even "counts_as_kill" = yes; doesn't change that. After massLockedBehaviour = "OO_MASSLOCKED_NEVER"; is working this shouldn't be a problem anymore.
montana05 wrote: Tue Nov 07, 2017 3:04 am
In which OXP I could find the tanker anaconda ?
I think this:

Code: Select all

wildShips_anaconda = {
                like_ship = "anaconda";
                name = "Anaconda Tanker";
                roles = "wildShips_tanker wildShips_anaconda";
};
WildShips it is, thank you a lot
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
montana05
---- E L I T E ----
---- 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

Post by montana05 »

Is there any way that I can assign specific pilots to all escape pods of a ship ? Its easy to have 8 pods with different designs but Oolite seems to accept only 1 assigned pilot and fills the remaining ones with random characters.

Update: Never mind, I found a solution already, not perfect but close enough.
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
montana05
---- E L I T E ----
---- 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

Post by montana05 »

A simple way to assign multiple characters to a ship:

create your character(s) in the characters.plist

in the shipdata.plist using "like_ship" create for every character an escape pod.

with "pilot =" you can assign each character to his pod, don't forget to set "unpiloted" = no;

include to your ship like following lines:

"death_actions" =
(
"spawn: my-escape-capsule_01 1",
"spawn: my_escape-capsule_02 2"
);


Voila, multiple pods with custom made characters. For sure not the most elegant method but east to implement.
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2657
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Scripters cove

Post by Redspear »

Using a visual effect stolen from Norby's telescope oxp...

Image

Note the target displayed in the bottom right of the HUD.

Any way to light it up when it is (presumably) subject to very similar lighting conditions to those of the target which it replicates?
User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 847
Joined: Tue Sep 07, 2010 2:23 pm

Re: Scripters cove

Post by Mauiby de Fug »

For some reason I have decided to be somewhat obsessive about the balance of the ships and stations in my Ooniverse. I've been looking through the wiki at the new roles that the populator uses (or at least, new since I last properly played) and am very interested in [wiki]http://wiki.alioth.net/index.php/Oolite ... le_Weights[/wiki]. I am a big fan of variety in my game, but I would like to tweak the chances of seeing lots of the oxp ships to make them more of a rarity and not outweigh the core ships too much.

My question: is there a way to use the debug console to list all the ships that Oolite is choosing from and to print out their role weights? I've found ship.roleWeights, which is great, but I'd need to be able to spawn one of every ship to check them. Which is more awkward than going through all the shipdata.plists by hand (which was my first thought, but I thought I'd see if there was a way to automate and speed up the process)...
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2657
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Scripters cove

Post by Redspear »

This may not be quite what you're looking for Mauiby, but it could save you time if you're using additional shipsets (with many ships per shipdata.plist).

Most role weights are <=1, right?

Therefore find and replace 'trader(0.' with 'trader(0.0' and you now have traders that appear only 10% as often as before.
You could also use replace 'trader ' (note the space) and 'trader"' (note the quotes) with 'trader(0.1)' and trader(0.1)" respectively. As long as trader (or whatever role you're editing) does not occur in the ship name then I think you'll be fine (even if it does, you won't break anything).

You'd nead to repeat for the various roles of course.

It wouldn't be very quick but it should still be much quicker than editing each role weight individually...
Better suggestions welcome because I have a similar problem.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripters cove

Post by spara »

A fellow balancer :). Don't know about a simple debug-command, but a simple script using keysForRole followed by shipDataForKey should do the get you a list of key and roles. Don't know what you plan to do with that though :). I find it best to go through oxps I'm using one by one comparing role weights with the core roles. Tedious job, but I just can't play the game if there's a noticable spawn balance problem. Somewhere around the forum should still float my old rebalancer for Griff's extra ship, if you need some inspiration :).
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2657
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Scripters cove

Post by Redspear »

Could the problem be solved largely in game by a condition script?

Not actual code but the rough idea:

this.allowSpawnShip
if shipKey != core ship && random 1-5 >3
else
spawn core ship of same role

In this example core ships would number 60% of the ships appearing.

Core ships might need to be listed in their entirety (not sure) but at least you'd only have to do it once.
Post Reply