cargoSpaceUsed faulty

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

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

cargoSpaceUsed faulty

Post by Frame »

I'm not sure this works as intended...

I had targeted a python in Riedquat , and wrote out its cargoSpaceUsed it said 0..

So i began tapping the ship with the laser... and suddenly he began dropping cargo pods.. 5 in all i was surprised by this, and pressed pause.. and wrote out cargoSpaceUsed again.. it now said 5... I then began tapping his hull again, when I accidental destroyed him... :twisted:

But the wreckage also left 5 cargo pods over, so in all now there was 10 cargo pods.

However the cargoSpaceUsed should have read out 5 tons to begin with, before I forced him til drop his cans, and diminished it to 0 when all the cargo pods had been ejected.

Cheers
Bounty Scanner
Number 935
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

It must also have some good points that do work. I have never seen something wrong with it and have used it in some scripting. In developing the deep_space_pirates.oxp I used it. Spawn ships started with zero cargo count and it incremented with every scooped normal barrel. (Scripted barrels are not added to the cargo hold). When maximum was reached the HOLD_FULL message was generated.

Your case is different though. It looks like the command to drop cargopods for some reason generates them for release and adds them to the inventory also. But without special scripting, ships should only be able to drop the cargopods during attack that have been scooped up previously. And for that the counter incremented always correctly on my 1.72 version.

I'll look a bit more at that property to see if when it goes wrong. Or is it only a 1.73 issue?
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

I was looking for if, the cargo carried on-board ships already had a signature.. as I was puzzling around with a cargo scanner... for the Missile Reticle in a custom mod I was making...

you can see my current modifications here (screenshot)

http://i304.photobucket.com/albums/nn18 ... grade1.jpg

It lists my speed, my targets speed(in ls), and my targets Energy(in %)... (care is taken when the target has neither)

I wanted to write some sort of pop up on the reticle that would list a targets cargo, and ultimately the kind of cargo carried. gold /food /computers / passenger or "special cargo", Unusual cargo and so on.

As I found Out the content of the cargo is unknown, which is why I wanted CargoSpaceUsed to be something.... so at least I could list the tonnage carried..

This is all in a custom build(that I will not make public), but rather suggest as being implemented into Oolite as Extras that you can buy in a later stage when I am going to suggest to reorganise Equipment screen (f5)

But more on that later

but CargoSpaceUsed should really be something when the trader is able to drop cargo... Even when it has not scooped anything, and CargoSpaceUsed should be the amount that the ship is supposed to drop in case of persuasive laser fire. (AI is acting weird here though, it drops cargo pods, then sometimes attacks. though its not like i'm going to let it "live" anyway... ;-)-.--

Cheers Frame...

Edit; on a sidenote..


It is fun watch the speed rise to 3.6 ls.. for NPC ships... when they flee.
should list player speed at all times though...

edit edit... player speed at torus speed in 0.350 cobra mk III is 11.2 ls in case you wonder...
Bounty Scanner
Number 935
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Frame wrote:
CargoSpaceUsed should be the amount that the ship is supposed to drop in case of persuasive laser fire. (AI is acting weird here though, it drops cargo pods, then sometimes attacks. though its not like i'm going to let it "live" anyway... ;-)-.--
Building a cargo scanner will not be possible because of how oolite initialises cargo.

Every cargo item is an entity and setting up entities takes time. Jumping to another system would take much more time if also cargo for every ship was created at that moment. When a ship is created Oolite creates an empty array with the size of max_cargo for that ship. It also sets a flag for what type of cargo it is carrying. The cargo (and its exact quantity) is than generated on explosion of the ship. This spreads the creation of cargo over time and most ships don't need cargo creation as they never explode.

The exception comes when a ship scoops cargo. This cargo goes into the empty array for the ship and the flag for the cargo type is set from any previous value to "real-cargo". When a ship with real-cargo explodes, this real-cargo is released. And now precisely: same barrel type and same content as the scooped one. Also the command "dumpCargo()" can only dump the real-cargo that was previously scooped.

The JS property cargoSpaceUsed does nothing more than giving the count of the entries in the cargo array. And this are only the scooped barrels. When this value is zero and the ship has never scooped up cargo, it still can spawn some barrels on explosion. (Normally this is 10% of max_cargo. When this value is over 15, it uses a random value ranging from 0 till 15)
Post Reply