Oolite Bulletins
http://www.aegidian.org/bb/

Scripters cove
http://www.aegidian.org/bb/viewtopic.php?f=4&t=3243
Page 94 of 95

Author:  phkb [ Sun Nov 05, 2017 11:58 pm ]
Post subject:  Re: Scripters cove

Part of the problem may lie in the function stacking your doing in this line:
Code:
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:
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.

Author:  Redspear [ Mon Nov 06, 2017 1:49 am ]
Post subject:  Re: Scripters cove

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.

Author:  Redspear [ Tue Nov 07, 2017 1:02 am ]
Post subject:  Re: Scripters cove

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...

Author:  phkb [ Tue Nov 07, 2017 1:07 am ]
Post subject:  Re: Scripters cove

Can you send me the entire script file?

Author:  Redspear [ Tue Nov 07, 2017 1:30 am ]
Post subject:  Re: Scripters cove

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:

Author:  montana05 [ Tue Nov 07, 2017 3:04 am ]
Post subject:  Re: Scripters cove

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.

Author:  Norby [ Tue Nov 07, 2017 10:10 am ]
Post subject:  Re: Scripters cove

Quote:
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.
Quote:
In which OXP I could find the tanker anaconda ?
I think this:
Code:
wildShips_anaconda = {
                like_ship = "anaconda";
                name = "Anaconda Tanker";
                roles = "wildShips_tanker wildShips_anaconda";
};

Author:  montana05 [ Tue Nov 07, 2017 10:35 am ]
Post subject:  Re: Scripters cove

Quote:
Quote:
Quote:
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.
Quote:
Quote:
In which OXP I could find the tanker anaconda ?
I think this:
Code:
wildShips_anaconda = {
                like_ship = "anaconda";
                name = "Anaconda Tanker";
                roles = "wildShips_tanker wildShips_anaconda";
};
WildShips it is, thank you a lot

Author:  montana05 [ Fri Dec 01, 2017 9:36 am ]
Post subject:  Re: Scripters cove

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.

Author:  montana05 [ Mon Dec 04, 2017 2:05 am ]
Post subject:  Re: Scripters cove

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.

Author:  Redspear [ Fri Feb 09, 2018 6:14 pm ]
Post subject:  Re: Scripters cove

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?

Author:  Mauiby de Fug [ Sun Feb 11, 2018 12:51 pm ]
Post subject:  Re: Scripters cove

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)...

Author:  Redspear [ Sun Feb 11, 2018 2:28 pm ]
Post subject:  Re: Scripters cove

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.

Author:  spara [ Sun Feb 11, 2018 2:34 pm ]
Post subject:  Re: Scripters cove

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 :).

Author:  Redspear [ Sun Feb 11, 2018 2:54 pm ]
Post subject:  Re: Scripters cove

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.

Page 94 of 95 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/