mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
- Mod artifacts can have components
- Mod artifacts can be for commander / stack - Commander / stack artifacts will be automatically disabled from random spawning is related module is disabled
This commit is contained in:
@@ -437,10 +437,10 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
|
|||||||
case ArtBearer::HERO: //TODO: allow arts having several possible bearers
|
case ArtBearer::HERO: //TODO: allow arts having several possible bearers
|
||||||
break;
|
break;
|
||||||
case ArtBearer::COMMANDER:
|
case ArtBearer::COMMANDER:
|
||||||
makeItCommanderArt(art->id); //TODO: when id is deduced?
|
makeItCommanderArt (art, false); //do not erase already existing slots
|
||||||
break;
|
break;
|
||||||
case ArtBearer::CREATURE:
|
case ArtBearer::CREATURE:
|
||||||
makeItCreatureArt(art->id);
|
makeItCreatureArt (art, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -475,6 +475,8 @@ CArtifact * CArtHandler::loadArtifact(const JsonNode & node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readComponents (node, art);
|
||||||
|
|
||||||
BOOST_FOREACH (const JsonNode &bonus, node["bonuses"].Vector())
|
BOOST_FOREACH (const JsonNode &bonus, node["bonuses"].Vector())
|
||||||
{
|
{
|
||||||
auto b = JsonUtils::parseBonus(bonus);
|
auto b = JsonUtils::parseBonus(bonus);
|
||||||
@@ -660,10 +662,8 @@ void CArtHandler::giveArtBonus(TArtifactID aid, Bonus *bonus)
|
|||||||
|
|
||||||
artifacts[aid]->addNewBonus(bonus);
|
artifacts[aid]->addNewBonus(bonus);
|
||||||
}
|
}
|
||||||
|
void CArtHandler::makeItCreatureArt (CArtifact * a, bool onlyCreature /*=true*/)
|
||||||
void CArtHandler::makeItCreatureArt (TArtifactInstanceID aid, bool onlyCreature /*=true*/)
|
|
||||||
{
|
{
|
||||||
CArtifact *a = artifacts[aid];
|
|
||||||
if (onlyCreature)
|
if (onlyCreature)
|
||||||
{
|
{
|
||||||
a->possibleSlots[ArtBearer::HERO].clear();
|
a->possibleSlots[ArtBearer::HERO].clear();
|
||||||
@@ -672,9 +672,14 @@ void CArtHandler::makeItCreatureArt (TArtifactInstanceID aid, bool onlyCreature
|
|||||||
a->possibleSlots[ArtBearer::CREATURE].push_back(ArtifactPosition::CREATURE_SLOT);
|
a->possibleSlots[ArtBearer::CREATURE].push_back(ArtifactPosition::CREATURE_SLOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CArtHandler::makeItCommanderArt( TArtifactInstanceID aid, bool onlyCommander /*= true*/ )
|
void CArtHandler::makeItCreatureArt (TArtifactInstanceID aid, bool onlyCreature /*=true*/)
|
||||||
{
|
{
|
||||||
CArtifact *a = artifacts[aid];
|
CArtifact *a = artifacts[aid];
|
||||||
|
makeItCreatureArt (a, onlyCreature);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CArtHandler::makeItCommanderArt (CArtifact * a, bool onlyCommander /*= true*/ )
|
||||||
|
{
|
||||||
if (onlyCommander)
|
if (onlyCommander)
|
||||||
{
|
{
|
||||||
a->possibleSlots[ArtBearer::HERO].clear();
|
a->possibleSlots[ArtBearer::HERO].clear();
|
||||||
@@ -684,6 +689,12 @@ void CArtHandler::makeItCommanderArt( TArtifactInstanceID aid, bool onlyCommande
|
|||||||
a->possibleSlots[ArtBearer::COMMANDER].push_back(i);
|
a->possibleSlots[ArtBearer::COMMANDER].push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CArtHandler::makeItCommanderArt( TArtifactInstanceID aid, bool onlyCommander /*= true*/ )
|
||||||
|
{
|
||||||
|
CArtifact *a = artifacts[aid];
|
||||||
|
makeItCommanderArt (a, onlyCommander);
|
||||||
|
}
|
||||||
|
|
||||||
void CArtHandler::addBonuses()
|
void CArtHandler::addBonuses()
|
||||||
{
|
{
|
||||||
const JsonNode config(ResourceID("config/artifacts.json"));
|
const JsonNode config(ResourceID("config/artifacts.json"));
|
||||||
@@ -702,21 +713,27 @@ void CArtHandler::addBonuses()
|
|||||||
else if(artifact.second["type"].String() == "Commander")
|
else if(artifact.second["type"].String() == "Commander")
|
||||||
makeItCommanderArt(ga->id);
|
makeItCommanderArt(ga->id);
|
||||||
|
|
||||||
|
readComponents (artifact.second, ga);
|
||||||
|
|
||||||
|
VLC->modh->identifiers.registerObject ("artifact." + artifact.first, ga->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CArtHandler::readComponents (const JsonNode & node, CArtifact * art)
|
||||||
|
{
|
||||||
const JsonNode *value;
|
const JsonNode *value;
|
||||||
value = &artifact.second["components"];
|
value = &node["components"];
|
||||||
if (!value->isNull())
|
if (!value->isNull())
|
||||||
{
|
{
|
||||||
ga->constituents = new std::vector<ui32>();
|
art->constituents = new std::vector<ui32>();
|
||||||
BOOST_FOREACH (auto component, value->Vector())
|
BOOST_FOREACH (auto component, value->Vector())
|
||||||
{
|
{
|
||||||
VLC->modh->identifiers.requestIdentifier(std::string("artifact.") + component.String(),
|
VLC->modh->identifiers.requestIdentifier(std::string("artifact.") + component.String(),
|
||||||
boost::bind (&CArtifact::addConstituent, ga, _1)
|
boost::bind (&CArtifact::addConstituent, art, _1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VLC->modh->identifiers.registerObject ("artifact." + artifact.first, ga->id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CArtHandler::clear()
|
void CArtHandler::clear()
|
||||||
@@ -755,7 +772,15 @@ void CArtHandler::initAllowedArtifactsList(const std::vector<ui8> &allowed)
|
|||||||
}
|
}
|
||||||
for (int i = GameConstants::ARTIFACTS_QUANTITY; i < artifacts.size(); ++i) //allow all new artifacts by default
|
for (int i = GameConstants::ARTIFACTS_QUANTITY; i < artifacts.size(); ++i) //allow all new artifacts by default
|
||||||
{
|
{
|
||||||
|
if (artifacts[i]->possibleSlots[ArtBearer::HERO].size())
|
||||||
allowedArtifacts.push_back(artifacts[i]);
|
allowedArtifacts.push_back(artifacts[i]);
|
||||||
|
else //check if active modules allow artifact to be every used
|
||||||
|
{
|
||||||
|
if (artifacts[i]->possibleSlots[ArtBearer::COMMANDER].size() && VLC->modh->modules.COMMANDERS ||
|
||||||
|
artifacts[i]->possibleSlots[ArtBearer::CREATURE].size() && VLC->modh->modules.STACK_ARTIFACT)
|
||||||
|
allowedArtifacts.push_back(artifacts[i]);
|
||||||
|
//keep im mind that artifact can be worn by more than one type of bearer
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -234,6 +234,8 @@ public:
|
|||||||
void load(const JsonNode & node);
|
void load(const JsonNode & node);
|
||||||
/// load one artifact from json config
|
/// load one artifact from json config
|
||||||
CArtifact * loadArtifact(const JsonNode & node);
|
CArtifact * loadArtifact(const JsonNode & node);
|
||||||
|
///read (optional) components of combined artifact
|
||||||
|
void readComponents (const JsonNode & node, CArtifact * art);
|
||||||
|
|
||||||
void sortArts();
|
void sortArts();
|
||||||
void addBonuses();
|
void addBonuses();
|
||||||
@@ -247,7 +249,9 @@ public:
|
|||||||
bool isBigArtifact (TArtifactID artID) const {return bigArtifacts.find(artID) != bigArtifacts.end();}
|
bool isBigArtifact (TArtifactID artID) const {return bigArtifacts.find(artID) != bigArtifacts.end();}
|
||||||
void initAllowedArtifactsList(const std::vector<ui8> &allowed); //allowed[art_id] -> 0 if not allowed, 1 if allowed
|
void initAllowedArtifactsList(const std::vector<ui8> &allowed); //allowed[art_id] -> 0 if not allowed, 1 if allowed
|
||||||
static int convertMachineID(int id, bool creToArt);
|
static int convertMachineID(int id, bool creToArt);
|
||||||
|
void makeItCreatureArt (CArtifact * a, bool onlyCreature = true);
|
||||||
void makeItCreatureArt (TArtifactInstanceID aid, bool onlyCreature = true);
|
void makeItCreatureArt (TArtifactInstanceID aid, bool onlyCreature = true);
|
||||||
|
void makeItCommanderArt (CArtifact * a, bool onlyCommander = true);
|
||||||
void makeItCommanderArt (TArtifactInstanceID aid, bool onlyCommander = true);
|
void makeItCommanderArt (TArtifactInstanceID aid, bool onlyCommander = true);
|
||||||
CArtHandler();
|
CArtHandler();
|
||||||
~CArtHandler();
|
~CArtHandler();
|
||||||
|
Reference in New Issue
Block a user