瀏覽代碼

Partial handling of Seer Hut and sketch of Quest Guard.

DjWarmonger 15 年之前
父節點
當前提交
8e81b35e92
共有 4 個文件被更改,包括 121 次插入39 次删除
  1. 25 16
      hch/CGeneralTextHandler.cpp
  2. 74 9
      hch/CObjectHandler.cpp
  3. 21 13
      hch/CObjectHandler.h
  4. 1 1
      lib/RegisterTypes.cpp

+ 25 - 16
hch/CGeneralTextHandler.cpp

@@ -440,47 +440,56 @@ void CGeneralTextHandler::load()
 		loadToIt(buffo,buf,it,3);
 		levels.push_back(buffo);
 	}
+
 	buf = bitmaph->getTextFile ("SEERHUT.TXT");
 	it = 0;
-	for (i = 0; i < 7; ++i) //misc description
-		loadToIt (dump,buf,it,3);
-	tlog5 << "\t\t Drop the crap\n";
+	loadToIt (dump, buf, it, 3);
+	loadToIt (dump, buf, it, 4); //dump description
 	seerEmpty.resize(6);
-	for (i = 0; i < 6; ++i)
+	for (i = 0; i < 5; ++i)
 	{
-		loadToIt(tmp, buf, it, 4);
-		seerEmpty.push_back(tmp);
+		loadToIt(seerEmpty[i], buf, it, 4);
+		trimQuotation (seerEmpty[i]);
 	}
-	tlog5 << "\t\t Loaded empty\n";
+	loadToIt (seerEmpty[5], buf, it, 3);
+	trimQuotation (seerEmpty[5]);
 	int j,k;
-	quests.resize(6);
-	for (i = 0; i < 6; ++i)
+	quests.resize(10);
+	for (i = 0; i < 9; ++i) //9 types of quests
 	{
 		quests[i].resize(5);
 		for (j = 0; j < 5; ++j)
 		{
-			quests[i][j].resize(6);
 			loadToIt (dump, buf, it, 4); //front desciption
-			for (k = 0; k < 6; ++k)
+			quests[i][j].resize(6);
+			for (k = 0; k < 5; ++k)
 			{
 				loadToIt (quests[i][j][k], buf, it, 4);
 				trimQuotation (quests[i][j][k]);
 			}
+			loadToIt (quests[i][j][5], buf, it, 3);
+			trimQuotation (quests[i][j][5]);
 		}
 	}
-	tlog5 << "\t\t Loaded quests\n";
-	for (i = 0; i < 6; ++i) //gap description
-		loadToIt(dump,buf,it,4);
+	quests[9].resize(1);
+	quests[9][0].resize(6);
+
+	for (k = 0; k < 5; ++k) //Time limit
+	{
+		loadToIt (quests[9][0][k], buf, it, 4);
+	}
+	loadToIt (quests[9][0][k], buf, it, 3);
+	for (i = 0; i < 2; ++i) //gap description
+		loadToIt(dump,buf,it,3);
 	seerNames.resize(48);
 	for (i = 0; i < 14; ++i) //additional tabs
 	{
 		loadToIt(seerNames[i], buf, it, 4);
 		loadToIt(dump, buf, it, 3);
 	}
-	tlog5 << "\t\t Loaded names1\n";
+	
 	for (i = 14; i < 48; ++i)
 		loadToIt(seerNames[i], buf, it, 3);
-	tlog5 << "\t\t Loaded names2\n";
 }
 
 

+ 74 - 9
hch/CObjectHandler.cpp

@@ -3188,31 +3188,96 @@ bool CQuest::checkQuest (const CGHeroInstance * h) const
 void CGSeerHut::initObj()
 {
 	seerName = VLC->generaltexth->seerNames[ran()%VLC->generaltexth->seerNames.size()];
+	textOption = ran()%3;
+	progress = 0;
+	firstVisitText = VLC->generaltexth->quests[missionType][0][textOption];
+	nextVisitText = VLC->generaltexth->quests[missionType][1][textOption];
+	completedText = VLC->generaltexth->quests[missionType][2][textOption];
 }
 
 const std::string & CGSeerHut::getHoverText() const
 {
-	//return VLC->generaltexth->names[ID]; //TODO
-	return seerName;
+	hoverName = VLC->generaltexth->allTexts[347];
+	boost::algorithm::replace_first(hoverName,"%s", seerName);
+	return hoverName;
 }
 
-void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
+void CGSeerHut::setPropertyDer (ui8 what, ui32 val)
 {
-	if (missionType)
+	switch (what)
 	{
+		case 10:
+			progress = val;
+			break;
+		case 11:
+			missionType = CQuest::MISSION_NONE;
+			break;
 	}
-	else
+}
+
+void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
+{
+	InfoWindow iw;
+	iw.player = h->getOwner();
+	if (missionType)
 	{
-		if (checkQuest(h))
+		if (!progress)
 		{
-			finishQuest(h);
+				iw.text << firstVisitText;
+				cb->setObjProperty (id,10,1);
 		}
 		else
-		{
-		}
+			if (!checkQuest(h))
+				iw.text << nextVisitText;
+			else
+			{
+				//iw.text << completedText;
+				completeQuest (h);
+				return;
+			}
 	}
+	else
+	{
+		iw.text << VLC->generaltexth->seerEmpty[textOption];
+		iw.text.addReplacement(seerName);
+	}
+	cb->showInfoDialog(&iw);
+}
+
+void CGSeerHut::completeQuest (const CGHeroInstance * h) const
+{
+	cb->setObjProperty (id,11,0); //no more mission avaliable
 }
 
+void CGQuestGuard::initObj()
+{
+	progress = 0;
+	textOption = ran()%3 + 3; //3-5
+	firstVisitText = VLC->generaltexth->quests[missionType][0][textOption];
+	nextVisitText = VLC->generaltexth->quests[missionType][1][textOption];
+	completedText = VLC->generaltexth->quests[missionType][2][textOption];
+}
+const std::string & CGQuestGuard::getHoverText() const
+{
+	hoverName = VLC->generaltexth->names[ID];
+	if (progress){}//what does it seek for?
+	return hoverName;
+}
+void CGQuestGuard::onHeroVisit( const CGHeroInstance * h ) const
+{}
+void CGQuestGuard::completeQuest (const CGHeroInstance * h) const
+{
+	BlockingDialog bd (true, false);
+	bd.player = h->getOwner();
+	bd.soundID = soundBase::QUEST;
+	bd.text << completedText;
+	cb->showBlockingDialog (&bd, boost::bind (&CGQuestGuard::openGate, this, h, _1));	
+}
+void CGQuestGuard::openGate(const CGHeroInstance *h, ui32 accept) const
+{
+	if (accept)
+		cb->removeObject(id);
+}
 void CGWitchHut::initObj()
 {
 	ability = allowedAbilities[ran()%allowedAbilities.size()];

+ 21 - 13
hch/CObjectHandler.h

@@ -76,7 +76,7 @@ public:
 	enum Emission {MISSION_NONE = 0, MISSION_LEVEL = 1, MISSION_PRIMARY_STAT = 2, MISSION_KILL_HERO = 3, MISSION_KILL_CREATURE = 4,
 		MISSION_ART = 5, MISSION_ARMY = 6, MISSION_RESOURCES = 7, MISSION_HERO = 8, MISSION_PLAYER = 9};
 
-	ui8 missionType;
+	ui8 missionType, progress;
 	si32 lastDay; //after this day (first day is 0) mission cannot be completed; if -1 - no limit
 
 	ui32 m13489val;
@@ -88,10 +88,11 @@ public:
 	std::string firstVisitText, nextVisitText, completedText;
 
 	bool checkQuest (const CGHeroInstance * h) const; //determines whether the quest is complete or not
+	virtual void completeQuest (const CGHeroInstance * h) const {};
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
-		h & missionType & lastDay & m13489val & m2stats & m5arts & m6creatures & m7resources
+		h & missionType & progress & lastDay & m13489val & m2stats & m5arts & m6creatures & m7resources
 			& firstVisitText & nextVisitText & completedText;
 	}
 };
@@ -603,13 +604,29 @@ public:
 
 	void initObj();
 	const std::string & getHoverText() const;
+	void setPropertyDer (ui8 what, ui32 val);
 	void onHeroVisit (const CGHeroInstance * h) const;
-	void finishQuest (const CGHeroInstance * h) const {};
+	void completeQuest (const CGHeroInstance * h) const;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 		h & static_cast<CGObjectInstance&>(*this) & static_cast<CQuest&>(*this);
-		h & rewardType & rID & rVal & textOption;
+		h & rewardType & rID & rVal & textOption & seerName;
+	}
+};
+
+class DLL_EXPORT CGQuestGuard : public CGSeerHut
+{
+public:
+	void initObj();
+	const std::string & getHoverText() const;
+	void onHeroVisit( const CGHeroInstance * h ) const;
+	void completeQuest (const CGHeroInstance * h) const;
+	void openGate (const CGHeroInstance *h, ui32 accept) const;
+ 
+	template <typename Handler> void serialize(Handler &h, const int version)
+	{
+		h & static_cast<CGSeerHut&>(*this);
 	}
 };
 
@@ -730,15 +747,6 @@ public:
 	}
 };
 
-class DLL_EXPORT CGQuestGuard : public CGObjectInstance, public CQuest
-{
-public:
-	template <typename Handler> void serialize(Handler &h, const int version)
-	{
-		h & static_cast<CQuest&>(*this) & static_cast<CGObjectInstance&>(*this);
-	}
-};
-
 class DLL_EXPORT CGMine : public CArmedInstance
 {
 public: 

+ 1 - 1
lib/RegisterTypes.cpp

@@ -33,6 +33,7 @@ void registerTypes1(Serializer &s)
 	s.template registerType<CGCreature>();
 	s.template registerType<CGSignBottle>();
 	s.template registerType<CGSeerHut>();
+	s.template registerType<CGQuestGuard>();
 	s.template registerType<CGWitchHut>();
 	s.template registerType<CGScholar>();
 	s.template registerType<CGGarrison>();
@@ -40,7 +41,6 @@ void registerTypes1(Serializer &s)
 	s.template registerType<CGResource>();
 	s.template registerType<CGMine>();
 	s.template registerType<CGShrine>();
-	s.template registerType<CGQuestGuard>();
 	s.template registerType<CGBonusingObject>();
 	s.template registerType<CGMagicSpring>();
 	s.template registerType<CGMagicWell>();