Difference between revisions of "OXP tutorial"

From Elite Wiki
(New page: ==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 direc...)
 
m (Tidied up the formatting)
Line 17: Line 17:
 
Below is a blank template for a [[Property_list|Property list]]. For our purposes we need to use the header and footer below and don't need to understand them.
 
Below is a blank template for a [[Property_list|Property list]]. For our purposes we need to use the header and footer below and don't need to understand them.
   
<code>
+
<code><pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?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">
 
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Line 25: Line 25:
 
<!-- you can ignore the header and footer parts -->
 
<!-- you can ignore the header and footer parts -->
 
</plist>
 
</plist>
</code>
+
</pre></code>
   
 
Enough preamble - on with our first [[OXP]]. We are going to build a ship. It will be like the [[Cobra_Mk.3_(Oolite)|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.
 
Enough preamble - on with our first [[OXP]]. We are going to build a ship. It will be like the [[Cobra_Mk.3_(Oolite)|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.
   
<code>
+
<code><pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?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">
 
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs PropertyList-1.0.dtd">
Line 48: Line 48:
 
<!-- the end of the custom code and the start of the footer -->
 
<!-- the end of the custom code and the start of the footer -->
 
</plist>
 
</plist>
</code>
+
</pre></code>
   
 
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 the header and footer can get boring very quickly and add clutter I won't include them from here on. Unless I do.
Line 56: Line 56:
 
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:
 
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:
   
<code>
+
<code><pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?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">
 
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Line 64: Line 64:
 
</array>
 
</array>
 
</plist>
 
</plist>
</code>
+
</pre></code>
   
 
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.
 
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.
Line 74: Line 74:
 
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.pdata|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.pdata|here]].
   
<code>
+
<code><pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?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">
 
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Line 136: Line 136:
 
</dict>
 
</dict>
 
</plist>
 
</plist>
</code>
+
</pre></code>
   
 
This should all be straight forward but a useful reference for plist files can be found [[OXP_howto|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.
 
This should all be straight forward but a useful reference for plist files can be found [[OXP_howto|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.
Line 144: Line 144:
 
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.
 
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:
+
'''shipdata.plist:
<code>
+
<code><pre>
 
<dict>
 
<dict>
 
<key>cobraball_cobra_1_2</key>
 
<key>cobraball_cobra_1_2</key>
Line 177: Line 177:
 
</dict>
 
</dict>
 
</dict>
 
</dict>
</code>
+
</pre></code>
   
   
shipyard.plist:
+
'''shipyard.plist:
<code>
+
<code><pre>
 
<dict>
 
<dict>
 
<key>cobraball_cobra_1_2</key>
 
<key>cobraball_cobra_1_2</key>
Line 223: Line 223:
 
</dict>
 
</dict>
 
</dict>
 
</dict>
</code>
+
</pre></code>
   
 
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]].
 
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]].
Line 235: Line 235:
 
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:
 
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:
   
<code>
+
<code><pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?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">
 
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Line 258: Line 258:
 
</dict>
 
</dict>
 
</plist>
 
</plist>
</code>
+
</pre></code>
   
 
We have created a Fer-De-Lance that thinks it's a buoy. Lets have a look for one...
 
We have created a Fer-De-Lance that thinks it's a buoy. Lets have a look for one...

Revision as of 17:57, 26 September 2007

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">
  <!-- 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.

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>

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

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


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