1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Merge pull request #3992 from IvanSavenko/mod_validation_fix

Tweaks to modding docs
This commit is contained in:
Ivan Savenko 2024-05-19 15:43:16 +03:00 committed by GitHub
commit 692cbfb7e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 3 deletions

View File

@ -230,7 +230,12 @@ This property describes how object state should be reset. Objects without this f
## Appear Chance definition
This property describes chance for reward to be selected.
When object is initialized on map load, game will roll a "dice" - random number in range 0-99, and pick all awards that have appear chance within selected number
When object is initialized on map load, game will roll a "dice" - random number in range 0-99, and pick all awards that have appear chance within selected number.
Note that object that uses appearChance MUST have continious range for every value in 0-99 range. For example, object with 3 different rewards may want to define them as
- `"min" : 0, "max" : 33`
- `"min" : 33, "max" : 66`
- `"min" : 66, "max" : 100`
In other words, min chance of second reward must be equal to max chance of previous reward
```jsonc
"appearChance":

View File

@ -53,7 +53,13 @@ void CRewardableConstructor::configureObject(CGObjectInstance * object, CRandomG
bonus.sid = BonusSourceID(rewardableObject->ID);
}
}
assert(!rewardableObject->configuration.info.empty());
if (rewardableObject->configuration.info.empty())
{
if (objectInfo.getParameters()["rewards"].isNull())
logMod->error("Object %s has invalid configuration! No defined rewards found!", getJsonKey());
else
logMod->error("Object %s has invalid configuration! Make sure that defined appear chances are continious!", getJsonKey());
}
}
}

View File

@ -333,9 +333,13 @@ void CIdentifierStorage::registerObject(const std::string & scope, const std::st
std::pair<const std::string, ObjectData> mapping = std::make_pair(fullID, data);
if(!vstd::containsMapping(registeredObjects, mapping))
{
logMod->trace("registered %s as %s:%s", fullID, scope, identifier);
logMod->trace("registered '%s' as %s:%s", fullID, scope, identifier);
registeredObjects.insert(mapping);
}
else
{
logMod->trace("Duplicate object '%s' found!", fullID);
}
}
std::vector<CIdentifierStorage::ObjectData> CIdentifierStorage::getPossibleIdentifiers(const ObjectCallback & request) const