1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-08 23:22:25 +02:00

Partial Stack Exp operations. Can't really test it as battle is unplayable atm.

This commit is contained in:
DjWarmonger
2011-02-12 18:48:11 +00:00
parent 7a49240520
commit 252cee96f5
6 changed files with 64 additions and 24 deletions

View File

@@ -218,10 +218,18 @@ void CCreatureSet::setStackCount(TSlot slot, TQuantity count)
{
assert(hasStackAtSlot(slot));
assert(count > 0);
if (STACK_EXP)
stacks[slot]->experience *= ((stacks[slot]->count + count)/(float)stacks[slot]->count);
stacks[slot]->count = count;
armyChanged();
}
void CCreatureSet::giveStackExp(expType exp)
{
for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); i++)
i->second->giveStackExp(exp);
}
void CCreatureSet::clear()
{
while(!stacks.empty())
@@ -453,6 +461,19 @@ int CStackInstance::getExpRank() const
}
}
void CStackInstance::giveStackExp(expType exp)
{
int level = type->level;
if (!iswith(level, 1, 7))
level = 0;
CCreatureHandler * creh = VLC->creh;
amin(exp, (expType)creh->expRanks[level].back()); //prevent exp overflow due to different types
amin(exp, (exp * creh->maxExpPerBattle[level])/100);
amin(experience += exp, creh->expRanks[level].back()); //can't get more exp than this limit
}
void CStackInstance::setType(int creID)
{
setType(VLC->creh->creatures[creID]);
@@ -461,7 +482,11 @@ void CStackInstance::setType(int creID)
void CStackInstance::setType(const CCreature *c)
{
if(type)
{
detachFrom(const_cast<CCreature*>(type));
if (type->isMyUpgrade(c) && STACK_EXP)
experience *= VLC->creh->expAfterUpgrade / 100.0f;
}
type = c;