1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-16 10:19:47 +02:00
vcmi/docs/modders/Readme.md

216 lines
10 KiB
Markdown
Raw Normal View History

< [Documentation](../Readme.md) / Modding
2023-08-25 12:02:01 +02:00
# Creating mod
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
To make your own mod you need to create subdirectory in **<data dir>/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.
2023-08-12 11:39:44 +02:00
Example of how directory structure of your mod may look like:
2023-08-25 12:02:01 +02:00
```
2023-08-12 11:39:44 +02:00
Mods/
2023-09-01 11:11:35 +02:00
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 or .smk
2023-08-25 12:02:01 +02:00
```
2023-08-12 11:39:44 +02:00
## Creating mod file
2023-08-25 12:02:01 +02:00
All VCMI configuration files use [JSON format](http://en.wikipedia.org/wiki/Json) 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.
2023-08-12 11:39:44 +02:00
Minimalistic version of this file:
``` javascript
{
"name" : "My test mod",
"description" : "My test mod that add a lot of useless stuff into the game"
}
```
2023-09-01 00:30:26 +02:00
See [Mod file Format](Mod_File_Format.md) for its full description.
2023-08-12 11:39:44 +02:00
2023-09-01 11:11:35 +02:00
## 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.
2. Add reference to new object in corresponding section of mod.json file
### List of supported new object types
Random Map Generator:
2023-09-01 12:14:05 +02:00
- [Random Map Template](Random_Map_Template.md)
2023-09-01 11:11:35 +02:00
Game Entities:
2023-09-01 11:11:35 +02:00
- [Artifact](Entities_Format/Artifact_Format.md)
- [Creature](Entities_Format/Creature_Format.md)
- [Faction](Entities_Format/Faction_Format.md)
2023-09-01 12:14:05 +02:00
- [Hero Class](Entities_Format/Hero_Class_Format.md)
2023-09-01 11:11:35 +02:00
- [Hero Type](Entities_Format/Hero_Type_Format.md)
- [Spell](Entities_Format/Spell_Format.md)
2023-09-01 12:14:05 +02:00
- [Secondary Skill](Entities_Format/Secondary_Skill_Format.md)
2023-09-01 11:11:35 +02:00
Map objects:
- [Map Objects](Map_Object_Format.md)
2023-09-01 11:11:35 +02:00
- - [Rewardable](Map_Objects/Rewardable.md)
- - [Creature Bank](Map_Objects/Creature_Bank.md)
- - [Dwelling](Map_Objects/Dwelling.md)
- - [Market](Map_Objects/Markets.md)
- - [Boat](Map_Objects/Boat.md)
Other:
2023-09-01 11:11:35 +02:00
- [Terrain](Entities_Format/Terrain_Format.md)
- [River](Entities_Format/River_Format.md)
- [Road](Entities_Format/Road_Format.md)
- [Battlefield](Entities_Format/Battlefield_Format.md)
- [Battle Obstacle](Entities_Format/Battle_Obstacle_Format.md)
2023-09-01 00:30:26 +02:00
## Game Identifiers system
2023-08-12 11:39:44 +02:00
2023-09-01 11:11:35 +02:00
VCMI uses strings to reference objects. Examples:
2023-08-12 11:39:44 +02:00
- Referencing H3 objects: `"nativeTerrain" : "sand"`. All mods can freely access any existing objects from H3 data.
2023-08-12 11:39:44 +02:00
- Referencing object from another mod: `"nativeTerrain" : "asphalt"`. Mods can only reference object from mods that are marked as dependencies
2023-09-01 00:30:26 +02:00
- Referencing objects in bonus system: `"subtype" : "creature.archer"`. Bonus system requires explicit definition of object type since different bonuses may require different identifier class.
2023-09-01 00:30:26 +02:00
- 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.
2023-09-01 00:30:26 +02:00
### Modifying existing objects
Alternatively to creating new objects, you can edit existing objects. Normally, when creating new objects you specify object name as:
``` javascript
"newCreature" : {
// creature parameters
}
```
In order to access and modify existing object you need to specify mod that you wish to edit:
``` javascript
/// "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.
2023-09-01 11:11:35 +02:00
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.
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
## Overriding graphical files from Heroes III
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
Any graphical replacer mods fall under this category. In VCMI directory **<mod name>/Content** acts as mod-specific game root directory. So for example file **<mod name>/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
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
This includes archives added by expansions (e.g. **H3ab_bmp.lod** uses same rules as **H3Bitmap.lod**)
2023-08-12 11:39:44 +02:00
2023-09-01 11:11:35 +02:00
- **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.
2023-08-25 12:02:01 +02:00
### Replacing .def animation files
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
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:
2023-08-12 11:39:44 +02:00
- Replacing one (or several) icons in set
- Replacing animation with fully-colored 32-bit images
2023-09-01 11:11:35 +02:00
In VCMI these animation files can also be replaced by json description of their content. See [Animation Format](Animation_Format.md) for full description of this format.
2023-08-12 11:39:44 +02:00
Example: replacing single icon
``` javascript
{
// List of replaced images
2023-08-25 12:02:01 +02:00
"images" :
[
{
"frame" : 0, // Index of replaced frame
"file" : "HPS000KN.bmp" //name of file that will be used as replacement
}
2023-08-12 11:39:44 +02:00
]
}
```
2023-08-25 12:02:01 +02:00
# Publishing mods in VCMI Repository
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
This will allow players to install mods directly from VCMI Launcher without visiting any 3rd-party sites.
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
## Where files are hosted
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
Mods list hosted under main VCMI organization: [vcmi-mods-repository](https://github.com/vcmi/vcmi-mods-repository).
Each mod hosted in it's own repository under separate organization [vcmi-mods](https://github.com/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.
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
## Why Git / GitHub?
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
It's solve a lot of problems:
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
- 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](https://desktop.github.com/) 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.
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
## On backward compatibility
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
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.
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
## Getting into vcmi-mods organization
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
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
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
## Rules of repository
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
### Allowed name for mod identifier
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
For sanity reasons mod identifier must only contain lower-case English characters, numbers and hyphens.
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
my-mod-name
2000-new-maps
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
Sub-mods can be named as you like, but we strongly encourage everyone to use proper identifiers for them as well.
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
### Rewriting History
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
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.
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
## Submitting mods to repository
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
Once mod ready for general public maintainer to make PR to [vcmi-mods-repository](https://github.com/vcmi/vcmi-mods-repository).
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
## Requirements
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
Right now main requirements for a mod to be accepted into VCMI mods list are:
2023-08-12 11:39:44 +02:00
2023-08-25 12:02:01 +02:00
- 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)