1
0
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:
Ivan Savenko
2025-02-18 14:35:52 +00:00
parent aef04236b9
commit 085409bea9
5 changed files with 28 additions and 3 deletions

View File

@@ -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" : [

View File

@@ -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"

View File

@@ -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

View File

@@ -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());

View File

@@ -82,8 +82,16 @@ Rewardable::Configuration TownRewardableBuildingInstance::generateConfiguration(
{ {
for (auto & bonus : rewardInfo.reward.bonuses) for (auto & bonus : rewardInfo.reward.bonuses)
{ {
bonus.source = BonusSource::TOWN_STRUCTURE; if (building->mapObjectLikeBonuses.hasValue())
bonus.sid = BonusSourceID(building->getUniqueTypeID()); {
bonus.source = BonusSource::OBJECT_TYPE;
bonus.sid = BonusSourceID(building->mapObjectLikeBonuses);
}
else
{
bonus.source = BonusSource::TOWN_STRUCTURE;
bonus.sid = BonusSourceID(building->getUniqueTypeID());
}
} }
} }
return result; return result;
@@ -158,7 +166,10 @@ 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());
return contextHero->hasBonusFrom(BonusSource::TOWN_STRUCTURE, BonusSourceID(building->getUniqueTypeID())); if (building->mapObjectLikeBonuses.hasValue())
return contextHero->hasBonusFrom(BonusSource::OBJECT_TYPE, BonusSourceID(building->mapObjectLikeBonuses));
else
return contextHero->hasBonusFrom(BonusSource::TOWN_STRUCTURE, BonusSourceID(building->getUniqueTypeID()));
} }
case Rewardable::VISIT_HERO: case Rewardable::VISIT_HERO:
return visitors.find(contextHero->id) != visitors.end(); return visitors.find(contextHero->id) != visitors.end();