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

Merge remote-tracking branch 'remotes/origin/develop' into feature/VCMIMapFormat1

Conflicts:
	lib/CArtHandler.h
	lib/mapObjects/MiscObjects.cpp
This commit is contained in:
AlexVinS
2016-01-24 15:39:41 +03:00
27 changed files with 432 additions and 181 deletions

View File

@ -393,6 +393,7 @@ void CGCreature::joinDecision(const CGHeroInstance *h, int cost, ui32 accept) co
if(cost)
cb->giveResource(h->tempOwner,Res::GOLD,-cost);
giveReward(h);
cb->tryJoiningArmy(this, h, true, true);
}
}
@ -456,6 +457,7 @@ void CGCreature::battleFinished(const CGHeroInstance *hero, const BattleResult &
if(result.winner==0)
{
giveReward(hero);
cb->removeObject(this);
}
else
@ -558,6 +560,35 @@ int CGCreature::getNumberOfStacks(const CGHeroInstance *hero) const
return split;
}
void CGCreature::giveReward(const CGHeroInstance * h) const
{
InfoWindow iw;
iw.player = h->tempOwner;
if(resources.size())
{
cb->giveResources(h->tempOwner, resources);
for(int i = 0; i < resources.size(); i++)
{
if(resources[i] > 0)
iw.components.push_back(Component(Component::RESOURCE, i, resources[i], 0));
}
}
if(gainedArtifact != ArtifactID::NONE)
{
cb->giveHeroNewArtifact(h, VLC->arth->artifacts[gainedArtifact], ArtifactPosition::FIRST_AVAILABLE);
iw.components.push_back(Component(Component::ARTIFACT, gainedArtifact, 0, 0));
}
if(iw.components.size())
{
iw.text.addTxt(MetaString::ADVOB_TXT, 183); // % has found treasure
iw.text.addReplacement(h->name);
cb->showInfoDialog(&iw);
}
}
void CGCreature::writeJsonOptions(JsonNode& json) const
{
@ -1791,6 +1822,7 @@ void CGMagi::onHeroVisit(const CGHeroInstance * h) const
cb->sendAndApply(&cv);
}
cv.pos = h->getPosition(false);
cv.focusTime = 0;
cb->sendAndApply(&cv);
}
}