script-spawned splinters

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

script-spawned splinters

Post by Commander McLane »

It seems that script-spawned splinters don't behave like "real" ones. Specifically, their isCargo-property is false, even though they have the correct scanClass CLASS_CARGO and can be scooped (and correctly award minerals when scooped).

But they (1) count as a kill when shot, and (2) award an incorrect bounty (1Cr instead of 0.1Cr) when shot.

(1) can be circumvented by setting counts_as_kill in shipdata, and (2) by a script calculation, but still I think it's wrong that they're not fully recognized as cargo in the first place.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: script-spawned splinters

Post by Thargoid »

On a possibly related note - the same applies to inactive Thargons. They are scanclass cargo, but isCargo is false for them.
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: script-spawned splinters

Post by Eric Walch »

How should oolite see that a script spawned item should be a splinter? If it results from an boulder explosion, oolite knows. :D

I do see that the splinters from ore_processor, are listed as isCargo and don't award a kill when shot. But that is because they are defined as CARGO_SCRIPTED_ITEM. Minerals are only added to splinters on creating them as splinters.

You could very explicit add minerals to it by using the key:

Code: Select all

cargo_carried = "minerals";
I just tested it and that works. I see if this should go to shipData in trunk, or that it needs an other fix. When oolite creates splinters, it explicit sets the bounty to zero. That part is not dealt with above code. But that can be set by starting with zero bounty. I have no idea why they have a bounty of 1 in shipData.

The addition of the cargo as defined by cargo_type only happened on scooping. It was never needed to know it sooner. Now with al that scripting, scripts want to know sooner :P Probably the whole definition should happen on creation, not on scooping. But, there must be a reason for this order.
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: script-spawned splinters

Post by Eric Walch »

I moved the addition of the special cases to the ship setUp part. The problem was mainly splinters, as anything containing a role 'cargopods' already was auto filled with random commodity on script addition. That change should cover all cases of script added stuff that is mend to be scooped.

I'll test it a bit though before adding to trunk. In the mean time, adding a key cargo_carried as above, makes it work in 1.76 and older. For trunk, that key will not be needed, but will no no harm either. Just realise the key was never mend to be used together with a cargo_type = CARGO_MINERALS and on scooping it will always be minerals, whatever cargo_carried was defined.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: script-spawned splinters

Post by Commander McLane »

Eric Walch wrote:
I have no idea why they have a bounty of 1 in shipData.
I think it's correct behaviour that they give a bounty of 0.1. For "normal" splinters that works correctly, just like for rocks. But not for script-spawned splinters. I'll try to set their bounty to 0.1, maybe that works.

EDIT: No, that doesn't work, but it isn't necessary, either. The combination of

Code: Select all

		<key>cargo_carried</key>
		<string>minerals</string>
		<key>cargo_type</key>
		<string>CARGO_MINERALS</string>
solves indeed all above mentioned problems. :D

By the way:

Code: Select all

		<key>cargo_carried</key>
		<string>minerals</string>
		<key>cargo_type</key>
		<string>CARGO_SCRIPTED_ITEM</string>
or

Code: Select all

		<key>cargo_carried</key>
		<string>Minerals</string>
		<key>cargo_type</key>
		<string>CARGO_SCRIPTED_ITEM</string>
don't work for me. No minerals are awarded. But the first one is definitely working in 1.76.1.
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: script-spawned splinters

Post by Eric Walch »

Commander McLane wrote:
By the way:
...
don't work for me. No minerals are awarded. But the first one is definitely working in 1.76.1.
That is correct. The 'trick' of using

Code: Select all

cargo_carried = minerals;
only makes that is gets a label of carrying cargo. The cargo_type field will mess with it again when it is not CARGO_CARRIED as it should by according the correct use. But at least will it make things that don't contain a 'cargopod' role, backwards compatible with scripts that look at the isCargo property.

Thinking about.... That will not work for the tharglets because they will than be seen as cargo immediately after creation.
Will also work for tharglets as cargo is defined in JS as:

Code: Select all

([entity scanClass] == CLASS_CARGO && [entity commodityAmount] > 0)
So as long they are still active, the presence of a commodityAmount > 0 is no problem. But used in a hulk, it could become actual cargo and scoopable. :(
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: script-spawned splinters

Post by Eric Walch »

Commander McLane wrote:
It seems that script-spawned splinters don't behave like "real" ones. Specifically, their isCargo-property is false, even though they have the correct scanClass CLASS_CARGO and can be scooped (and correctly award minerals when scooped).
Should be fixed in r4996. (Also for inactive tharglets and other related stuff. )
Post Reply