DjWarmonger 12 vuotta sitten
vanhempi
sitoutus
b1a569910b
2 muutettua tiedostoa jossa 18 lisäystä ja 23 poistoa
  1. 14 20
      lib/CObjectHandler.cpp
  2. 4 3
      lib/CObjectHandler.h

+ 14 - 20
lib/CObjectHandler.cpp

@@ -4400,10 +4400,10 @@ void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &component
 	switch (missionType)
 	{
 		case MISSION_LEVEL:
-		components.push_back(Component (Component::EXPERIENCE, 1, m13489val, 0));
-		if (!isCustom)
-			iwText.addReplacement(m13489val);
-		break;
+			components.push_back(Component (Component::EXPERIENCE, 1, m13489val, 0));
+			if (!isCustom)
+				iwText.addReplacement(m13489val);
+			break;
 		case MISSION_PRIMARY_STAT:
 		{
 			MetaString loot;
@@ -4666,10 +4666,16 @@ void CGSeerHut::setObjToKill()
 	}
 }
 
-void CGSeerHut::initObj()
+void CGSeerHut::init()
 {
 	seerName = VLC->generaltexth->seerNames[ran()%VLC->generaltexth->seerNames.size()];
-	quest->textOption = ran()%3;
+	quest->textOption = ran() % 3;
+}
+
+void CGSeerHut::initObj()
+{
+	init();
+
 	quest->progress = CQuest::NOT_ACTIVE;
 	if (quest->missionType)
 	{
@@ -4986,22 +4992,10 @@ void CGSeerHut::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer)
 	finishQuest(hero, answer);
 }
 
-void CGQuestGuard::initObj()
+void CGQuestGuard::init()
 {
 	blockVisit = true;
-	quest->progress = CQuest::NOT_ACTIVE;
-	quest->textOption = ran()%3 + 3; //3-5
-	if (quest->missionType)
-	{
-		if (!quest->isCustomFirst)
-			quest->firstVisitText = VLC->generaltexth->quests[quest->missionType-1][0][quest->textOption];
-		if (!quest->isCustomNext)
-			quest->nextVisitText = VLC->generaltexth->quests[quest->missionType-1][1][quest->textOption];
-		if (!quest->isCustomComplete)
-			quest->completedText = VLC->generaltexth->quests[quest->missionType-1][2][quest->textOption];
-	}
-	else
-		quest->firstVisitText = VLC->generaltexth->seerEmpty[quest->textOption];
+	quest->textOption = (ran() % 3) + 3; //3-5
 }
 void CGQuestGuard::completeQuest(const CGHeroInstance *h) const
 {

+ 4 - 3
lib/CObjectHandler.h

@@ -837,6 +837,7 @@ public:
 	void onHeroVisit(const CGHeroInstance * h) const override;
 	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
+	virtual void init();
 	int checkDirection() const; //calculates the region of map where monster is placed
 	void setObjToKill(); //remember creatures / heroes to kill after they are initialized
 	const CGHeroInstance *getHeroToKill(bool allowNull = false) const;
@@ -844,7 +845,7 @@ public:
 	void getRolloverText (MetaString &text, bool onHover) const;
 	void getCompletionText(MetaString &text, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h = nullptr) const;
 	void finishQuest (const CGHeroInstance * h, ui32 accept) const; //common for both objects
-	void completeQuest (const CGHeroInstance * h) const;
+	virtual void completeQuest (const CGHeroInstance * h) const;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -859,8 +860,8 @@ class DLL_LINKAGE CGQuestGuard : public CGSeerHut
 {
 public:
 	CGQuestGuard() : CGSeerHut(){};
-	void initObj() override;
-	void completeQuest (const CGHeroInstance * h) const;
+	void init() override;
+	void completeQuest (const CGHeroInstance * h) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{