Difference between revisions of "Rulesets (OpenXcom)"

From UFOpaedia
Jump to navigation Jump to search
(Added a (crappy) article to introduce rulesets to noobs)
 
m (→‎Modular Rulesets: ordering rulesets)
 
(131 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Rulesets are a way that OpenXcom exposes it's inner workings to users and modders in an easy to edit YAML text files. These text files have .rul or .dat extensions and contain 'rules' that describe a wide variety of the games behavior. Although rulesets can be edited with any text editor (like notepad) it is easier to use a YAML editor like Notepad++ because the information in a ruleset file isn't formatted, making it difficult to find a specific rule you might want to edit.
+
In OpenXcom a ruleset is an easy to edit text file that contains settings (rules) that describe almost everything about how the game operates. Here are just some of the things that are in the ruleset:
 +
*The costs, stats and characteristics of all items, units, facilities, X-COM craft and UFOs
 +
*Dependencies and costs for research, manufacture and UFOpedia
 +
*Your starting base
 +
*The costs of personnel and transfer time.
 +
*The stats of the funding countries and regions of the world.
  
----
+
You can find the rulesets in your ''Data\Ruleset'' folder.
  
__TOC__
+
==Editing Rulesets (YAML)==
 +
[[Image:OpenXcomNotepadYaml.png|right|thumb|Notepad++ Settings for editing OpenXcom YAML files]]
  
==Rules==
+
OpenXcom exposes its inner workings to users and modders in the form of [[:Wikipedia:YAML|YAML]] text files. Although YAML can be edited with any text editor, such as Notepad, it is much easier to use a dedicated YAML editor. YAML has a special syntax so any incorrect whitespace or character can cause an error, but it's a simple human-readable format so you should be able to figure it out by looking at the existing rulesets. Make sure you use UTF-8 encoding! (this is important for when you add strings and translations)
Each rule describes a single item in a list and various attributes pertaining to that item. A list of these items is a ruleset. For example there is a ruleset containing a list of all the facilities in the game. Each facility has a type(what building it is), cost to build, time to build in days, and several other bits of information. The entry with the type STR_GENERAL_STORES has an amount of storage space as an attribute, and hypothetically if you were to copy that attribute and value combination and paste it into the list of attributes for the facility type STR_LIVING_QUARTERS then when you play OpenXcom Living Quarters should give you 50 storage space. As long as you didn't remove the part of the living quarters rule that says living quarters give 50 people a place to sleep, the living quarters facility would fulfill the functions of both facilities.
 
  
==Viewing and Editing Rulesets (YAML)==
+
===Notepad++===
YAML is a data storage language designed to be very easy to read and edit both for a human with a text editor and for a computer. If you don't feel comfortable editing INI files you have almost no chance of editing a ruleset in something like notepad. Most code-literate people will prefere a YAML editor over notepad as well however.
+
You can open any rulesets (or savegame files) in Notepad++ and select Language>YAML. This will help you keep the proper tabbing structure and also allow you to collapse large regions. You can set Notepad++ to recognize *.rul, *.sav and *.cfg files as YAML file extensions under preferences so that you don't have to set the language every time you edit one of OpenXcom's files.
  
Assuming you're a nerd but haven't heard of YAML, just open any rulesets (or save files) in notepad++ and select Language>YAML. Or find another YAML editor (eclispe has a plugin).  
+
===Can't Notepad++?===
 +
Alternatively you could conjure up a Google search and look for YAML editors that are compatible with your OS. There are YAML plugins for both Visual Studio and Eclipse. Yedit for Eclipse is popular. There's also [http://yaml-online-parser.appspot.com/ online YAML validators].
  
OK, now that those nerdy weirdos are gone, go google Notepad++ and download and install it. You have to be on windows to use it but if you a Linux user and you don't know how to use Google to find your own YAML editor then something is very very wrong.
+
*Note: You should be able to collapse regions in whatever YAML editor you use. If not, you're in for a lot of scrolling as the files are quite large.  
  
Now, once it's installed go into the folder where you have OpenXcom installed and find the ruleset file 'Xcom1Ruleset.rul' in the Rulesets folder that's in the Data folder. Right click the file and select 'Edit with Notepad++'. Once it's opened hold your breath and click the 'Language' dropdown menu. It's OK, calm down, you don't need to worry about all those scary programing languages, just select the one at the bottom YAML.
+
==Your First Edit (Cheat)==
 +
# Open the ''Data\Ruleset\Xcom1Ruleset.rul'' file in your YAML editor.
 +
# Collapse everything (Alt-0 in Notepad++) and then open (uncollapse) the "facilities:" section.
 +
# Open "- type: STR_LIVING_QUARTERS"
 +
# change "personnel: 50" to "personnel: 500"
 +
# Congratulations! You can now have 500 personal per living quarters.
  
You can use the vertical bar on the left of the editor to collapse regions of the rulesets file that you aren't interested in. Just click the little grey triangle things by the names of stuff to expand or collapse a region.  
+
==A couple other examples==
 +
1. Fusion Ball Launcher balance update: Let's make something other than plasma cannons useful
 +
*change "craftWeapons:" -> "type: STR_FUSION_BALL_UC" -> "ammoMax: 2" to "ammoMax: 6"
 +
*change "craftWeapons:" -> "type: STR_PLASMA_BEAM_UC" -> "range: 52" to "range: 40" (just inside a terror-ships range)
 +
*set the range for Laser Cannons to 34 (same as large scout) and set Stingray and avalanche ranges even shorter
 +
:Now there's a reason to build Fusion-Ball Launchers - ''shoot down Battleships and Terrorships'', there's also a reason for Plasma Beams - <i>shoot down Supply Ships and Large Scouts without getting hit</i>, and a reason for Laser Cannons - ''shoot down Harvesters or Abductors safely and shoot down Large Scouts at equal range''.
  
(this part may change) At the very top off the file you will see where the facilities list starts followed by a list of facilities and various attributes about them. Locate the living quarters facility and change the number nest to "Personnel:" from 50 to however many people you think should actually be able to live in a living quarters (maybe 200). Congratulations, you have just modded OpenXcoms living quarters to hold more people, don't forget to save.
+
 
 +
2. Sectopod Buff: It's time to put the fear of Sectopod in those power-suit/hovertank squads that think Ethereal Terrorsites are some kind of joke!
 +
* "units:" -> "- type: STR_SECTOPOD_TERRORIST" -> "stats:" set TUs to 110, stamina to 125, Firing Accuracy to 100, Psi-Strength to 160 and health to 135.
 +
* Note the field "armor: SECTOPOD_ARMOR". So close "units:" and open "armors:" -> "type: SECTOPOD_ARMOR"
 +
* Set rear armor to 130 (a sectopod has a finely armored buttox, thankyou).
 +
* Open "damageModifier:" (its part of the armor) and find a "- 1.5" and a "- 0.8" just below it. These are the values for how much damage a unit wearing sectopod armor takes from laser(1.5x) and plasma(0.8x). Increase the laser bonus to 1.8 and reduce the plasma further to 0.65 (it's now actually worth it to bring laser weapons just for the sectopods)
 +
*Close "armors:" and open "items:" -> "type: SECTOPOD_WEAPON" and let's give it a good 145 weapon power. No need to adjust the weapon accuracy since we already increased the stat.
 +
:Now you can go back to having nightmares about Sectopods, just like you did when you were a young child who got in trouble for playing X-COM on the family computer after bed-time when you hadn't even done your homework.
 +
 
 +
 
 +
3. Early Blaster: The best time to have a Blaster Launcher is in the back of a Skyranger full of rookies.
 +
* Go to "items:" and pick anything that's purchasable. Copy the line with "costBuy:" and a number. Make sure you copy the tabs before "costBuy:". ''The best way to do this is to put the cursor at the end of the line above it, shift-down-arrow and shift-end to select the entire line and the line-break characters.''
 +
* Go to "type: STR_BLASTER_LAUNCHER" and add the "costBuy:" line. ''If the new line your adding doesn't look like the other lines in your YAML editor (like if it's red or black text instead of blue) then it's probably wrong and you probably have incorrect tab or line-break characters in it.''
 +
* Remove the section "required:"
 +
* Do those last two things for Blaster Bombs as well.
 +
* Open "startingBase:" -> "lon: 0.0" -> "items:" and replace "STR_CANNON" and "STR_CANNON_ROUNDS_X50" with "STR_BLASTER_BOMB" and "STR_BLASTER_LAUNCHER"
 +
* Finally if you want to be able to equip blasters to your squad and use them you will have to remove the tech requirement. Go back to "items:" and completely remove the section for tech requirements from both blasters and bombs.
 +
:Start a new game, load up blasters on your sky-ranger, and land by a medium scout. Now hit the side of the medium scout with one shot to make a hole, hit that silly glowy thing in the middle with the second shot. Voilà, that rookie killing death-trap is now just like a crash-site, except with even less live aliens inside.
 +
 
 +
== Modular Rulesets ==
 +
 
 +
However, editing the main ''Xcom1Ruleset.rul'' is bad practice, as your changes will be wiped by any new versions, and it makes it a pain to keep updating and combining different rulesets. Instead you should make it modular, by making your own ruleset file (saved in ''data\Ruleset'') with only the changes it makes to the base game, for example a ''BiggerQuarters.rul'':
 +
 
 +
facilities:
 +
  - type: STR_LIVING_QUARTERS
 +
    personnel: 500
 +
 
 +
Then to load your extra ruleset into the game, you just go in your ''[[Options (OpenXcom)|options.cfg]]'' file and add it like so:
 +
 
 +
rulesets:
 +
  - Xcom1Ruleset
 +
  - BiggerQuarters
 +
 
 +
Now when you start up the game, it'll automatically combine all the rulesets listed in the ''options.cfg''. Note that the order is important, as subsequent rulesets will modify the contents of previous ones (if the '''type''' is the same), so in this case ''BiggerQuarters'' will modify the STR_LIVING_QUARTERS of ''Xcom1Ruleset'', which is what you want. Normally you always want ''Xcom1Ruleset'' to come first.  Note that you can also specify the order of your rulesets when starting your game by selecting the rulesets in the order you would like to have them applied.
 +
 
 +
If you need to specifically erase a field, for example to clear requirements for something (like making an item or research available from the start of the game), you can use "" for an empty string, [] for an empty list and {} for an empty map. For example:
 +
 
 +
requires: []
 +
 
 +
If you want to remove an entire entry from a previous ruleset, you just need to specify "delete: STR_ID", for example:
 +
 
 +
facilities:
 +
  - delete: STR_LIVING_QUARTERS
 +
 
 +
But be careful, as this will break any saves already using that item. If you want people to be able to use your new ruleset on existing saves, it's safer to just disable it, like adding a requirement that can not be met. For example, if you want to make the Heavy Plasma unavailable for the player, you can add an otherwise non-existing research topic (for example "STR_ALIENS_ONLY", so it can be easily identified for later modifications...). this would have to be researched in order to use the weapon, but since it isn't defined anywhere else, it effectively disables the weapon for the player:
 +
 
 +
  - type: STR_HEAVY_PLASMA
 +
    requires:
 +
      - STR_ALIENS_ONLY
 +
 
 +
== See Also ==
 +
 
 +
* [[Ruleset Reference (OpenXcom)|Ruleset Reference]]
 +
* [http://openxcom.org/forum/index.php/board,8.0.html Modding forum]
 +
 
 +
[[Category:OpenXcom]]

Latest revision as of 22:53, 13 February 2015

In OpenXcom a ruleset is an easy to edit text file that contains settings (rules) that describe almost everything about how the game operates. Here are just some of the things that are in the ruleset:

  • The costs, stats and characteristics of all items, units, facilities, X-COM craft and UFOs
  • Dependencies and costs for research, manufacture and UFOpedia
  • Your starting base
  • The costs of personnel and transfer time.
  • The stats of the funding countries and regions of the world.

You can find the rulesets in your Data\Ruleset folder.

Editing Rulesets (YAML)

Notepad++ Settings for editing OpenXcom YAML files

OpenXcom exposes its inner workings to users and modders in the form of YAML text files. Although YAML can be edited with any text editor, such as Notepad, it is much easier to use a dedicated YAML editor. YAML has a special syntax so any incorrect whitespace or character can cause an error, but it's a simple human-readable format so you should be able to figure it out by looking at the existing rulesets. Make sure you use UTF-8 encoding! (this is important for when you add strings and translations)

Notepad++

You can open any rulesets (or savegame files) in Notepad++ and select Language>YAML. This will help you keep the proper tabbing structure and also allow you to collapse large regions. You can set Notepad++ to recognize *.rul, *.sav and *.cfg files as YAML file extensions under preferences so that you don't have to set the language every time you edit one of OpenXcom's files.

Can't Notepad++?

Alternatively you could conjure up a Google search and look for YAML editors that are compatible with your OS. There are YAML plugins for both Visual Studio and Eclipse. Yedit for Eclipse is popular. There's also online YAML validators.

  • Note: You should be able to collapse regions in whatever YAML editor you use. If not, you're in for a lot of scrolling as the files are quite large.

Your First Edit (Cheat)

  1. Open the Data\Ruleset\Xcom1Ruleset.rul file in your YAML editor.
  2. Collapse everything (Alt-0 in Notepad++) and then open (uncollapse) the "facilities:" section.
  3. Open "- type: STR_LIVING_QUARTERS"
  4. change "personnel: 50" to "personnel: 500"
  5. Congratulations! You can now have 500 personal per living quarters.

A couple other examples

1. Fusion Ball Launcher balance update: Let's make something other than plasma cannons useful

  • change "craftWeapons:" -> "type: STR_FUSION_BALL_UC" -> "ammoMax: 2" to "ammoMax: 6"
  • change "craftWeapons:" -> "type: STR_PLASMA_BEAM_UC" -> "range: 52" to "range: 40" (just inside a terror-ships range)
  • set the range for Laser Cannons to 34 (same as large scout) and set Stingray and avalanche ranges even shorter
Now there's a reason to build Fusion-Ball Launchers - shoot down Battleships and Terrorships, there's also a reason for Plasma Beams - shoot down Supply Ships and Large Scouts without getting hit, and a reason for Laser Cannons - shoot down Harvesters or Abductors safely and shoot down Large Scouts at equal range.


2. Sectopod Buff: It's time to put the fear of Sectopod in those power-suit/hovertank squads that think Ethereal Terrorsites are some kind of joke!

  • "units:" -> "- type: STR_SECTOPOD_TERRORIST" -> "stats:" set TUs to 110, stamina to 125, Firing Accuracy to 100, Psi-Strength to 160 and health to 135.
  • Note the field "armor: SECTOPOD_ARMOR". So close "units:" and open "armors:" -> "type: SECTOPOD_ARMOR"
  • Set rear armor to 130 (a sectopod has a finely armored buttox, thankyou).
  • Open "damageModifier:" (its part of the armor) and find a "- 1.5" and a "- 0.8" just below it. These are the values for how much damage a unit wearing sectopod armor takes from laser(1.5x) and plasma(0.8x). Increase the laser bonus to 1.8 and reduce the plasma further to 0.65 (it's now actually worth it to bring laser weapons just for the sectopods)
  • Close "armors:" and open "items:" -> "type: SECTOPOD_WEAPON" and let's give it a good 145 weapon power. No need to adjust the weapon accuracy since we already increased the stat.
Now you can go back to having nightmares about Sectopods, just like you did when you were a young child who got in trouble for playing X-COM on the family computer after bed-time when you hadn't even done your homework.


3. Early Blaster: The best time to have a Blaster Launcher is in the back of a Skyranger full of rookies.

  • Go to "items:" and pick anything that's purchasable. Copy the line with "costBuy:" and a number. Make sure you copy the tabs before "costBuy:". The best way to do this is to put the cursor at the end of the line above it, shift-down-arrow and shift-end to select the entire line and the line-break characters.
  • Go to "type: STR_BLASTER_LAUNCHER" and add the "costBuy:" line. If the new line your adding doesn't look like the other lines in your YAML editor (like if it's red or black text instead of blue) then it's probably wrong and you probably have incorrect tab or line-break characters in it.
  • Remove the section "required:"
  • Do those last two things for Blaster Bombs as well.
  • Open "startingBase:" -> "lon: 0.0" -> "items:" and replace "STR_CANNON" and "STR_CANNON_ROUNDS_X50" with "STR_BLASTER_BOMB" and "STR_BLASTER_LAUNCHER"
  • Finally if you want to be able to equip blasters to your squad and use them you will have to remove the tech requirement. Go back to "items:" and completely remove the section for tech requirements from both blasters and bombs.
Start a new game, load up blasters on your sky-ranger, and land by a medium scout. Now hit the side of the medium scout with one shot to make a hole, hit that silly glowy thing in the middle with the second shot. Voilà, that rookie killing death-trap is now just like a crash-site, except with even less live aliens inside.

Modular Rulesets

However, editing the main Xcom1Ruleset.rul is bad practice, as your changes will be wiped by any new versions, and it makes it a pain to keep updating and combining different rulesets. Instead you should make it modular, by making your own ruleset file (saved in data\Ruleset) with only the changes it makes to the base game, for example a BiggerQuarters.rul:

facilities:
  - type: STR_LIVING_QUARTERS
    personnel: 500

Then to load your extra ruleset into the game, you just go in your options.cfg file and add it like so:

rulesets:
  - Xcom1Ruleset
  - BiggerQuarters

Now when you start up the game, it'll automatically combine all the rulesets listed in the options.cfg. Note that the order is important, as subsequent rulesets will modify the contents of previous ones (if the type is the same), so in this case BiggerQuarters will modify the STR_LIVING_QUARTERS of Xcom1Ruleset, which is what you want. Normally you always want Xcom1Ruleset to come first. Note that you can also specify the order of your rulesets when starting your game by selecting the rulesets in the order you would like to have them applied.

If you need to specifically erase a field, for example to clear requirements for something (like making an item or research available from the start of the game), you can use "" for an empty string, [] for an empty list and {} for an empty map. For example:

requires: []

If you want to remove an entire entry from a previous ruleset, you just need to specify "delete: STR_ID", for example:

facilities:
  - delete: STR_LIVING_QUARTERS

But be careful, as this will break any saves already using that item. If you want people to be able to use your new ruleset on existing saves, it's safer to just disable it, like adding a requirement that can not be met. For example, if you want to make the Heavy Plasma unavailable for the player, you can add an otherwise non-existing research topic (for example "STR_ALIENS_ONLY", so it can be easily identified for later modifications...). this would have to be researched in order to use the weapon, but since it isn't defined anywhere else, it effectively disables the weapon for the player:

 - type: STR_HEAVY_PLASMA
   requires:
     - STR_ALIENS_ONLY

See Also