diff --git a/config/threatlevel.txt b/config/threatlevel.txt new file mode 100644 index 000000000..16d58e1e2 --- /dev/null +++ b/config/threatlevel.txt @@ -0,0 +1,14 @@ + +Threat: +Effortless +Very Weak +Weak +A bit weaker +Equal +A bit stronger +Strong +Very Strong +Challenging +Overpowering +Deadly +Impossible diff --git a/lib/CGeneralTextHandler.cpp b/lib/CGeneralTextHandler.cpp index f71e6c346..8e6fe578d 100644 --- a/lib/CGeneralTextHandler.cpp +++ b/lib/CGeneralTextHandler.cpp @@ -533,6 +533,15 @@ void CGeneralTextHandler::load() } } while (nameBuf.size()); } + + std::ifstream ifs(DATA_DIR "/config/threatlevel.txt", std::ios::in | std::ios::binary); + getline(ifs, buf); //skip 1st line + for (int i = 0; i < 13; ++i) + { + getline(ifs, buf); + threat.push_back(buf); + tlog1 << buf << "\n"; + } } diff --git a/lib/CGeneralTextHandler.h b/lib/CGeneralTextHandler.h index a7519a8be..649ef2192 100644 --- a/lib/CGeneralTextHandler.h +++ b/lib/CGeneralTextHandler.h @@ -68,6 +68,7 @@ public: std::vector > > quests; //[quest][type][index] //type: quest, progress, complete, rollover, log OR time limit //index: 0-2 seer hut, 3-5 border guard std::vector seerNames; + std::vector threat; //power rating for neutral stacks //sec skills std::vector skillName; diff --git a/lib/CObjectHandler.cpp b/lib/CObjectHandler.cpp index 5066252fe..366585cc5 100644 --- a/lib/CObjectHandler.cpp +++ b/lib/CObjectHandler.cpp @@ -2825,20 +2825,24 @@ const std::string & CGCreature::getHoverText() const if(const CGHeroInstance *selHero = cb->getSelectedHero(cb->getCurrentPlayer())) { - hoverName += "\n\n Threat: "; + std::vector * texts = &VLC->generaltexth->threat; + hoverName += "\n\n "; + hoverName += (*texts)[0]; + int choice; float ratio = ((float)getArmyStrength() / selHero->getTotalStrength()); - if (ratio < 0.1) hoverName += "Effortless"; - else if (ratio < 0.25) hoverName += "Very Weak"; - else if (ratio < 0.6) hoverName += "Weak"; - else if (ratio < 0.9) hoverName += "A bit weaker"; - else if (ratio < 1.1) hoverName += "Equal"; - else if (ratio < 1.3) hoverName += "A bit stronger"; - else if (ratio < 1.8) hoverName += "Strong"; - else if (ratio < 2.5) hoverName += "Very Strong"; - else if (ratio < 4) hoverName += "Challenging"; - else if (ratio < 8) hoverName += "Overpowering"; - else if (ratio < 20) hoverName += "Deadly"; - else hoverName += "Impossible"; + if (ratio < 0.1) choice = 1; + else if (ratio < 0.25) choice = 2; + else if (ratio < 0.6) choice = 3; + else if (ratio < 0.9) choice = 4; + else if (ratio < 1.1) choice = 5; + else if (ratio < 1.3) choice = 6; + else if (ratio < 1.8) choice = 7; + else if (ratio < 2.5) choice = 8; + else if (ratio < 4) choice = 9; + else if (ratio < 8) choice = 10; + else if (ratio < 20) choice = 11; + else choice = 12; + hoverName += (*texts)[choice]; } return hoverName; }