OXP tutorial
Contents
My First OXP
An OXP is an expansion pack to Oolite. You can customise the whole Oolite experience. In the same directory as the oolite.app directory is an AddOns directory. An OXP is a directory under AddOns called oxpname.oxp where oxpname is the name of your expansion pack. I have rashly committed to an ambitious OXP on the oolite BB[1] - this tutorial / blog is the story of how I got there.
1.0 Creating My First Ship
My first OXP will be to create a ship. There are 2 approaches to this. The first involves 3D modelling. That is time consuming and too involved for my level of impatience. So we'll use the second method - borrowing someone else's model.
Configuration files and scripts are either property lists (.plist extension) or javascript (.js extension). Both are text format. Notepad++[2] is a good editting tool - even if I prefer vi[www.vim.org/download.php]. Though you can use whatever editor you are comfortable with (apart from Windows notepad).
First we need a name for our expansion pack. If you plan on deploying it try to make it unique. Thargons.oxp is a stunningly bad name as it is likely to crash. Thus I will call this expansion pack cobraball_1_0.oxp. Throughout this tutorial I am using a major and minor version number - so you can download and identify all the examples.
Having come up with a catchy (well unique) name, we need a directory. Create a directory called cobraball_1_0.oxp in the AddOns directory. Create a Config sub directory. Within the Config directory create a text file called shipdata.plist.
This will be our first Property list. There are 2 different formats, but this a tutorial not a reference manual so we will ignore one of them and use the XML format.
Below is a blank template for a Property list. For our purposes we need to use the header and footer below and don't need to understand them.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
</plist>
Enough preamble - on with our first OXP. We are going to build a ship. It will be like the Cobra Mk III (the playable version not the pirate / trader)- except we'll change it around a bit - otherwise what is the point? The key (internal name) for the ship will be cobraball_cobra_1_0 - this is never seen by the player. Note the use of the like_ship key. Take the code below and save it in shipdata.plist.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>cobraball_cobra_1_0</key>
<dict>
<key>like_ship</key>
<string>cobra3-player</string>
<key>name</key>
<string>My Custom Cobra Mk III</string>
</dict>
</dict>
</plist>
As the header and footer can get boring very quickly and add clutter I won't include them from here on. Unless I do.
As might be obvious shipdata.plist is the ships configuration file. The shipdata.plist information in all the installed OXPs is added to the standard definition in the central shipdata.plist to get the master list used in the gameplay. For the impatient the full list of available fields is available here.
The ship now exists, but it would not be particularly easy to find at the moment. Thus we need more code wizardry. Create a new text file demoships.plist in the same Config directory as shipdata.plist. Add the following code to it:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>cobraball_cobra_1_0</string>
</array>
</plist>
Now fire up Oolite. And when it asks if you want to load the previous commander - press "N". Then use the left arrow to toggle through the ships - and delight in your new caption.
1.1 Creating My First Useful Ship
Ok, all so far, so impressive, but that was an awful lot of work to look at the standard Cobra. Now what we want to do is fly this baby.
Before we can fly it, we need to buy it. So we need a new configuration file in the OXP. Create a new text file shipyard.plist. For the impatient the full list of available fields is available here.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>cobraball_cobra_1_0</key>
<dict>
<key>chance</key>
<real>1</real>
<key>optional_equipment</key>
<array>
<string>EQ_ECM</string>
<string>EQ_FUEL_SCOOPS</string>
<string>EQ_ENERGY_BOMB</string>
<string>EQ_ENERGY_UNIT</string>
<string>EQ_NAVAL_ENERGY_UNIT</string>
<string>EQ_DOCK_COMP</string>
<string>EQ_WEAPON_PULSE_LASER</string>
<string>EQ_WEAPON_BEAM_LASER</string>
<string>EQ_WEAPON_MINING_LASER</string>
<string>EQ_WEAPON_MILITARY_LASER</string>
<string>EQ_FUEL_INJECTION</string>
<string>EQ_SCANNER_SHOW_MISSILE_TARGET</string>
<string>EQ_MULTI_TARGET</string>
<string>EQ_GAL_DRIVE</string>
<string>EQ_ADVANCED_COMPASS</string>
<string>EQ_SHIELD_BOOSTER</string>
<string>EQ_NAVAL_SHIELD_BOOSTER</string>
<string>EQ_HEAT_SHIELD</string>
</array>
<key>price</key>
<integer>10</integer>
<key>standard_equipment</key>
<dict>
<key>extras</key>
<array>
<string>EQ_ESCAPE_POD</string>
</array>
<key>forward_weapon_type</key>
<string>EQ_WEAPON_BEAM_LASER</string>
<key>missiles</key>
<integer>1</integer>
</dict>
<key>techlevel</key>
<integer>1</integer>
<key>weapon_facings</key>
<integer>15</integer>
</dict>
</dict>
</plist>
This should all be straight forward but a useful reference for plist files can be found here. But enough of that dry academia, let's fly. Start up Oolite. Start a new game. Press F3 twice. Buy your very own ship and take it for a spin.
1.2 Creating My First Game Killer Ship
Now this is all well and good, but where is the fun? I know you are going to build a stupidly overspecified mean machine, so we may as well show you how so you can get it out of your system.
shipdata.plist:
<dict>
<key>cobraball_cobra_1_2</key>
<dict>
<key>energy_recharge_rate</key>
<real>100</real>
<key>laser_color</key>
<string>yellowColor</string>
<key>like_ship</key>
<string>cobra3-player</string>
<key>max_energy</key>
<real>920</real>
<key>max_cargo</key>
<integer>250</integer>
<key>max_flight_pitch</key>
<real>3.0</real>
<key>max_flight_roll</key>
<real>4.2</real>
<key>max_flight_speed</key>
<real>1000</real>
<key>max_missiles</key>
<real>20</real>
<key>name</key>
<string>Super Cobra Mk III (1.2)</string>
<key>thrust</key>
<real>100</real>
</dict>
</dict>
shipyard.plist:
<dict>
<key>cobraball_cobra_1_2</key>
<dict>
<key>chance</key>
<real>1</real>
<key>optional_equipment</key>
<array>
<string>EQ_WEAPON_MILITARY_LASER</string>
</array>
<key>price</key>
<integer>10</integer>
<key>standard_equipment</key>
<dict>
<key>extras</key>
<array>
<string>EQ_ESCAPE_POD</string>
<string>EQ_ECM</string>
<string>EQ_FUEL_SCOOPS</string>
<string>EQ_ENERGY_BOMB</string>
<string>EQ_NAVAL_ENERGY_UNIT</string>
<string>EQ_DOCK_COMP</string>
<string>EQ_FUEL_INJECTION</string>
<string>EQ_SCANNER_SHOW_MISSILE_TARGET</string>
<string>EQ_MULTI_TARGET</string>
<string>EQ_GAL_DRIVE</string>
<string>EQ_ADVANCED_COMPASS</string>
<string>EQ_NAVAL_SHIELD_BOOSTER</string>
<string>EQ_HEAT_SHIELD</string>
<string>EQ_CLOAKING_DEVICE</string>
<string>EQ_MILITARY_JAMMER</string>
<string>EQ_MILITARY_SCANNER_FILTER</string>
</array>
<key>missiles</key>
<integer>20</integer>
</dict>
<key>techlevel</key>
<integer>1</integer>
<key>weapon_facings</key>
<integer>15</integer>
</dict>
</dict>
Make all the good stuff standard. Including some stuff only available as a mission reward. This is a game play killer so don't. The EQ_ codes are defined in Equipment.plist.
The trouble with super ships like the above is that they wreck the balance of the game - they take away the challenge and make life too easy. Just because we can does not mean we should. Superman would be mighty dull without Kryptonite to add some drama.
1.3 Can I watch?
By now, hopefully, you are bored of omnisicience. So lets try to make someone to interact with. We start again from scratch. Create a new OXP by creating cobraball_1_3.oxp in the AddOns directory. Create a Config directory underneath it. We'll have another shipdata.plist now:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>cobraball_fdl_1_3</key>
<dict>
<key>ai_type</key>
<string>buoyAI.plist</string>
<key>like_ship</key>
<string>ferdelance</string>
<key>name</key>
<string>Trader Ferdelance (1.3)</string>
<key>roles</key>
<string>cobraball_cobra_1_2_role</string>
<key>rotating</key>
<true/>
<key>scanClass</key>
<string>CLASS_BUOY</string>
</dict>
</dict>
</plist>
We have created a Fer-De-Lance that thinks it's a buoy. Lets have a look for one...