1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

I don't have time this week to finish and test Creature Banks, so I submit what have been made so far.

This commit is contained in:
DjWarmonger
2009-09-01 14:36:48 +00:00
parent 1fd156e79d
commit 749d54f686
3 changed files with 16 additions and 11 deletions

View File

@@ -1517,7 +1517,7 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
} }
} }
for (std::vector<CGTownBuilding*>::const_iterator i = bonusingBuildings.begin(); i != bonusingBuildings.end(); i++) for (std::vector<CGTownBuilding*>::const_iterator i = bonusingBuildings.begin(); i != bonusingBuildings.end(); i++)
(*i)->onHeroVisit (h); (*i)->onHeroVisit (h); //does not work
cb->heroVisitCastle(id, h->id); cb->heroVisitCastle(id, h->id);
} }
@@ -3810,7 +3810,7 @@ void CBank::initObj()
} }
void CBank::reset(ui16 var1, ui16 var2) //prevents desync void CBank::reset(ui16 var1, ui16 var2) //prevents desync
{ {
int chance = 0; ui8 chance = 0;
for (ui8 i = 0; i < VLC->objh->banksInfo[index].size(); i++) for (ui8 i = 0; i < VLC->objh->banksInfo[index].size(); i++)
{ {
if (var1 < (chance += VLC->objh->banksInfo[index][i].chance)) if (var1 < (chance += VLC->objh->banksInfo[index][i].chance))
@@ -4020,10 +4020,13 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
iw.player = h->getOwner(); iw.player = h->getOwner();
//grant resources //grant resources
for (int it = 0; it < bc->resources.size(); it++) for (int it = 0; it < bc->resources.size(); it++)
{
if (bc->resources[it] != 0)
{ {
iw.components.push_back (Component (Component::RESOURCE, it, bc->resources[it], 0)); iw.components.push_back (Component (Component::RESOURCE, it, bc->resources[it], 0));
cb->giveResource (h->getOwner(), it, bc->resources[it]); cb->giveResource (h->getOwner(), it, bc->resources[it]);
} }
}
//grant artifacts //grant artifacts
for (std::vector<ui32>::const_iterator it = artifacts.begin(); it != artifacts.end(); it++) for (std::vector<ui32>::const_iterator it = artifacts.begin(); it != artifacts.end(); it++)
{ {
@@ -4031,6 +4034,7 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
iw.text.addReplacement (MetaString::ART_NAMES, *it); iw.text.addReplacement (MetaString::ART_NAMES, *it);
cb->giveHeroArtifact (*it, h->id ,-2); cb->giveHeroArtifact (*it, h->id ,-2);
} }
cb->showInfoDialog(&iw);
//grant creatures //grant creatures
CCreatureSet ourArmy; CCreatureSet ourArmy;
for (std::vector< std::pair <ui16, ui32> >::const_iterator it = bc->creatures.begin(); it != bc->creatures.end(); it++) for (std::vector< std::pair <ui16, ui32> >::const_iterator it = bc->creatures.begin(); it != bc->creatures.end(); it++)
@@ -4038,7 +4042,7 @@ void CBank::endBattle (const CGHeroInstance *h, const BattleResult *result) cons
int slot = ourArmy.getSlotFor (it->second); int slot = ourArmy.getSlotFor (it->second);
ourArmy.slots[slot] = *it; //assuming we're not going to add multiple stacks of same creature ourArmy.slots[slot] = *it; //assuming we're not going to add multiple stacks of same creature
} }
cb->giveCreatures (id, cb->getHero (cb->getSelectedHero()), &ourArmy); cb->giveCreatures (id, cb->getHero (h->getOwner()), &ourArmy);
cb->setObjProperty (id, 15, 0); //bc = NULL cb->setObjProperty (id, 15, 0); //bc = NULL
} }
else else

View File

@@ -849,8 +849,8 @@ public:
} }
}; };
class DLL_EXPORT CGOnceVisitable class DLL_EXPORT CGOnceVisitable : public CPlayersVisited
: public CPlayersVisited //wagon, corpse, lean to, warriors tomb ///wagon, corpse, lean to, warriors tomb
{ {
public: public:
ui8 artOrRes; //0 - nothing; 1 - artifact; 2 - resource ui8 artOrRes; //0 - nothing; 1 - artifact; 2 - resource
@@ -948,8 +948,7 @@ struct BankConfig
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & level & chance & upgradeChance & guards & combatValue & resources & creatures & artifacts h & level & chance & upgradeChance & guards & combatValue & resources & creatures & artifacts & value & rewardDifficulty & easiest;
& value & rewardDifficulty & easiest;
} }
}; };

View File

@@ -1486,6 +1486,8 @@ void CGameHandler::giveResource(int player, int which, int val)
} }
void CGameHandler::giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet *creatures) void CGameHandler::giveCreatures (int objid, const CGHeroInstance * h, CCreatureSet *creatures)
{ {
if (creatures->slots.size() <= 0)
return;
CCreatureSet heroArmy = h->army; CCreatureSet heroArmy = h->army;
while(creatures) while(creatures)
{ {