1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
vcmi/docs/modders
Ivan Savenko 6056d385ed Always load json configs from mod that references it
This should fix rather common problem with mods, where two unrelated mods
accidentally use same file name for a config file, leading to very unclear
conflict since this result in a file override.

Now all config files referenced in mod.json are loaded specifically from
filesystem of mod that referenced it. In other words, it is no longer
possible for one mod to override config from another mod.

As a side effect, this allows mods to use shorter directory layout, e.g.
`config/modName/xxx.json` can now be safely replaced with `config/
xxx.json` without fear of broken mod if there is another mod with same
path to config. Similarly, now all mods can use `config/translation/
language.json` scheme for translation files

Since this is no longer a problem, I've also simplified directory layout
of our built-in 'vcmi' mod, by moving all files from `config/vcmi`
directory directly to `config` directory.

- Overrides for miscellaneous configs like mainmenu.json should works as
before
- Images / animations (png's or def's) work as before (and may still
result in confict)
- Rebalance mods work as before and can modify another mod via standard
`modName:objectName` syntax
2024-10-31 14:49:11 +00:00
..
Bonus Merge branch 'develop' into mechanical_bonus 2024-10-31 15:14:51 +02:00
Entities_Format fused artifacts 2024-10-12 16:43:04 +03:00
Map_Objects Added support for daily income to flaggable objects 2024-10-25 19:01:00 +00:00
Animation_Format.md fix headings of md files 2024-07-16 20:29:20 +02:00
Bonus_Format.md fix headings of md files 2024-07-16 20:29:20 +02:00
Building_Bonuses.md fix headings of md files 2024-07-16 20:29:20 +02:00
Campaign_Format.md scenario name for campaigns 2024-09-24 11:23:10 +02:00
Configurable_Widgets.md Merge branch 'vcmi/master' into 'vcmi/develop' 2024-08-05 10:36:10 +00:00
Difficulty.md fix headings of md files 2024-07-16 20:29:20 +02:00
File_Formats.md Update documentation 2024-10-14 13:05:10 +00:00
Game_Identifiers.md fix headings of md files 2024-07-16 20:29:20 +02:00
Map_Editor.md fix headings of md files 2024-07-16 20:29:20 +02:00
Map_Object_Format.md Updated documentation 2024-10-25 18:47:19 +00:00
Mod_File_Format.md Always load json configs from mod that references it 2024-10-31 14:49:11 +00:00
Random_Map_Template.md Add docs for new options 2024-09-14 13:20:24 +02:00
Readme.md Update the French translation 2024-09-10 08:55:10 +02:00

Modding Readme

Creating mod

To make your own mod you need to create subdirectory in /Mods/ with name that will be used as identifier for your mod. Main mod is file called mod.json and should be placed into main folder of your mod, e.g. Mods/myMod/mod.json All content of your mod should go into Content directory, e.g. Mods/myMod/Content/. Alternatively, it is possible to replace this directory with single .zip archive.

Example of how directory structure of your mod may look like:

    Mods/
        myMod/
            mod.json
            Content/
                config/  - json configuration files
                data/    - unorganized files, mostly bitmap images (.bmp, .png, .pcx)
                maps/    - h3m maps added or modified by mod
                music/   - music files. Mp3 and ogg/vorbis are supported
                sounds/  - sound files, in wav format.
                sprites/ - animation, image sets (H3 .def files or VCMI .json files)
                video/   - video files, .bik, .smk, .ogv .webm

See File Formats page for more information on which formats are supported or recommended for vcmi

Creating mod file

All VCMI configuration files use JSON format so you may want to familiarize yourself with it first. Mod.json is main file in your mod and must be present in any mod. This file contains basic description of your mod, dependencies or conflicting mods (if present), list of new content and so on. Minimalistic version of this file:

{
    "name" : "My test mod",
    "description" : "My test mod that add a lot of useless stuff into the game",
    "version" : "1.00",
	"modType" : "Graphical",	
	"contact" : "http://www.contact.example.com"
}

See Mod file Format for its full description.

Creation of new objects

In order to create new object use following steps:

  1. Create json file with definition of new object. See list of supported object types below.
  2. Add any resources needed for this object, such as images, animations or sounds.
  3. Add reference to new object in corresponding section of mod.json file

List of supported new object types

Random Map Generator:

Game Entities:

Map objects:

Other:

Game Identifiers system

VCMI uses strings to reference objects. Examples:

  • Referencing H3 objects: "nativeTerrain" : "sand". All mods can freely access any existing objects from H3 data.

  • Referencing object from another mod: "nativeTerrain" : "asphalt". Mods can only reference object from mods that are marked as dependencies

  • Referencing objects in bonus system: "subtype" : "creature.archer". Bonus system requires explicit definition of object type since different bonuses may require different identifier class.

  • Referencing object from specific mod: "nativeTerrain" : "hota.cove:sorceress". In some cases, for example to resolve conflicts when multiple mods use same object name you might need to explicitly specify mod in which game needs to look up an identifier. Alternatively, you can use this form for clarity if you want to clearly specify that object comes from another mod.

Modifying existing objects

Alternatively to creating new objects, you can edit existing objects. Normally, when creating new objects you specify object name as:

"newCreature" : {
    // creature parameters
}

In order to access and modify existing object you need to specify mod that you wish to edit:

/// "core" specifier refers to objects that exist in H3
"core:archer" : {
	/// This will set health of Archer to 10
	"hitPoints" : 10,
},

/// Modifying object named "jumpSoldier" in mod "forge"
"forge:jumpSoldier" : {
	/// Set attack of Jump Soldiers to 20
	"attack": 20
},

/// Modifying object named "sorceress" in submod "cove" of mod "hota"
"hota.cove:sorceress" : {
	/// Set speed of Sorceresses to 10
	"speed" : 10
},

Note that modification of existing objects does not requires a dependency on edited mod. Such definitions will only be used by game if corresponding mod is installed and active.

This allows using objects editing not just for rebalancing mods but also to provide compatibility between two different mods or to add interaction between two mods.

Overriding graphical files from Heroes III

Any graphical replacer mods fall under this category. In VCMI directory /Content acts as mod-specific game root directory. So for example file /Content/Data/AISHIELD.PNG will replace file with same name from H3Bitmap.lod game archive. Any other files can be replaced in exactly same way. Note that replacing files from archives requires placing them into specific location:

  • H3Bitmap.lod -> Data
  • H3Sprite.lod -> Sprites
  • Heroes3.snd -> Sounds
  • Video.vid -> Video

This includes archives added by expansions (e.g. H3ab_bmp.lod uses same rules as H3Bitmap.lod)

  • Warning: overriding graphical files from other mods is discouraged and may be removed in future versions of vcmi. Please use modification of existing objects instead.

Replacing .def animation files

Heroes III uses custom format for storing animation: def files. These files are used to store all in-game animations as well as for some GUI elements like buttons and for icon sets. These files can be replaced by another def file but in some cases original format can't be used. This includes but not limited to:

  • Replacing one (or several) icons in set
  • Replacing animation with fully-colored 32-bit images In VCMI these animation files can also be replaced by json description of their content. See Animation Format for full description of this format. Example: replacing single icon
{
	// List of replaced images
	"images" :
	[
		{
			"frame" : 0, // Index of replaced frame
			"file" : "HPS000KN.bmp" //name of file that will be used as replacement
		}
	]
}

Publishing mods in VCMI Repository

This will allow players to install mods directly from VCMI Launcher without visiting any 3rd-party sites.

Where files are hosted

Mods list hosted under main VCMI organization: vcmi-mods-repository. Each mod hosted in it's own repository under separate organization vcmi-mods. This way if engine become more popular in future we can create separate teams for each mod and accept as many people as needed.

Why Git / GitHub?

It's solve a lot of problems:

  • Engine developers get control over all mods and can easily update them without adding extra burden for modders / mod maintainers.
  • With tools such as GitHub Desktop it's easy for non-programmers to contribute.
  • Forward and backward compatibility. Stable releases of game use compatible version of mods while users of daily builds will be able to test mods supporting bleeding edge features.
  • Tracking of changes for repository and mods. It's not big deal now, but once we have scripting it's will be important to keep control over what code included in mods.
  • GitHub also create ZIP archives for us so mods will be stored uncompressed and version can be identified by commit hash.

On backward compatibility

Our mod list in vcmi-mods-repository had "develop" as primary branch. Daily builds of VCMI use mod list file from this branch. Once VCMI get stable release there will be branching into "1.0.0", "1.1.0", etc. Launcher of released version will request mod list for particular version. Same way we can also create special stable branch for every mod under "vcmi-mods" organization umbrella once new stable version is released. So this way it's will be easier to maintain two versions of same mod: for stable and latest version.

Getting into vcmi-mods organization

Before your mod can be accepted into official mod list you need to get it into repository under "vcmi-mods" organization umbrella. To do this contact one of mod repository maintainers. If needed you can get own team within "vcmi-mods" organization. Link to our mod will looks like that: https://github.com/vcmi-mods/adventure-ai-trace

Rules of repository

Allowed name for mod identifier

For sanity reasons mod identifier must only contain lower-case English characters, numbers and hyphens.

my-mod-name
2000-new-maps

Sub-mods can be named as you like, but we strongly encourage everyone to use proper identifiers for them as well.

Rewriting History

Once you submitted certain commit into official mod list you are not allowed to rewrite history before that commit. This way we can make sure that VCMI launcher will always be able to download older version of any mod. Branches such as "develop" or stable branches like "1.0.0" should be marked as protected on GitHub.

Submitting mods to repository

Once mod ready for general public maintainer to make PR to vcmi-mods-repository.

Requirements

Right now main requirements for a mod to be accepted into VCMI mods list are:

  • Mod must be complete. For work-in-progress mods it is better to use other way of distribution.
  • Mod must met some basic quality requirements. Having high-quality content is always preferable.
  • Mod must not contain any errors detectable by validation (console message you may see during loading)
  • Music files must be in Ogg/Vorbis format (*.ogg extension)