mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
fix for banks(crypt, ships) not giving morale penalty (#384)
* fix for banks(crypt, ships) not giving morale penalty also texts should be closer to original now
This commit is contained in:
committed by
Alexander Shishkin
parent
9cf3f4fe93
commit
5a01aba9c8
@@ -95,63 +95,40 @@ bool CBank::wasVisited (PlayerColor player) const
|
|||||||
return !bc; //FIXME: player A should not know about visit done by player B
|
return !bc; //FIXME: player A should not know about visit done by player B
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBank::onHeroVisit (const CGHeroInstance * h) const
|
void CBank::onHeroVisit(const CGHeroInstance * h) const
|
||||||
{
|
{
|
||||||
if (bc)
|
int banktext = 0;
|
||||||
|
ui16 soundID = soundBase::ROGUE;
|
||||||
|
switch (ID)
|
||||||
{
|
{
|
||||||
int banktext = 0;
|
case Obj::DERELICT_SHIP:
|
||||||
ui16 soundID = soundBase::ROGUE;
|
banktext = 41;
|
||||||
switch (ID)
|
break;
|
||||||
{
|
case Obj::DRAGON_UTOPIA:
|
||||||
case Obj::CREATURE_BANK:
|
banktext = 47;
|
||||||
banktext = 32;
|
break;
|
||||||
break;
|
case Obj::CRYPT:
|
||||||
case Obj::DERELICT_SHIP:
|
banktext = 119;
|
||||||
banktext = 41;
|
break;
|
||||||
break;
|
case Obj::SHIPWRECK:
|
||||||
case Obj::DRAGON_UTOPIA:
|
banktext = 122;
|
||||||
banktext = 47;
|
break;
|
||||||
break;
|
case Obj::PYRAMID:
|
||||||
case Obj::CRYPT:
|
soundID = soundBase::MYSTERY;
|
||||||
banktext = 119;
|
banktext = 105;
|
||||||
break;
|
break;
|
||||||
case Obj::SHIPWRECK:
|
case Obj::CREATURE_BANK:
|
||||||
banktext = 122;
|
default:
|
||||||
break;
|
banktext = 32;
|
||||||
case Obj::PYRAMID:
|
break;
|
||||||
soundID = soundBase::MYSTERY;
|
|
||||||
banktext = 105;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
BlockingDialog bd (true, false);
|
|
||||||
bd.player = h->getOwner();
|
|
||||||
bd.soundID = soundID;
|
|
||||||
bd.text.addTxt(MetaString::ADVOB_TXT, banktext);
|
|
||||||
if (ID == Obj::CREATURE_BANK)
|
|
||||||
bd.text.addReplacement(getObjectName());
|
|
||||||
cb->showBlockingDialog (&bd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
InfoWindow iw;
|
|
||||||
iw.soundID = soundBase::GRAVEYARD;
|
|
||||||
iw.player = h->getOwner();
|
|
||||||
if (ID == Obj::PYRAMID) // You come upon the pyramid ... pyramid is completely empty.
|
|
||||||
{
|
|
||||||
iw.text << VLC->generaltexth->advobtxt[107];
|
|
||||||
iw.components.push_back (Component (Component::LUCK, 0 , -2, 0));
|
|
||||||
GiveBonus gb;
|
|
||||||
gb.bonus = Bonus(Bonus::ONE_BATTLE,Bonus::LUCK,Bonus::OBJECT,-2,id.getNum(),VLC->generaltexth->arraytxt[70]);
|
|
||||||
gb.id = h->id.getNum();
|
|
||||||
cb->giveHeroBonus(&gb);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iw.text << VLC->generaltexth->advobtxt[33];// This was X, now is completely empty
|
|
||||||
iw.text.addReplacement(getObjectName());
|
|
||||||
}
|
|
||||||
cb->showInfoDialog(&iw);
|
|
||||||
}
|
}
|
||||||
|
BlockingDialog bd(true, false);
|
||||||
|
bd.player = h->getOwner();
|
||||||
|
bd.soundID = soundID;
|
||||||
|
bd.text.addTxt(MetaString::ADVOB_TXT, banktext);
|
||||||
|
if (banktext == 32)
|
||||||
|
bd.text.addReplacement(getObjectName());
|
||||||
|
cb->showBlockingDialog(&bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBank::doVisit(const CGHeroInstance * hero) const
|
void CBank::doVisit(const CGHeroInstance * hero) const
|
||||||
@@ -161,59 +138,88 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
|||||||
iw.player = hero->getOwner();
|
iw.player = hero->getOwner();
|
||||||
MetaString loot;
|
MetaString loot;
|
||||||
|
|
||||||
switch (ID)
|
if (bc)
|
||||||
{
|
{
|
||||||
case Obj::CREATURE_BANK:
|
switch (ID)
|
||||||
case Obj::DRAGON_UTOPIA:
|
{
|
||||||
textID = 34;
|
case Obj::DERELICT_SHIP:
|
||||||
break;
|
|
||||||
case Obj::DERELICT_SHIP:
|
|
||||||
if (!bc)
|
|
||||||
textID = 43;
|
textID = 43;
|
||||||
else
|
break;
|
||||||
{
|
case Obj::CRYPT:
|
||||||
GiveBonus gbonus;
|
|
||||||
gbonus.id = hero->id.getNum();
|
|
||||||
gbonus.bonus.duration = Bonus::ONE_BATTLE;
|
|
||||||
gbonus.bonus.source = Bonus::OBJECT;
|
|
||||||
gbonus.bonus.sid = ID;
|
|
||||||
gbonus.bdescr << "\n" << VLC->generaltexth->arraytxt[101];
|
|
||||||
gbonus.bonus.type = Bonus::MORALE;
|
|
||||||
gbonus.bonus.val = -1;
|
|
||||||
cb->giveHeroBonus(&gbonus);
|
|
||||||
textID = 42;
|
|
||||||
iw.components.push_back (Component (Component::MORALE, 0 , -1, 0));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Obj::CRYPT:
|
|
||||||
if (bc)
|
|
||||||
textID = 121;
|
textID = 121;
|
||||||
else
|
break;
|
||||||
|
case Obj::SHIPWRECK:
|
||||||
|
textID = 124;
|
||||||
|
break;
|
||||||
|
case Obj::PYRAMID:
|
||||||
|
textID = 106;
|
||||||
|
break;
|
||||||
|
case Obj::CREATURE_BANK:
|
||||||
|
case Obj::DRAGON_UTOPIA:
|
||||||
|
default:
|
||||||
|
textID = 34;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (ID)
|
||||||
|
{
|
||||||
|
case Obj::SHIPWRECK:
|
||||||
|
case Obj::DERELICT_SHIP:
|
||||||
|
case Obj::CRYPT:
|
||||||
{
|
{
|
||||||
iw.components.push_back (Component (Component::MORALE, 0 , -1, 0));
|
|
||||||
GiveBonus gbonus;
|
GiveBonus gbonus;
|
||||||
gbonus.id = hero->id.getNum();
|
gbonus.id = hero->id.getNum();
|
||||||
gbonus.bonus.duration = Bonus::ONE_BATTLE;
|
gbonus.bonus.duration = Bonus::ONE_BATTLE;
|
||||||
gbonus.bonus.source = Bonus::OBJECT;
|
gbonus.bonus.source = Bonus::OBJECT;
|
||||||
gbonus.bonus.sid = ID;
|
gbonus.bonus.sid = ID;
|
||||||
gbonus.bdescr << "\n" << VLC->generaltexth->arraytxt[ID];
|
|
||||||
gbonus.bonus.type = Bonus::MORALE;
|
gbonus.bonus.type = Bonus::MORALE;
|
||||||
gbonus.bonus.val = -1;
|
gbonus.bonus.val = -1;
|
||||||
|
switch (ID)
|
||||||
|
{
|
||||||
|
case Obj::SHIPWRECK:
|
||||||
|
textID = 123;
|
||||||
|
gbonus.bdescr << VLC->generaltexth->arraytxt[99];
|
||||||
|
break;
|
||||||
|
case Obj::DERELICT_SHIP:
|
||||||
|
textID = 42;
|
||||||
|
gbonus.bdescr << VLC->generaltexth->arraytxt[101];
|
||||||
|
break;
|
||||||
|
case Obj::CRYPT:
|
||||||
|
textID = 120;
|
||||||
|
gbonus.bdescr << VLC->generaltexth->arraytxt[98];
|
||||||
|
break;
|
||||||
|
}
|
||||||
cb->giveHeroBonus(&gbonus);
|
cb->giveHeroBonus(&gbonus);
|
||||||
textID = 120;
|
iw.components.push_back(Component(Component::MORALE, 0, -1, 0));
|
||||||
iw.components.push_back (Component (Component::MORALE, 0 , -1, 0));
|
iw.soundID = soundBase::GRAVEYARD;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
case Obj::PYRAMID:
|
||||||
case Obj::SHIPWRECK:
|
{
|
||||||
if (bc)
|
GiveBonus gb;
|
||||||
textID = 124;
|
gb.bonus = Bonus(Bonus::ONE_BATTLE, Bonus::LUCK, Bonus::OBJECT, -2, id.getNum(), VLC->generaltexth->arraytxt[70]);
|
||||||
else
|
gb.id = hero->id.getNum();
|
||||||
textID = 123;
|
cb->giveHeroBonus(&gb);
|
||||||
break;
|
textID = 107;
|
||||||
case Obj::PYRAMID:
|
iw.components.push_back(Component(Component::LUCK, 0, -2, 0));
|
||||||
textID = 106;
|
break;
|
||||||
|
}
|
||||||
|
case Obj::CREATURE_BANK:
|
||||||
|
case Obj::DRAGON_UTOPIA:
|
||||||
|
default:
|
||||||
|
iw.text << VLC->generaltexth->advobtxt[33];// This was X, now is completely empty
|
||||||
|
iw.text.addReplacement(getObjectName());
|
||||||
|
}
|
||||||
|
if(textID != -1)
|
||||||
|
{
|
||||||
|
iw.text.addTxt(MetaString::ADVOB_TXT, textID);
|
||||||
|
}
|
||||||
|
cb->showInfoDialog(&iw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//grant resources
|
//grant resources
|
||||||
if (bc)
|
if (bc)
|
||||||
{
|
{
|
||||||
@@ -221,25 +227,25 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
|||||||
{
|
{
|
||||||
if (bc->resources[it] != 0)
|
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));
|
||||||
loot << "%d %s";
|
loot << "%d %s";
|
||||||
loot.addReplacement(iw.components.back().val);
|
loot.addReplacement(iw.components.back().val);
|
||||||
loot.addReplacement(MetaString::RES_NAMES, iw.components.back().subtype);
|
loot.addReplacement(MetaString::RES_NAMES, iw.components.back().subtype);
|
||||||
cb->giveResource (hero->getOwner(), static_cast<Res::ERes>(it), bc->resources[it]);
|
cb->giveResource(hero->getOwner(), static_cast<Res::ERes>(it), bc->resources[it]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//grant artifacts
|
//grant artifacts
|
||||||
for (auto & elem : bc->artifacts)
|
for (auto & elem : bc->artifacts)
|
||||||
{
|
{
|
||||||
iw.components.push_back (Component (Component::ARTIFACT, elem, 0, 0));
|
iw.components.push_back(Component(Component::ARTIFACT, elem, 0, 0));
|
||||||
loot << "%s";
|
loot << "%s";
|
||||||
loot.addReplacement(MetaString::ART_NAMES, elem);
|
loot.addReplacement(MetaString::ART_NAMES, elem);
|
||||||
cb->giveHeroNewArtifact (hero, VLC->arth->artifacts[elem], ArtifactPosition::FIRST_AVAILABLE);
|
cb->giveHeroNewArtifact(hero, VLC->arth->artifacts[elem], ArtifactPosition::FIRST_AVAILABLE);
|
||||||
}
|
}
|
||||||
//display loot
|
//display loot
|
||||||
if (!iw.components.empty())
|
if (!iw.components.empty())
|
||||||
{
|
{
|
||||||
iw.text.addTxt (MetaString::ADVOB_TXT, textID);
|
iw.text.addTxt(MetaString::ADVOB_TXT, textID);
|
||||||
if (textID == 34)
|
if (textID == 34)
|
||||||
{
|
{
|
||||||
const CCreature * strongest = boost::range::max_element(bc->guards, [](const CStackBasicDescriptor & a, const CStackBasicDescriptor & b)
|
const CCreature * strongest = boost::range::max_element(bc->guards, [](const CStackBasicDescriptor & a, const CStackBasicDescriptor & b)
|
||||||
@@ -262,16 +268,20 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
|||||||
std::set<SpellID> spells;
|
std::set<SpellID> spells;
|
||||||
|
|
||||||
bool noWisdom = false;
|
bool noWisdom = false;
|
||||||
|
if(textID == 106)
|
||||||
|
{
|
||||||
|
iw.text.addTxt(MetaString::ADVOB_TXT, textID); //pyramid
|
||||||
|
}
|
||||||
for(const SpellID & spellId : bc->spells)
|
for(const SpellID & spellId : bc->spells)
|
||||||
{
|
{
|
||||||
const CSpell * spell = spellId.toSpell();
|
const CSpell * spell = spellId.toSpell();
|
||||||
iw.text.addTxt (MetaString::SPELL_NAME, spellId);
|
iw.text.addTxt(MetaString::SPELL_NAME, spellId);
|
||||||
if(spell->level <= hero->maxSpellLevel())
|
if(spell->level <= hero->maxSpellLevel())
|
||||||
{
|
{
|
||||||
if(hero->canLearnSpell(spell))
|
if(hero->canLearnSpell(spell))
|
||||||
{
|
{
|
||||||
spells.insert(spellId);
|
spells.insert(spellId);
|
||||||
iw.components.push_back(Component (Component::SPELL, spellId, 0, 0));
|
iw.components.push_back(Component(Component::SPELL, spellId, 0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -279,15 +289,15 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!hero->getArt(ArtifactPosition::SPELLBOOK))
|
if (!hero->getArt(ArtifactPosition::SPELLBOOK))
|
||||||
iw.text.addTxt (MetaString::ADVOB_TXT, 109); //no spellbook
|
iw.text.addTxt(MetaString::ADVOB_TXT, 109); //no spellbook
|
||||||
else if (noWisdom)
|
else if(noWisdom)
|
||||||
iw.text.addTxt (MetaString::ADVOB_TXT, 108); //no expert Wisdom
|
iw.text.addTxt(MetaString::ADVOB_TXT, 108); //no expert Wisdom
|
||||||
|
|
||||||
if(!iw.components.empty() || !iw.text.toString().empty())
|
if(!iw.components.empty() || !iw.text.toString().empty())
|
||||||
cb->showInfoDialog(&iw);
|
cb->showInfoDialog(&iw);
|
||||||
|
|
||||||
if(!spells.empty())
|
if(!spells.empty())
|
||||||
cb->changeSpells (hero, true, spells);
|
cb->changeSpells(hero, true, spells);
|
||||||
}
|
}
|
||||||
|
|
||||||
iw.components.clear();
|
iw.components.clear();
|
||||||
@@ -310,16 +320,16 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
|||||||
if(ourArmy.stacksCount())
|
if(ourArmy.stacksCount())
|
||||||
{
|
{
|
||||||
if(ourArmy.stacksCount() == 1 && ourArmy.Slots().begin()->second->count == 1)
|
if(ourArmy.stacksCount() == 1 && ourArmy.Slots().begin()->second->count == 1)
|
||||||
iw.text.addTxt (MetaString::ADVOB_TXT, 185);
|
iw.text.addTxt(MetaString::ADVOB_TXT, 185);
|
||||||
else
|
else
|
||||||
iw.text.addTxt (MetaString::ADVOB_TXT, 186);
|
iw.text.addTxt(MetaString::ADVOB_TXT, 186);
|
||||||
|
|
||||||
iw.text.addReplacement(loot.buildList());
|
iw.text.addReplacement(loot.buildList());
|
||||||
iw.text.addReplacement(hero->name);
|
iw.text.addReplacement(hero->name);
|
||||||
cb->showInfoDialog(&iw);
|
cb->showInfoDialog(&iw);
|
||||||
cb->giveCreatures(this, hero, ourArmy, false);
|
cb->giveCreatures(this, hero, ourArmy, false);
|
||||||
}
|
}
|
||||||
cb->setObjProperty (id, ObjProperty::BANK_CLEAR, 0); //bc = nullptr
|
cb->setObjProperty(id, ObjProperty::BANK_CLEAR, 0); //bc = nullptr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user