| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | #define VCMI_DLL
 | 
					
						
							|  |  |  | #include "../stdafx.h"
 | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | #include "CSpellHandler.h"
 | 
					
						
							| 
									
										
										
										
											2007-08-29 12:18:31 +00:00
										 |  |  | #include "CLodHandler.h"
 | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | #include "../lib/VCMI_Lib.h"
 | 
					
						
							|  |  |  | #include <boost/algorithm/string/replace.hpp>
 | 
					
						
							| 
									
										
										
										
											2011-06-25 06:55:35 +00:00
										 |  |  | #include <boost/assign/std/set.hpp>
 | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | #include <cctype>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | extern CLodHandler *bitmaph; | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-15 14:03:31 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * CSpellHandler.cpp, part of VCMI engine | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Authors: listed in file AUTHORS in main folder | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * License: GNU General Public License v2.0 or later | 
					
						
							|  |  |  |  * Full text of license available in license.txt file, in main folder | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2011-06-25 06:55:35 +00:00
										 |  |  | using namespace boost::assign; | 
					
						
							| 
									
										
										
										
											2009-04-15 14:03:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | namespace SRSLPraserHelpers | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-05-23 22:57:39 +00:00
										 |  |  | 	static int XYToHex(int x, int y) | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		return x + 17 * y; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-23 22:57:39 +00:00
										 |  |  | 	static int XYToHex(std::pair<int, int> xy) | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		return XYToHex(xy.first, xy.second); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-23 22:57:39 +00:00
										 |  |  | 	static int hexToY(int battleFieldPosition) | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		return battleFieldPosition/17; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-23 22:57:39 +00:00
										 |  |  | 	static int hexToX(int battleFieldPosition) | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		int pos = battleFieldPosition - hexToY(battleFieldPosition) * 17; | 
					
						
							|  |  |  | 		return pos; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-23 22:57:39 +00:00
										 |  |  | 	static std::pair<int, int> hexToPair(int battleFieldPosition) | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		return std::make_pair(hexToX(battleFieldPosition), hexToY(battleFieldPosition)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//moves hex by one hex in given direction
 | 
					
						
							|  |  |  | 	//0 - left top, 1 - right top, 2 - right, 3 - right bottom, 4 - left bottom, 5 - left
 | 
					
						
							| 
									
										
										
										
											2009-05-23 22:57:39 +00:00
										 |  |  | 	static std::pair<int, int> gotoDir(int x, int y, int direction) | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		switch(direction) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 		case 0: //top left
 | 
					
						
							|  |  |  | 			return std::make_pair(y%2 ? x-1 : x, y-1); | 
					
						
							|  |  |  | 		case 1: //top right
 | 
					
						
							|  |  |  | 			return std::make_pair(y%2 ? x : x+1, y-1); | 
					
						
							|  |  |  | 		case 2:  //right
 | 
					
						
							|  |  |  | 			return std::make_pair(x+1, y); | 
					
						
							|  |  |  | 		case 3: //right bottom
 | 
					
						
							|  |  |  | 			return std::make_pair(y%2 ? x : x+1, y+1); | 
					
						
							|  |  |  | 		case 4: //left bottom
 | 
					
						
							|  |  |  | 			return std::make_pair(y%2 ? x-1 : x, y+1); | 
					
						
							|  |  |  | 		case 5: //left
 | 
					
						
							|  |  |  | 			return std::make_pair(x-1, y); | 
					
						
							| 
									
										
										
										
											2009-06-23 08:14:49 +00:00
										 |  |  | 		default: | 
					
						
							|  |  |  | 			throw std::string("Disaster: wrong direction in SRSLPraserHelpers::gotoDir!\n"); | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-23 22:57:39 +00:00
										 |  |  | 	static std::pair<int, int> gotoDir(std::pair<int, int> xy, int direction) | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		return gotoDir(xy.first, xy.second, direction); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-23 22:57:39 +00:00
										 |  |  | 	static bool isGoodHex(std::pair<int, int> xy) | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		return xy.first >=0 && xy.first < 17 && xy.second >= 0 && xy.second < 11; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//helper fonction for std::set<ui16> CSpell::rangeInHexes(unsigned int centralHex, ui8 schoolLvl ) const
 | 
					
						
							| 
									
										
										
										
											2009-05-23 22:57:39 +00:00
										 |  |  | 	static std::set<ui16> getInRange(unsigned int center, int low, int high) | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		std::set<ui16> ret; | 
					
						
							|  |  |  | 		if(low == 0) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			ret.insert(center); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		std::pair<int, int> mainPointForLayer[6]; //A, B, C, D, E, F points
 | 
					
						
							|  |  |  | 		for(int b=0; b<6; ++b) | 
					
						
							|  |  |  | 			mainPointForLayer[b] = hexToPair(center); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for(int it=1; it<=high; ++it) //it - distance to the center
 | 
					
						
							|  |  |  | 		{		 | 
					
						
							|  |  |  | 			for(int b=0; b<6; ++b) | 
					
						
							|  |  |  | 				mainPointForLayer[b] = gotoDir(mainPointForLayer[b], b); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if(it>=low) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				std::pair<int, int> curHex; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				//adding lines (A-b, B-c, C-d, etc)
 | 
					
						
							|  |  |  | 				for(int v=0; v<6; ++v) | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					curHex = mainPointForLayer[v]; | 
					
						
							|  |  |  | 					for(int h=0; h<it; ++h) | 
					
						
							|  |  |  | 					{ | 
					
						
							|  |  |  | 						if(isGoodHex(curHex)) | 
					
						
							|  |  |  | 							ret.insert(XYToHex(curHex)); | 
					
						
							|  |  |  | 						curHex = gotoDir(curHex, (v+2)%6); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			} //if(it>=low)
 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return ret; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | using namespace SRSLPraserHelpers; | 
					
						
							| 
									
										
										
										
											2009-09-24 17:54:02 +00:00
										 |  |  | CSpellHandler::CSpellHandler() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	VLC->spellh = this; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | std::set<ui16> CSpell::rangeInHexes(unsigned int centralHex, ui8 schoolLvl ) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	std::set<ui16> ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	std::string rng = range[schoolLvl] + ','; //copy + artificial comma for easier handling
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(rng.size() >= 1 && rng[0] != 'X') //there is at lest one hex in range
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		std::string number1, number2; | 
					
						
							|  |  |  | 		int beg, end; | 
					
						
							|  |  |  | 		bool readingFirst = true; | 
					
						
							|  |  |  | 		for(int it=0; it<rng.size(); ++it) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			if( std::isdigit(rng[it]) ) //reading numer
 | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				if(readingFirst) | 
					
						
							|  |  |  | 					number1 += rng[it]; | 
					
						
							|  |  |  | 				else | 
					
						
							|  |  |  | 					number2 += rng[it]; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else if(rng[it] == ',') //comma
 | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				//calculating variables
 | 
					
						
							|  |  |  | 				if(readingFirst) | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					beg = atoi(number1.c_str()); | 
					
						
							|  |  |  | 					number1 = ""; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				else | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					end = atoi(number2.c_str()); | 
					
						
							|  |  |  | 					number2 = ""; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				//obtaining new hexes
 | 
					
						
							|  |  |  | 				std::set<ui16> curLayer; | 
					
						
							|  |  |  | 				if(readingFirst) | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					curLayer = getInRange(centralHex, beg, beg); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				else | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					curLayer = getInRange(centralHex, beg, end); | 
					
						
							|  |  |  | 					readingFirst = true; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				//adding abtained hexes
 | 
					
						
							|  |  |  | 				for(std::set<ui16>::iterator it = curLayer.begin(); it != curLayer.end(); ++it) | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					ret.insert(*it); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else if(rng[it] == '-') //dash
 | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				beg = atoi(number1.c_str()); | 
					
						
							|  |  |  | 				number1 = ""; | 
					
						
							|  |  |  | 				readingFirst = false; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-21 16:53:23 +00:00
										 |  |  | CSpell::ETargetType CSpell::getTargetType() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if(attributes.find("CREATURE_TARGET_1") != std::string::npos | 
					
						
							|  |  |  | 		|| attributes.find("CREATURE_TARGET_2") != std::string::npos) | 
					
						
							|  |  |  | 		return CREATURE_EXPERT_MASSIVE; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(attributes.find("CREATURE_TARGET") != std::string::npos) | 
					
						
							|  |  |  | 		return CREATURE; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(attributes.find("OBSTACLE_TARGET") != std::string::npos) | 
					
						
							|  |  |  | 		return OBSTACLE; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return NO_TARGET; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-20 13:24:38 +00:00
										 |  |  | static bool startsWithX(const std::string &s) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return s.size() && s[0] == 'x'; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-20 22:17:19 +00:00
										 |  |  | bool DLL_EXPORT isInScreenRange(const int3 ¢er, const int3 &pos) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int3 diff = pos - center; | 
					
						
							|  |  |  | 	if(diff.x >= -9  &&  diff.x <= 9  &&  diff.y >= -8  &&  diff.y <= 8) | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | void CSpellHandler::loadSpells() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 	std::string buf = bitmaph->getTextFile("SPTRAITS.TXT"), pom; | 
					
						
							|  |  |  | 	int andame = buf.size(), i=0; //buf iterator
 | 
					
						
							|  |  |  | 	for(int z=0; z<5; ++z) | 
					
						
							|  |  |  | 		loadToIt(pom,buf,i,3); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-09 20:23:44 +00:00
										 |  |  | 	bool combSpells=false; //true, if we are reading combat spells
 | 
					
						
							| 
									
										
										
										
											2008-09-12 13:06:53 +00:00
										 |  |  | 	bool creatureAbility=false; //if true, only creature can use this spell
 | 
					
						
							|  |  |  | 	int ifHit = 0; | 
					
						
							| 
									
										
										
										
											2007-06-09 20:23:44 +00:00
										 |  |  | 	while(i<andame) | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2007-07-16 14:42:44 +00:00
										 |  |  | 		if(spells.size()==81) | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		CSpell * nsp = new CSpell; //new currently being read spell
 | 
					
						
							| 
									
										
										
										
											2007-06-09 20:23:44 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		loadToIt(nsp->name,buf,i,4); | 
					
						
							|  |  |  | 		if(nsp->name == std::string("")) | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2008-09-12 13:06:53 +00:00
										 |  |  | 			if(ifHit == 0) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				combSpells = true; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if(ifHit == 1) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				creatureAbility = true; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 			for(int z=0; z<3; ++z) | 
					
						
							|  |  |  | 				loadToIt(pom,buf,i,3); | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 			loadToIt(nsp->name,buf,i,4); | 
					
						
							| 
									
										
										
										
											2008-09-12 13:06:53 +00:00
										 |  |  | 			++ifHit; | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		loadToIt(nsp->abbName,buf,i,4); | 
					
						
							|  |  |  | 		loadToIt(nsp->level,buf,i,4); | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 		loadToIt(pom,buf,i,4); | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		nsp->earth = startsWithX(pom); | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 		loadToIt(pom,buf,i,4); | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		nsp->water = startsWithX(pom); | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 		loadToIt(pom,buf,i,4); | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		nsp->fire = startsWithX(pom); | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 		loadToIt(pom,buf,i,4); | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		nsp->air = startsWithX(pom); | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		nsp->costs.resize(4); | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 		for (int z = 0; z < 4 ; z++) | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 			loadToIt(nsp->costs[z],buf,i,4); | 
					
						
							|  |  |  | 		loadToIt(nsp->power,buf,i,4); | 
					
						
							|  |  |  | 		nsp->powers.resize(4); | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 		for (int z = 0; z < 4 ; z++) | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 			loadToIt(nsp->powers[z],buf,i,4); | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		nsp->probabilities.resize(9); | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 		for (int z = 0; z < 9 ; z++) | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 			loadToIt(nsp->probabilities[z],buf,i,4); | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		nsp->AIVals.resize(4); | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 		for (int z = 0; z < 4 ; z++) | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 			loadToIt(nsp->AIVals[z],buf,i,4); | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		nsp->descriptions.resize(4); | 
					
						
							| 
									
										
										
										
											2008-08-20 06:57:53 +00:00
										 |  |  | 		for (int z = 0; z < 4 ; z++) | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 			loadToIt(nsp->descriptions[z],buf,i,4); | 
					
						
							|  |  |  | 			boost::algorithm::replace_all(nsp->descriptions[z],"\"",""); | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 		loadToIt(nsp->attributes,buf,i,3); | 
					
						
							|  |  |  | 		nsp->id = spells.size(); | 
					
						
							|  |  |  | 		nsp->combatSpell = combSpells; | 
					
						
							|  |  |  | 		nsp->creatureAbility = creatureAbility; | 
					
						
							|  |  |  | 		nsp->mainEffectAnim = -1; | 
					
						
							| 
									
										
										
										
											2007-06-09 13:28:03 +00:00
										 |  |  | 		spells.push_back(nsp); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-04-23 09:57:51 +00:00
										 |  |  | 	boost::replace_first (spells[47]->attributes, "2", ""); // disrupting ray will now affect single creature
 | 
					
						
							| 
									
										
										
										
											2008-12-20 17:08:51 +00:00
										 |  |  | 	//loading of additional spell traits
 | 
					
						
							|  |  |  | 	std::ifstream ast; | 
					
						
							| 
									
										
										
										
											2009-10-04 02:02:45 +00:00
										 |  |  | 	ast.open(DATA_DIR "/config/spell_info.txt", std::ios::binary); | 
					
						
							| 
									
										
										
										
											2008-12-20 17:08:51 +00:00
										 |  |  | 	if(!ast.is_open()) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		tlog1<<"lack of config/spell_info.txt file!"<<std::endl; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		//reading header
 | 
					
						
							|  |  |  | 		std::string dump; | 
					
						
							| 
									
										
										
										
											2009-04-22 10:03:13 +00:00
										 |  |  | 		for(int i=0; i<60; ++i) ast>>dump; | 
					
						
							| 
									
										
										
										
											2008-12-20 17:08:51 +00:00
										 |  |  | 		//reading exact info
 | 
					
						
							|  |  |  | 		int spellID; | 
					
						
							|  |  |  | 		ast>>spellID; | 
					
						
							|  |  |  | 		while(spellID != -1) | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			int buf; | 
					
						
							| 
									
										
										
										
											2009-04-22 10:03:13 +00:00
										 |  |  | 			ast >> buf; | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 			spells[spellID]->positiveness = buf; | 
					
						
							| 
									
										
										
										
											2009-04-22 10:03:13 +00:00
										 |  |  | 			ast >> buf; | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 			spells[spellID]->mainEffectAnim = buf; | 
					
						
							| 
									
										
										
										
											2009-04-22 10:03:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 			spells[spellID]->range.resize(4); | 
					
						
							| 
									
										
										
										
											2009-04-14 14:48:57 +00:00
										 |  |  | 			for(int g=0; g<4; ++g) | 
					
						
							| 
									
										
										
										
											2010-12-19 14:39:56 +00:00
										 |  |  | 				ast>>spells[spellID]->range[g]; | 
					
						
							| 
									
										
										
										
											2008-12-20 17:08:51 +00:00
										 |  |  | 			ast>>spellID; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-04-25 09:03:13 +00:00
										 |  |  | 	ast.close(); | 
					
						
							| 
									
										
										
										
											2011-05-13 09:02:16 +00:00
										 |  |  | 	spells.push_back(spells[80]); //clone Acid Breath attributes for Acid Breath damage effect
 | 
					
						
							| 
									
										
										
										
											2011-06-25 06:55:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	damageSpells += 11, 13, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 57, 77; | 
					
						
							| 
									
										
										
										
											2008-12-20 17:08:51 +00:00
										 |  |  | } |