Difference between revisions of "User:Ivan/Mod format WIP"

From VCMI Project Wiki
Jump to: navigation, search
Line 1: Line 1:
Sandbox, testing syntax highlight
+
Future mod format, WIP
 
 
 
<syntaxhighlight lang="javascript">  
 
<syntaxhighlight lang="javascript">  
// Very long comment
 
// Following section describes configuration files with content added by mod
 
// It can be split into several files in any way you want but recommended organization is
 
// to keep one file per object (creature/hero/etc) and, if applicable, add separate file
 
// with translatable strings for each type of content
 
// See "additional links" at the bottom of page for descriptions of each of these formats
 
// Following section describes configuration files with content added by mod
 
// It can be split into several files in any way you want but recommended organization is
 
// to keep one file per object (creature/hero/etc) and, if applicable, add separate file
 
// with translatable strings for each type of content
 
// See "additional links" at the bottom of page for descriptions of each of these formats
 
 
{
 
{
"artifacts":
+
    // This is description on how files are organized in your mod
[
+
    // Make sure to replace "myMod" with name of your mod
{
+
    // In most cases you do not need to modify anything else in this field
"id": 146, /* axe of smashing */
+
    // TODO: make this entry optional
"bonusesPerLevel":
+
    "filesystem":
[
+
    {
{
+
        "":
"level": 6,
+
            [
"bonus": ["PRIMARY_SKILL", 1, 0, 0]
+
                {"type" : "dir", "path" : "ALL/MODS/myMod/Override"}
}
+
            ]
]
+
    },
},
+
{
+
    // Name of your mod. While it does not have hard length limit
"id": 147, //mithril mail
+
    // it should not be longer than ~30 symbols to fit into allowed space
"bonusesPerLevel":
+
    "name" : "My test mod",
[
+
   
{
+
    // Version of the mod. Consists from up to 3 numbers:
"level": 1,
+
    // 1) Major - changed when there is large change in functionality
"bonus": ["STACK_HEALTH", 1, 0, 0]
+
    // 2) Minor - some minor changes notable by players
}
+
    // 3) Patch - small bugfix releases
]
+
    "version" : "1.0.2"
},
+
   
{
+
    // autor of mod. Can be nickname, real name or name of team
"id": 148, //sword of sharpness
+
    "author" : "Anonymous"
"bonusesPerLevel":
+
   
[
+
    // Home page of mod or link to forum thread
{
+
    "weblink" : "http://example.com"
"level": 1,
+
"bonus": ["CREATURE_DAMAGE", 1, 0, 0]
+
    // More lengthy description of mod. No hard limit
}
+
    // TODO: show it in some kind of mod manager
]
+
    "description" : "My test mods that add a lot of useless stuff into the game",
}
+
 
]
+
    // List of mods that are required to run this one
}
+
    "depends" :
</syntaxhighlight>
+
    [
 +
        "baseMod"
 +
    ],
 +
 
 +
    // List of mods that can't be enabled in the same time as this one
 +
    "conflicts" :
 +
    [
 +
        "badMod"
 +
    ],
 +
 +
    // Priority in which your mod will be loaded. Bigger priority will make mod load later
 +
    // and override whatever changes were made by previous mod
 +
    // Can be modified by user as well as by game so this field is more like a hint
 +
    "priority" : 20,
 +
 +
    // Following section describes configuration files with content added by mod
 +
    // It can be split into several files in any way you want but recommended organization is
 +
    // to keep one file per object (creature/hero/etc) and, if applicable, add separate file
 +
    // with translatable strings for each type of content
 +
    // See "additional links" at the bottom of page for descriptions of each of these formats
 +
 +
    // list of factions/towns configuration files
 +
    "factions" :
 +
    [
 +
        "config/myMod/faction.json"
 +
    ]
 +
 +
    // List of hero classes configuration files
 +
    "heroClasses" :
 +
    [
 +
        "config/myMod/heroClasses.json"
 +
    ],
 +
 
  
<syntaxhighlight lang="cpp">
+
    // List of heroes configuration files
int CHeroClass::chooseSecSkill(const std::set<int> & possibles) const //picks secondary skill out from given possibilities
+
    "heroes" :
{
+
    [
if(possibles.size()==1) /* picks secondary skill out from given  */
+
        "config/myMod/heroes.json"
return *possibles.begin();
+
    ],
int totalProb = 0;
+
for(std::set<int>::const_iterator i=possibles.begin(); i!=possibles.end(); i++)
+
    // list of creature configuration files
{
+
    "creatures" :
totalProb += proSec[*i];
+
    [
}
+
        "config/myMod/creatures.json"
int ran = rand()%totalProb;
+
    ],
for(std::set<int>::const_iterator i=possibles.begin(); i!=possibles.end(); i++)
+
{
+
    // List of artifacts configuration files
ran -= proSec[*i];
+
    "artifacts" :
if(ran<0)
+
    [
return *i;
+
        "config/myMod/artifacts.json"
}
+
    ],
throw std::runtime_error("\tCannot pick secondary skill!\r\n");
+
   
 +
    // Overriding of configuration of another mod
 +
    // Uses same set of fields as mod configuration
 +
    // TODO: allow filesystem overriding as well?
 +
    "override" :
 +
    {
 +
        // Override of creature of base mod on which current one depends
 +
        // This method may be used to replace any fields in config
 +
        "baseMod" :
 +
        {
 +
            "creatures" :
 +
            [
 +
                "config/myMod/creaturesBaseMod.json"
 +
            ]
 +
        },
 +
 
 +
        // Override of artifact in another unrelated mod
 +
        // In this case override will be used only if mod is present
 +
        "anotherMod" :
 +
        {
 +
            "artifacts" :
 +
            [
 +
                "config/myMod/artifactsAnotherMod.json"
 +
            ]
 +
        },
 +
    }
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 23:05, 27 December 2012

Future mod format, WIP

 
{
    // This is description on how files are organized in your mod
    // Make sure to replace "myMod" with name of your mod
    // In most cases you do not need to modify anything else in this field
    // TODO: make this entry optional
    "filesystem":
    {
        "":
            [
                {"type" : "dir",  "path" : "ALL/MODS/myMod/Override"}
            ]
    },
 
    // Name of your mod. While it does not have hard length limit
    // it should not be longer than ~30 symbols to fit into allowed space
    "name" : "My test mod",
    
    // Version of the mod. Consists from up to 3 numbers:
    // 1) Major - changed when there is large change in functionality
    // 2) Minor - some minor changes notable by players
    // 3) Patch - small bugfix releases
    "version" : "1.0.2"
    
    // autor of mod. Can be nickname, real name or name of team
    "author" : "Anonymous"
    
    // Home page of mod or link to forum thread
    "weblink" : "http://example.com"
 
    // More lengthy description of mod. No hard limit
    // TODO: show it in some kind of mod manager
    "description" : "My test mods that add a lot of useless stuff into the game",

    // List of mods that are required to run this one
    "depends" :
    [
        "baseMod"
    ],

    // List of mods that can't be enabled in the same time as this one
    "conflicts" :
    [
        "badMod"
    ],
 
    // Priority in which your mod will be loaded. Bigger priority will make mod load later
    // and override whatever changes were made by previous mod
    // Can be modified by user as well as by game so this field is more like a hint
    "priority" : 20,
 
    // Following section describes configuration files with content added by mod
    // It can be split into several files in any way you want but recommended organization is
    // to keep one file per object (creature/hero/etc) and, if applicable, add separate file
    // with translatable strings for each type of content
    // See "additional links" at the bottom of page for descriptions of each of these formats
 
    // list of factions/towns configuration files
    "factions" :
    [
        "config/myMod/faction.json"
    ]
 
    // List of hero classes configuration files
    "heroClasses" :
    [
        "config/myMod/heroClasses.json"
    ],


    // List of heroes configuration files
    "heroes" :
    [
        "config/myMod/heroes.json"
    ],
 
    // list of creature configuration files
    "creatures" :
    [
        "config/myMod/creatures.json"
    ],
 
    // List of artifacts configuration files
    "artifacts" :
    [
        "config/myMod/artifacts.json"
    ],
    
    // Overriding of configuration of another mod
    // Uses same set of fields as mod configuration
    // TODO: allow filesystem overriding as well?
    "override" :
    {
        // Override of creature of base mod on which current one depends
        // This method may be used to replace any fields in config
        "baseMod" :
        {
            "creatures" :
            [
                "config/myMod/creaturesBaseMod.json"
            ]
        },

        // Override of artifact in another unrelated mod
        // In this case override will be used only if mod is present
        "anotherMod" :
        {
            "artifacts" :
            [
                "config/myMod/artifactsAnotherMod.json"
            ]
        },
    }
}