Преглед изворни кода

Fixed bugs 275 & 324

+Some minor tweaks
DjWarmonger пре 16 година
родитељ
комит
711094da82
5 измењених фајлова са 59 додато и 12 уклоњено
  1. 1 1
      hch/CHeroHandler.h
  2. 49 3
      hch/CObjectHandler.cpp
  3. 7 6
      hch/CObjectHandler.h
  4. 1 1
      lib/CGameState.h
  5. 1 1
      lib/map.cpp

+ 1 - 1
hch/CHeroHandler.h

@@ -137,7 +137,7 @@ public:
 	void loadPuzzleInfo();
 
 	unsigned int level(ui64 experience); //calculates level corresponding to given experience amount
-	ui64 reqExp(unsigned int level); //calculates experience resuired for given level
+	ui64 reqExp(unsigned int level); //calculates experience required for given level
 
 	void loadHeroes();
 	void loadHeroClasses();

+ 49 - 3
hch/CObjectHandler.cpp

@@ -1680,10 +1680,13 @@ void CGTownInstance::initObj()
 
 void CGTownInstance::newTurn() const
 {
-	if (cb->getDate(0)%7 == 1) //reset on new week
+	if (cb->getDate(0)%7 == 1 && subID == 5) //reset on new for week for Dungeon, needs to be moved if town list expands
 	{
 		for (std::vector<CGTownBuilding*>::const_iterator i = bonusingBuildings.begin(); i!=bonusingBuildings.end(); i++)
-			cb->setObjProperty (id, 12, 0); //reset visitors for Mana Vortex
+		{
+			if ((*i)->ID == 21)
+				cb->setObjProperty (id, 12, (*i)->id); //reset visitors for Mana Vortex
+		}
 	}
 
 }
@@ -2096,7 +2099,7 @@ void COPWBonus::onHeroVisit (const CGHeroInstance * h) const
 				}
 				break;
 			case 5: //Mana Vortex
-				if (visitors.find(heroID) == visitors.end() && h->mana <= h->manaLimit())
+				if (visitors.empty() && h->mana <= h->manaLimit())
 				{
 					cb->setManaPoints (heroID, 2 * h->manaLimit()); 
 					cb->setObjProperty (id, 5, true);
@@ -3094,6 +3097,10 @@ bool CQuest::checkQuest (const CGHeroInstance * h) const
 			return true;
 			break;
 		case MISSION_KILL_HERO:
+			if (h->cb->getHero (m13489val)) //first we must check if the hero was ever alive
+				return false; //if the pointer is not NULL
+			return true;
+			break;
 		case MISSION_KILL_CREATURE:
 			if (h->cb->getObj (m13489val))
 				return false; //if the pointer is not NULL
@@ -3111,6 +3118,22 @@ bool CQuest::checkQuest (const CGHeroInstance * h) const
 			return true;
 			break;
 		case MISSION_ARMY:
+			{
+				TSlots::const_iterator it, cre;
+				ui32 count;
+				for (cre = m6creatures.begin(); cre != m6creatures.end(); ++cre)
+				{
+					for (count = 0, it = h->army.slots.begin(); it !=  h->army.slots.end(); ++it)
+					{
+						if (it->second.first == cre->second.first)
+							count += it->second.second;
+					}
+					if (count < cre->second.second) //not enough creatures of this kind
+						return false;
+				}
+			}
+			return true;
+			break;
 		case MISSION_RESOURCES:
 			for (int i = 0; i < 7; ++i) //including Mithril ?
 			{	//Quest has no direct access to callback
@@ -3134,11 +3157,33 @@ bool CQuest::checkQuest (const CGHeroInstance * h) const
 	}
 }
 
+void CGSeerHut::initObj()
+{
+	//seerName = & (VLC->generaltexth->seerNames[ran()%VLC->generaltexth->seerNames.size()]);
+}
+
 const std::string & CGSeerHut::getHoverText() const
 {
 	return VLC->generaltexth->names[ID]; //TODO
 }
 
+void CGSeerHut::onHeroVisit( const CGHeroInstance * h ) const
+{
+	if (missionType)
+	{
+	}
+	else
+	{
+		if (checkQuest(h))
+		{
+			finishQuest(h);
+		}
+		else
+		{
+		}
+	}
+}
+
 void CGWitchHut::initObj()
 {
 	ability = allowedAbilities[ran()%allowedAbilities.size()];
@@ -3987,6 +4032,7 @@ void CGOnceVisitable::onHeroVisit( const CGHeroInstance * h ) const
 		txtid++;
 		if(ID == 105) //wagon has extra text (for finding art) we need to omit
 			txtid++;
+		iw.text.addTxt(MetaString::ADVOB_TXT, txtid);
 	}
 	else //first visit - give bonus!
 	{

+ 7 - 6
hch/CObjectHandler.h

@@ -82,12 +82,12 @@ public:
 	ui32 m13489val;
 	std::vector<ui32> m2stats;
 	std::vector<ui16> m5arts; //artifacts id
-	std::vector<std::pair<ui32, ui32> > m6creatures; //pair[cre id, cre count]
+	TSlots m6creatures; //pair[cre id, cre count], CreatureSet info irrelevant
 	std::vector<ui32> m7resources;
 
 	std::string firstVisitText, nextVisitText, completedText;
 
-	bool checkQuest (const CGHeroInstance * h) const; //determines whether the quest ic complete or not
+	bool checkQuest (const CGHeroInstance * h) const; //determines whether the quest is complete or not
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -593,17 +593,18 @@ public:
 	ui8 rewardType; //type of reward: 0 - no reward; 1 - experience; 2 - mana points; 3 - morale bonus; 4 - luck bonus; 5 - resources; 6 - main ability bonus (attak, defence etd.); 7 - secondary ability gain; 8 - artifact; 9 - spell; 10 - creature
 	si32 rID; //reward ID
 	si32 rVal; //reward value
-	ui8 textOption; //store randomized mission write-ups
+	ui8 textOption; //store randomized mission write-ups rather than entire string (?)
+	std::string * seerName;
 
-	void initObj() {};
+	void initObj();
 	const std::string & getHoverText() const;
-	void onHeroVisit (const CGHeroInstance * h) const {};
+	void onHeroVisit (const CGHeroInstance * h) const;
 	void finishQuest (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;
 	}
 };
 

+ 1 - 1
lib/CGameState.h

@@ -372,7 +372,7 @@ public:
 	si8 battleMaxSpellLevel(); //calculates maximum spell level possible to be cast on battlefield - takes into account artifacts of both heroes; if no effects are set, SPELL_LEVELS is returned
 	bool battleCanShoot(int ID, int dest); //determines if stack with given ID shoot at the selected destination
 	UpgradeInfo getUpgradeInfo(const CArmedInstance *obj, int stackPos);
-	float getMarketEfficiency(int player, int mode=0);
+	float getMarketEfficiency(int player, int mode=0);
 	std::set<int> getBuildingRequiments(const CGTownInstance *t, int ID);
 	int canBuildStructure(const CGTownInstance *t, int ID);// 0 - no more than one capitol, 1 - lack of water, 2 - forbidden, 3 - Add another level to Mage Guild, 4 - already built, 5 - cannot build, 6 - cannot afford, 7 - build, 8 - lack of requirements
 	bool checkForVisitableDir(const int3 & src, const int3 & dst) const; //check if src tile is visitable from dst tile

+ 1 - 1
lib/map.cpp

@@ -2068,7 +2068,7 @@ void Mapa::loadQuest(CQuest * guard, const unsigned char * bufor, int & i)
 			{
 				ui32 creType = readNormalNr(bufor,i, 2); i+=2;
 				ui32 creNumb = readNormalNr(bufor,i, 2); i+=2;
-				guard->m6creatures.push_back(std::make_pair(creType,creNumb));
+				guard->m6creatures[hh] = std::make_pair(creType,creNumb);
 			}
 			break;
 		}