void Battle::EagleEyeSkillAction(HeroBase & hero, const SpellStorage & spells, bool local) { if(spells.empty() || !hero.HaveSpellBook()) return; SpellStorage new_spells; new_spells.reserve(10); const Skill::Secondary eagleeye(Skill::Secondary::EAGLEEYE, hero.GetLevelSkill(Skill::Secondary::EAGLEEYE)); // filter spells for(SpellStorage::const_iterator it = spells.begin(); it != spells.end(); ++it) { const Spell & sp = *it; if(!hero.HaveSpell(sp)) { switch(eagleeye.Level()) { case Skill::Level::BASIC: // 20% if(3 > sp.Level() && eagleeye.GetValues() >= Rand::Get(1, 100)) new_spells.push_back(sp); break; case Skill::Level::ADVANCED: // 30% if(4 > sp.Level() && eagleeye.GetValues() >= Rand::Get(1, 100)) new_spells.push_back(sp); break; case Skill::Level::EXPERT: // 40% if(5 > sp.Level() && eagleeye.GetValues() >= Rand::Get(1, 100)) new_spells.push_back(sp); break; default: break; } } } // add new spell for(SpellStorage::const_iterator it = new_spells.begin(); it != new_spells.end(); ++it) { const Spell & sp = *it; if(local) { std::string msg = _("Through eagle-eyed observation, %{name} is able to learn the magic spell %{spell}."); String::Replace(msg, "%{name}", hero.GetName()); String::Replace(msg, "%{spell}", sp.GetName()); Game::PlayPickupSound(); Dialog::SpellInfo("", msg, sp); } } hero.AppendSpellsToBook(new_spells, true); }