1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Half-done Altar of Sacrifice. (Sacrificing creatures should work)

This commit is contained in:
Michał W. Urbańczyk
2010-07-20 06:05:45 +00:00
parent 7afc478ff4
commit cedf6d812c
14 changed files with 885 additions and 345 deletions

View File

@ -4866,5 +4866,33 @@ bool CGameHandler::tryAttackingGuard(const int3 &guardPos, const CGHeroInstance
const TerrainTile &guardTile = gs->map->terrain[guardPos.x][guardPos.y][guardPos.z];
objectVisited(guardTile.visitableObjects.back(), h);
visitObjectAfterVictory = true;
return true;
}
bool CGameHandler::sacrificeCreatures(const IMarket *market, const CGHeroInstance *hero, TSlot slot, ui32 count)
{
int oldCount = hero->getAmount(slot);
int newCount = oldCount - count;
if(oldCount < count)
COMPLAIN_RET("Not enough creatures to sacrifice!")
else if(oldCount == count && hero->Slots().size() == 1 && hero->needsLastStack())
COMPLAIN_RET("Cannot sacrifice last creature!");
int crid = hero->getStack(slot).type->idNumber;
SetGarrisons sg;
sg.garrs[hero->id] = hero->getArmy();
if(newCount)
sg.garrs[hero->id].setStackCount(slot, newCount);
else
sg.garrs[hero->id].eraseStack(slot);
sendAndApply(&sg);
int dump, exp;
market->getOffer(crid, 0, dump, exp, CREATURE_EXP);
exp *= count;
changePrimSkill (hero->id, 4, exp);
return true;
}