Browse Source

Moved artifact-related text to CArtifact class.

DjWarmonger 13 years ago
parent
commit
cff758cfba

+ 19 - 12
lib/CArtHandler.cpp

@@ -27,18 +27,16 @@ extern boost::rand48 ran;
 
 
 const std::string & CArtifact::Name() const
 const std::string & CArtifact::Name() const
 {
 {
-	if(name.size())
-		return name;
-	else
-		return VLC->generaltexth->artifNames[id];
+	return name;
 }
 }
 
 
 const std::string & CArtifact::Description() const
 const std::string & CArtifact::Description() const
 {
 {
-	if(description.size())
-		return description;
-	else
-		return VLC->generaltexth->artifDescriptions[id];
+	return description;
+}
+const std::string & CArtifact::EventText() const
+{
+	return eventText;
 }
 }
 
 
 bool CArtifact::isBig () const
 bool CArtifact::isBig () const
@@ -184,10 +182,18 @@ std::string CArtifact::nodeName() const
 // // 	//boost::algorithm::replace_first(description, "[spell name]", VLC->spellh->spells[spellid].name);
 // // 	//boost::algorithm::replace_first(description, "[spell name]", VLC->spellh->spells[spellid].name);
 // }
 // }
 
 
+void CArtifact::setName (std::string desc)
+{
+	name = desc;
+}
 void CArtifact::setDescription (std::string desc)
 void CArtifact::setDescription (std::string desc)
 {
 {
 	description = desc;
 	description = desc;
 }
 }
+void CArtifact::setEventText (std::string desc)
+{
+	eventText = desc;
+}
 
 
 void CGrowingArtifact::levelUpArtifact (CArtifactInstance * art)
 void CGrowingArtifact::levelUpArtifact (CArtifactInstance * art)
 {
 {
@@ -240,12 +246,11 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
 	  map_list_of('S',CArtifact::ART_SPECIAL)('T',CArtifact::ART_TREASURE)('N',CArtifact::ART_MINOR)('J',CArtifact::ART_MAJOR)('R',CArtifact::ART_RELIC);
 	  map_list_of('S',CArtifact::ART_SPECIAL)('T',CArtifact::ART_TREASURE)('N',CArtifact::ART_MINOR)('J',CArtifact::ART_MAJOR)('R',CArtifact::ART_RELIC);
 
 
 	CLegacyConfigParser parser("DATA/ARTRAITS.TXT");
 	CLegacyConfigParser parser("DATA/ARTRAITS.TXT");
+	CLegacyConfigParser events("DATA/ARTEVENT.TXT");
 
 
 	parser.endLine(); // header
 	parser.endLine(); // header
 	parser.endLine();
 	parser.endLine();
 
 
-	VLC->generaltexth->artifNames.resize(GameConstants::ARTIFACTS_QUANTITY);
-	VLC->generaltexth->artifDescriptions.resize(GameConstants::ARTIFACTS_QUANTITY);
 	std::map<ui32,ui8>::iterator itr;
 	std::map<ui32,ui8>::iterator itr;
 
 
 	for (int i=0; i<GameConstants::ARTIFACTS_QUANTITY; i++)
 	for (int i=0; i<GameConstants::ARTIFACTS_QUANTITY; i++)
@@ -261,7 +266,9 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
 		}
 		}
 		CArtifact &nart = *art;
 		CArtifact &nart = *art;
 		nart.id=i;
 		nart.id=i;
-		VLC->generaltexth->artifNames[i] = parser.readString();
+		nart.setName (parser.readString());
+		nart.setEventText (events.readString());
+		events.endLine();
 
 
 		nart.price= parser.readNumber();
 		nart.price= parser.readNumber();
 
 
@@ -277,7 +284,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
 		nart.aClass = classes[parser.readString()[0]];
 		nart.aClass = classes[parser.readString()[0]];
 
 
 		//load description and remove quotation marks
 		//load description and remove quotation marks
-		VLC->generaltexth->artifDescriptions[i] = parser.readString();
+		nart.setDescription (parser.readString());
 
 
 		parser.endLine();
 		parser.endLine();
 
 

+ 4 - 0
lib/CArtHandler.h

@@ -63,12 +63,16 @@ class DLL_LINKAGE CArtifact : public CBonusSystemNode //container for artifacts
 {
 {
 protected:
 protected:
 	std::string name, description; //set if custom
 	std::string name, description; //set if custom
+	std::string eventText; //short story displayed upon picking
 public:
 public:
 	enum EartClass {ART_SPECIAL=1, ART_TREASURE=2, ART_MINOR=4, ART_MAJOR=8, ART_RELIC=16}; //artifact classes
 	enum EartClass {ART_SPECIAL=1, ART_TREASURE=2, ART_MINOR=4, ART_MAJOR=8, ART_RELIC=16}; //artifact classes
 	const std::string &Name() const; //getter
 	const std::string &Name() const; //getter
 	const std::string &Description() const; //getter
 	const std::string &Description() const; //getter
+	const std::string &EventText() const;
 	bool isBig () const;
 	bool isBig () const;
+	void setName (std::string desc);
 	void setDescription (std::string desc);
 	void setDescription (std::string desc);
+	void setEventText (std::string desc);
 
 
 	int getArtClassSerial() const; //0 - treasure, 1 - minor, 2 - major, 3 - relic, 4 - spell scroll, 5 - other
 	int getArtClassSerial() const; //0 - treasure, 1 - minor, 2 - major, 3 - relic, 4 - spell scroll, 5 - other
 	std::string nodeName() const OVERRIDE;
 	std::string nodeName() const OVERRIDE;

+ 10 - 1
lib/CCreatureHandler.cpp

@@ -823,6 +823,8 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
 		b.type = Bonus::DEATH_STARE;
 		b.type = Bonus::DEATH_STARE;
 		b.subtype = 0; //Gorgon
 		b.subtype = 0; //Gorgon
 		break;
 		break;
+	case 'F':
+		b.type = Bonus::FEAR; break;
 	case 'g':
 	case 'g':
 		b.type = Bonus::SPELL_DAMAGE_REDUCTION;
 		b.type = Bonus::SPELL_DAMAGE_REDUCTION;
 		b.subtype = -1; //all magic schools
 		b.subtype = -1; //all magic schools
@@ -988,7 +990,9 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
 		break;
 		break;
 
 
 	case 'a':
 	case 'a':
-	case 'c': //some special abilities are threated as spells, work in progress
+	case 'c':
+	case 'K':
+	case 'k':
 		b.type = Bonus::SPELL_AFTER_ATTACK;
 		b.type = Bonus::SPELL_AFTER_ATTACK;
 		b.subtype = stringToNumber(mod); 
 		b.subtype = stringToNumber(mod); 
 		break;
 		break;
@@ -997,10 +1001,15 @@ void CCreatureHandler::loadStackExp(Bonus & b, BonusList & bl, CLegacyConfigPars
 		b.subtype = stringToNumber(mod);
 		b.subtype = stringToNumber(mod);
 		break;
 		break;
 	case 'p':
 	case 'p':
+	case 'J':
 		b.type = Bonus::SPELL_BEFORE_ATTACK;
 		b.type = Bonus::SPELL_BEFORE_ATTACK;
 		b.subtype = stringToNumber(mod);
 		b.subtype = stringToNumber(mod);
 		b.additionalInfo = 3; //always expert?
 		b.additionalInfo = 3; //always expert?
 		break;
 		break;
+	case 'r':
+		b.type = Bonus::HP_REGENERATION;
+		b.val = stringToNumber(mod);
+		break;
 	case 's':
 	case 's':
 		b.type = Bonus::ENCHANTED;
 		b.type = Bonus::ENCHANTED;
 		b.subtype = stringToNumber(mod);
 		b.subtype = stringToNumber(mod);

+ 4 - 3
lib/CGameState.cpp

@@ -173,6 +173,10 @@ void MetaString::getLocalString(const std::pair<ui8,ui32> &txt, std::string &dst
 	{
 	{
 		dst = VLC->arth->artifacts[ser]->Description();
 		dst = VLC->arth->artifacts[ser]->Description();
 	}
 	}
+	else if (type == ART_EVNTS)
+	{
+		dst = VLC->arth->artifacts[ser]->EventText(); 
+	}
 	else
 	else
 	{
 	{
 		std::vector<std::string> *vec;
 		std::vector<std::string> *vec;
@@ -202,9 +206,6 @@ void MetaString::getLocalString(const std::pair<ui8,ui32> &txt, std::string &dst
 		case ADVOB_TXT:
 		case ADVOB_TXT:
 			vec = &VLC->generaltexth->advobtxt;
 			vec = &VLC->generaltexth->advobtxt;
 			break;
 			break;
-		case ART_EVNTS:
-			vec = &VLC->generaltexth->artifEvents;
-			break;
 		case SEC_SKILL_NAME:
 		case SEC_SKILL_NAME:
 			vec = &VLC->generaltexth->skillName;
 			vec = &VLC->generaltexth->skillName;
 			break;
 			break;

+ 0 - 1
lib/CGeneralTextHandler.cpp

@@ -166,7 +166,6 @@ void CGeneralTextHandler::load()
 	readToVector("DATA/TVRNINFO.TXT", tavernInfo);
 	readToVector("DATA/TVRNINFO.TXT", tavernInfo);
 	readToVector("DATA/TURNDUR.TXT",  turnDurations);
 	readToVector("DATA/TURNDUR.TXT",  turnDurations);
 	readToVector("DATA/HEROSCRN.TXT", heroscrn);
 	readToVector("DATA/HEROSCRN.TXT", heroscrn);
-	readToVector("DATA/ARTEVENT.TXT", artifEvents);
 	readToVector("DATA/TENTCOLR.TXT", tentColors);
 	readToVector("DATA/TENTCOLR.TXT", tentColors);
 	readToVector("DATA/SKILLLEV.TXT", levels);
 	readToVector("DATA/SKILLLEV.TXT", levels);
 	readToVector("DATA/OBJNAMES.TXT", names);
 	readToVector("DATA/OBJNAMES.TXT", names);

+ 0 - 5
lib/CGeneralTextHandler.h

@@ -67,11 +67,6 @@ public:
 	std::vector<std::string> capColors; //names of player colors with first letter capitalized ("Red",...)
 	std::vector<std::string> capColors; //names of player colors with first letter capitalized ("Red",...)
 	std::vector<std::string> turnDurations; //turn durations for pregame (1 Minute ... Unlimited) 
 	std::vector<std::string> turnDurations; //turn durations for pregame (1 Minute ... Unlimited) 
 
 
-	//artifacts
-	std::vector<std::string> artifEvents;
-	std::vector<std::string> artifNames;
-	std::vector<std::string> artifDescriptions;
-
 	//towns
 	//towns
 	std::vector<std::string> tcommands, hcommands, fcommands; //texts for town screen, town hall screen and fort screen
 	std::vector<std::string> tcommands, hcommands, fcommands; //texts for town screen, town hall screen and fort screen
 	std::vector<std::string> tavernInfo;
 	std::vector<std::string> tavernInfo;

+ 1 - 1
lib/CObjectHandler.cpp

@@ -3790,7 +3790,7 @@ void CGArtifact::onHeroVisit( const CGHeroInstance * h ) const
 				if(message.length())
 				if(message.length())
 					iw.text <<  message;
 					iw.text <<  message;
 				else
 				else
-					iw.text << std::pair<ui8,ui32>(12,subID);
+					iw.text << std::pair<ui8, ui32> (MetaString::ART_EVNTS, subID);
 			}
 			}
 			break;
 			break;
 		case Obj::SPELL_SCROLL:
 		case Obj::SPELL_SCROLL:

+ 0 - 7
server/CGameHandler.cpp

@@ -4623,13 +4623,6 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
 			}
 			}
 			else
 			else
 				sse.stacks.push_back (st->ID);
 				sse.stacks.push_back (st->ID);
-			//from handleSpellCasting
-			//SetStackEffect sse;
-			//Bonus pseudoBonus;
-			//pseudoBonus.sid = spellID;
-			//pseudoBonus.val = spellLvl;
-			//pseudoBonus.turnsRemain = gs->curB->calculateSpellDuration(spell, caster, stackSpellPower ? stackSpellPower : usedSpellPower);
-			//CStack::stackEffectToFeature(sse.effect, pseudoBonus);
 
 
 			Bonus pseudoBonus;
 			Bonus pseudoBonus;
 			pseudoBonus.sid = b->subtype;
 			pseudoBonus.sid = b->subtype;