1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-24 03:47:18 +02:00

* more appropriate calculation of spell level by SPELL bonus

This commit is contained in:
mateuszb 2010-08-05 09:11:38 +00:00
parent 7002e73908
commit f41c85212f
4 changed files with 29 additions and 6 deletions

View File

@ -636,15 +636,15 @@ void CArtHandler::addBonuses()
//Sea Captain's Hat
giveArtBonus(123,Bonus::WHIRLPOOL_PROTECTION,0);
giveArtBonus(123,Bonus::SEA_MOVEMENT,+500);
giveArtBonus(123,Bonus::SPELL,3,0);
giveArtBonus(123,Bonus::SPELL,3,1);
giveArtBonus(123,Bonus::SPELL,3,0, Bonus::INDEPENDENT_MAX);
giveArtBonus(123,Bonus::SPELL,3,1, Bonus::INDEPENDENT_MAX);
giveArtBonus(124,Bonus::SPELLS_OF_LEVEL,3,1); //Spellbinder's Hat
giveArtBonus(125,Bonus::ENEMY_CANT_ESCAPE,0); //Shackles of War
giveArtBonus(126,Bonus::BLOCK_SPELLS_ABOVE_LEVEL,0);//Orb of Inhibition
//Armageddon's Blade
giveArtBonus(128, Bonus::SPELL, 3, 26);
giveArtBonus(128, Bonus::SPELL, 3, 26, Bonus::INDEPENDENT_MAX);
giveArtBonus(128, Bonus::SPELL_IMMUNITY, 26);
ART_ATTACK_AND_DEFENSE(128, +3);
ART_PRIM_SKILL(128, 2, +3);

View File

@ -1285,6 +1285,10 @@ ui8 CGHeroInstance::getSpellSchoolLevel(const CSpell * spell, int *outSelectedSc
amax(skill, valOfBonuses(Bonus::MAGIC_SCHOOL_SKILL, 0)); //any school bonus
if (hasBonusOfType(Bonus::SPELL, spell->id))
{
amax(skill, valOfBonuses(Bonus::SPELL, spell->id));
}
assert(skill >= 0 && skill <= 3);
return skill;
}

View File

@ -22,6 +22,8 @@ int DLL_EXPORT BonusList::totalValue() const
int percentToBase = 0;
int percentToAll = 0;
int additive = 0;
int indepMax = 0;
bool hasIndepMax = false;
for(const_iterator i = begin(); i != end(); i++)
{
@ -38,12 +40,28 @@ int DLL_EXPORT BonusList::totalValue() const
break;
case Bonus::ADDITIVE_VALUE:
additive += i->val;
break;
case Bonus::INDEPENDENT_MAX:
if (!indepMax)
{
indepMax = i->val;
hasIndepMax = true;
}
else
{
amax(indepMax, i->val);
}
break;
}
}
int modifiedBase = base + (base * percentToBase) / 100;
modifiedBase += additive;
return (modifiedBase * (100 + percentToAll)) / 100;
int valFirst = (modifiedBase * (100 + percentToAll)) / 100;
if (hasIndepMax)
return std::max(valFirst, indepMax);
else
return valFirst;
}
const DLL_EXPORT Bonus * BonusList::getFirst(const CSelector &selector) const

View File

@ -208,7 +208,8 @@ struct DLL_EXPORT Bonus
ADDITIVE_VALUE,
BASE_NUMBER,
PERCENT_TO_ALL,
PERCENT_TO_BASE
PERCENT_TO_BASE,
INDEPENDENT_MAX //used for SPELL bonus
};
ui8 duration; //uses BonusDuration values
@ -220,7 +221,7 @@ struct DLL_EXPORT Bonus
ui8 source;//source type" uses BonusSource values - what gave that bonus
si32 val;
ui32 id; //source id: id of object/artifact/spell
ui8 valType;
ui8 valType; //by ValueType enum
si32 additionalInfo;
ui8 effectRange; //if not NO_LIMIT, bonus will be ommitted by default