Skip to content
TheChatArchiveThe Chat Archive
o1-preview-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

i'm thinking about trying to figure out how to mod the AI "intelligence" in crusader…

  1. User

    i'm thinking about trying to figure out how to mod the AI "intelligence" in crusader king 3 as well as try and balance the game so the human player doesnt have such a huge advantage by recruiting men at arms as they are able to lets say focus on them more efficiently and "outscale" the AI who might rely more on lower class levy or simple weak soldier numerical advantage. can you look at this info about modding and try to make a high level overview of how i can start thinking about this?

    Modding
    Jump to navigationJump to search
    This article is timeless and should be accurate for any version of the game.
    
    
    CK3 Modding #1 -Brief introduction to modding. Mr Samuel Streamer (former Roll1D2 Games) guide on useful tools and how-to mod beginner's guide.
    Modding, or creating mods, is the act of modifying the assets or behavior of the game either for personal use, or to release publicly to other players, for instance via Paradox Mods or the Steam Workshop.
    
    Crusader Kings III is moddable to a great extent and the goals of modders may vary: more events or decisions, better map and models, total conversions, accessibility, translations, etc.
    
    Modding CK3 doesn't require knowledge of any programming language and most of it can be done with a simple text editor. The game uses its own scripting language that is intended to be easy to use and learn. However, this puts some limits on what can be modded, compared to other games.
    
    Mods no longer disable achievements since 1.9 patch. Mods also don't invalidate ironman saves. In multiplayer, all players must use the same mods in the same load order.
    
    This article is a brief introduction to CK3 modding. To learn more, inspect game files and other mods, experiment on your own and join the modding discord.
    
    
    Contents
    1	Tips & guidelines
    1.1	Localization Files
    1.2	Launch options
    2	Creating a mod
    3	Uploading/updating a mod
    4	Installing mods manually
    4.1	Installing Forum mods
    4.2	Installing Paradox Mods
    5	Extracting files From Microsoft Store version
    6	Mod load order
    7	Troubleshooting
    7.1	A mod from Paradox Mods is broken
    7.2	The mod you uploaded to Steam doesn't work
    7.3	Mods stopped working
    7.4	Mods are conflicting
    7.4.1	Full file override
    7.4.2	Single object override
    7.4.3	Searching mod files
    8	Tools & utilities
    9	Save game editing
    9.1	Contents of the gamestate file
    10	Mods with wiki pages
    11	External links
    Tips & guidelines
    Start the game with -debug_mode -develop launch option to instantly reload files and use the console.
    On Steam: right-click the game on Steam -> Properties -> add -debug_mode -develop to Launch Options at the bottom
    Windows: Create a shortcut for the .exe file -> right-click it -> Properties -> add -debug_mode -develop at the end of the Target field
    Windows Xbox Game Pass: Open 'Command Prompt' and run 'start shell:AppsFolder\ParadoxInteractive.ProjectTitus_zfnrdv2de78ny!App -debug_mode -develop’
    Create a mod for your modifications: use a personal mod even for minor changes, and never directly modify the game files in the CK3 game folder as they may be overwritten without warning.
    Use a good text editor to edit files and search through folders. The following are free:
    Visual Studio Code. Has a fan-made CWTools extension with Paradox syntax highlighting, validation and tooltips for triggers and effects. To install it, use the link or go to Extensions on the left panel of VSC and search for CWTools. (Note: validation rules are incomplete and will show some false errors)
    Notepad++. Choose Perl as your language, as it will provide good highlighting and allow to fold blocks of code and comments. To set it as default, go to Settings, Styler Configurator, find Perl in the list on the left and add "gui txt" (without quotes) to the "User ext." field at the bottom.
    Atom. Doesn't include UTF-8-BOM encoding needed for localization files. Otherwise is very customizable. Choose Perl 6 (Raku) as your language for better results. To set it as default, go to File, Config, find "core:" and add below it: "customFileTypes: "source.perl6": [ "txt" "gui"]", like in this example.
    Sublime Text. There is an extension for it released by the developers of Imperator which could be used with CK3: Sublime Tools. It adds colored highlighting for effects and triggers. If you want to toggle comments in Sublime, you also need to add this file to the same "User" folder.
    Intellij IDEA. Has a fan-made Paradox Language Support plugin with Paradox syntax highlighting and validation. To install it, go to File -> Settings -> Plugins and search for "Paradox Language Support".
    Always check the error.log file for execution errors. Documents/Paradox Interactive/Crusader Kings III/logs/error.log
    The log folder also contains lists of effects, triggers and scopes. Use script_docs and dump_data_types console commands in the game to generate them.
    The directory for the CK3 folder on Linux is ~/.local/share/Paradox Interactive/Crusader Kings III
    Communicate key facts about your mod:
    List the main changes and additions at the top of the description. To help with compatibility, you may add a list of changed files at the bottom.
    Provide links to your mod on other platforms (Workshop, Paradox Mods, forums).
    When possible, upload your mod to all platforms, especially if it is popular. Not everybody owns the game on Steam.
    Backup your work. Either manually or with a source control system like Git. Consider using GitHub and Discord for team collaboration.
    Remove your local copy of the mod when you subscribe to the Steam version, otherwise it will not work in the game. (removing the .mod file or changing its extension is enough)
    Use a proper merge tool (like WinMerge) to merge between folders and update modified files for a new patch.
    If you're replacing text across dozens or hundreds lines of code, regular expressions may save a lot of time. They are available in all of the text editors above. Learning resources: RegexOne, RegExr.
    Win+V opens your clipboard history. You'll be copying a lot of text while modding, and this lets you access older copied entries without going back to their source.
    Join CK3 Modding discord to ask any questions and help others
    The Modding Git Guide is a community made guide for using Git, GitHub/GitLab, and related tools such as KDiff3. It can be a useful stop for questions beyond this wiki, and contains step by step guides for much of what is talked about here. Though the examples are HOI4 based, the principles apply equally well to any Paradox game mod.
    Localization Files
    *.yml files in the localization folder must be saved with UTF-8 + BOM encoding to be read properly by the game.
    filenames need to be saved in the form as *l_<language>.yml for the game to read the file correctly. For example council_l_english.yml.
    You must use the US spelling of "localization". The Commonwealth spelling of "localisation" will not work.
    Note, l_ is a lower case L, as in language, not capital i.
    To overwrite existing localization values, put your files with changes into a folder named "replace" within the localization folder.
    If a mod only has English localization, any player using a different language will see unlocalized strings_like_this. It is better to copy your localization for other languages, even if you don't provide a translation. Modding discord has a tool to copy all the files and rename their language markers in one click.
    Launch options
    -debug_mode - enables dev tooltips and interactions
    
    -develop - enables hot reload of most files
    
    -mapeditor - opens the map editor
    
    -debug_controller_camera - adds support for controlling camera with a controller (before 1.9 it was -handle_controller_input)
    
    -nographics - launches the game without creating a window or rendering anything and starts an observer game
    
    -random_seed=42 - launches the game with a fixed RNG seed (in this example 42), works only in combination with -debug_mode
    
    -benchmark - runs an automated test for 1.5 years, moving the camera around and opening various windows. Outputs timer_dump logs showing how much time each tick took to process (convert them to tables and make graphs to analyze)
    
    -continuelastsave - can be used in a shortcut to ck3.exe to automatically load the last save, same as pressing Resume in the launcher
    
    Creating a mod
    Main article: Mod structure#Creating initial files
    It is recommended to use the game launcher to create initial mod files:
    
    Open the game launcher.
    Go to All Installed Mods on the left.
    Press Upload Mod in the top right.
    Press Create a Mod.
    Enter a name, version of the mod (not the game), directory (the launcher will create it) and at least one tag. All of these must be completed before you can press Create at the bottom.
    (Name must be at least 3 symbols long. DIrectory can include spaces, but cannot end with one.)
    After this, copy the game files you want to edit to the created mod folder, following the same folder structure. For example, mod/my_new_mod/events/test_events.txt
    
    Uploading/updating a mod
    Uploading and updating follows the same process:
    
    Open the game launcher.
    Go to All Installed Mods on the left.
    Press Upload Mod in the top right.
    Choose your mod from the dropdown menu.
    Choose what platform to upload it to.
    Enter any description. (If updating, make sure the launcher copied the most recent one from the site.)
    Add a thumbnail
    For the Steam Workshop, put thumbnail.png in the mod folder. Use 1:1 ratio, 1MB max. The biggest thumbnail the Workshop displays is around 600x600 pixels.
    For Paradox Mods, drag the thumbnail to the field below the description. Suggested minimum size is 900x500, png or jpg, 1MB max.
    Press "Upload".
    On Steam, the mod will be uploaded in private mode and appear in your Steam Profile -> Workshop Items. Open it and change visibility on the side bar to Public to actually publish.
    On Paradox Mods the mod will be published after the verification process. You may need to edit your description, as the site usually removes line breaks and BBCode formatting.
    Installing mods manually
    Mods are installed to your Documents/Paradox Interactive/Crusader Kings III/mod folder in Windows or ~/.local/share/Paradox Interactive/Crusader Kings III/mod/ in Linux.
    
    Every mod in it must have a .mod file and a folder. (For example, "Nameplates.mod" and "nameplates" folder)
    
    Note that the individual mod folder doesn't need to be in the main CK3 mod folder, only the .mod file is required to be here. You can just edit the .mod file to point at a new mod folder path. (As in change the line path="mod/my mod" to for example path="C:/Local_Documents/CK3_mods/my mod") This is very helpful if your OneDrive is getting full, and you don't want to pay for more space.
    
    Installing Forum mods
    Modders will usually zip both the .mod file and the mod folder. In this case, you only need to unpack the zip file directly to your "mod" directory. If instead you see descriptor.mod and a number of other folders, continue to the next section:
    
    Installing Paradox Mods
    Mods downloaded from Paradox Mods only have the contents of the mod folder and require the following:
    
    Create a new folder in your "mod" directory. Give it any name, like "my mod".
    Unzip the downloaded mod directly to this new folder.
    Copy descriptor.mod from it and paste to your "mod" folder.
    Rename the copied descriptor file to anything.
    Open it with a text editor and add a line path="mod/my mod" (where "my mod" is the name of the folder you created). Save the file.
    After this, you should be able to add this mod in the launcher.
    If this didn't work, you can try to create a new mod from the launcher and then copy the downloaded files to its folder (excluding descriptor.mod).
    
    Extracting files From Microsoft Store version
    If you want to read the files using the Microsoft Store version, you can use a program called UWPDumper to extract the files.
    
    Download the latest x64 binary of UWPDumper
    Enable Developer Mode (Windows Settings -> Update and Security -> For Developers -> Developer Mode).
    Run CK3.
    Run UWPInjector.exe from the program you just downloaded.
    Enter the number next to ck3.exe : ParadoxInteractive.ProjectTitus_zfnrdv2de78ny as the processID.
    Check where it is going to store the files (probably somewhere like C:\Users\%USERPROFILE%\AppData\Local\Packages\ParadoxInteractive.ProjectTitus_zfnrdv2de78ny\TempState\DUMP
    Wait for the program to finish.
    The files should then be present in the directory specified earlier. If you want to edit the files, create a mod and copy the desired files there.
    
    Mod load order
    Load order only matters when two or more mods change the same files, this is called a mod conflict.
    
    Mods are loaded in order from top to bottom of the playset.
    
    The mod lower in the playset will overwrite identical files from above.
    
    So if you want to make sure that a mod is not overwritten by anything, put it at the very bottom of the playset.
    
    Always read mod description. Modders will often list what files they change and what compatibility issues might arise with other mods.
    
    Some popular mods have compatches that merge conflicting files together and let players use both mods. The compatch mod is loaded after the other two mods.
    
    Otherwise, load order doesn't impact anything.
    
    Troubleshooting
    A mod from Paradox Mods is broken
    Currently, there is a bug when adding mods from the Paradox Mods website. If a mod adds new files, the game completely ignores them.
    
    To fix it, remove the mod from the playset, download it and install manually, following these steps.
    
    The mod you uploaded to Steam doesn't work
    Make sure that you only use one version of the mod: either from Steam Workshop or your local copy. Unsubscribe or remove the other one. Otherwise, even if one if them is disabled, the game will be confused and may not load the mod at all.
    
    Mods stopped working
    For unknown reasons, mods sometime stop working. There are two ways to solve this:
    
    Reload from the launcher:
    Open the launcher
    Go to All Installed Mods on the left
    Press Reload Mods in the top right and Reload (Clearing cache doesn't seem to be necessary)
    Go to Playsets. The mod should have a warning saying the files aren't present on disk. Remove it from the playset.
    Close the launcher
    Resubscribe to the mod.
    Open the launcher and add the mod back again.
    If nothing helps, delete the following files if they are present and restart the launcher:
    Documents/Paradox Interactive/Crusader Kings III/mods_registry.json
    Documents/Paradox Interactive/Crusader Kings III/launcher-v2.sqlite
    Mods are conflicting
    If several mods modify the same vanilla files or vanilla objects, they cause conflicts: only one version of an object is loaded, and either of the two mods might not be working properly.
    
    There are two different rules that govern what is actually loaded in the game on launch:
    
    Full file override
    When a mod has the same file as vanilla (identical path + identical filename), the mod's file replaces the vanilla file.
    
    When two mods have the same file (identical path + identical filename), the file of the mod that is lower in the load order is loaded.
    
    Single object override
    If the same object is defined in two different files (either in vanilla and a mod, in two different mods, or even twice in the same mod), the game loads the object's version from the file last in alphabetical order (with the exception of gui types and templates, there it's the opposite). Those replacements are logged in Documents/Paradox Interactive/Crusader Kings III/logs/database_conflicts.log
    
    When doing single object override, it is a good idea to prefix your files with your mod's name, so you can easily spot in database_conflicts.log whether it is your mod's version of an object that was loaded.
    
    Searching mod files
    To easily track which mod is causing an incompatibility issue, you can find them easily if you have a good text editor. For example, in Visual Studio Code, you can set-up a workspace that includes the files from all mods you subscribed to, so you can easily search through them. If you are using Steam, that folder is likelyC:\Program Files (x86)\Steam\steamapps\workshop\content
    
    Search for the key of the object that seems to be causing a conflict across all subbed mods at the same time, to figure out which mod is the source of the conflict.
    
    Tools & utilities
    Exporters (Maya and Photoshop)
    Community-made modding tools
    Clausewitz Maya Exporter: a tool to create and export 3D models to use in CK3 and other Clausewitz games.
    UWPDumper: a tool to extract files from Microsoft Store games.
    CK3 triggers, modifiers, effects, event scopes, event targets, on actions, code revisions and setup.log: List of valid inputs for most game versions since launch. Use GitHub file history feature to compare_versions.
    Save game editing
    > This doesn't seem to work anymore
    
    Save files are located in:
    
    Windows: Documents\Paradox Interactive\Crusader Kings III\save games
    Linux: ~/.local/share/Paradox Interactive/Crusader Kings III/save games
    First start the game in the debug mode and save. If it's an ironman game, exit to menu to autosave.
    
    On Steam: right-click the game on Steam -> Properties -> add -debug_mode to Launch Options at the bottom
    Windows: Create a shortcut for the .exe file -> right-click it -> Properties -> add -debug_mode at the end of the Target field
    PC:
    
    Find the save file in the save games folder.
    If it was an autosave, skip to the next step. Else:
    Right-click the save file and extract it like an archive with 7-Zip or WinRar
    Rename the extracted 'gamestate' file to have a .ck3 extension.
    Right-click it and open with a text editor (Windows Notepad is not recommended as the save files are very big).
    Edit the file and save it.
    To remove ironman status, search for "ironman=yes" and change it to "no"
    Load it in the game.
    
    Mac:
    
    Open Terminal
    Ensure that the directory is set to the correct folder
    Type in "unzip FileName.ck3"
    Rename the extracted 'gamestate' file to something with a .ck3 extension
    Edit this plain-text save
    Load it directly in the game (no need to re-compress)
    OS	Save type	Location
    Windows	Local	C:\Users\%USERPROFILE%\Documents\Paradox Interactive\Crusader Kings III\save games
    Windows	Steam Cloud	C:\Program Files (x86)\Steam\userdata\####\1158310\remote\save games
    Mac	Local	$HOME/Documents/Paradox Interactive/Crusader Kings III/save games
    Linux	Local	$HOME/.local/share/Paradox Interactive/Crusader Kings III/save games
    Contents of the gamestate file
    The table below contains the possible first-level blocks in the gamestate file. Entries are provided in order of appearance.
    
  2. Assistant

    Absolutely! Let's break down how you can start thinking about modding Crusader Kings III (CK3) to adjust the AI's use of Men-at-Arms and balance the game to reduce the human player's advantage.

    1. Understanding Your Modding Goal

    Your objective is to modify the AI behavior so that it utilizes Men-at-Arms more effectively, matching the human player's ability to 'outscale' through efficient recruitment. This involves:

    • Analyzing AI Recruitment Strategies: Determine how the AI currently prioritizes unit recruitment, particularly Men-at-Arms versus levies.
    • Adjusting AI Decision-Making: Modify the AI scripts to encourage better investment in Men-at-Arms.
    • Balancing Gameplay Mechanics: Ensure that changes don't unbalance other aspects of the game.

    2. Familiarize Yourself with CK3 Modding Basics

    Before diving into AI behavior, it's crucial to understand the fundamentals of CK3 modding:

    • Modding Language: CK3 uses a proprietary scripting language that's relatively easy to learn.
    • File Structure: Mods mirror the game’s directory structure, and changes are made by overriding or adding files.
    • Tools Needed:
      • Text Editor: Visual Studio Code is recommended, along with the CWTools extension for syntax highlighting and validation.
      • Debugging Tools: Use the game's -debug_mode and -develop launch options for testing and hot-reloading changes.
      • Modding Resources: Refer to the CK3 Modding Discord and community guides for support.

    3. Setting Up Your Mod Environment

    a. Enable Debug Mode

    This will allow you to test your changes in real-time and use the console for advanced functions.

    • Steam Users: Right-click CK3 in your library > Properties > General > Launch Options: -debug_mode -develop.
    • Non-Steam Users: Modify the game shortcut by adding -debug_mode -develop at the end of the target field.

    b. Create a New Mod

    Use the CK3 Launcher to create a mod:

    1. Open the CK3 Launcher.
    2. Go to All Installed Mods > Upload Mod > Create a Mod.
    3. Fill in the required details: Name, Version, Directory, Tags.
    4. This creates a basic mod structure in your documents folder.

    4. Identifying AI Behavior Files

    To modify AI behavior, you'll need to locate the relevant game files:

    • AI Behavior Scripts: Generally found in the common/ai_behavior and common/ai_vassalage directories.
    • AI Strategies and Personalities: Located in common/ai_personalities and common/ai_strategies.

    5. Modifying AI Recruitment Behavior

    a. Analyze Current AI Scripts

    • Open the AI behavior files to understand existing decision-making processes. Look for scripts related to military recruitment and resource allocation.
    • Identify variables and triggers that dictate when and how the AI recruits Men-at-Arms.

    b. Adjust Recruitment Priorities

    • Increase AI Emphasis on Men-at-Arms:
      • Modify the weights and conditions that influence the AI's preference for recruiting Men-at-Arms.
      • Adjust economic thresholds to ensure the AI has the funds to maintain these units.
    • Balance with Levies:
      • Ensure that changes don't cause the AI to neglect levies entirely, which could create new imbalance issues.

    c. Test Incrementally

    • After making changes, use the -develop mode to hot-reload the scripts.
    • Observe AI behavior in-game to see if it's recruiting and utilizing Men-at-Arms more effectively.
    • Make further adjustments based on observations.

    6. Balancing the Game

    a. Review Game Mechanics

    • Understand how Men-at-Arms interact with other game systems, such as economy, technologies, and cultural innovations.
    • Ensure that increasing AI competence doesn't unintentionally overpower them.

    b. Adjust Related Systems if Necessary

    • Economic Adjustments: Modify AI economic behaviors to support increased military expenditures.
    • Technological Progression: Ensure the AI researches appropriate military technologies.

    7. Testing and Iteration

    • Simulate Different Scenarios: Play or observe games across various start dates and difficulties to test AI performance.
    • Check for Unintended Consequences: Monitor for any negative impacts on game balance or AI competitiveness.
    • Seek Feedback: If you plan to share your mod, early feedback from other players can be invaluable.

    8. Utilizing Modding Best Practices

    a. Maintain a Clean Mod Structure

    • Mirror the game's directory structure in your mod folder.
    • Only include files that you've modified to reduce conflicts.

    b. Document Your Changes

    • Keep track of all modifications for future reference or updates.
    • Comment within scripts to explain the purpose of changes.

    c. Compatibility Considerations

    • Be mindful of potential conflicts with other mods, especially those that also alter AI behavior.
    • Use unique file names or prefixes where possible.

    9. Finalizing and Sharing Your Mod

    a. Test Thoroughly

    • Ensure your mod is stable and achieves your desired outcomes.

    b. Add Descriptions and Tags

    • Clearly describe what your mod does and any compatibility notes.

    c. Uploading Your Mod

    • Use the CK3 Launcher to upload your mod to platforms like Steam Workshop or Paradox Mods.
    • Follow the guidelines for including thumbnails and setting visibility.

    Additional Tips

    • Consult the Logs: Check error.log and database_conflicts.log for any issues.
    • Backup Your Work: Regularly save copies of your mod progress.
    • Stay Updated: Keep an eye on game updates that might affect mod compatibility.

    Resources for Further Learning

    • CK3 Modding Wiki: Provides detailed explanations of modding concepts.
    • Modding Discord: Join the community for advice and collaboration.
    • Paradox Forums: Participate in discussions and access additional guides.

    Conclusion

    Starting to mod CK3 to adjust AI intelligence involves:

    • Understanding the game's scripting and AI behavior files.
    • Setting up a proper modding environment with the necessary tools.
    • Carefully modifying AI scripts to enhance their recruitment strategies.
    • Testing your changes thoroughly to ensure balance and stability.

    By taking a methodical approach and utilizing available resources, you'll be able to develop a mod that enhances the AI's use of Men-at-Arms and creates a more balanced gameplay experience.