Worms 4 Tweaking

Le tweaking ou comment créer ses armes au delà de l'usine d'armes
 
AccueilPortailFAQRechercherS'enregistrerMembresGroupesConnexion

Partagez | 
 

 3 - Understanding XOM

Aller en bas 
AuteurMessage
_Kilburn
Admin
avatar

Nombre de messages : 1133
Age : 26
Localisation : data\\Tweak\\
Date d'inscription : 25/05/2006

MessageSujet: 3 - Understanding XOM   Mar 1 Jan - 22:47

XOM (XML object model) is the syntax used for the tweak files. You can skip this tutorial, but it is highly recommended that you read it, so you can understand tweaking a lot more. It may be hard to understand, but try to read, it's really worth it.

Open a tweak file (WeapTwk.xml will do nicely) and follow the structure as you read this tutorial.

What is the structure of a tweak file?

A tweak file always starts with
Code:
<?xml version="1.0"?>
<xomArchive>
  <xomObjects>
and ends with
Code:
  </xomObjects>
</xomArchive>

Between <xomObjects> and </xomObjects>, you are most likely to find a long sequence of object definitions.

What is an object?

In XOM, an object is simply something that can have properties and can be duplicated several times. For example, the Bazooka weapon is an object : it has different properties (its appearance, the damage inflicted by its projectile, etc...).

A class is a base for making objects. It defines the properties that the objects created from this class would have. Classes are defined in the game engine, thus, you can't define your own class, or modify a class.

Any objects that have the same class have the exact same properties, with different values, but perform approximatively the same action (depending on the values of their properties).

Here is how an object is defined:

Code:
<Classname id="name">
  <Property1>Value1</Property1>
  <Property2>Value2</Property2>
  <Property3>Value3</Property3>
</Classname>

Each object has a different ID (a name, if you prefer), so the game can make the difference between several objects from the same class, and so you can access to them later.

Sometimes, when a few properties are numerical values or strings (=text), they can be transfered next to the class name in the object definition.

Code:
<Classname id="name" Property3=Value3>
  <Property1>Value1</Property1>
  <Property2>Value2</Property2>
</Classname>

When the value of a property must be an object with few properties (here, prop1, prop2, prop3...):

Code:
<Classname id="name" Property3=Value3>
  <Property1 prop1=val1 prop2=val2 prop3=val3...></Property1>
</Classname>

Note that <Property></Property> and <Property /> are the exact same thing. The second syntax is more easy to write when you have nothing between > and <.


For bigger objects that have too many properties, an invidiual object should be defined, and have its ID given to the property like this:

Code:
<Classname1 id="name1">
  <Property href="name2" />
</Classname1>
<Classname2 id="name2">
  <Property1>Value1</Property1>
  <Property2>Value2</Property2>
  ...
</Classname2>

Here, the value of Property in object "name1" is equal to the object "name2". The keyword "href" is massively used in tweak files, thus, do not forget what it means.

Main classes found in tweaks

First, you will always find a XDataBank object with the name "id-0", in any tweak file. This object tells the game what objects it should load. It has a first "Section" property, with the value 0. Never change it.

Then, you will find a long sequence with properties that have the same name ("IntResources", "ContainerResources", etc...). These contain the resource objects to load. There are 7 different classes of resource objects :

XIntResourceDetails : Stores an integer value (between -2147483647 and 2147483647).
XUintResourceDetails : Stores an unsigned (=positive) integer value (between 0 and 4294967295).
XFloatResourceDetails : Stores a floating point value (decimal value, if you prefer)
XStringResourceDetails : Stores a string value (=text data)
XVectorResourceDetails : Stores a 3D vector (x,y,z)
XColorResourceDetails : Stores a color (R,G,B,A)
XContainerResourceDetails : Stores any object

All of these classes have the same properties:

Value : Contains the value to be stored.
For vectors, you should give an object with x, y and z properties. For example :
Code:
<Value x="20" y="30" z="40" />

For colours, you should give an object with r, g, b, and a properties (each are integers between 0 and 255. r is the Red component, g is the Green component, b is the Blue component, and a is the Alpha component, which defines the opacity of the colour (255 is opaque, 0 is completely transparent). For example:
Code:
<Value r="255" g="0" b="30" a="255" />

For object containers, you should use "href" to make a reference to the object you want to be stored.

Name : Name of the object
Should be the same string as the ID of your resource object.

Flags : The effect of this value is unknown for now, so you should not change it. It is usually 81 for container resources, and 64 for any other resource type.

Indeed, a XIntResourceDetails object should go in the IntResources of a XDatabank, a XUintResourceDetails object should go in the UintResources of a XDatabank, and so on...

The XDatabank object is followed by the X...ResourceDetails objects. Note that XContainerResourceDetails objects are always followed by the objects they have to store. Note that this object has the ID of the resource object, followed by "-0". For example, if a container resource object has the ID "Hello", then the object it has to store will have the ID "Hello-0".
It is just a naming convention, you can decide not to follow it if you want.


Remember to create a container resource object for each new object you will create, and add this object in the XDatabank.


Tutorial written by _Kilburn

_________________
Windows did not detect any keyboard. Press Enter to continue...
Revenir en haut Aller en bas
Voir le profil de l'utilisateur http://w4-tweaking.bb-fr.com
 
3 - Understanding XOM
Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Worms 4 Tweaking :: ENGLISH Section :: ENGLISH Section :: Tweaking Tutorials and Support :: Tweaking Basics Tutorial-
Sauter vers: