1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +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:
godric3
2017-11-15 21:16:44 +01:00
committed by Alexander Shishkin
parent 9cf3f4fe93
commit 5a01aba9c8

View File

@@ -96,16 +96,11 @@ bool CBank::wasVisited (PlayerColor player) const
} }
void CBank::onHeroVisit(const CGHeroInstance * h) const void CBank::onHeroVisit(const CGHeroInstance * h) const
{
if (bc)
{ {
int banktext = 0; int banktext = 0;
ui16 soundID = soundBase::ROGUE; ui16 soundID = soundBase::ROGUE;
switch (ID) switch (ID)
{ {
case Obj::CREATURE_BANK:
banktext = 32;
break;
case Obj::DERELICT_SHIP: case Obj::DERELICT_SHIP:
banktext = 41; banktext = 41;
break; break;
@@ -122,37 +117,19 @@ void CBank::onHeroVisit (const CGHeroInstance * h) const
soundID = soundBase::MYSTERY; soundID = soundBase::MYSTERY;
banktext = 105; banktext = 105;
break; break;
case Obj::CREATURE_BANK:
default:
banktext = 32;
break;
} }
BlockingDialog bd(true, false); BlockingDialog bd(true, false);
bd.player = h->getOwner(); bd.player = h->getOwner();
bd.soundID = soundID; bd.soundID = soundID;
bd.text.addTxt(MetaString::ADVOB_TXT, banktext); bd.text.addTxt(MetaString::ADVOB_TXT, banktext);
if (ID == Obj::CREATURE_BANK) if (banktext == 32)
bd.text.addReplacement(getObjectName()); bd.text.addReplacement(getObjectName());
cb->showBlockingDialog(&bd); 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);
}
}
void CBank::doVisit(const CGHeroInstance * hero) const void CBank::doVisit(const CGHeroInstance * hero) const
{ {
@@ -161,58 +138,87 @@ void CBank::doVisit(const CGHeroInstance * hero) const
iw.player = hero->getOwner(); iw.player = hero->getOwner();
MetaString loot; MetaString loot;
if (bc)
{
switch (ID) switch (ID)
{ {
case Obj::CREATURE_BANK:
case Obj::DRAGON_UTOPIA:
textID = 34;
break;
case Obj::DERELICT_SHIP: case Obj::DERELICT_SHIP:
if (!bc)
textID = 43; textID = 43;
else
{
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; break;
case Obj::CRYPT: case Obj::CRYPT:
if (bc)
textID = 121; textID = 121;
else
{
iw.components.push_back (Component (Component::MORALE, 0 , -1, 0));
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[ID];
gbonus.bonus.type = Bonus::MORALE;
gbonus.bonus.val = -1;
cb->giveHeroBonus(&gbonus);
textID = 120;
iw.components.push_back (Component (Component::MORALE, 0 , -1, 0));
}
break; break;
case Obj::SHIPWRECK: case Obj::SHIPWRECK:
if (bc)
textID = 124; textID = 124;
else
textID = 123;
break; break;
case Obj::PYRAMID: case Obj::PYRAMID:
textID = 106; 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:
{
GiveBonus gbonus;
gbonus.id = hero->id.getNum();
gbonus.bonus.duration = Bonus::ONE_BATTLE;
gbonus.bonus.source = Bonus::OBJECT;
gbonus.bonus.sid = ID;
gbonus.bonus.type = Bonus::MORALE;
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);
iw.components.push_back(Component(Component::MORALE, 0, -1, 0));
iw.soundID = soundBase::GRAVEYARD;
break;
}
case Obj::PYRAMID:
{
GiveBonus gb;
gb.bonus = Bonus(Bonus::ONE_BATTLE, Bonus::LUCK, Bonus::OBJECT, -2, id.getNum(), VLC->generaltexth->arraytxt[70]);
gb.id = hero->id.getNum();
cb->giveHeroBonus(&gb);
textID = 107;
iw.components.push_back(Component(Component::LUCK, 0, -2, 0));
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)
@@ -262,6 +268,10 @@ 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();