mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Stables in Castle will now check for and give same bonuses as map stable
This commit is contained in:
@@ -185,6 +185,7 @@
|
|||||||
"ship": { "id" : 20, "upgrades" : "shipyard" },
|
"ship": { "id" : 20, "upgrades" : "shipyard" },
|
||||||
"special2": {
|
"special2": {
|
||||||
"requires" : [ "dwellingLvl4" ],
|
"requires" : [ "dwellingLvl4" ],
|
||||||
|
"mapObjectLikeBonuses" : "stables",
|
||||||
"configuration" : {
|
"configuration" : {
|
||||||
"visitMode" : "bonus",
|
"visitMode" : "bonus",
|
||||||
"rewards" : [
|
"rewards" : [
|
||||||
|
@@ -65,6 +65,10 @@
|
|||||||
"description" : "If set to true, this building will not automatically activate on new day or on entering town and needs to be activated manually on click",
|
"description" : "If set to true, this building will not automatically activate on new day or on entering town and needs to be activated manually on click",
|
||||||
"type" : "boolean"
|
"type" : "boolean"
|
||||||
},
|
},
|
||||||
|
"mapObjectLikeBonuses" : {
|
||||||
|
"description" : "Optional, all bonuses granted by configurable buildings will have source set to specified map object",
|
||||||
|
"type" : "string"
|
||||||
|
},
|
||||||
"configuration" : {
|
"configuration" : {
|
||||||
"description" : "Optional, configuration of building that can be activated by visiting hero",
|
"description" : "Optional, configuration of building that can be activated by visiting hero",
|
||||||
"$ref" : "rewardable.json"
|
"$ref" : "rewardable.json"
|
||||||
|
@@ -46,6 +46,7 @@ public:
|
|||||||
bool upgradeReplacesBonuses = false;
|
bool upgradeReplacesBonuses = false;
|
||||||
bool manualHeroVisit = false;
|
bool manualHeroVisit = false;
|
||||||
BonusList buildingBonuses;
|
BonusList buildingBonuses;
|
||||||
|
MapObjectID mapObjectLikeBonuses;
|
||||||
|
|
||||||
Rewardable::Info rewardableObjectInfo; ///configurable rewards for special buildings
|
Rewardable::Info rewardableObjectInfo; ///configurable rewards for special buildings
|
||||||
|
|
||||||
|
@@ -329,6 +329,14 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
|
|||||||
|
|
||||||
loadBuildingBonuses(source["bonuses"], ret->buildingBonuses, ret);
|
loadBuildingBonuses(source["bonuses"], ret->buildingBonuses, ret);
|
||||||
|
|
||||||
|
if(!source["mapObjectLikeBonuses"].isNull())
|
||||||
|
{
|
||||||
|
VLC->identifiers()->requestIdentifierOptional("object", source["mapObjectLikeBonuses"], [=](si32 identifier)
|
||||||
|
{
|
||||||
|
ret->mapObjectLikeBonuses = MapObjectID(identifier);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if(!source["configuration"].isNull())
|
if(!source["configuration"].isNull())
|
||||||
ret->rewardableObjectInfo.init(source["configuration"], ret->getBaseTextID());
|
ret->rewardableObjectInfo.init(source["configuration"], ret->getBaseTextID());
|
||||||
|
|
||||||
|
@@ -81,11 +81,19 @@ Rewardable::Configuration TownRewardableBuildingInstance::generateConfiguration(
|
|||||||
for(auto & rewardInfo : result.info)
|
for(auto & rewardInfo : result.info)
|
||||||
{
|
{
|
||||||
for (auto & bonus : rewardInfo.reward.bonuses)
|
for (auto & bonus : rewardInfo.reward.bonuses)
|
||||||
|
{
|
||||||
|
if (building->mapObjectLikeBonuses.hasValue())
|
||||||
|
{
|
||||||
|
bonus.source = BonusSource::OBJECT_TYPE;
|
||||||
|
bonus.sid = BonusSourceID(building->mapObjectLikeBonuses);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
bonus.source = BonusSource::TOWN_STRUCTURE;
|
bonus.source = BonusSource::TOWN_STRUCTURE;
|
||||||
bonus.sid = BonusSourceID(building->getUniqueTypeID());
|
bonus.sid = BonusSourceID(building->getUniqueTypeID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,6 +166,9 @@ bool TownRewardableBuildingInstance::wasVisitedBefore(const CGHeroInstance * con
|
|||||||
case Rewardable::VISIT_BONUS:
|
case Rewardable::VISIT_BONUS:
|
||||||
{
|
{
|
||||||
const auto building = town->getTown()->buildings.at(getBuildingType());
|
const auto building = town->getTown()->buildings.at(getBuildingType());
|
||||||
|
if (building->mapObjectLikeBonuses.hasValue())
|
||||||
|
return contextHero->hasBonusFrom(BonusSource::OBJECT_TYPE, BonusSourceID(building->mapObjectLikeBonuses));
|
||||||
|
else
|
||||||
return contextHero->hasBonusFrom(BonusSource::TOWN_STRUCTURE, BonusSourceID(building->getUniqueTypeID()));
|
return contextHero->hasBonusFrom(BonusSource::TOWN_STRUCTURE, BonusSourceID(building->getUniqueTypeID()));
|
||||||
}
|
}
|
||||||
case Rewardable::VISIT_HERO:
|
case Rewardable::VISIT_HERO:
|
||||||
|
Reference in New Issue
Block a user