mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Smarter handling of Magic Resistance & Resistance hero skill.
This commit is contained in:
parent
60ee0e1a3c
commit
d4465ec929
@ -155,17 +155,6 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
|
||||
bonusItems.push_back (new CBonusItem(genRect(0, 0, 251, 57), text, stack->bonusToString(b, true), stack->bonusToGraphics(b)));
|
||||
}
|
||||
}
|
||||
ui32 resistanceVal = stack->magicResistance(); //ugly solution
|
||||
if (resistanceVal)
|
||||
{
|
||||
text = CGI->creh->stackBonuses.find(Bonus::MAGIC_RESISTANCE)->second.first;
|
||||
std::string text2 = CGI->creh->stackBonuses.find(Bonus::MAGIC_RESISTANCE)->second.second;
|
||||
boost::algorithm::replace_first(text2, "%d", boost::lexical_cast<std::string>( stack->magicResistance() ));
|
||||
Bonus bonus;
|
||||
bonus.type = Bonus::MAGIC_RESISTANCE;
|
||||
std::string gfxName = stack->bonusToGraphics(&bonus);
|
||||
bonusItems.push_back (new CBonusItem(genRect(0, 0, 251, 57), text, text2, gfxName));
|
||||
}
|
||||
|
||||
bonusRows = std::min ((int)((bonusItems.size() + 1) / 2), (conf.cc.resy - 230) / 60);
|
||||
amin(bonusRows, 4);
|
||||
|
@ -624,6 +624,9 @@ void CCreatureHandler::loadCreatures()
|
||||
}
|
||||
}
|
||||
ifs.close();
|
||||
//handle magic resistance secondary skill premy, potentialy may be buggy
|
||||
std::map<TBonusType, std::pair<std::string, std::string> >::iterator it = stackBonuses.find(Bonus::MAGIC_RESISTANCE);
|
||||
stackBonuses[Bonus::SECONDARY_SKILL_PREMY] = std::pair<std::string, std::string>(it->second.first, it->second.second);
|
||||
|
||||
if (STACK_EXP) //reading default stack experience bonuses
|
||||
{
|
||||
|
@ -598,6 +598,16 @@ std::string CStackInstance::bonusToString(Bonus *bonus, bool description) const
|
||||
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(valOfBonuses(Selector::typeSybtype(bonus->type, bonus->subtype))));
|
||||
break;
|
||||
//Complex descriptions
|
||||
case Bonus::SECONDARY_SKILL_PREMY: //only if there's no simple MR
|
||||
if (bonus->subtype == CGHeroInstance::RESISTANCE)
|
||||
{
|
||||
if (!hasBonusOfType(Bonus::MAGIC_RESISTANCE))
|
||||
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>( magicResistance() ));
|
||||
}
|
||||
break;
|
||||
case Bonus::MAGIC_RESISTANCE:
|
||||
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>( magicResistance() ));
|
||||
break;
|
||||
case Bonus::HATE:
|
||||
boost::algorithm::replace_first(text, "%d", boost::lexical_cast<std::string>(valOfBonuses(Selector::typeSybtype(bonus->type, bonus->subtype))));
|
||||
boost::algorithm::replace_first(text, "%s", VLC->creh->creatures[bonus->subtype]->namePl);
|
||||
@ -637,8 +647,9 @@ std::string CStackInstance::bonusToString(Bonus *bonus, bool description) const
|
||||
case Bonus::SPELL_IMMUNITY:
|
||||
boost::algorithm::replace_first(text, "%s", VLC->spellh->spells[bonus->subtype]->name);
|
||||
break;
|
||||
case Bonus::MAGIC_RESISTANCE: //handled separately
|
||||
return "";
|
||||
case Bonus::SECONDARY_SKILL_PREMY:
|
||||
if (bonus->subtype != CGHeroInstance::RESISTANCE || hasBonusOfType(Bonus::MAGIC_RESISTANCE)) //handle it there
|
||||
text = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -681,6 +692,12 @@ std::string CStackInstance::bonusToGraphics(Bonus *bonus) const
|
||||
fileName = "E_DRAGON.bmp"; break;
|
||||
case Bonus::MAGIC_RESISTANCE:
|
||||
fileName = "E_DWARF.bmp"; break;
|
||||
case Bonus::SECONDARY_SKILL_PREMY:
|
||||
if (bonus->subtype = CGHeroInstance::RESISTANCE)
|
||||
{
|
||||
fileName = "E_DWARF.bmp";
|
||||
}
|
||||
break;
|
||||
case Bonus::FEAR:
|
||||
fileName = "E_FEAR.bmp"; break;
|
||||
case Bonus::FEARLESS:
|
||||
|
@ -976,7 +976,7 @@ void Mapa::readHeader( const unsigned char * bufor, int &i)
|
||||
{
|
||||
BOOST_FOREACH(CArtifact *artifact, VLC->arth->artifacts)
|
||||
{
|
||||
if (artifact->constituents != NULL) //combo
|
||||
if (artifact->constituents) //combo
|
||||
{
|
||||
allowedArtifact[artifact->id] = false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user