- UID
- 6679
- UCC
-
- 声望
-
- 好评
-
- 贡献
-
- 最后登录
- 1970-1-1
|
原帖:http://forum.egosoft.com/viewtopic.php?t=347831
作者:Observe
X Rebirth - Modding Guide
The following contains information that may be of interest to those involved in modding this game. The mod extension developed for this guide is available to download for those interested in following the examples given.
Note: It would be a massive understatement to say this guide barely scratches the surface of what can be done in modding this game! I will add and refine content to this guide as time permits.
----------------------------------------------------------------------------------
Installing Mods
Most of you will not be modding the game but simply use them.
The game's mod folder will be something like...
\Steam\steamapps\common\x_rebirth\extensions\
You probably have to create the "extensions" folder but then you can just drag and drop custom mod folders in there.
Just to verify, the end result would look like...
\Steam\steamapps\common\x_rebirth\extensions\AwesomeMod_v2\content.xml
That's it. Next time you launch the game, check if the new "extension" is enabled.
----------------------------------------------------------------------------------
Preface
Modding, as it relates to X Rebirth, means modifying the game by creating new or altered content. This guide focuses primarily on working with xml files to control various aspects of the game.
Mods for Rebirth are considered game extensions, and mod content goes in the \extensions directory. Available extensions are listed in the extensions sub-menu found in the Start Menu. Individual extensions can be activated or deactivated.
Possible mods can be as simple as changing specific game visuals (example highway tube color) to creating new additions to the universe map, to writing custom AI and/or Mission Director scripts.
Creating new models (meshes) for the game is beyond the scope of this guide, and will be covered separately.
Modding activities for X Rebirth fall into several general categories, including (but not limited to):
1. Materials and Effects
2. Universe (map)
3. Mission Director and AI Scripts
4. Model meshes (not covered here)
There are many Rebirth files that will be of interest to modders. Here are some important file locations:
\aiscripts - Contains script for controlling various aspects of AI (fight, move, mine, etc).
\extensions - This is where your distributed mods go
\index - components.xml and macros.xml. There are two important files that reference other files and locations.
\libraries - Files defining a variety of game elements.
\maps - Map files for Galaxy, clusters, Highways and zones
\md - Mission files using Mission Director
\t - Language files
Important:
To merge or not to merge - that is the question. Changes to the game (mods) must never alter the core game files. Otherwise, there is no way to separate multiple mods which may be affecting changes to common files. This means that all your changes must go in mod extension files and be applied in the correct manner.
When your mod is active, the game will examine your mod directory structure to see if your mod contains files located and named the same as those being used by the core game. If the game finds a "core" file in your mod, it will need to know what to do with the information.
Standard XML files are merged at one level below the root node, so your file should only contain the additional entries you want to introduce.
It is also possible to use a different XML file format in mods. This is known as patch format, and it uses the XML Patch standard to define changes to the base file. This is more powerful as it can directly modify the base XML document, adding, altering and removing nodes and attributes.
One common requirement is to change or replace a template or macro with your own. This is achieved by adding your own index entry for the required macro name (in an index file, the defined behavior is for later entries of the same name to replace earlier ones, and since the base file entries are loaded first your mod entry will overwrite whatever is in the base file) and redirecting it to a template or macro definition in your mod. From there you can change pretty much anything about the template or macro, including properties, meshes and so on.
Notes:
Please refer to the Appendix (link soon) for a description of the Component Model and the Universe Structure. It is important to have a basic understand of these concepts.
You may need to extract the core game files (cat/dat) to examine and better understand what you need to do to affect the changes you are interested in for your mod. This is accomplished by using the Egosoft XRCatTool.exe.
For sake of clarity, it has been pointed out, that the word "Cluster" used in this guide, may not be familiar to players; because in-game, the word used is "System". However, for the purpose of this guide, I use "Cluster", because that is how it is referred to in the various files that you will be working with as a modder.
Contents:
This guide demonstrates various methods that can be used to modify the game. For the purpose of "learning by doing", this guide is written in the form of a tutorial involving various examples of additions to the Universe map and other alterations.
Part One: Images and Effects
Example 1: Create a mod extension
Example 2: Change a material effect color
Example 3: Create a custom billboard advertisement
Part Two section A: Universe Editing
Example 4: Add a new cluster
Example 5: Add a new Sector
Example 6 Working with zones
Part Two section B: Universe Editing
Example 7: Highways and Super Highways
Example 8: Working with Regions
Example 9. Create a custom cluster background material
Example 10. Create a custom Planet texture material
Part Three: Bringing the Universe to life
Example 11: Working with Jobs (AI spawning)
Example 12: Working with Mission Director
Conclusion
Appendix
Suggested software and reference materials:
1. Visual Studio Express (free) or similar XML Editor.
2. Image Editor such as Photoshop (free CS2 version) with DDS Plug-in or Gimp (plugin here ).
3. 7-Zip File Manager (or other) for extracting core image files
4. Egosoft XRCatTool.exe for extracting core game data files (link soon)
5. Example mod extension developed for this guide (download here)
6. XML Patch document standard RFC 5261.
7. HHD Free Hex Editor (or equiv).
8. Official Mission Director Guide (link soon)
Examples
Part One: Extensions, Images and Effects
Example 1: Create a mod extension
Before we do anything else, we first need to establish a folder location for our mod files.
1. There is a game folder named extensions located off the game root directory. You may need to create this directory if it doesn't already exist.
2. Download the mod file osr_universe.rar containing the examples referred to throughout this guide and extract into the game extensions folder. Your directory structure will look like this:
Code:
X Rebirth
extensions
osr_universe
assets
index
libraries
maps
md
3. Open the content.xml file in the osr_universe directory with your xml editor. Here you will see various text fields for author, description and a few other things related to identifying your mod and providing information displayed in the extensions sub-menu of the game.
4. The most basic mod extension consists of a single mod directory and content.xml. Such a mod wouldn't actually do anything, but it would show in the menu and could be activated and deactivated there.
Example 2: Change a material effect color
Here we will change the default local highway tube color from yellow to blue.
1. Open the file material_library.xml located in extensions\osr_universe\libraries
2. If you have extracted the game data files (using XRCatTool.exe), you can open the core game material_library.xml for comparison with the one included in our example file.
3. In the core game file (not the example file), search for the string "highway_tube" in material_libary.xml. You will see the material definition for the highway tube effect. It looks something like this code snippet:
Code:
<material name="highway_tube" shader="shaderfx\high\XU_highway_tube.fx" blendmode="additive" preview="none">
<properties>
.....
<property type="Color" name="color_tint" r="180" g="200" b="120" a="255" value="(color 180 200 120)"></property>
......
</properties>
<variations></variations>
</material>
In this case, all I want to do is change the color-tint property of an existing material definition. If I wanted to create a new material, I could simple add a single new entry in my mod version of this file, and the game would find it appended at the end of the material_libary.xml definitions.
However, since I don't want to add or merge a new entry, I will use the "patch" method to modify the existing definition as follows (refer to XML Patch standard RFC 5261 to understand how this is done):
Code:
<diff>
<!-- Changes Tube Color from yellow to blue -->
<replace sel="/materiallibrary/collection[@name='effects']/material[@name='highway_tube']/properties/property[@name='color_tint']">
<property type="Color" name="color_tint" r="120" g="124" b="200" a="255" value="(color 33 13 98)"></property>
</replace>
</diff>
This new version of material_libary.xml differs from the standard file as follows:
a). Notice the <diff> root node. This instructs the game that I am applying some "difference" to the existing core definitions. Using <replace sel> we search for the values we are changing. In this case, we are changing the color_tint for this effect.
b). Our patch file contains ONLY the changes we are making . It does NOT include all the other entries (if it did, the game would get confused because of double entries).
Note: The original core game files should never be changed. All you are doing is creating modified versions and putting them in your extension folder/s.
The following image shows how this change looks in the game:
Example 3: Create a custom billboard advertisement
Let us see what is involved in replacing one of the existing billboard ads.
First, it is a good idea to extract the existing game textures associated with ads. This way, we can see which image we need to replace. Note: you will need to have the extracted game files available (XRCatTool.exe).
1. Identify one of the existing billboards that you want to replace.
2. Locate folder \assets\fx\textures\ads\ads
3. Extract all the .gz files into some directory for viewing
4. Using a command prompt, navigate to the extraction directory
5. Type the following command: rename *.* *.dds. This will give all the files their dds image extension (for that is what they are).
6. Using your dds capable image editor, locate and open the image that corresponds to the billboard ad you want to replace.
8. Create and save a new .dds image that exactly matches the size, channels, etc of the one you are replacing. In my example, I have named this image as: ads_osr_01.dds
9. Remove the .dds extension from your new image. Note: This isn't necessary, but I'm doing it to match the results of the extraction tool.
10. Using 7-Zip (or equivalent), create an archive with .gz extension containing your new image. Name this archive: ads_osr_01.gz. ] This file is located in \extensions\osr_reborn\assets\fx\textures\ads
11. Open the provided example file libraries\material_library.xml and notice the following:
Code:
<!-- Replace ads-plamacells with Observe Space Research advertisement -->
<replace sel="/materiallibrary/collection[@name='ads']/material[@name='ads_plasmacells']/properties/property[@name='diffuse_map']">
<property type="BitMap" name="diffuse_map" value="extensions\osr_universe\assets\fx\textures\ads\ads_osr_01"></property>
</replace>
Here I am replacing the normal definition for the plasma cell advertisement with one of my own specifying my custom image.
Note: If you don't want to replace all instances of the standard billboard image, you would need to create a custom billboard mesh (or modify the material reference in an existing mesh) and change the macro reference to use your mesh instead of the normal one. This technique will be used in a subsequent example.
Example custom billboard:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
|