1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

Neutral creatures are now correctly split into stacks & merged after a battle.

TODO: find relation to adventure map tile
This commit is contained in:
DjWarmonger
2011-04-14 07:58:19 +00:00
parent d6bd8514e7
commit 6a8e3f1b57
2 changed files with 36 additions and 4 deletions

View File

@ -2943,6 +2943,27 @@ void CGCreature::endBattle( BattleResult *result ) const
cb->setHoverName(id,&ms);
cb->setObjProperty(id, 11, slots.begin()->second.count * 1000);
*/
//merge stacks into one
TSlots::const_iterator i;
CCreature * cre = VLC->creh->creatures[restore.basicType];
for (i = stacks.begin(); i != stacks.end(); i++)
{
if (cre->isMyUpgrade(i->second->type))
{
cb->changeStackType (StackLocation(this, i->first), cre); //un-upgrade creatures
}
}
while (stacks.size() > 1) //hopefully that's enough
{
i = stacks.end();
i--;
TSlot slot = getSlotFor(i->second->type);
if (slot == i->first) //no reason to move stack to its own slot
break;
else
cb->moveStack (StackLocation(this, i->first), StackLocation(this, slot), i->second->count);
}
}
}
@ -3005,6 +3026,9 @@ void CGCreature::setPropertyDer(ui8 what, ui32 val)
case 12:
giveStackExp(val);
break;
case 13:
restore.basicType = val;
break;
}
}
@ -3134,6 +3158,7 @@ void CGCreature::fight( const CGHeroInstance *h ) const
//split stacks
int totalCount; //TODO: multiple creature types in a stack?
int basicType = stacks.begin()->second->type->idNumber;
cb->setObjProperty(id, 13, basicType); //store info about creature stack
float relativePower = ((float)h->getTotalStrength() / getArmyStrength());
int stacksCount;
@ -3182,7 +3207,7 @@ void CGCreature::fight( const CGHeroInstance *h ) const
}
if (stacksCount > 1)
{
if (rand()%100 > 50) //upgrade
if (rand()%100 < 50) //upgrade
{
TSlot slotId = (stacks.size() / 2);
if(ui32 upgradesSize = getStack(slotId).type->upgrades.size())
@ -3196,8 +3221,6 @@ void CGCreature::fight( const CGHeroInstance *h ) const
cb->startBattleI(h, this, boost::bind(&CGCreature::endBattle,this,_1));
//stacks.clear();
//stacks.insert(
}
void CGCreature::flee( const CGHeroInstance * h ) const