From 2156204306b8e579c5005edf129de4a26d93fe17 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Fri, 6 Feb 2015 15:42:09 +0300 Subject: [PATCH] Visions spell in case of monsters --- lib/mapObjects/MiscObjects.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 375ca9002..5a3d7bf06 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -101,7 +101,33 @@ std::string CGCreature::getHoverText(PlayerColor player) const std::string CGCreature::getHoverText(const CGHeroInstance * hero) const { - std::string hoverName = getHoverText(hero->tempOwner); + //VISIONS spell support + + static const std::string cached = boost::to_string((boost::format("type_%d__subtype_0") % Bonus::VISIONS)); + + std::string hoverName; + + const int visionsMultiplier = hero->valOfBonuses(Selector::typeSubtype(Bonus::VISIONS,0), cached); + + int visionsRadius = visionsMultiplier * hero->getPrimSkillLevel(PrimarySkill::SPELL_POWER); + + if (visionsMultiplier > 0) + vstd::amin(visionsRadius, 3); //minimum range is 3 tiles, but only if VISIONS bonus present + + const bool inVisionsRange = (pos.dist2d(hero->pos) < visionsRadius) && (pos.z == hero->pos.z); + + if(inVisionsRange) + { + MetaString ms; + ms << stacks.begin()->second->count; + ms << " " ; + ms.addTxt(MetaString::CRE_PL_NAMES,subID); + ms.toString(hoverName); + } + else + { + hoverName = getHoverText(hero->tempOwner); + } const JsonNode & texts = VLC->generaltexth->localizedTexts["adventureMap"]["monsterThreat"];