User:Ivan/Mod format WIP
From VCMI Project Wiki
Sandbox, testing syntax highlight
// 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":
[
{
"id": 146, /* axe of smashing */
"bonusesPerLevel":
[
{
"level": 6,
"bonus": ["PRIMARY_SKILL", 1, 0, 0]
}
]
},
{
"id": 147, //mithril mail
"bonusesPerLevel":
[
{
"level": 1,
"bonus": ["STACK_HEALTH", 1, 0, 0]
}
]
},
{
"id": 148, //sword of sharpness
"bonusesPerLevel":
[
{
"level": 1,
"bonus": ["CREATURE_DAMAGE", 1, 0, 0]
}
]
}
]
}
int CHeroClass::chooseSecSkill(const std::set<int> & possibles) const //picks secondary skill out from given possibilities
{
if(possibles.size()==1) /* picks secondary skill out from given */
return *possibles.begin();
int totalProb = 0;
for(std::set<int>::const_iterator i=possibles.begin(); i!=possibles.end(); i++)
{
totalProb += proSec[*i];
}
int ran = rand()%totalProb;
for(std::set<int>::const_iterator i=possibles.begin(); i!=possibles.end(); i++)
{
ran -= proSec[*i];
if(ran<0)
return *i;
}
throw std::runtime_error("\tCannot pick secondary skill!\r\n");
}