1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

Fixed #427 (custom quest messages).

This commit is contained in:
yupsi
2011-10-16 19:24:05 +00:00
parent e43ac3fa06
commit 828a3f0776
3 changed files with 47 additions and 38 deletions

View File

@ -4052,13 +4052,12 @@ void CGSeerHut::initObj()
progress = 0; progress = 0;
if (missionType) if (missionType)
{ {
if (!isCustom) if (!isCustomFirst)
{ firstVisitText = VLC->generaltexth->quests[missionType-1][0][textOption];
if (!isCustomNext)
firstVisitText = VLC->generaltexth->quests[missionType-1][0][textOption]; nextVisitText = VLC->generaltexth->quests[missionType-1][1][textOption];
nextVisitText = VLC->generaltexth->quests[missionType-1][1][textOption]; if (!isCustomComplete)
completedText = VLC->generaltexth->quests[missionType-1][2][textOption]; completedText = VLC->generaltexth->quests[missionType-1][2][textOption];
}
if(missionType == MISSION_KILL_CREATURE) if(missionType == MISSION_KILL_CREATURE)
{ {
@ -4200,9 +4199,25 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
iw.player = h->getOwner(); iw.player = h->getOwner();
if (missionType) if (missionType)
{ {
if (!progress) //propose quest bool firstVisit = !progress;
bool failRequirements = !checkQuest(h);
bool isCustom;
std::string text;
if (firstVisit)
{
isCustom = isCustomFirst;
text = firstVisitText;
cb->setObjProperty (id, 10, 1);
}
else if (failRequirements)
{
isCustom = isCustomNext;
text = nextVisitText;
}
iw.text << text;
if (firstVisit || failRequirements)
{ {
iw.text << firstVisitText;
switch (missionType) switch (missionType)
{ {
case MISSION_LEVEL: case MISSION_LEVEL:
@ -4230,7 +4245,7 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
case MISSION_KILL_HERO: case MISSION_KILL_HERO:
iw.components.push_back(Component(Component::HERO, heroPortrait, 0, 0)); iw.components.push_back(Component(Component::HERO, heroPortrait, 0, 0));
if (!isCustom) if (!isCustom)
addReplacements(iw.text, firstVisitText); addReplacements(iw.text, text);
break; break;
case MISSION_HERO: case MISSION_HERO:
iw.components.push_back(Component (Component::HERO, m13489val, 0, 0)); iw.components.push_back(Component (Component::HERO, m13489val, 0, 0));
@ -4241,7 +4256,7 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
{ {
iw.components.push_back(Component(stackToKill)); iw.components.push_back(Component(stackToKill));
if (!isCustom) if (!isCustom)
addReplacements(iw.text, firstVisitText); addReplacements(iw.text, text);
} }
break; break;
case MISSION_ART: case MISSION_ART:
@ -4293,17 +4308,9 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
iw.text.addReplacement(VLC->generaltexth->colors[m13489val]); iw.text.addReplacement(VLC->generaltexth->colors[m13489val]);
break; break;
} }
cb->setObjProperty (id,10,1);
cb->showInfoDialog(&iw); cb->showInfoDialog(&iw);
} }
else if (!checkQuest(h)) if (!failRequirements) // propose completion, also on first visit
{
iw.text << nextVisitText;
if(!isCustom)
addReplacements(iw.text, nextVisitText);
cb->showInfoDialog(&iw);
}
if (checkQuest(h)) // propose completion, also on first visit
{ {
BlockingDialog bd (true, false); BlockingDialog bd (true, false);
bd.player = h->getOwner(); bd.player = h->getOwner();
@ -4312,7 +4319,7 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
switch (missionType) switch (missionType)
{ {
case CQuest::MISSION_LEVEL: case CQuest::MISSION_LEVEL:
if (!isCustom) if (!isCustomComplete)
bd.text.addReplacement(m13489val); bd.text.addReplacement(m13489val);
break; break;
case CQuest::MISSION_PRIMARY_STAT: case CQuest::MISSION_PRIMARY_STAT:
@ -4328,7 +4335,7 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
loot.addReplacement(VLC->generaltexth->primarySkillNames[i]); loot.addReplacement(VLC->generaltexth->primarySkillNames[i]);
} }
} }
if (!isCustom) if (!isCustomComplete)
bd.text.addReplacement(loot.buildList()); bd.text.addReplacement(loot.buildList());
} }
break; break;
@ -4340,7 +4347,7 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
loot << "%s"; loot << "%s";
loot.addReplacement(MetaString::ART_NAMES, *it); loot.addReplacement(MetaString::ART_NAMES, *it);
} }
if (!isCustom) if (!isCustomComplete)
bd.text.addReplacement(loot.buildList()); bd.text.addReplacement(loot.buildList());
} }
break; break;
@ -4352,7 +4359,7 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
loot << "%s"; loot << "%s";
loot.addReplacement(*it); loot.addReplacement(*it);
} }
if (!isCustom) if (!isCustomComplete)
bd.text.addReplacement(loot.buildList()); bd.text.addReplacement(loot.buildList());
} }
break; break;
@ -4368,21 +4375,21 @@ void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
loot.addReplacement(MetaString::RES_NAMES, i); loot.addReplacement(MetaString::RES_NAMES, i);
} }
} }
if (!isCustom) if (!isCustomComplete)
bd.text.addReplacement(loot.buildList()); bd.text.addReplacement(loot.buildList());
} }
break; break;
case MISSION_KILL_HERO: case MISSION_KILL_HERO:
case MISSION_KILL_CREATURE: case MISSION_KILL_CREATURE:
if (!isCustom) if (!isCustomComplete)
addReplacements(bd.text, completedText); addReplacements(bd.text, completedText);
break; break;
case MISSION_HERO: case MISSION_HERO:
if (!isCustom) if (!isCustomComplete)
bd.text.addReplacement(VLC->heroh->heroes[m13489val]->name); bd.text.addReplacement(VLC->heroh->heroes[m13489val]->name);
break; break;
case MISSION_PLAYER: case MISSION_PLAYER:
if (!isCustom) if (!isCustomComplete)
bd.text.addReplacement(VLC->generaltexth->colors[m13489val]); bd.text.addReplacement(VLC->generaltexth->colors[m13489val]);
break; break;
} }
@ -4578,11 +4585,14 @@ void CGQuestGuard::initObj()
blockVisit = true; blockVisit = true;
progress = 0; progress = 0;
textOption = ran()%3 + 3; //3-5 textOption = ran()%3 + 3; //3-5
if (missionType && !isCustom) if (missionType)
{ {
firstVisitText = VLC->generaltexth->quests[missionType-1][0][textOption]; if (!isCustomFirst)
nextVisitText = VLC->generaltexth->quests[missionType-1][1][textOption]; firstVisitText = VLC->generaltexth->quests[missionType-1][0][textOption];
completedText = VLC->generaltexth->quests[missionType-1][2][textOption]; if (!isCustomNext)
nextVisitText = VLC->generaltexth->quests[missionType-1][1][textOption];
if (!isCustomComplete)
completedText = VLC->generaltexth->quests[missionType-1][2][textOption];
} }
else else
firstVisitText = VLC->generaltexth->seerEmpty[textOption]; firstVisitText = VLC->generaltexth->seerEmpty[textOption];

View File

@ -72,7 +72,7 @@ public:
std::vector<ui32> m7resources; std::vector<ui32> m7resources;
std::string firstVisitText, nextVisitText, completedText; std::string firstVisitText, nextVisitText, completedText;
bool isCustom; bool isCustomFirst, isCustomNext, isCustomComplete;
bool checkQuest (const CGHeroInstance * h) const; //determines whether the quest is complete or not bool checkQuest (const CGHeroInstance * h) const; //determines whether the quest is complete or not
virtual void completeQuest (const CGHeroInstance * h) const {}; virtual void completeQuest (const CGHeroInstance * h) const {};
@ -80,7 +80,7 @@ public:
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & missionType & progress & lastDay & m13489val & m2stats & m5arts & m6creatures & m7resources h & missionType & progress & lastDay & m13489val & m2stats & m5arts & m6creatures & m7resources
& firstVisitText & nextVisitText & completedText & isCustom; & firstVisitText & nextVisitText & completedText & isCustomFirst & isCustomNext & isCustomComplete;
} }
}; };

View File

@ -575,7 +575,7 @@ int Mapa::loadSeerHut( const unsigned char * bufor, int i, CGObjectInstance *& n
{ {
hut->missionType = 0; //no mission hut->missionType = 0; //no mission
} }
hut->isCustom = false; hut->isCustomFirst = hut->isCustomNext = hut->isCustomComplete = false;
} }
if(hut->missionType) if(hut->missionType)
@ -2035,10 +2035,9 @@ void Mapa::loadQuest(CQuest * guard, const unsigned char * bufor, int & i)
guard->firstVisitText = readString(bufor,i); guard->firstVisitText = readString(bufor,i);
guard->nextVisitText = readString(bufor,i); guard->nextVisitText = readString(bufor,i);
guard->completedText = readString(bufor,i); guard->completedText = readString(bufor,i);
if (guard->firstVisitText.size() && guard->nextVisitText.size() && guard->completedText.size()) guard->isCustomFirst = guard->firstVisitText.size() > 0;
guard->isCustom = true; guard->isCustomNext = guard->nextVisitText.size() > 0;
else guard->isCustomComplete = guard->completedText.size() > 0;
guard->isCustom = false; //randomize all if any text is missing
} }
TerrainTile & Mapa::getTile( const int3 & tile ) TerrainTile & Mapa::getTile( const int3 & tile )