[RELEASE] - Mining OXP

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

Moderators: winston, another_commander

Post Reply
User avatar
docwild
Dangerous
Dangerous
Posts: 64
Joined: Thu Mar 29, 2007 1:36 pm

[RELEASE] - Mining OXP

Post by docwild » Thu Jul 22, 2010 9:30 pm

http://www.box.net/shared/5i3h37u1ay

Mines are placed in the system randomly for every new visit. Mines will persist in their locations when you save but only in the current system, allowing you to continue a search pattern (if that's your kind of thing). The exception to that is the mines which you have already taken over which will always be in the location you left them. They are placed centred around the sun within 1 wp->sun distance. Unclaimed mines will reveal their location to you as will the mines you own, the mines which are claimed by others may reveal their beacon to you or, more likely, you may notice a battle or explosion in deep space (keep an eye on your port and starboard views) which provides clues. Beacons are not available immediately as a lightspeed delay is worked out, this is in order that the beacons are uploaded to the compass in the order that you receive them allowing you to know what status the mines are. Unclaimed mines are more likely in less stable governments, and is impossible by default in rich capitalists (but you may still intercept beacons). Leave the mine too long and it may be taken over. Taking over mines is as simple as docking, although for claimed mines this will fall to random chance but if you don't have the requisite resources the AI will be grumpy. Mines require resources, 20t of food and 5t of slaves (standard), extras can be taken in the form of commodities which the human workers like increasing productivity but also increasing your likelihood of gaining a criminal record. Asteroid claims can be destroyed by taking the station to low energy although this isn't fully implemented yet for claimed mines but it should work-ish for owned mines.

This is still in early stages, it only gives gold (and probably too much) which will be available after at least one day of mining. I have released it under the same license as Oolite so contributions are open and you may use it within those terms (I don't really mind, but dropping me a note would be appreciated). The code is rough around the edges and is in need of a bloomin good refactoring. However, trying to test everything which I have so far is a huge task for one person so an alpha release is my solution. If you'd like to test, contribute or comment I'd be most humbled. Thank you.


Still to do:

Add miners, probably modified pirateAIs
Orient stations, because my cheaty workaround sucks
Tweak economy, possibility of mines which give mostly alloys or precious metals but it shouldn't be exclusively one kind of thing.
I'm thinking of making the produce available for free, once it is available on the stations commodity market rather than script-awarding it
More action

Let me know:

Too many stations, not enough? in Mining.oxp/Scripts/miningScript.js the lines "this.minMines" and "this.maxMines" are available for tweaking, but it doesn't check that max is greater than min so be careful.

Too much gold or required resources? Not enough?

Does this slow your machine down? (it shouldn't as it's mostly precalculated, destroying your own mine claims is possible and is processed ingame to allow for an immediate jump without introducing a bug, so if you have a slow machine you might like to try that)

Suggestions, contributions or hateful vitriol will be accepted in good humour. Razz


docwild

User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks » Sun Jul 25, 2010 11:14 am

OK, I've had a chance to have a bit of a look at the oxp:

First of all, it seems you've uncovered a vector related crash within trunk.
Thanks for that, we probably wouldn't have spotted it without mining.oxp!


Second, you're doing something like

Code: Select all

					var pirate = system.addShips("blackdog", 1, ships[i].position, 5);
					if(pirate)
						pirate[0].ship.explode();
In a few places within the code.
Each element of the array returned by addShips is a ship already, so in effect you're writing ship.ship.explode().

Needless to say since no ship has got a ship property inside itself, Oolite just says 'meh' & doesn't do anything (well, ok: it says: pirate[0].ship has no properties - in javascript, saying "has no property" for an object's property is more-or-less the same as saying "doesn't exist"! :) )

So, whenever you have pirate[x].ship.whatever(), remove the extra, unnecessary .ship, so it just reads pirate[x].whatever().


And last (for now, anyway!) but not least, two things about the zipped files themselves:

One: on macs, whatever.oxp is shown as just one item, the actual directory structure is not immediately visible on that platform at any point, so anybody using that platform won't have a chance to see either readme.txt or licence.txt.
They need to be just outside the .oxp directory, and preferably with a unique name. Going with what quite a few other oxps have, I'd use mining_readme.txt & mining_licence.txt as names for those two files.

Two: you seem to have left quite a few temporary files inside the zip. Not a major problem, but it basically made the zip file almost twice as big as it needed to be... (not that 42k is that big a download, anyway!) :P


That's it for now! :D

Cheers,

Kaks
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)

User avatar
docwild
Dangerous
Dangerous
Posts: 64
Joined: Thu Mar 29, 2007 1:36 pm

Post by docwild » Sun Jul 25, 2010 12:24 pm

That's appreciated Kaks, thank you.

The 42k dl was the first upload, it was updated yesterday and now measures at <24k. I hadn't considered the directory structure, that's what happens when I spend all my time in a shell I guess.

The ship reference is also handy info, I hadn't got round to testing any of that yet. I'll fix it on my next pass, as it were.

I've just uploaded the most recent version, still buggy but better and with the directory issues and temp files fixed.

I'll look into it if no one knows off hand but with the licensing, what is the deal with mixing GPLs and CCx licenses for media content? For example there is a file I'd like to include which lists its licenses as:

GNU GPL 2.0
GNU GPL 3.0
GNU LGPL 2.0
GNU LGPL 3.0
CC-BY 3.0
CC-BY-SA 3.0

I'm guessing that info could just be added to the license text file along with where and when I downloaded it. As I say, I'll do research if no one knows but I'd rather not trawl through the legal docs if I can help it. I haven't included those files yet, until I'm certain.

many thanks.

User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton » Sun Jul 25, 2010 1:48 pm

The most likely intention is that you can redistribute under any of those licenses, but it doesn’t look like the author has thought very clearly about what they mean. (For instance, it doesn’t make sense to say “CC-by 3.0 or CC-by-sa 3.0”, since CC-by 3.0 is strictly more general than CC-by-sa 3.0.) I’d e-mail and ask.

User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks » Sun Jul 25, 2010 2:56 pm

It looks like I'm a bit behind the times with this fast-paced oxp! :)


However, I did notice one other thing:

If the player hasn't got the advanced compass installed they won't be able to select any beacons. It's best if you don't show the 'beacon message' if they haven't got the equipment for it! :)

Cheers,

Kaks.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)

User avatar
docwild
Dangerous
Dangerous
Posts: 64
Joined: Thu Mar 29, 2007 1:36 pm

Post by docwild » Sun Jul 25, 2010 4:55 pm

I would have completely overlooked the compass, you da man Kaks.

Ahruman: Well, if you're going to be all logical about it... lol. Superb idea, thank you.

User avatar
docwild
Dangerous
Dangerous
Posts: 64
Joined: Thu Mar 29, 2007 1:36 pm

Post by docwild » Wed Jul 28, 2010 5:02 pm

New version available.

This adds a management menu available when you dock at a mine. From here you can add resources, if available and view your owned mine stats as well as taking your gold when it is ready.

The AI's are now added properly for distant battles and explosions, thanks be to Kaks. Your station is safe for 3 days after which random chance will decide whether the claim exists. Dropping off firearms will decrease this likelihood. Fail to visit your mine for too long and it will be lost. No messages are given to lost mines, they simply disappear from your beacon and mine management menu. You may have a slave/food (5t/20t) type mine or a machinery/computers (20t/5t) type mine and this can be changed from the menu.

More is to be added but it should now be playable.

Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 1998
Joined: Mon May 31, 2010 11:11 pm

Post by Switeck » Thu Jul 29, 2010 8:02 pm

The music doesn't seem to want to stop when I leave the area of a claimed mine.

Also, I crash on exiting an asteroid mine.

User avatar
docwild
Dangerous
Dangerous
Posts: 64
Joined: Thu Mar 29, 2007 1:36 pm

Post by docwild » Thu Jul 29, 2010 10:06 pm

Hey Switeck. Ah.. spelling error.

Line 203 in mine.js should read

Code: Select all

    if(this.ship.playerDetectedFlag)
I am missing the 'ed' on the end of detect. Editing this should resolve that issue. Strange that I didn't notice it, but it is likely because I never left without docking. Good catch.

As for the crash, I'd appreciate some more details. Oolite version, OS, machine specs and contents of log after crash would be ideal as I haven't experienced this. Does it quit with a seg fault?

Anyway, thanks for trying it.

Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 1998
Joined: Mon May 31, 2010 11:11 pm

Post by Switeck » Fri Jul 30, 2010 1:26 am

I'll have to reinstall it and test again...may be a day or 2 before I can get crash details.

I've got very few OXPs installed:
behemoth 2.5.4.oxp
DeepSpacePirates 1.2.4.oxp
FuelCollectorV0.06.oxp (buggy I believe)
Fuel Tank v2.2
Missile Analyser 1.2.oxp
Ore_processor 1.57.oxp
Pirate Coves (1.2)
Switeck_mod.oxp
TAF Reset (Do I even need this anymore?)
Target Autolock Plus 1.10.oxp
Traffic Control v1.10
Welcome Mat v1.10
Witchspace Analyser v1.1

bare minimum system specs:
Windows XP Pro SP3, 1 GB ram, ATI Radeon 9600 AGP video card, on-board soundcard, Intel 82801DB motherboard, 2.53 Ghz P-4 cpu.
...Running Oolite v1.74.2

Last section of my very long log starting moments before I docked with it, till which the game crashed:

[script.javaScript.warning.ooliteDefinedError]: ----- JavaScript warning (Fuel Collector 0.06): Ship.hasEquipment("EQ_FRAME_FUEL_COLLECTOR") is deprecated, use ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") == "EQUIPMENT_OK" instead.
[script.javaScript.warning.ooliteDefinedError]: ----- JavaScript warning (Fuel Collector 0.06): Ship.hasEquipment("EQ_FUEL_SCOOPS") is deprecated, use ship.equipmentStatus("EQ_FUEL_SCOOPS") == "EQUIPMENT_OK" instead.
[miningScript]: Docked with non-main station, checking type...
i = 0this.systemAsteroidObjects.minePos = (20791.6, 173370, 131725)station.position = (-106336, 1.25328e+006, -616566)
[miningScript]: minetemp = [Station "SlaveMine-" "SlaveMine-" position: (20791.9, 173370, 131725) scanClass: CLASS_STATION status: STATUS_IN_FLIGHT]
[miningScript]: This isn't the one we're docked at
this.systemAsteroidObjects.mineEntity = [Station "SlaveMine-" "SlaveMine-" position: (20791.9, 173370, 131725) scanClass: CLASS_STATION status: STATUS_IN_FLIGHT] station = [Station "SlaveMine-" "SlaveMine-" position: (-106336, 1.25328e+006, -616566) scanClass: CLASS_STATION status: STATUS_IN_FLIGHT]
[miningScript]: Docked with non-main station, checking type...
i = 1this.systemAsteroidObjects.minePos = (-106337, 1.25328e+006, -616566)station.position = (-106336, 1.25328e+006, -616566)
[miningScript]: minetemp = [Station "SlaveMine-" "SlaveMine-" position: (-106336, 1.25328e+006, -616566) scanClass: CLASS_STATION status: STATUS_IN_FLIGHT]
[miningScript]: this is a mine
[miningScript]: Docked with claimed asteroid: SlaveMine-CLAIMED
[worldScripts.miningMethods]: choice = 3_NOTNOW
[worldScripts.miningMethods]: NOTNOW choice = 3_NOTNOW
[miningMethods]: launch()
[worldScripts.miningMethods]: NOTNOWCLAIMED launch()ed
[script.javaScript.warning.ooliteDefinedError]: ----- JavaScript warning (Fuel Collector 0.06): Ship.hasEquipment("EQ_FRAME_FUEL_COLLECTOR") is deprecated, use ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") == "EQUIPMENT_OK" instead.
[script.javaScript.warning.ooliteDefinedError]: ----- JavaScript warning (Fuel Collector 0.06): Ship.hasEquipment("EQ_FUEL_SCOOPS") is deprecated, use ship.equipmentStatus("EQ_FUEL_SCOOPS") == "EQUIPMENT_OK" instead.
[miningScript]: delay = 18.322855162774733 i = 0
[miningScript]: delay = 89.3330716046594 i = 1
[script.javaScript.warning.ooliteDefinedError]: ----- JavaScript warning (Fuel Collector 0.06): Ship.hasEquipment("EQ_FRAME_FUEL_COLLECTOR") is deprecated, use ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") == "EQUIPMENT_OK" instead.
[script.javaScript.warning.ooliteDefinedError]: ----- JavaScript warning (Fuel Collector 0.06): Ship.hasEquipment("EQ_FUEL_SCOOPS") is deprecated, use ship.equipmentStatus("EQ_FUEL_SCOOPS") == "EQUIPMENT_OK" instead.
[script.javaScript.warning.ooliteDefinedError]: ----- JavaScript warning (Fuel Collector 0.06): Ship.hasEquipment("EQ_FRAME_FUEL_COLLECTOR") is deprecated, use ship.equipmentStatus("EQ_FRAME_FUEL_COLLECTOR") == "EQUIPMENT_OK" instead.
[script.javaScript.warning.ooliteDefinedError]: ----- JavaScript warning (Fuel Collector 0.06): Ship.hasEquipment("EQ_FUEL_SCOOPS") is deprecated, use ship.equipmentStatus("EQ_FUEL_SCOOPS") == "EQUIPMENT_OK" instead.

Post Reply