Pārlūkot izejas kodu

Visions spell in case of monsters

AlexVinS 10 gadi atpakaļ
vecāks
revīzija
2156204306
1 mainītis faili ar 27 papildinājumiem un 1 dzēšanām
  1. 27 1
      lib/mapObjects/MiscObjects.cpp

+ 27 - 1
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"];