mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Correct, yet ugly handling of Magic Resistance.
This commit is contained in:
parent
5786c26586
commit
936005aa1c
@ -155,6 +155,17 @@ 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);
|
||||
|
@ -1905,14 +1905,7 @@ std::vector<ui32> BattleInfo::calculateResistedStacks( const CSpell * sp, const
|
||||
else
|
||||
bonusHero = hero2;
|
||||
|
||||
int prob = (*it)->valOfBonuses(Bonus::MAGIC_RESISTANCE); //probability of resistance in %
|
||||
if(bonusHero)
|
||||
{
|
||||
//bonusHero's resistance support (secondary skils and artifacts)
|
||||
prob += bonusHero->valOfBonuses(Bonus::MAGIC_RESISTANCE);
|
||||
//resistance skill
|
||||
prob += bonusHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, 26) / 100.0f;
|
||||
}
|
||||
int prob = (*it)->magicResistance(); //probability of resistance in %
|
||||
|
||||
if(prob > 100) prob = 100;
|
||||
|
||||
|
@ -589,9 +589,9 @@ void CArtHandler::addBonuses()
|
||||
giveArtBonus(55,Bonus::SECONDARY_SKILL_PREMY,+10, CGHeroInstance::NECROMANCY, Bonus::ADDITIVE_VALUE);//Vampire's Cowl
|
||||
giveArtBonus(56,Bonus::SECONDARY_SKILL_PREMY,+15, CGHeroInstance::NECROMANCY, Bonus::ADDITIVE_VALUE);//Dead Man's Boots
|
||||
|
||||
giveArtBonus(57,Bonus::MAGIC_RESISTANCE,+5);//Garniture of Interference
|
||||
giveArtBonus(58,Bonus::MAGIC_RESISTANCE,+10);//Surcoat of Counterpoise
|
||||
giveArtBonus(59,Bonus::MAGIC_RESISTANCE,+15);//Boots of Polarity
|
||||
giveArtBonus(57,Bonus::MAGIC_RESISTANCE,+5, 0);//Garniture of Interference
|
||||
giveArtBonus(58,Bonus::MAGIC_RESISTANCE,+10, 0);//Surcoat of Counterpoise
|
||||
giveArtBonus(59,Bonus::MAGIC_RESISTANCE,+15, 0);//Boots of Polarity
|
||||
|
||||
//archery bonus
|
||||
giveArtBonus(60,Bonus::SECONDARY_SKILL_PREMY,+5, CGHeroInstance::ARCHERY, Bonus::ADDITIVE_VALUE);//Bow of Elven Cherrywood
|
||||
|
@ -493,6 +493,18 @@ int CStackInstance::getExpRank() const
|
||||
}
|
||||
}
|
||||
|
||||
si32 CStackInstance::magicResistance() const
|
||||
{
|
||||
si32 val = valOfBonuses(Selector::type(Bonus::MAGIC_RESISTANCE));
|
||||
if (const CGHeroInstance * hero = dynamic_cast<const CGHeroInstance *>(_armyObj))
|
||||
{
|
||||
//resistance skill
|
||||
val += hero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, CGHeroInstance::RESISTANCE);
|
||||
}
|
||||
amin (val, 100);
|
||||
return val;
|
||||
}
|
||||
|
||||
void CStackInstance::giveStackExp(expType exp)
|
||||
{
|
||||
int level = type->level;
|
||||
@ -574,8 +586,7 @@ std::string CStackInstance::bonusToString(Bonus *bonus, bool description) const
|
||||
case Bonus::RECEPTIVE:
|
||||
case Bonus::DIRECT_DAMAGE_IMMUNITY:
|
||||
break;
|
||||
//One numeric value
|
||||
case Bonus::MAGIC_RESISTANCE:
|
||||
//One numeric value. magic resistance handled separately
|
||||
case Bonus::SPELL_RESISTANCE_AURA:
|
||||
case Bonus::SPELL_DAMAGE_REDUCTION:
|
||||
case Bonus::LEVEL_SPELL_IMMUNITY:
|
||||
@ -626,6 +637,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 "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return text;
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
int getQuantityID() const;
|
||||
std::string getQuantityTXT(bool capitalized = true) const;
|
||||
int getExpRank() const;
|
||||
si32 magicResistance() const;
|
||||
void init();
|
||||
CStackInstance();
|
||||
CStackInstance(TCreature id, TQuantity count);
|
||||
|
@ -320,6 +320,11 @@ int IBonusBearer::getPrimSkillLevel(int id) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
si32 IBonusBearer::magicResistance() const
|
||||
{
|
||||
return valOfBonuses(Selector::type(Bonus::MAGIC_RESISTANCE));
|
||||
}
|
||||
|
||||
Bonus * CBonusSystemNode::getBonus(const CSelector &selector)
|
||||
{
|
||||
Bonus *ret = bonuses.getFirst(selector);
|
||||
|
@ -414,6 +414,7 @@ public:
|
||||
si32 Attack() const; //get attack of stack with all modificators
|
||||
si32 Defense(bool withFrenzy = true) const; //get defense of stack with all modificators
|
||||
ui16 MaxHealth() const; //get max HP of stack with all modifiers
|
||||
virtual si32 magicResistance() const;
|
||||
|
||||
si32 manaLimit() const; //maximum mana value for this hero (basically 10*knowledge)
|
||||
int getPrimSkillLevel(int id) const; //0-attack, 1-defence, 2-spell power, 3-knowledge
|
||||
|
Loading…
Reference in New Issue
Block a user