mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
hero animation
This commit is contained in:
parent
f6953057d7
commit
3c4923a31e
@ -207,6 +207,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
int3 hp = CGI->heroh->heroInstances[details.heroID]->pos;
|
||||
if(details.dst.x+1 == details.src.x && details.dst.y+1 == details.src.y) //tl
|
||||
{
|
||||
ho->moveDir = 1;
|
||||
CGI->mh->ttiles[hp.x-3][hp.y-2][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, -31, -31)));
|
||||
CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, 1, -31)));
|
||||
CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, 33, -31)));
|
||||
@ -239,6 +240,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x == details.src.x && details.dst.y+1 == details.src.y) //t
|
||||
{
|
||||
ho->moveDir = 2;
|
||||
CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, 0, -31)));
|
||||
CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, 32, -31)));
|
||||
CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, 64, -31)));
|
||||
@ -265,6 +267,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x-1 == details.src.x && details.dst.y+1 == details.src.y) //tr
|
||||
{
|
||||
ho->moveDir = 3;
|
||||
CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, -1, -31)));
|
||||
CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, 31, -31)));
|
||||
CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, 63, -31)));
|
||||
@ -297,6 +300,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x-1 == details.src.x && details.dst.y == details.src.y) //r
|
||||
{
|
||||
ho->moveDir = 4;
|
||||
subRect(hp.x-2, hp.y-1, hp.z, genRect(32, 32, -1, 0), ho->id);
|
||||
subRect(hp.x-1, hp.y-1, hp.z, genRect(32, 32, 31, 0), ho->id);
|
||||
subRect(hp.x, hp.y-1, hp.z, genRect(32, 32, 63, 0), ho->id);
|
||||
@ -319,6 +323,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x-1 == details.src.x && details.dst.y-1 == details.src.y) //br
|
||||
{
|
||||
ho->moveDir = 5;
|
||||
subRect(hp.x-2, hp.y-1, hp.z, genRect(32, 32, -1, -1), ho->id);
|
||||
subRect(hp.x-1, hp.y-1, hp.z, genRect(32, 32, 31, -1), ho->id);
|
||||
subRect(hp.x, hp.y-1, hp.z, genRect(32, 32, 63, -1), ho->id);
|
||||
@ -351,6 +356,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x == details.src.x && details.dst.y-1 == details.src.y) //b
|
||||
{
|
||||
ho->moveDir = 6;
|
||||
subRect(hp.x-2, hp.y-1, hp.z, genRect(32, 32, 0, -1), ho->id);
|
||||
subRect(hp.x-1, hp.y-1, hp.z, genRect(32, 32, 32, -1), ho->id);
|
||||
subRect(hp.x, hp.y-1, hp.z, genRect(32, 32, 64, -1), ho->id);
|
||||
@ -377,6 +383,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x+1 == details.src.x && details.dst.y-1 == details.src.y) //bl
|
||||
{
|
||||
ho->moveDir = 7;
|
||||
CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, -31, -1)));
|
||||
subRect(hp.x-2, hp.y-1, hp.z, genRect(32, 32, 1, -1), ho->id);
|
||||
subRect(hp.x-1, hp.y-1, hp.z, genRect(32, 32, 33, -1), ho->id);
|
||||
@ -409,6 +416,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
}
|
||||
else if(details.dst.x+1 == details.src.x && details.dst.y == details.src.y) //l
|
||||
{
|
||||
ho->moveDir = 8;
|
||||
CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.push_back(std::make_pair(ho, genRect(32, 32, -31, 0)));
|
||||
subRect(hp.x-2, hp.y-1, hp.z, genRect(32, 32, 1, 0), ho->id);
|
||||
subRect(hp.x-1, hp.y-1, hp.z, genRect(32, 32, 33, 0), ho->id);
|
||||
@ -432,7 +440,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
//first initializing done
|
||||
SDL_framerateDelay(mainFPSmng); // after first move
|
||||
//main moving
|
||||
for(int i=1; i<32; ++i)
|
||||
for(int i=1; i<32; i+=4)
|
||||
{
|
||||
if(details.dst.x+1 == details.src.x && details.dst.y+1 == details.src.y) //tl
|
||||
{
|
||||
@ -722,6 +730,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
delObjRect(hp.x, hp.y, hp.z, ho->id);
|
||||
}
|
||||
CGI->heroh->heroInstances[details.heroID]->pos = details.dst; //actualizing hero position
|
||||
ho->moveDir = 0; //move ended
|
||||
//move finished
|
||||
}
|
||||
void CPlayerInterface::heroKilled(const CHeroInstance * hero)
|
||||
|
@ -532,6 +532,8 @@ void CAmbarCendamo::deh3m()
|
||||
nobj->pos.z = bufor[i++];
|
||||
nobj->defNumber = readNormalNr(i, 4); i+=4;
|
||||
nobj->defObjInfoNumber = -1;
|
||||
nobj->isHero = false;
|
||||
nobj->moveDir = 0;
|
||||
|
||||
//if (((nobj.x==0)&&(nobj.y==0)) || nobj.x>map.width || nobj.y>map.height || nobj.z>1 || nobj.defNumber>map.defy.size())
|
||||
// std::cout << "Alarm!!! Obiekt "<<ww<<" jest kopniety (lub wystaje poza mape)\n";
|
||||
@ -882,6 +884,8 @@ void CAmbarCendamo::deh3m()
|
||||
nobj->info = spec;
|
||||
//////creating CHeroInstance
|
||||
CHeroInstance * nhi = new CHeroInstance;
|
||||
spec->myInstance = nhi;
|
||||
nobj->isHero = true;
|
||||
nhi->exp = spec->experience;
|
||||
nhi->level = CGI->heroh->level(nhi->exp);
|
||||
nhi->primSkills.resize(PRIMARY_SKILLS);
|
||||
|
@ -6,7 +6,9 @@
|
||||
#include "CGeneralTextHandler.h"
|
||||
#include "CLodHandler.h"
|
||||
#include "CAbilityHandler.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
|
||||
CHeroHandler::~CHeroHandler()
|
||||
{
|
||||
@ -310,6 +312,59 @@ void CHeroHandler::loadHeroClasses()
|
||||
++i;
|
||||
}
|
||||
++i;
|
||||
std::stringstream nm;
|
||||
nm<<"AH";
|
||||
nm<<std::setw(2);
|
||||
nm<<std::setfill('0');
|
||||
nm<<heroClasses.size();
|
||||
nm<<"_.DEF";
|
||||
hc->moveAnim = CGI->spriteh->giveDef(nm.str());
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
for(int ff=0; ff<hc->moveAnim->ourImages.size(); ++ff)
|
||||
{
|
||||
CSDL_Ext::fullAlphaTransform(hc->moveAnim->ourImages[ff].bitmap);
|
||||
}
|
||||
hc->moveAnim->alphaTransformed = true;
|
||||
heroClasses.push_back(hc);
|
||||
}
|
||||
}
|
||||
@ -386,122 +441,21 @@ unsigned int CHeroInstance::getLowestCreatureSpeed()
|
||||
|
||||
void CHeroHandler::initTerrainCosts()
|
||||
{
|
||||
for(int i=0; i<heroClasses.size(); ++i)
|
||||
std::ifstream inp;
|
||||
inp.open("TERCOSTS.TXT", std::ios_base::in|std::ios_base::binary);
|
||||
int tynum;
|
||||
inp>>tynum;
|
||||
for(int i=0; i<2*tynum; i+=2)
|
||||
{
|
||||
switch (i)
|
||||
int catNum;
|
||||
inp>>catNum;
|
||||
for(int k=0; k<catNum; ++k)
|
||||
{
|
||||
case EHeroClasses::HERO_KNIGHT: case EHeroClasses::HERO_CLERIC:
|
||||
{
|
||||
heroClasses[i]->terrCosts.push_back(100); //dirt
|
||||
heroClasses[i]->terrCosts.push_back(150); //sand
|
||||
heroClasses[i]->terrCosts.push_back(100); //grass
|
||||
heroClasses[i]->terrCosts.push_back(150); //snow
|
||||
heroClasses[i]->terrCosts.push_back(175); //swamp
|
||||
heroClasses[i]->terrCosts.push_back(125); //rough
|
||||
heroClasses[i]->terrCosts.push_back(100); //subterrain
|
||||
heroClasses[i]->terrCosts.push_back(100); //lava
|
||||
heroClasses[i]->terrCosts.push_back(-1); //water
|
||||
heroClasses[i]->terrCosts.push_back(-1); //rock
|
||||
break;
|
||||
}
|
||||
case EHeroClasses::HERO_RANGER: case EHeroClasses::HERO_DRUID:
|
||||
{
|
||||
heroClasses[i]->terrCosts.push_back(100); //dirt
|
||||
heroClasses[i]->terrCosts.push_back(150); //sand
|
||||
heroClasses[i]->terrCosts.push_back(100); //grass
|
||||
heroClasses[i]->terrCosts.push_back(150); //snow
|
||||
heroClasses[i]->terrCosts.push_back(175); //swamp
|
||||
heroClasses[i]->terrCosts.push_back(125); //rough
|
||||
heroClasses[i]->terrCosts.push_back(100); //subterrain
|
||||
heroClasses[i]->terrCosts.push_back(100); //lava
|
||||
heroClasses[i]->terrCosts.push_back(-1); //water
|
||||
heroClasses[i]->terrCosts.push_back(-1); //rock
|
||||
break;
|
||||
}
|
||||
case EHeroClasses::HERO_ALCHEMIST: case EHeroClasses::HERO_WIZARD:
|
||||
{
|
||||
heroClasses[i]->terrCosts.push_back(100); //dirt
|
||||
heroClasses[i]->terrCosts.push_back(150); //sand
|
||||
heroClasses[i]->terrCosts.push_back(100); //grass
|
||||
heroClasses[i]->terrCosts.push_back(100); //snow
|
||||
heroClasses[i]->terrCosts.push_back(175); //swamp
|
||||
heroClasses[i]->terrCosts.push_back(125); //rough
|
||||
heroClasses[i]->terrCosts.push_back(100); //subterrain
|
||||
heroClasses[i]->terrCosts.push_back(100); //lava
|
||||
heroClasses[i]->terrCosts.push_back(-1); //water
|
||||
heroClasses[i]->terrCosts.push_back(-1); //rock
|
||||
break;
|
||||
}
|
||||
case EHeroClasses::HERO_DEMONIAC: case EHeroClasses::HERO_HERETIC:
|
||||
{
|
||||
heroClasses[i]->terrCosts.push_back(100); //dirt
|
||||
heroClasses[i]->terrCosts.push_back(150); //sand
|
||||
heroClasses[i]->terrCosts.push_back(100); //grass
|
||||
heroClasses[i]->terrCosts.push_back(150); //snow
|
||||
heroClasses[i]->terrCosts.push_back(175); //swamp
|
||||
heroClasses[i]->terrCosts.push_back(125); //rough
|
||||
heroClasses[i]->terrCosts.push_back(100); //subterrain
|
||||
heroClasses[i]->terrCosts.push_back(100); //lava
|
||||
heroClasses[i]->terrCosts.push_back(-1); //water
|
||||
heroClasses[i]->terrCosts.push_back(-1); //rock
|
||||
break;
|
||||
}
|
||||
case EHeroClasses::HERO_DEATHKNIGHT: case EHeroClasses::HERO_NECROMANCER:
|
||||
{
|
||||
heroClasses[i]->terrCosts.push_back(100); //dirt
|
||||
heroClasses[i]->terrCosts.push_back(150); //sand
|
||||
heroClasses[i]->terrCosts.push_back(100); //grass
|
||||
heroClasses[i]->terrCosts.push_back(150); //snow
|
||||
heroClasses[i]->terrCosts.push_back(175); //swamp
|
||||
heroClasses[i]->terrCosts.push_back(125); //rough
|
||||
heroClasses[i]->terrCosts.push_back(100); //subterrain
|
||||
heroClasses[i]->terrCosts.push_back(100); //lava
|
||||
heroClasses[i]->terrCosts.push_back(-1); //water
|
||||
heroClasses[i]->terrCosts.push_back(-1); //rock
|
||||
break;
|
||||
}
|
||||
case EHeroClasses::HERO_WARLOCK: case EHeroClasses::HERO_OVERLORD:
|
||||
{
|
||||
heroClasses[i]->terrCosts.push_back(100); //dirt
|
||||
heroClasses[i]->terrCosts.push_back(150); //sand
|
||||
heroClasses[i]->terrCosts.push_back(100); //grass
|
||||
heroClasses[i]->terrCosts.push_back(150); //snow
|
||||
heroClasses[i]->terrCosts.push_back(175); //swamp
|
||||
heroClasses[i]->terrCosts.push_back(125); //rough
|
||||
heroClasses[i]->terrCosts.push_back(100); //subterrain
|
||||
heroClasses[i]->terrCosts.push_back(100); //lava
|
||||
heroClasses[i]->terrCosts.push_back(-1); //water
|
||||
heroClasses[i]->terrCosts.push_back(-1); //rock
|
||||
break;
|
||||
}
|
||||
case EHeroClasses::HERO_BARBARIAN: case EHeroClasses::HERO_BATTLEMAGE:
|
||||
{
|
||||
heroClasses[i]->terrCosts.push_back(100); //dirt
|
||||
heroClasses[i]->terrCosts.push_back(150); //sand
|
||||
heroClasses[i]->terrCosts.push_back(100); //grass
|
||||
heroClasses[i]->terrCosts.push_back(150); //snow
|
||||
heroClasses[i]->terrCosts.push_back(175); //swamp
|
||||
heroClasses[i]->terrCosts.push_back(100); //rough
|
||||
heroClasses[i]->terrCosts.push_back(100); //subterrain
|
||||
heroClasses[i]->terrCosts.push_back(100); //lava
|
||||
heroClasses[i]->terrCosts.push_back(-1); //water
|
||||
heroClasses[i]->terrCosts.push_back(-1); //rock
|
||||
break;
|
||||
}
|
||||
case EHeroClasses::HERO_BEASTMASTER: case EHeroClasses::HERO_WITCH:
|
||||
{
|
||||
heroClasses[i]->terrCosts.push_back(100); //dirt
|
||||
heroClasses[i]->terrCosts.push_back(150); //sand
|
||||
heroClasses[i]->terrCosts.push_back(100); //grass
|
||||
heroClasses[i]->terrCosts.push_back(150); //snow
|
||||
heroClasses[i]->terrCosts.push_back(100); //swamp
|
||||
heroClasses[i]->terrCosts.push_back(125); //rough
|
||||
heroClasses[i]->terrCosts.push_back(100); //subterrain
|
||||
heroClasses[i]->terrCosts.push_back(100); //lava
|
||||
heroClasses[i]->terrCosts.push_back(-1); //water
|
||||
heroClasses[i]->terrCosts.push_back(-1); //rock
|
||||
break;
|
||||
}
|
||||
int curCost;
|
||||
inp>>curCost;
|
||||
heroClasses[i]->terrCosts.push_back(curCost);
|
||||
heroClasses[i+1]->terrCosts.push_back(curCost);
|
||||
}
|
||||
}
|
||||
inp.close();
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
class CHeroClass;
|
||||
class CObjectInstance;
|
||||
|
||||
class CDefHandler;
|
||||
|
||||
class CHero
|
||||
{
|
||||
@ -40,6 +40,7 @@ public:
|
||||
std::vector<int> proSec; //probabilities of gaining secondary skills (out of 112), in id order
|
||||
int selectionProbability[9]; //probability of selection in towns
|
||||
std::vector<int> terrCosts; //default costs of going through terrains: dirt, sand, grass, snow, swamp, rough, subterrain, lava, water, rock; -1 means terrain is imapassable
|
||||
CDefHandler * moveAnim; //added group 10: up - left, 11 - left and 12 - left down
|
||||
};
|
||||
|
||||
class CHeroInstance
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
std::vector<CAbility *> abilities; //hero's abilities
|
||||
std::vector<int> abilityLevels; //hero ability levels
|
||||
bool defaultMainStats; //if true attack, defence, power and knowledge are typical
|
||||
CHeroInstance * myInstance; //pointer to appropriate hero instance
|
||||
};
|
||||
|
||||
class CCreatureObjInfo : public CSpecObjInfo
|
||||
@ -295,6 +296,8 @@ public:
|
||||
int id; //number of object in CObjectHandler's vector
|
||||
int3 pos; // position
|
||||
CSpecObjInfo * info; //pointer to something with additional information
|
||||
bool isHero; //true if this is a hero
|
||||
unsigned char moveDir; //direction of hero movement (0 - default; 1 - lt; 2 - t; 3 - tr; 4 - r; 5 - br; 6 - b; 7 - bl; 8 - l)
|
||||
bool operator<(const CObjectInstance & cmp) const; //screen printing priority comparing
|
||||
};
|
||||
|
||||
|
136
mapHandler.cpp
136
mapHandler.cpp
@ -496,13 +496,131 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
sr.y = (by)*32;
|
||||
|
||||
SDL_Rect pp = ttiles[x+bx][y+by][level].objects[h].second;
|
||||
int imgVal = CGI->ac->map.defy[
|
||||
ttiles[x+bx][y+by][level].objects[h].first->defNumber]
|
||||
.handler->ourImages.size();
|
||||
SDL_Surface * tb = CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages[anim%imgVal].bitmap;
|
||||
SDL_BlitSurface(
|
||||
CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages[anim%imgVal].bitmap,
|
||||
&pp,su,&sr);
|
||||
if(ttiles[x+bx][y+by][level].objects[h].first->isHero && ttiles[x+bx][y+by][level].objects[h].first->moveDir)
|
||||
{
|
||||
int imgVal = 8;
|
||||
SDL_Surface * tb;
|
||||
switch(ttiles[x+bx][y+by][level].objects[h].first->moveDir)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)ttiles[x+bx][y+by][level].objects[h].first->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
||||
for(int gg=0; gg<iv.size(); ++gg)
|
||||
{
|
||||
if(iv[gg].groupNumber==10)
|
||||
{
|
||||
tb = iv[gg+anim%imgVal].bitmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)ttiles[x+bx][y+by][level].objects[h].first->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
||||
for(int gg=0; gg<iv.size(); ++gg)
|
||||
{
|
||||
if(iv[gg].groupNumber==5)
|
||||
{
|
||||
tb = iv[gg+anim%imgVal].bitmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)ttiles[x+bx][y+by][level].objects[h].first->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
||||
for(int gg=0; gg<iv.size(); ++gg)
|
||||
{
|
||||
if(iv[gg].groupNumber==6)
|
||||
{
|
||||
tb = iv[gg+anim%imgVal].bitmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)ttiles[x+bx][y+by][level].objects[h].first->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
||||
for(int gg=0; gg<iv.size(); ++gg)
|
||||
{
|
||||
if(iv[gg].groupNumber==7)
|
||||
{
|
||||
tb = iv[gg+anim%imgVal].bitmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)ttiles[x+bx][y+by][level].objects[h].first->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
||||
for(int gg=0; gg<iv.size(); ++gg)
|
||||
{
|
||||
if(iv[gg].groupNumber==8)
|
||||
{
|
||||
tb = iv[gg+anim%imgVal].bitmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)ttiles[x+bx][y+by][level].objects[h].first->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
||||
for(int gg=0; gg<iv.size(); ++gg)
|
||||
{
|
||||
if(iv[gg].groupNumber==9)
|
||||
{
|
||||
tb = iv[gg+anim%imgVal].bitmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)ttiles[x+bx][y+by][level].objects[h].first->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
||||
for(int gg=0; gg<iv.size(); ++gg)
|
||||
{
|
||||
if(iv[gg].groupNumber==12)
|
||||
{
|
||||
tb = iv[gg+anim%imgVal].bitmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)ttiles[x+bx][y+by][level].objects[h].first->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
||||
for(int gg=0; gg<iv.size(); ++gg)
|
||||
{
|
||||
if(iv[gg].groupNumber==11)
|
||||
{
|
||||
tb = iv[gg+anim%imgVal].bitmap;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDL_BlitSurface(tb,&pp,su,&sr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int imgVal = CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages.size();
|
||||
SDL_BlitSurface(CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages[anim%imgVal].bitmap,&pp,su,&sr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -823,8 +941,8 @@ int CMapHandler::getCost(int3 &a, int3 &b, CHeroInstance *hero)
|
||||
{
|
||||
int ret = hero->type->heroClass->terrCosts[CGI->mh->ttiles[a.x][a.y][a.z].malle];
|
||||
if(!(a.x==b.x || a.y==b.y))
|
||||
ret*=1.4142;
|
||||
ret*=1.41421;
|
||||
|
||||
//TODO: use hero's pathfinding skill during calculating cost
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user