mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
implement luck and morale cheats from OH3
This commit is contained in:
parent
13673335a0
commit
4bad88f141
@ -93,6 +93,16 @@ int AFactionMember::getPrimSkillLevel(PrimarySkill id) const
|
||||
|
||||
int AFactionMember::moraleValAndBonusList(TConstBonusListPtr & bonusList) const
|
||||
{
|
||||
int32_t maxGoodMorale = VLC->settings()->getVector(EGameSettings::COMBAT_GOOD_MORALE_DICE).size();
|
||||
int32_t maxBadMorale = - (int32_t) VLC->settings()->getVector(EGameSettings::COMBAT_BAD_MORALE_DICE).size();
|
||||
|
||||
if(getBonusBearer()->hasBonusOfType(BonusType::MAX_MORALE))
|
||||
{
|
||||
if(bonusList && !bonusList->empty())
|
||||
bonusList = std::make_shared<const BonusList>();
|
||||
return maxGoodMorale;
|
||||
}
|
||||
|
||||
static const auto unaffectedByMoraleSelector = Selector::type()(BonusType::NON_LIVING).Or(Selector::type()(BonusType::UNDEAD))
|
||||
.Or(Selector::type()(BonusType::SIEGE_WEAPON)).Or(Selector::type()(BonusType::NO_MORALE));
|
||||
|
||||
@ -109,14 +119,21 @@ int AFactionMember::moraleValAndBonusList(TConstBonusListPtr & bonusList) const
|
||||
static const std::string cachingStrMor = "type_MORALE";
|
||||
bonusList = getBonusBearer()->getBonuses(moraleSelector, cachingStrMor);
|
||||
|
||||
int32_t maxGoodMorale = VLC->settings()->getVector(EGameSettings::COMBAT_GOOD_MORALE_DICE).size();
|
||||
int32_t maxBadMorale = - (int32_t) VLC->settings()->getVector(EGameSettings::COMBAT_BAD_MORALE_DICE).size();
|
||||
|
||||
return std::clamp(bonusList->totalValue(), maxBadMorale, maxGoodMorale);
|
||||
}
|
||||
|
||||
int AFactionMember::luckValAndBonusList(TConstBonusListPtr & bonusList) const
|
||||
{
|
||||
int32_t maxGoodLuck = VLC->settings()->getVector(EGameSettings::COMBAT_GOOD_LUCK_DICE).size();
|
||||
int32_t maxBadLuck = - (int32_t) VLC->settings()->getVector(EGameSettings::COMBAT_BAD_LUCK_DICE).size();
|
||||
|
||||
if(getBonusBearer()->hasBonusOfType(BonusType::MAX_LUCK))
|
||||
{
|
||||
if(bonusList && !bonusList->empty())
|
||||
bonusList = std::make_shared<const BonusList>();
|
||||
return maxGoodLuck;
|
||||
}
|
||||
|
||||
if(getBonusBearer()->hasBonusOfType(BonusType::NO_LUCK))
|
||||
{
|
||||
if(bonusList && !bonusList->empty())
|
||||
@ -128,9 +145,6 @@ int AFactionMember::luckValAndBonusList(TConstBonusListPtr & bonusList) const
|
||||
static const std::string cachingStrLuck = "type_LUCK";
|
||||
bonusList = getBonusBearer()->getBonuses(luckSelector, cachingStrLuck);
|
||||
|
||||
int32_t maxGoodLuck = VLC->settings()->getVector(EGameSettings::COMBAT_GOOD_LUCK_DICE).size();
|
||||
int32_t maxBadLuck = - (int32_t) VLC->settings()->getVector(EGameSettings::COMBAT_BAD_LUCK_DICE).size();
|
||||
|
||||
return std::clamp(bonusList->totalValue(), maxBadLuck, maxGoodLuck);
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,8 @@ class JsonNode;
|
||||
BONUS_NAME(MOVEMENT) /*Subtype is 1 - land, 0 - sea*/ \
|
||||
BONUS_NAME(MORALE) \
|
||||
BONUS_NAME(LUCK) \
|
||||
BONUS_NAME(MAX_MORALE) /*cheat bonus*/ \
|
||||
BONUS_NAME(MAX_LUCK) /*cheat bonus*/ \
|
||||
BONUS_NAME(PRIMARY_SKILL) /*uses subtype to pick skill; additional info if set: 1 - only melee, 2 - only distance*/ \
|
||||
BONUS_NAME(SIGHT_RADIUS) \
|
||||
BONUS_NAME(MANA_REGENERATION) /*points per turn*/ \
|
||||
|
@ -383,6 +383,24 @@ void PlayerMessageProcessor::cheatPuzzleReveal(PlayerColor player)
|
||||
}
|
||||
}
|
||||
|
||||
void PlayerMessageProcessor::cheatMaxLuck(PlayerColor player, const CGHeroInstance * hero)
|
||||
{
|
||||
GiveBonus gb;
|
||||
gb.bonus = Bonus(BonusDuration::PERMANENT, BonusType::MAX_LUCK, BonusSource::OTHER, 0, BonusSourceID(Obj(Obj::NO_OBJ)));
|
||||
gb.id = hero->id;
|
||||
|
||||
gameHandler->giveHeroBonus(&gb);
|
||||
}
|
||||
|
||||
void PlayerMessageProcessor::cheatMaxMorale(PlayerColor player, const CGHeroInstance * hero)
|
||||
{
|
||||
GiveBonus gb;
|
||||
gb.bonus = Bonus(BonusDuration::PERMANENT, BonusType::MAX_MORALE, BonusSource::OTHER, 0, BonusSourceID(Obj(Obj::NO_OBJ)));
|
||||
gb.id = hero->id;
|
||||
|
||||
gameHandler->giveHeroBonus(&gb);
|
||||
}
|
||||
|
||||
bool PlayerMessageProcessor::handleCheatCode(const std::string & cheat, PlayerColor player, ObjectInstanceID currObj)
|
||||
{
|
||||
std::vector<std::string> words;
|
||||
@ -415,6 +433,8 @@ bool PlayerMessageProcessor::handleCheatCode(const std::string & cheat, PlayerCo
|
||||
"vcminahar", "vcmimove", "nwcnebuchadnezzar",
|
||||
"vcmiforgeofnoldorking", "vcmiartifacts",
|
||||
"vcmiolorin", "vcmiexp",
|
||||
"nwcfollowthewhiterabbit",
|
||||
"nwcmorpheus"
|
||||
};
|
||||
|
||||
if (!vstd::contains(townTargetedCheats, cheatName) && !vstd::contains(playerTargetedCheats, cheatName) && !vstd::contains(heroTargetedCheats, cheatName))
|
||||
@ -489,60 +509,62 @@ void PlayerMessageProcessor::executeCheatCode(const std::string & cheatName, Pla
|
||||
const auto & doCheatMapReveal = [&]() { cheatMapReveal(player, true); };
|
||||
const auto & doCheatMapHide = [&]() { cheatMapReveal(player, false); };
|
||||
const auto & doCheatRevealPuzzle = [&]() { cheatPuzzleReveal(player); };
|
||||
const auto & doCheatMaxLuck = [&]() { cheatMaxLuck(player, hero); };
|
||||
const auto & doCheatMaxMorale = [&]() { cheatMaxMorale(player, hero); };
|
||||
|
||||
// Unimplemented H3 cheats:
|
||||
// nwcfollowthewhiterabbit - The currently selected hero permanently gains maximum luck.
|
||||
// nwcmorpheus - The currently selected hero permanently gains maximum morale.
|
||||
// nwcphisherprice - Changes and brightens the game colors.
|
||||
|
||||
std::map<std::string, std::function<void()>> callbacks = {
|
||||
{"vcmiainur", [&] () {doCheatGiveArmyFixed({ "archangel", "5" });} },
|
||||
{"nwctrinity", [&] () {doCheatGiveArmyFixed({ "archangel", "5" });} },
|
||||
{"vcmiangband", [&] () {doCheatGiveArmyFixed({ "blackKnight", "10" });} },
|
||||
{"vcmiglaurung", [&] () {doCheatGiveArmyFixed({ "crystalDragon", "5000" });} },
|
||||
{"vcmiarchangel", [&] () {doCheatGiveArmyFixed({ "archangel", "5" });} },
|
||||
{"nwcagents", [&] () {doCheatGiveArmyFixed({ "blackKnight", "10" });} },
|
||||
{"vcmiblackknight", [&] () {doCheatGiveArmyFixed({ "blackKnight", "10" });} },
|
||||
{"vcmicrystal", [&] () {doCheatGiveArmyFixed({ "crystalDragon", "5000" });} },
|
||||
{"vcmiazure", [&] () {doCheatGiveArmyFixed({ "azureDragon", "5000" });} },
|
||||
{"vcmifaerie", [&] () {doCheatGiveArmyFixed({ "fairieDragon", "5000" });} },
|
||||
{"vcmiarmy", doCheatGiveArmyCustom },
|
||||
{"vcminissi", doCheatGiveArmyCustom },
|
||||
{"vcmiistari", doCheatGiveSpells },
|
||||
{"vcmispells", doCheatGiveSpells },
|
||||
{"nwcthereisnospoon", doCheatGiveSpells },
|
||||
{"vcmiarmenelos", doCheatBuildTown },
|
||||
{"vcmibuild", doCheatBuildTown },
|
||||
{"nwczion", doCheatBuildTown },
|
||||
{"vcminoldor", doCheatGiveMachines },
|
||||
{"vcmimachines", doCheatGiveMachines },
|
||||
{"nwclotsofguns", doCheatGiveMachines },
|
||||
{"vcmiforgeofnoldorking", doCheatGiveArtifacts },
|
||||
{"vcmiartifacts", doCheatGiveArtifacts },
|
||||
{"vcmiglorfindel", doCheatLevelup },
|
||||
{"vcmilevel", doCheatLevelup },
|
||||
{"nwcneo", doCheatLevelup },
|
||||
{"vcmiolorin", doCheatExperience },
|
||||
{"vcmiexp", doCheatExperience },
|
||||
{"vcminahar", doCheatMovement },
|
||||
{"vcmimove", doCheatMovement },
|
||||
{"nwcnebuchadnezzar", doCheatMovement },
|
||||
{"vcmiformenos", doCheatResources },
|
||||
{"vcmiresources", doCheatResources },
|
||||
{"nwctheconstruct", doCheatResources },
|
||||
{"nwcbluepill", doCheatDefeat },
|
||||
{"vcmimelkor", doCheatDefeat },
|
||||
{"vcmilose", doCheatDefeat },
|
||||
{"nwcredpill", doCheatVictory },
|
||||
{"vcmisilmaril", doCheatVictory },
|
||||
{"vcmiwin", doCheatVictory },
|
||||
{"nwcwhatisthematrix", doCheatMapReveal },
|
||||
{"vcmieagles", doCheatMapReveal },
|
||||
{"vcmimap", doCheatMapReveal },
|
||||
{"vcmiungoliant", doCheatMapHide },
|
||||
{"vcmihidemap", doCheatMapHide },
|
||||
{"nwcignoranceisbliss", doCheatMapHide },
|
||||
{"nwcoracle", doCheatRevealPuzzle },
|
||||
{"vcmiainur", [&] () {doCheatGiveArmyFixed({ "archangel", "5" });} },
|
||||
{"nwctrinity", [&] () {doCheatGiveArmyFixed({ "archangel", "5" });} },
|
||||
{"vcmiangband", [&] () {doCheatGiveArmyFixed({ "blackKnight", "10" });} },
|
||||
{"vcmiglaurung", [&] () {doCheatGiveArmyFixed({ "crystalDragon", "5000" });} },
|
||||
{"vcmiarchangel", [&] () {doCheatGiveArmyFixed({ "archangel", "5" });} },
|
||||
{"nwcagents", [&] () {doCheatGiveArmyFixed({ "blackKnight", "10" });} },
|
||||
{"vcmiblackknight", [&] () {doCheatGiveArmyFixed({ "blackKnight", "10" });} },
|
||||
{"vcmicrystal", [&] () {doCheatGiveArmyFixed({ "crystalDragon", "5000" });} },
|
||||
{"vcmiazure", [&] () {doCheatGiveArmyFixed({ "azureDragon", "5000" });} },
|
||||
{"vcmifaerie", [&] () {doCheatGiveArmyFixed({ "fairieDragon", "5000" });} },
|
||||
{"vcmiarmy", doCheatGiveArmyCustom },
|
||||
{"vcminissi", doCheatGiveArmyCustom },
|
||||
{"vcmiistari", doCheatGiveSpells },
|
||||
{"vcmispells", doCheatGiveSpells },
|
||||
{"nwcthereisnospoon", doCheatGiveSpells },
|
||||
{"vcmiarmenelos", doCheatBuildTown },
|
||||
{"vcmibuild", doCheatBuildTown },
|
||||
{"nwczion", doCheatBuildTown },
|
||||
{"vcminoldor", doCheatGiveMachines },
|
||||
{"vcmimachines", doCheatGiveMachines },
|
||||
{"nwclotsofguns", doCheatGiveMachines },
|
||||
{"vcmiforgeofnoldorking", doCheatGiveArtifacts },
|
||||
{"vcmiartifacts", doCheatGiveArtifacts },
|
||||
{"vcmiglorfindel", doCheatLevelup },
|
||||
{"vcmilevel", doCheatLevelup },
|
||||
{"nwcneo", doCheatLevelup },
|
||||
{"vcmiolorin", doCheatExperience },
|
||||
{"vcmiexp", doCheatExperience },
|
||||
{"vcminahar", doCheatMovement },
|
||||
{"vcmimove", doCheatMovement },
|
||||
{"nwcnebuchadnezzar", doCheatMovement },
|
||||
{"vcmiformenos", doCheatResources },
|
||||
{"vcmiresources", doCheatResources },
|
||||
{"nwctheconstruct", doCheatResources },
|
||||
{"nwcbluepill", doCheatDefeat },
|
||||
{"vcmimelkor", doCheatDefeat },
|
||||
{"vcmilose", doCheatDefeat },
|
||||
{"nwcredpill", doCheatVictory },
|
||||
{"vcmisilmaril", doCheatVictory },
|
||||
{"vcmiwin", doCheatVictory },
|
||||
{"nwcwhatisthematrix", doCheatMapReveal },
|
||||
{"vcmieagles", doCheatMapReveal },
|
||||
{"vcmimap", doCheatMapReveal },
|
||||
{"vcmiungoliant", doCheatMapHide },
|
||||
{"vcmihidemap", doCheatMapHide },
|
||||
{"nwcignoranceisbliss", doCheatMapHide },
|
||||
{"nwcoracle", doCheatRevealPuzzle },
|
||||
{"nwcfollowthewhiterabbit", doCheatMaxLuck },
|
||||
{"nwcmorpheus", doCheatMaxMorale },
|
||||
};
|
||||
|
||||
assert(callbacks.count(cheatName));
|
||||
|
@ -38,6 +38,8 @@ class PlayerMessageProcessor
|
||||
void cheatDefeat(PlayerColor player);
|
||||
void cheatMapReveal(PlayerColor player, bool reveal);
|
||||
void cheatPuzzleReveal(PlayerColor player);
|
||||
void cheatMaxLuck(PlayerColor player, const CGHeroInstance * hero);
|
||||
void cheatMaxMorale(PlayerColor player, const CGHeroInstance * hero);
|
||||
|
||||
public:
|
||||
CGameHandler * gameHandler;
|
||||
|
Loading…
Reference in New Issue
Block a user