2008-01-09 19:21:31 +02:00
|
|
|
#include "../stdafx.h"
|
2007-06-08 17:58:04 +03:00
|
|
|
#include "CHeroHandler.h"
|
2007-08-30 13:11:53 +03:00
|
|
|
#include "../CGameInfo.h"
|
2007-07-11 15:08:42 +03:00
|
|
|
#include <sstream>
|
2007-08-30 13:11:53 +03:00
|
|
|
#include "../CGameInfo.h"
|
2007-08-04 22:01:22 +03:00
|
|
|
#include "CGeneralTextHandler.h"
|
2007-08-29 15:18:31 +03:00
|
|
|
#include "CLodHandler.h"
|
|
|
|
#include "CAbilityHandler.h"
|
2007-10-21 19:52:41 +03:00
|
|
|
#include "../SDL_Extensions.h"
|
2007-09-14 16:11:10 +03:00
|
|
|
#include <cmath>
|
2007-09-15 21:04:12 +03:00
|
|
|
#include <iomanip>
|
2008-06-11 04:53:57 +03:00
|
|
|
#include "CDefHandler.h"
|
2007-07-20 02:38:11 +03:00
|
|
|
CHeroHandler::~CHeroHandler()
|
|
|
|
{
|
|
|
|
for (int j=0;j<heroes.size();j++)
|
|
|
|
{
|
|
|
|
if (heroes[j]->portraitSmall)
|
|
|
|
SDL_FreeSurface(heroes[j]->portraitSmall);
|
|
|
|
delete heroes[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void CHeroHandler::loadPortraits()
|
|
|
|
{
|
2007-09-16 20:21:23 +03:00
|
|
|
std::ifstream of("config/portrety.txt");
|
2007-07-20 02:38:11 +03:00
|
|
|
for (int j=0;j<heroes.size();j++)
|
|
|
|
{
|
|
|
|
int ID;
|
|
|
|
of>>ID;
|
|
|
|
std::string path;
|
|
|
|
of>>path;
|
2008-06-12 09:45:51 +03:00
|
|
|
heroes[ID]->portraitSmall=BitmapHandler::loadBitmap(path);
|
2007-07-20 02:38:11 +03:00
|
|
|
if (!heroes[ID]->portraitSmall)
|
2007-10-17 01:39:11 +03:00
|
|
|
std::cout<<"Can't read small portrait for "<<ID<<" ("<<path<<")\n";
|
2008-01-13 18:24:24 +02:00
|
|
|
for(int ff=0; ff<path.size(); ++ff) //size letter is usually third one, but there are exceptions an it should fix the problem
|
|
|
|
{
|
|
|
|
if(path[ff]=='S')
|
|
|
|
{
|
|
|
|
path[ff]='L';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-06-12 09:45:51 +03:00
|
|
|
heroes[ID]->portraitLarge=BitmapHandler::loadBitmap(path);
|
2007-10-17 01:39:11 +03:00
|
|
|
if (!heroes[ID]->portraitLarge)
|
|
|
|
std::cout<<"Can't read large portrait for "<<ID<<" ("<<path<<")\n";
|
|
|
|
SDL_SetColorKey(heroes[ID]->portraitLarge,SDL_SRCCOLORKEY,SDL_MapRGB(heroes[ID]->portraitLarge->format,0,255,255));
|
|
|
|
|
2007-07-20 02:38:11 +03:00
|
|
|
}
|
|
|
|
of.close();
|
2008-06-12 09:45:51 +03:00
|
|
|
pskillsb = CDefHandler::giveDef("PSKILL.DEF");
|
|
|
|
resources = CDefHandler::giveDef("RESOUR82.DEF");
|
|
|
|
un44 = CDefHandler::giveDef("UN44.DEF");
|
2007-11-19 00:58:28 +02:00
|
|
|
|
|
|
|
std::string strs = CGI->bitmaph->getTextFile("PRISKILL.TXT");
|
|
|
|
int itr=0;
|
|
|
|
for (int i=0; i<PRIMARY_SKILLS; i++)
|
|
|
|
{
|
|
|
|
std::string tmp;
|
|
|
|
CGeneralTextHandler::loadToIt(tmp, strs, itr, 3);
|
|
|
|
pskillsn.push_back(tmp);
|
|
|
|
}
|
2007-07-20 02:38:11 +03:00
|
|
|
}
|
2008-06-12 09:45:51 +03:00
|
|
|
void CHeroHandler::loadHeroFlags()
|
|
|
|
{
|
|
|
|
flags1.push_back(CDefHandler::giveDef("ABF01L.DEF")); //red
|
|
|
|
flags1.push_back(CDefHandler::giveDef("ABF01G.DEF")); //blue
|
|
|
|
flags1.push_back(CDefHandler::giveDef("ABF01R.DEF")); //tan
|
|
|
|
flags1.push_back(CDefHandler::giveDef("ABF01D.DEF")); //green
|
|
|
|
flags1.push_back(CDefHandler::giveDef("ABF01B.DEF")); //orange
|
|
|
|
flags1.push_back(CDefHandler::giveDef("ABF01P.DEF")); //purple
|
|
|
|
flags1.push_back(CDefHandler::giveDef("ABF01W.DEF")); //teal
|
|
|
|
flags1.push_back(CDefHandler::giveDef("ABF01K.DEF")); //pink
|
|
|
|
|
|
|
|
for(int q=0; q<8; ++q)
|
|
|
|
{
|
|
|
|
for(int o=0; o<flags1[q]->ourImages.size(); ++o)
|
|
|
|
{
|
|
|
|
if(flags1[q]->ourImages[o].groupNumber==6)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags1[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 10;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags1[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(flags1[q]->ourImages[o].groupNumber==7)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags1[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 11;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags1[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(flags1[q]->ourImages[o].groupNumber==8)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags1[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 12;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags1[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int ff=0; ff<flags1[q]->ourImages.size(); ++ff)
|
|
|
|
{
|
|
|
|
SDL_SetColorKey(flags1[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY,
|
|
|
|
SDL_MapRGB(flags1[q]->ourImages[ff].bitmap->format, 0, 255, 255)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
flags1[q]->alphaTransformed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags2.push_back(CDefHandler::giveDef("ABF02L.DEF")); //red
|
|
|
|
flags2.push_back(CDefHandler::giveDef("ABF02G.DEF")); //blue
|
|
|
|
flags2.push_back(CDefHandler::giveDef("ABF02R.DEF")); //tan
|
|
|
|
flags2.push_back(CDefHandler::giveDef("ABF02D.DEF")); //green
|
|
|
|
flags2.push_back(CDefHandler::giveDef("ABF02B.DEF")); //orange
|
|
|
|
flags2.push_back(CDefHandler::giveDef("ABF02P.DEF")); //purple
|
|
|
|
flags2.push_back(CDefHandler::giveDef("ABF02W.DEF")); //teal
|
|
|
|
flags2.push_back(CDefHandler::giveDef("ABF02K.DEF")); //pink
|
|
|
|
|
|
|
|
for(int q=0; q<8; ++q)
|
|
|
|
{
|
|
|
|
for(int o=0; o<flags2[q]->ourImages.size(); ++o)
|
|
|
|
{
|
|
|
|
if(flags2[q]->ourImages[o].groupNumber==6)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags2[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 10;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags2[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(flags2[q]->ourImages[o].groupNumber==7)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags2[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 11;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags2[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(flags2[q]->ourImages[o].groupNumber==8)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags2[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 12;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags2[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int ff=0; ff<flags2[q]->ourImages.size(); ++ff)
|
|
|
|
{
|
|
|
|
SDL_SetColorKey(flags2[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY,
|
|
|
|
SDL_MapRGB(flags2[q]->ourImages[ff].bitmap->format, 0, 255, 255)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
flags2[q]->alphaTransformed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags3.push_back(CDefHandler::giveDef("ABF03L.DEF")); //red
|
|
|
|
flags3.push_back(CDefHandler::giveDef("ABF03G.DEF")); //blue
|
|
|
|
flags3.push_back(CDefHandler::giveDef("ABF03R.DEF")); //tan
|
|
|
|
flags3.push_back(CDefHandler::giveDef("ABF03D.DEF")); //green
|
|
|
|
flags3.push_back(CDefHandler::giveDef("ABF03B.DEF")); //orange
|
|
|
|
flags3.push_back(CDefHandler::giveDef("ABF03P.DEF")); //purple
|
|
|
|
flags3.push_back(CDefHandler::giveDef("ABF03W.DEF")); //teal
|
|
|
|
flags3.push_back(CDefHandler::giveDef("ABF03K.DEF")); //pink
|
|
|
|
|
|
|
|
for(int q=0; q<8; ++q)
|
|
|
|
{
|
|
|
|
for(int o=0; o<flags3[q]->ourImages.size(); ++o)
|
|
|
|
{
|
|
|
|
if(flags3[q]->ourImages[o].groupNumber==6)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags3[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 10;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags3[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(flags3[q]->ourImages[o].groupNumber==7)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags3[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 11;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags3[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(flags3[q]->ourImages[o].groupNumber==8)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags3[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 12;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags3[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int ff=0; ff<flags3[q]->ourImages.size(); ++ff)
|
|
|
|
{
|
|
|
|
SDL_SetColorKey(flags3[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY,
|
|
|
|
SDL_MapRGB(flags3[q]->ourImages[ff].bitmap->format, 0, 255, 255)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
flags3[q]->alphaTransformed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
flags4.push_back(CDefHandler::giveDef("AF00.DEF")); //red
|
|
|
|
flags4.push_back(CDefHandler::giveDef("AF01.DEF")); //blue
|
|
|
|
flags4.push_back(CDefHandler::giveDef("AF02.DEF")); //tan
|
|
|
|
flags4.push_back(CDefHandler::giveDef("AF03.DEF")); //green
|
|
|
|
flags4.push_back(CDefHandler::giveDef("AF04.DEF")); //orange
|
|
|
|
flags4.push_back(CDefHandler::giveDef("AF05.DEF")); //purple
|
|
|
|
flags4.push_back(CDefHandler::giveDef("AF06.DEF")); //teal
|
|
|
|
flags4.push_back(CDefHandler::giveDef("AF07.DEF")); //pink
|
|
|
|
|
|
|
|
|
|
|
|
for(int q=0; q<8; ++q)
|
|
|
|
{
|
|
|
|
for(int o=0; o<flags4[q]->ourImages.size(); ++o)
|
|
|
|
{
|
|
|
|
if(flags4[q]->ourImages[o].groupNumber==6)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 10;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags4[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(flags4[q]->ourImages[o].groupNumber==7)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 10;
|
|
|
|
nci.groupNumber = 11;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags4[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(flags4[q]->ourImages[o].groupNumber==8)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 10;
|
|
|
|
nci.groupNumber = 12;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags4[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int o=0; o<flags4[q]->ourImages.size(); ++o)
|
|
|
|
{
|
|
|
|
if(flags4[q]->ourImages[o].groupNumber==1)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 10;
|
|
|
|
nci.groupNumber = 13;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags4[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(flags4[q]->ourImages[o].groupNumber==2)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 10;
|
|
|
|
nci.groupNumber = 14;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags4[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(flags4[q]->ourImages[o].groupNumber==3)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(flags4[q]->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 10;
|
|
|
|
nci.groupNumber = 15;
|
|
|
|
nci.imName = std::string();
|
|
|
|
flags4[q]->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int ff=0; ff<flags4[q]->ourImages.size(); ++ff)
|
|
|
|
{
|
|
|
|
SDL_SetColorKey(flags4[q]->ourImages[ff].bitmap, SDL_SRCCOLORKEY,
|
|
|
|
SDL_MapRGB(flags4[q]->ourImages[ff].bitmap->format, 0, 255, 255)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
flags4[q]->alphaTransformed = true;
|
|
|
|
}
|
|
|
|
}
|
2007-06-08 17:58:04 +03:00
|
|
|
void CHeroHandler::loadHeroes()
|
|
|
|
{
|
2007-06-16 16:33:58 +03:00
|
|
|
int ID=0;
|
2008-06-13 00:08:04 +03:00
|
|
|
std::string buf = CGI->bitmaph->getTextFile("HOTRAITS.TXT");
|
2007-08-04 22:01:22 +03:00
|
|
|
int it=0;
|
2007-06-08 17:58:04 +03:00
|
|
|
std::string dump;
|
2007-08-04 22:01:22 +03:00
|
|
|
for(int i=0; i<2; ++i)
|
2007-06-08 17:58:04 +03:00
|
|
|
{
|
2007-08-04 22:01:22 +03:00
|
|
|
CGeneralTextHandler::loadToIt(dump,buf,it,3);
|
2007-06-08 17:58:04 +03:00
|
|
|
}
|
2007-08-04 22:01:22 +03:00
|
|
|
|
2007-07-16 13:03:54 +03:00
|
|
|
int numberOfCurrentClassHeroes = 0;
|
|
|
|
int currentClass = 0;
|
|
|
|
int additHero = 0;
|
|
|
|
EHeroClasses addTab[12];
|
|
|
|
addTab[0] = HERO_KNIGHT;
|
|
|
|
addTab[1] = HERO_WITCH;
|
|
|
|
addTab[2] = HERO_KNIGHT;
|
|
|
|
addTab[3] = HERO_WIZARD;
|
|
|
|
addTab[4] = HERO_RANGER;
|
|
|
|
addTab[5] = HERO_BARBARIAN;
|
|
|
|
addTab[6] = HERO_DEATHKNIGHT;
|
|
|
|
addTab[7] = HERO_WARLOCK;
|
|
|
|
addTab[8] = HERO_KNIGHT;
|
|
|
|
addTab[9] = HERO_WARLOCK;
|
|
|
|
addTab[10] = HERO_BARBARIAN;
|
|
|
|
addTab[11] = HERO_DEMONIAC;
|
|
|
|
|
2007-08-04 22:01:22 +03:00
|
|
|
|
|
|
|
for (int i=0; i<HEROES_QUANTITY; i++)
|
2007-06-08 17:58:04 +03:00
|
|
|
{
|
2007-07-16 13:03:54 +03:00
|
|
|
CHero * nher = new CHero;
|
|
|
|
if(currentClass<18)
|
|
|
|
{
|
|
|
|
nher->heroType = (EHeroClasses)currentClass;
|
|
|
|
++numberOfCurrentClassHeroes;
|
|
|
|
if(numberOfCurrentClassHeroes==8)
|
|
|
|
{
|
|
|
|
numberOfCurrentClassHeroes = 0;
|
|
|
|
++currentClass;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nher->heroType = addTab[additHero++];
|
|
|
|
}
|
2007-08-04 22:01:22 +03:00
|
|
|
|
|
|
|
std::string pom ;
|
|
|
|
CGeneralTextHandler::loadToIt(nher->name,buf,it,4);
|
|
|
|
|
2008-05-03 18:30:11 +03:00
|
|
|
for(int x=0;x<3;x++)
|
|
|
|
{
|
|
|
|
CGeneralTextHandler::loadToIt(pom,buf,it,4);
|
|
|
|
nher->lowStack[x] = atoi(pom.c_str());
|
|
|
|
CGeneralTextHandler::loadToIt(pom,buf,it,4);
|
|
|
|
nher->highStack[x] = atoi(pom.c_str());
|
|
|
|
CGeneralTextHandler::loadToIt(nher->refTypeStack[x],buf,it,(x==2) ? (3) : (4));
|
2008-05-31 23:37:54 +03:00
|
|
|
int hlp = nher->refTypeStack[x].find_first_of(' ',0);
|
|
|
|
if(hlp>=0)
|
|
|
|
nher->refTypeStack[x].replace(hlp,1,"");
|
2008-05-03 18:30:11 +03:00
|
|
|
}
|
2007-08-04 22:01:22 +03:00
|
|
|
|
|
|
|
nher->ID = heroes.size();
|
2007-06-08 17:58:04 +03:00
|
|
|
heroes.push_back(nher);
|
|
|
|
}
|
2007-06-09 16:28:03 +03:00
|
|
|
loadSpecialAbilities();
|
2007-08-04 22:01:22 +03:00
|
|
|
loadBiographies();
|
|
|
|
loadHeroClasses();
|
|
|
|
initHeroClasses();
|
2008-01-27 18:07:27 +02:00
|
|
|
expPerLevel.push_back(0);
|
|
|
|
expPerLevel.push_back(1000);
|
|
|
|
expPerLevel.push_back(2000);
|
|
|
|
expPerLevel.push_back(3200);
|
|
|
|
expPerLevel.push_back(4500);
|
|
|
|
expPerLevel.push_back(6000);
|
|
|
|
expPerLevel.push_back(7700);
|
|
|
|
expPerLevel.push_back(9000);
|
|
|
|
expPerLevel.push_back(11000);
|
|
|
|
expPerLevel.push_back(13200);
|
|
|
|
expPerLevel.push_back(15500);
|
|
|
|
expPerLevel.push_back(18500);
|
|
|
|
expPerLevel.push_back(22100);
|
|
|
|
expPerLevel.push_back(26420);
|
|
|
|
expPerLevel.push_back(31604);
|
2007-08-04 22:01:22 +03:00
|
|
|
return;
|
2007-07-17 23:51:49 +03:00
|
|
|
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
|
|
|
void CHeroHandler::loadSpecialAbilities()
|
|
|
|
{
|
2008-06-13 00:08:04 +03:00
|
|
|
std::string buf = CGI->bitmaph->getTextFile("HEROSPEC.TXT");
|
2007-08-04 22:01:22 +03:00
|
|
|
int it=0;
|
2007-06-09 16:28:03 +03:00
|
|
|
std::string dump;
|
2007-08-04 22:01:22 +03:00
|
|
|
for(int i=0; i<2; ++i)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-08-04 22:01:22 +03:00
|
|
|
CGeneralTextHandler::loadToIt(dump,buf,it,3);
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-08-04 22:01:22 +03:00
|
|
|
for (int i=0;i<heroes.size();i++)
|
2007-06-09 16:28:03 +03:00
|
|
|
{
|
2007-08-04 22:01:22 +03:00
|
|
|
CGeneralTextHandler::loadToIt(heroes[i]->bonusName,buf,it,4);
|
|
|
|
CGeneralTextHandler::loadToIt(heroes[i]->shortBonus,buf,it,4);
|
|
|
|
CGeneralTextHandler::loadToIt(heroes[i]->longBonus,buf,it,3);
|
2007-06-09 16:28:03 +03:00
|
|
|
}
|
2007-06-11 20:21:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CHeroHandler::loadBiographies()
|
2007-08-04 22:01:22 +03:00
|
|
|
{
|
2008-06-13 00:08:04 +03:00
|
|
|
std::string buf = CGI->bitmaph->getTextFile("HEROBIOS.TXT");
|
2007-08-04 22:01:22 +03:00
|
|
|
int it=0;
|
|
|
|
for (int i=0;i<heroes.size();i++)
|
2007-06-11 20:21:27 +03:00
|
|
|
{
|
2007-08-04 22:01:22 +03:00
|
|
|
CGeneralTextHandler::loadToIt(heroes[i]->biography,buf,it,3);
|
2007-06-11 20:21:27 +03:00
|
|
|
}
|
|
|
|
}
|
2007-06-18 13:49:06 +03:00
|
|
|
|
|
|
|
void CHeroHandler::loadHeroClasses()
|
|
|
|
{
|
2008-06-13 00:08:04 +03:00
|
|
|
std::string buf = CGI->bitmaph->getTextFile("HCTRAITS.TXT");
|
2007-07-16 17:42:44 +03:00
|
|
|
int andame = buf.size();
|
|
|
|
for(int y=0; y<andame; ++y)
|
|
|
|
if(buf[y]==',')
|
|
|
|
buf[y]='.';
|
2007-06-18 13:49:06 +03:00
|
|
|
int i = 0; //buf iterator
|
|
|
|
int hmcr = 0;
|
|
|
|
for(i; i<andame; ++i) //omitting rubbish
|
|
|
|
{
|
|
|
|
if(buf[i]=='\r')
|
|
|
|
++hmcr;
|
|
|
|
if(hmcr==2)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=2;
|
|
|
|
for(int ss=0; ss<18; ++ss) //18 classes of hero (including conflux)
|
|
|
|
{
|
|
|
|
CHeroClass * hc = new CHeroClass;
|
|
|
|
int befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hc->name = buf.substr(befi, i-befi);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hc->aggression = atof(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hc->initialAttack = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hc->initialDefence = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hc->initialPower = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hc->initialKnowledge = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
|
2008-05-03 18:30:11 +03:00
|
|
|
hc->primChance.resize(PRIMARY_SKILLS);
|
|
|
|
for(int x=0;x<PRIMARY_SKILLS;x++)
|
2007-06-18 15:48:29 +03:00
|
|
|
{
|
2008-05-03 18:30:11 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hc->primChance[x].first = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-18 15:48:29 +03:00
|
|
|
}
|
2008-05-03 18:30:11 +03:00
|
|
|
for(int x=0;x<PRIMARY_SKILLS;x++)
|
2007-06-18 15:48:29 +03:00
|
|
|
{
|
2008-05-03 18:30:11 +03:00
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hc->primChance[x].second = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
2007-06-18 15:48:29 +03:00
|
|
|
}
|
|
|
|
|
2007-07-16 13:03:54 +03:00
|
|
|
//CHero kkk = heroes[0];
|
2007-06-18 15:48:29 +03:00
|
|
|
|
2008-06-13 00:08:04 +03:00
|
|
|
for(int dd=0; dd<CGI->abilh->abilities.size(); ++dd)
|
2007-06-18 15:48:29 +03:00
|
|
|
{
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
int buff = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
hc->proSec.push_back(buff);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int dd=0; dd<9; ++dd)
|
|
|
|
{
|
|
|
|
befi=i;
|
|
|
|
for(i; i<andame; ++i)
|
|
|
|
{
|
|
|
|
if(buf[i]=='\t' || buf[i]=='\r')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
hc->selectionProbability[dd] = atoi(buf.substr(befi, i-befi).c_str());
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
++i;
|
2007-09-15 21:04:12 +03:00
|
|
|
std::stringstream nm;
|
|
|
|
nm<<"AH";
|
|
|
|
nm<<std::setw(2);
|
|
|
|
nm<<std::setfill('0');
|
|
|
|
nm<<heroClasses.size();
|
|
|
|
nm<<"_.DEF";
|
2008-06-12 09:45:51 +03:00
|
|
|
hc->moveAnim = CDefHandler::giveDef(nm.str());
|
2007-09-15 21:04:12 +03:00
|
|
|
|
|
|
|
for(int o=0; o<hc->moveAnim->ourImages.size(); ++o)
|
|
|
|
{
|
|
|
|
if(hc->moveAnim->ourImages[o].groupNumber==6)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 10;
|
|
|
|
nci.imName = std::string();
|
|
|
|
hc->moveAnim->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(hc->moveAnim->ourImages[o].groupNumber==7)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 11;
|
|
|
|
nci.imName = std::string();
|
|
|
|
hc->moveAnim->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
if(hc->moveAnim->ourImages[o].groupNumber==8)
|
|
|
|
{
|
|
|
|
for(int e=0; e<8; ++e)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o+e].bitmap);
|
|
|
|
nci.groupNumber = 12;
|
|
|
|
nci.imName = std::string();
|
|
|
|
hc->moveAnim->ourImages.push_back(nci);
|
|
|
|
}
|
|
|
|
o+=8;
|
|
|
|
}
|
|
|
|
}
|
2007-10-08 21:47:23 +03:00
|
|
|
for(int o=0; o<hc->moveAnim->ourImages.size(); ++o)
|
|
|
|
{
|
|
|
|
if(hc->moveAnim->ourImages[o].groupNumber==1)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o].bitmap);
|
|
|
|
nci.groupNumber = 13;
|
|
|
|
nci.imName = std::string();
|
|
|
|
hc->moveAnim->ourImages.push_back(nci);
|
|
|
|
//o+=1;
|
|
|
|
}
|
|
|
|
if(hc->moveAnim->ourImages[o].groupNumber==2)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o].bitmap);
|
|
|
|
nci.groupNumber = 14;
|
|
|
|
nci.imName = std::string();
|
|
|
|
hc->moveAnim->ourImages.push_back(nci);
|
|
|
|
//o+=1;
|
|
|
|
}
|
|
|
|
if(hc->moveAnim->ourImages[o].groupNumber==3)
|
|
|
|
{
|
|
|
|
Cimage nci;
|
|
|
|
nci.bitmap = CSDL_Ext::rotate01(hc->moveAnim->ourImages[o].bitmap);
|
|
|
|
nci.groupNumber = 15;
|
|
|
|
nci.imName = std::string();
|
|
|
|
hc->moveAnim->ourImages.push_back(nci);
|
|
|
|
//o+=1;
|
|
|
|
}
|
|
|
|
}
|
2007-09-15 21:04:12 +03:00
|
|
|
|
|
|
|
for(int ff=0; ff<hc->moveAnim->ourImages.size(); ++ff)
|
|
|
|
{
|
2008-02-10 19:44:51 +02:00
|
|
|
CSDL_Ext::alphaTransform(hc->moveAnim->ourImages[ff].bitmap);
|
2007-09-15 21:04:12 +03:00
|
|
|
}
|
|
|
|
hc->moveAnim->alphaTransformed = true;
|
2007-06-18 15:48:29 +03:00
|
|
|
heroClasses.push_back(hc);
|
2007-06-18 13:49:06 +03:00
|
|
|
}
|
|
|
|
}
|
2007-07-16 13:03:54 +03:00
|
|
|
|
|
|
|
void CHeroHandler::initHeroClasses()
|
|
|
|
{
|
|
|
|
for(int gg=0; gg<heroes.size(); ++gg)
|
|
|
|
{
|
|
|
|
heroes[gg]->heroClass = heroClasses[heroes[gg]->heroType];
|
|
|
|
}
|
2007-08-15 18:13:11 +03:00
|
|
|
initTerrainCosts();
|
2007-07-16 13:03:54 +03:00
|
|
|
}
|
2007-08-12 20:48:05 +03:00
|
|
|
|
|
|
|
unsigned int CHeroHandler::level(unsigned int experience)
|
|
|
|
{
|
2008-01-27 18:07:27 +02:00
|
|
|
int add=0;
|
|
|
|
while(experience>=expPerLevel[expPerLevel.size()-1])
|
2007-09-14 16:11:10 +03:00
|
|
|
{
|
2008-01-27 18:07:27 +02:00
|
|
|
experience/=1.2;
|
2008-01-31 23:35:30 +02:00
|
|
|
add+=1;
|
2007-09-14 16:11:10 +03:00
|
|
|
}
|
2008-01-27 18:07:27 +02:00
|
|
|
for(int i=expPerLevel.size()-1; i>=0; --i)
|
2007-09-14 16:11:10 +03:00
|
|
|
{
|
2008-01-27 18:07:27 +02:00
|
|
|
if(experience>=expPerLevel[i])
|
|
|
|
return i+add;
|
2007-09-14 16:11:10 +03:00
|
|
|
}
|
2008-01-31 14:10:59 +02:00
|
|
|
return -1;
|
2008-01-27 18:07:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int CHeroHandler::reqExp(unsigned int level)
|
|
|
|
{
|
|
|
|
level-=1;
|
|
|
|
if(level<=expPerLevel.size())
|
|
|
|
return expPerLevel[level];
|
|
|
|
else
|
2007-09-14 16:11:10 +03:00
|
|
|
{
|
2008-01-27 18:07:27 +02:00
|
|
|
unsigned int exp = expPerLevel[expPerLevel.size()-1];
|
|
|
|
level-=expPerLevel.size();
|
|
|
|
while(level>0)
|
2007-09-14 16:11:10 +03:00
|
|
|
{
|
2008-01-27 18:07:27 +02:00
|
|
|
--level;
|
|
|
|
exp*=1.2;
|
2007-09-14 16:11:10 +03:00
|
|
|
}
|
|
|
|
}
|
2008-01-31 14:10:59 +02:00
|
|
|
return -1;
|
2007-08-12 20:48:05 +03:00
|
|
|
}
|
|
|
|
|
2007-08-15 18:13:11 +03:00
|
|
|
void CHeroHandler::initTerrainCosts()
|
|
|
|
{
|
2007-09-15 21:04:12 +03:00
|
|
|
std::ifstream inp;
|
2007-09-17 20:36:20 +03:00
|
|
|
inp.open("config\\TERCOSTS.TXT", std::ios_base::in|std::ios_base::binary);
|
2007-09-15 21:04:12 +03:00
|
|
|
int tynum;
|
|
|
|
inp>>tynum;
|
|
|
|
for(int i=0; i<2*tynum; i+=2)
|
2007-08-15 18:13:11 +03:00
|
|
|
{
|
2007-09-15 21:04:12 +03:00
|
|
|
int catNum;
|
|
|
|
inp>>catNum;
|
|
|
|
for(int k=0; k<catNum; ++k)
|
2007-08-15 18:13:11 +03:00
|
|
|
{
|
2007-09-15 21:04:12 +03:00
|
|
|
int curCost;
|
|
|
|
inp>>curCost;
|
|
|
|
heroClasses[i]->terrCosts.push_back(curCost);
|
|
|
|
heroClasses[i+1]->terrCosts.push_back(curCost);
|
2007-08-15 18:13:11 +03:00
|
|
|
}
|
|
|
|
}
|
2007-09-15 21:04:12 +03:00
|
|
|
inp.close();
|
2007-10-17 23:05:49 +03:00
|
|
|
}
|
|
|
|
|