mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
99691b0f11
* added frenzy spell * repaired order in stack queue in case a unit has waited (it should work correctly now) * added spell positiveness info, positive spells cannot be cast on hostile stacks and vice versa
106 lines
2.5 KiB
C++
106 lines
2.5 KiB
C++
#define VCMI_DLL
|
|
#include "../stdafx.h"
|
|
#include "CSpellHandler.h"
|
|
#include "CLodHandler.h"
|
|
#include "../lib/VCMI_Lib.h"
|
|
#include <boost/algorithm/string/replace.hpp>
|
|
extern CLodHandler *bitmaph;
|
|
void CSpellHandler::loadSpells()
|
|
{
|
|
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);
|
|
|
|
bool combSpells=false; //true, if we are reading combat spells
|
|
bool creatureAbility=false; //if true, only creature can use this spell
|
|
int ifHit = 0;
|
|
while(i<andame)
|
|
{
|
|
if(spells.size()==81)
|
|
break;
|
|
CSpell nsp; //new currently being read spell
|
|
|
|
loadToIt(nsp.name,buf,i,4);
|
|
if(nsp.name == std::string(""))
|
|
{
|
|
if(ifHit == 0)
|
|
{
|
|
combSpells = true;
|
|
}
|
|
if(ifHit == 1)
|
|
{
|
|
creatureAbility = true;
|
|
}
|
|
for(int z=0; z<3; ++z)
|
|
loadToIt(pom,buf,i,3);
|
|
loadToIt(nsp.name,buf,i,4);
|
|
++ifHit;
|
|
}
|
|
|
|
loadToIt(nsp.abbName,buf,i,4);
|
|
loadToIt(nsp.level,buf,i,4);
|
|
|
|
loadToIt(pom,buf,i,4);
|
|
nsp.earth = pom[0]=='x' ? true : false;
|
|
loadToIt(pom,buf,i,4);
|
|
nsp.water = pom[0]=='x' ? true : false;
|
|
loadToIt(pom,buf,i,4);
|
|
nsp.fire = pom[0]=='x' ? true : false;
|
|
loadToIt(pom,buf,i,4);
|
|
nsp.air = pom[0]=='x' ? true : false;
|
|
|
|
nsp.costs.resize(4);
|
|
for (int z = 0; z < 4 ; z++)
|
|
loadToIt(nsp.costs[z],buf,i,4);
|
|
loadToIt(nsp.power,buf,i,4);
|
|
nsp.powers.resize(4);
|
|
for (int z = 0; z < 4 ; z++)
|
|
loadToIt(nsp.powers[z],buf,i,4);
|
|
|
|
nsp.probabilities.resize(9);
|
|
for (int z = 0; z < 9 ; z++)
|
|
loadToIt(nsp.probabilities[z],buf,i,4);
|
|
|
|
nsp.AIVals.resize(4);
|
|
for (int z = 0; z < 4 ; z++)
|
|
loadToIt(nsp.AIVals[z],buf,i,4);
|
|
|
|
nsp.descriptions.resize(4);
|
|
for (int z = 0; z < 4 ; z++)
|
|
{
|
|
loadToIt(nsp.descriptions[z],buf,i,4);
|
|
boost::algorithm::replace_all(nsp.descriptions[z],"\"","");
|
|
}
|
|
|
|
loadToIt(nsp.attributes,buf,i,3);
|
|
nsp.id = spells.size();
|
|
nsp.combatSpell = combSpells;
|
|
nsp.creatureAbility = creatureAbility;
|
|
spells.push_back(nsp);
|
|
}
|
|
//loading of additional spell traits
|
|
std::ifstream ast;
|
|
ast.open("config/spell_info.txt", std::ios::binary);
|
|
if(!ast.is_open())
|
|
{
|
|
tlog1<<"lack of config/spell_info.txt file!"<<std::endl;
|
|
}
|
|
else
|
|
{
|
|
//reading header
|
|
std::string dump;
|
|
for(int i=0; i<42; ++i) ast>>dump;
|
|
//reading exact info
|
|
int spellID;
|
|
ast>>spellID;
|
|
while(spellID != -1)
|
|
{
|
|
int buf;
|
|
ast>>buf;
|
|
spells[spellID].positiveness = buf;
|
|
ast>>spellID;
|
|
}
|
|
}
|
|
}
|