mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Added forceCombat
field for ambush-like objects
This commit is contained in:
@@ -52,7 +52,14 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *hero) const
|
|||||||
cb->sendAndApply(cov);
|
cb->sendAndApply(cov);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isGuarded())
|
if (!isGuarded())
|
||||||
|
doHeroVisit(hero);
|
||||||
|
|
||||||
|
if (configuration.forceCombat)
|
||||||
|
{
|
||||||
|
doStartBattle(hero);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
auto guardedIndexes = getAvailableRewards(hero, Rewardable::EEventType::EVENT_GUARDED);
|
auto guardedIndexes = getAvailableRewards(hero, Rewardable::EEventType::EVENT_GUARDED);
|
||||||
auto guardedReward = configuration.info.at(guardedIndexes.at(0));
|
auto guardedReward = configuration.info.at(guardedIndexes.at(0));
|
||||||
@@ -65,10 +72,6 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *hero) const
|
|||||||
|
|
||||||
cb->showBlockingDialog(this, &bd);
|
cb->showBlockingDialog(this, &bd);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
doHeroVisit(hero);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRewardableObject::heroLevelUpDone(const CGHeroInstance *hero) const
|
void CRewardableObject::heroLevelUpDone(const CGHeroInstance *hero) const
|
||||||
@@ -92,15 +95,18 @@ void CRewardableObject::garrisonDialogClosed(const CGHeroInstance *hero) const
|
|||||||
cb->eraseStack(StackLocation(id, stacks.begin()->first));
|
cb->eraseStack(StackLocation(id, stacks.begin()->first));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CRewardableObject::doStartBattle(const CGHeroInstance * hero) const
|
||||||
|
{
|
||||||
|
auto layout = BattleLayout::createLayout(cb, configuration.guardsLayout, hero, this);
|
||||||
|
cb->startBattle(hero, this, visitablePos(), hero, nullptr, layout, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void CRewardableObject::blockingDialogAnswered(const CGHeroInstance * hero, int32_t answer) const
|
void CRewardableObject::blockingDialogAnswered(const CGHeroInstance * hero, int32_t answer) const
|
||||||
{
|
{
|
||||||
if(isGuarded())
|
if(isGuarded())
|
||||||
{
|
{
|
||||||
if (answer)
|
if (answer)
|
||||||
{
|
doStartBattle(hero);
|
||||||
auto layout = BattleLayout::createLayout(cb, configuration.guardsLayout, hero, this);
|
|
||||||
cb->startBattle(hero, this, visitablePos(), hero, nullptr, layout, nullptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -25,6 +25,8 @@ protected:
|
|||||||
/// reward selected by player, no serialize
|
/// reward selected by player, no serialize
|
||||||
ui16 selectedReward = 0;
|
ui16 selectedReward = 0;
|
||||||
|
|
||||||
|
void doStartBattle(const CGHeroInstance * hero) const;
|
||||||
|
|
||||||
void grantReward(ui32 rewardID, const CGHeroInstance * hero) const override;
|
void grantReward(ui32 rewardID, const CGHeroInstance * hero) const override;
|
||||||
void markAsVisited(const CGHeroInstance * hero) const override;
|
void markAsVisited(const CGHeroInstance * hero) const override;
|
||||||
|
|
||||||
|
@@ -103,6 +103,7 @@ void Rewardable::Configuration::serializeJson(JsonSerializeFormat & handler)
|
|||||||
handler.serializeStruct("resetParameters", resetParameters);
|
handler.serializeStruct("resetParameters", resetParameters);
|
||||||
handler.serializeBool("canRefuse", canRefuse);
|
handler.serializeBool("canRefuse", canRefuse);
|
||||||
handler.serializeBool("showScoutedPreview", showScoutedPreview);
|
handler.serializeBool("showScoutedPreview", showScoutedPreview);
|
||||||
|
handler.serializeBool("forceCombat", forceCombat);
|
||||||
handler.serializeBool("coastVisitable", coastVisitable);
|
handler.serializeBool("coastVisitable", coastVisitable);
|
||||||
handler.serializeInt("infoWindowType", infoWindowType);
|
handler.serializeInt("infoWindowType", infoWindowType);
|
||||||
}
|
}
|
||||||
|
@@ -169,6 +169,9 @@ struct DLL_LINKAGE Configuration
|
|||||||
/// if true - player can refuse visiting an object (e.g. Tomb)
|
/// if true - player can refuse visiting an object (e.g. Tomb)
|
||||||
bool canRefuse = false;
|
bool canRefuse = false;
|
||||||
|
|
||||||
|
/// if set to true and object is guarded, then hero visit will immediately start combat without confirmation
|
||||||
|
bool forceCombat = false;
|
||||||
|
|
||||||
/// if true - right-clicking object will show preview of object rewards
|
/// if true - right-clicking object will show preview of object rewards
|
||||||
bool showScoutedPreview = false;
|
bool showScoutedPreview = false;
|
||||||
|
|
||||||
@@ -200,6 +203,8 @@ struct DLL_LINKAGE Configuration
|
|||||||
h & variables;
|
h & variables;
|
||||||
h & visitLimiter;
|
h & visitLimiter;
|
||||||
h & canRefuse;
|
h & canRefuse;
|
||||||
|
if (h.version >= Handler::Version::REWARDABLE_EXTENSIONS)
|
||||||
|
h & forceCombat;
|
||||||
h & showScoutedPreview;
|
h & showScoutedPreview;
|
||||||
h & infoWindowType;
|
h & infoWindowType;
|
||||||
h & coastVisitable;
|
h & coastVisitable;
|
||||||
|
@@ -458,6 +458,7 @@ void Rewardable::Info::configureObject(Rewardable::Configuration & object, vstd:
|
|||||||
|
|
||||||
object.canRefuse = parameters["canRefuse"].Bool();
|
object.canRefuse = parameters["canRefuse"].Bool();
|
||||||
object.showScoutedPreview = parameters["showScoutedPreview"].Bool();
|
object.showScoutedPreview = parameters["showScoutedPreview"].Bool();
|
||||||
|
object.forceCombat = parameters["forceCombat"].Bool();
|
||||||
object.guardsLayout = parameters["guardsLayout"].String();
|
object.guardsLayout = parameters["guardsLayout"].String();
|
||||||
object.coastVisitable = parameters["coastVisitable"].Bool();
|
object.coastVisitable = parameters["coastVisitable"].Bool();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user