Rules.ini: Difference between revisions
m →Python 3: debug |
|||
Line 42: | Line 42: | ||
;ReadRulesCode.py | ;ReadRulesCode.py | ||
{| | {| | ||
|style="text-align:right; line-height:1.3em;"|1<br/>2<br/>3<br/>4<br/>5<br/>6<br/>7<br/>8<br/>9<br/>10<br/>11<br/>12<br/>13<br/>14<br/>15<br/>16<br/>17<br/>18<br/>19<br/>20<br/>21<br/>22<br/>23<br/>24<br/>25<br/>26<br/>27<br/>28<br/>29<br/>30<br/>31<br/>32<br/>33<br/>34<br/>35<br/>36<br/>37<br/>38<br/>39<br/>40<br/>41<br/>42<br/>43<br/>44<br/>45<br/>46<br/>47<br/>48<br/>49<br/>50<br/>51<br/>52<br/>53<br/>54<br/>55<br/>56<br/>57<br/>58<br/>59<br/>60<br/>61<br/>62<br/>63<br/>64<br/>65<br/>66<br/>67<br/>68<br/>69<br/>70<br/>71<br/>72<br/>73<br/>74 | | style="text-align:right; line-height:1.3em;" |1<br/>2<br/>3<br/>4<br/>5<br/>6<br/>7<br/>8<br/>9<br/>10<br/>11<br/>12<br/>13<br/>14<br/>15<br/>16<br/>17<br/>18<br/>19<br/>20<br/>21<br/>22<br/>23<br/>24<br/>25<br/>26<br/>27<br/>28<br/>29<br/>30<br/>31<br/>32<br/>33<br/>34<br/>35<br/>36<br/>37<br/>38<br/>39<br/>40<br/>41<br/>42<br/>43<br/>44<br/>45<br/>46<br/>47<br/>48<br/>49<br/>50<br/>51<br/>52<br/>53<br/>54<br/>55<br/>56<br/>57<br/>58<br/>59<br/>60<br/>61<br/>62<br/>63<br/>64<br/>65<br/>66<br/>67<br/>68<br/>69<br/>70<br/>71<br/>72<br/>73<br/>74<br/>75<br/>76<br/>77 | ||
| | | | ||
<div style="line-height:1.3em;"> | <div style="line-height:1.3em;"> | ||
Line 54: | Line 54: | ||
# set the directory of CSF.ini that decoded by ReadCsf.py | # set the directory of CSF.ini that decoded by ReadCsf.py | ||
csf_ini_dir=r"C:\Users\August\Documents\CSF.ini" | csf_ini_dir=r"C:\Users\August\Documents\CSF.ini" | ||
# csf_ini_dir=r"/storage/emulated/0/1/CSF.ini"<br/> | # csf_ini_dir=r"/storage/emulated/0/1/CSF/CSF.ini"<br/> | ||
from configparser import ConfigParser | from configparser import ConfigParser | ||
import os | import os | ||
Line 61: | Line 61: | ||
rules.read(rules_dir) | rules.read(rules_dir) | ||
# read CSF.ini if it exists | # read CSF.ini if it exists | ||
csf_exist=False | |||
if os.path.isfile(csf_ini_dir): | if os.path.isfile(csf_ini_dir): | ||
csf=ConfigParser(delimiters="=") | csf=ConfigParser(delimiters="=") | ||
csf.read(csf_ini_dir, "UTF-8") | csf.read(csf_ini_dir, "UTF-8") | ||
csf_exist=True | |||
# sections of unit types | # sections of unit types | ||
type_list=["InfantryTypes", "VehicleTypes", "AircraftTypes", "BuildingTypes", "SuperWeaponTypes"] | type_list=["InfantryTypes", "VehicleTypes", "AircraftTypes", "BuildingTypes", "SuperWeaponTypes"] | ||
Line 97: | Line 99: | ||
elif rules.has_option(idcode, attr): | elif rules.has_option(idcode, attr): | ||
# try to translate UIName by CSF if the CSF exists | # try to translate UIName by CSF if the CSF exists | ||
if attr=="UIName" and | if attr=="UIName" and csf_exist: | ||
# browse the CSF for UIName by order | # browse the CSF for UIName by order | ||
UIName="N/A" | |||
for section in csf: | for section in csf: | ||
if csf.has_option(section, rules[idcode][attr]): | if csf.has_option(section, rules[idcode][attr]): |
Revision as of 10:50, 14 February 2024
The rules.ini (naming variations for expansions) is the core file of C&C modding. As indicated by the name, it contains the "rules" of the game – the properties of every object, weapon, warhead, etc. in the game. For any C&C game from Red Alert to Yuri's Revenge, this is the main modification file. For Generals and everything else based on the SAGE engine, the INI-system is more complex and wide-spread.
Disregarding the side functions of the other various INI files (like ai.ini or art.ini), there is no way to make any changes to the game other than what the rules.ini allows for1. Not everything in the game is customizable. Features that cannot be modified are called "hardcoded" features.
File Locations
Game | Location | Notes |
---|---|---|
Red Alert | redalert.mix → local.mix | |
Tiberian Sun | tibsun.mix → local.mix | The patches add a new rules.ini to patch.mix |
Firestorm | expand01.mix | rules-equivalent is called firestrm.ini, the mix also contains a new rules.ini for regular TS. |
Red Alert 2 | ra2.mix → local.mix | |
Yuri's Revenge | expandmd01.mix | Called rulesmd.ini, for mission disk. |
Mental Omega | expandmo99.mix | Called rulesmo.ini, for Mental Omega. |
Script to Read UnitsIdCode in Rules.ini
Python 3
This script will read the rules.ini and list the UnitType, SequenceNum, UnitIdCode, UnitUIName, UnitInternalName and Armor, and store these informations into a txt file.
To get the CSF.ini that required in this script, please go to page CSF File Format.
- ReadRulesCode.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# set the directory of rules.ini here # need to modify the rules.ini if there are any error reports during reading it by module configparser rules_dir=r"C:\Users\August\Documents\rulesmo_mod.ini" # rules_dir=r"/storage/emulated/0/1/rulesmo_mod.ini" # set the output file directory ofdir=r"C:\Users\August\Documents\UnitCodes.txt" # ofdir=r"/storage/emulated/0/1/UnitCodes.txt" # set the directory of CSF.ini that decoded by ReadCsf.py csf_ini_dir=r"C:\Users\August\Documents\CSF.ini" # csf_ini_dir=r"/storage/emulated/0/1/CSF/CSF.ini" |
Footnotes
1 ↑ An exception to this would be pd's RockPatch.
See Also
- Art.ini
- Sound.ini
- CSF
- Hardcoded features
- Rules(md).ini Sections
- Rules(md).ini Flags
- Lists of Applicable INI Flags