Difference between revisions of "OXP tutorial"

From Elite Wiki
m (Creating My First Useful Ship (cobraball_1_1): fixed link to Shipyard.plist)
m (Creating My First Useful Ship (cobraball_1_1): fixed another shipyard.plist link)
Line 72: Line 72:
 
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.  
 
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 [[Shipyard.plistfi|here]].  
+
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 [[Shipyard.plist|here]].  
  
 
<code><pre>
 
<code><pre>

Revision as of 05:24, 22 May 2010

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.

Creating My First Ship (cobraball_1_0)

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">
  <!-- this is a comment and is ignored by Oolite -->
  <!-- this is where in the file all of our stuff goes -->
  <!-- you can ignore the header and footer parts -->
</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">

<!-- the end of the header and the start of the custom code -->

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

<!-- the end of the custom code and the start of the footer -->
</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.

Creating My First Useful Ship (cobraball_1_1)

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>

<!-- The chance of getting this ship in a ship yard. 1 is certainty. 0 is never. We always want to see out ship, so we can test it-->
		<key>chance</key>
		<real>1</real>

<!-- This section determines what is available from the f3 screen -->
		<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>

<!-- Bargain for testing purposes -->
		<key>price</key>
		<integer>10</integer>

<!-- This section determines what is standard equipment -->
		<key>standard_equipment</key>
		<dict>

			<key>extras</key>
			<array>
				<string>EQ_ESCAPE_POD</string>
			</array>

<!-- Defines the default forward facing weapon -->
			<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.

Creating My First Game Killer Ship (cobraball_1_2)

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>
<!-- Stupidly high recharge rate - same as for a station -->  
   <key>energy_recharge_rate</key>
   <real>100</real>
<!-- I like yellow lasers -->     
   <key>laser_color</key>
   <string>yellowColor</string>   
   <key>like_ship</key>
   <string>cobra3-player</string>
<!-- Energy bars are energy divided by 64 -->
   <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.


BEYOND THIS POINT IS A WORK IN PROGRESS


Asteroids and positioning (cobraball_1_3)

Create a custom asteroid

Create an asteroid based on the standard version.

Add a flasher

Add flashers so we can identify our asteroid clearly.

Station View

Park by the station beacon.

Witchspace Beacon (cobraball_1_3_1)

Park by the beacon.

Surface of the Sun (cobraball_1_3_2)

Park near the sun closest to the planet.

Route 1(cobraball_1_3_3)

Randomly along route 1.

Route 2(cobraball_1_3_4)

Randomly along route 2.

Space Lanes (cobraball_1_3_5)

Create a space lane with 2 asteroids as buoys marking the space lane to witchspace.

Rings (cobraball_1_3_6)

Install the rings oxp - provide a rings models only version. And place along the space lane. We'll go for every 10% of the station beacon route.

Customising Models

A New Paint Job

Give the Cobra Mark III a bright pink paint job.


This is a work in progress to be continued