1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

* probably fixed #8 from 0.7b forum

* fixed blockmap for obstacle 10
* better handling of creature animation framesInGroup
* vcmiistari no longer gives creature spell-like abilities
* probably correct calculation of occupiable hexes on battlefield
This commit is contained in:
mateuszb 2009-02-20 13:06:20 +00:00
parent fd66234a39
commit 2e47b5ce10
9 changed files with 855 additions and 877 deletions

View File

@ -866,6 +866,18 @@ bool CBattleInterface::reverseCreature(int number, int hex, bool wideTrick)
return true;
}
void CBattleInterface::handleStartMoving(int number)
{
for(int i=0; i<creAnims[number]->framesInGroup(20)*getAnimSpeedMultiplier()-1; ++i)
{
show();
CSDL_Ext::update();
SDL_framerateDelay(LOCPLINT->mainFPSmng);
if((animCount+1)%(4/animSpeed)==0)
creAnims[number]->incrementFrame();
}
}
void CBattleInterface::bOptionsf()
{
CGI->curh->changeGraphic(0,0);
@ -967,7 +979,7 @@ void CBattleInterface::stackActivated(int number)
void CBattleInterface::stackMoved(int number, int destHex, bool endMoving)
{
bool startMoving = creAnims[number]->type==20;
bool startMoving = creAnims[number]->getType()==20;
//a few useful variables
int curStackPos = LOCPLINT->cb->battleGetPos(number);
int steps = creAnims[number]->framesInGroup(0)*getAnimSpeedMultiplier()-1;
@ -977,14 +989,7 @@ void CBattleInterface::stackMoved(int number, int destHex, bool endMoving)
if(startMoving) //animation of starting move; some units don't have this animation (ie. halberdier)
{
CGI->curh->hide();
for(int i=0; i<creAnims[number]->framesInGroup(20)*getAnimSpeedMultiplier()-1; ++i)
{
show();
CSDL_Ext::update();
SDL_framerateDelay(LOCPLINT->mainFPSmng);
if((animCount+1)%(4/animSpeed)==0)
creAnims[number]->incrementFrame();
}
handleStartMoving(number);
}
int mutPos = BattleInfo::mutualPosition(curStackPos, destHex);
@ -1200,6 +1205,11 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
void CBattleInterface::stackAttacking(int ID, int dest)
{
if(attackingInfo == NULL && creAnims[ID]->getType() == 20)
{
handleStartMoving(ID);
creAnims[ID]->setType(2);
}
while(attackingInfo != NULL || creAnims[ID]->getType()!=2)
{
show();

View File

@ -228,6 +228,7 @@ public:
void keyPressed(const SDL_KeyboardEvent & key);
void mouseMoved(const SDL_MouseMotionEvent &sEvent);
bool reverseCreature(int number, int hex, bool wideTrick = false); //reverses animation of given creature playing animation of reversing
void handleStartMoving(int number); //animation of starting move; some units don't have this animation (ie. halberdier)
struct SStackAttackedInfo
{

View File

@ -271,7 +271,7 @@ std::vector<int> BattleInfo::getAccessibility(int stackID, bool addOccupiable)
std::vector<int> rem;
for(int b=0; b<BFIELD_SIZE; ++b)
{
if( ac[b] && !ac[b-1] && !ac[b+1] && b%BFIELD_WIDTH != 0 && b%BFIELD_WIDTH != (BFIELD_WIDTH-1))
if( ac[b] && (!ac[b-1] || dist[b-1] > s->speed() ) && ( !ac[b+1] || dist[b+1] > s->speed() ) && b%BFIELD_WIDTH != 0 && b%BFIELD_WIDTH != (BFIELD_WIDTH-1))
{
rem.push_back(b);
}

View File

@ -2104,7 +2104,7 @@ void CPlayerInterface::actionStarted(const BattleAction* action)
}
if(!stack)
{
tlog1<<"Something wrong with stackNumber in actionStarted"<<std::endl;
tlog1<<"Something wrong with stackNumber in actionStarted. Stack number: "<<action->stackNumber<<std::endl;
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -8,25 +8,10 @@ int CCreatureAnimation::getType() const
void CCreatureAnimation::setType(int type)
{
this->type = type;
curFrame = 0;
internalFrame = 0;
if(type!=-1)
{
if(SEntries[curFrame].group!=type) //rewind
{
int j=-1; //first frame in displayed group
for(size_t g=0; g<SEntries.size(); ++g)
{
if(SEntries[g].group==type && j==-1)
{
j = g;
break;
}
}
if(curFrame != -1)
{
curFrame = j;
}
}
curFrame = frameGroups[type][0];
}
else
{
@ -37,7 +22,7 @@ void CCreatureAnimation::setType(int type)
}
}
CCreatureAnimation::CCreatureAnimation(std::string name) : RLEntries(NULL)
CCreatureAnimation::CCreatureAnimation(std::string name) : RLEntries(NULL), internalFrame(0)
{
FDef = CDefHandler::Spriteh->giveFile(name); //load main file
@ -64,35 +49,28 @@ CCreatureAnimation::CCreatureAnimation(std::string name) : RLEntries(NULL)
totalEntries=0;
for (int z=0; z<totalBlocks; z++)
{
std::vector<int> frameIDs;
int group = readNormalNr(i,4); i+=4; //block ID
totalInBlock = readNormalNr(i,4); i+=4;
for (j=SEntries.size(); j<totalEntries+totalInBlock; j++)
{
SEntries.push_back(SEntry());
SEntries[j].group = group;
frameIDs.push_back(j);
}
int unknown2 = readNormalNr(i,4); i+=4; //TODO use me
int unknown3 = readNormalNr(i,4); i+=4; //TODO use me
for (j=0; j<totalInBlock; j++)
{
for (int k=0;k<13;k++) Buffer[k]=FDef[i+k];
i+=13;
SEntries[totalEntries+j].name=Buffer;
}
i+=13*totalInBlock; //ommiting names
for (j=0; j<totalInBlock; j++)
{
SEntries[totalEntries+j].offset = readNormalNr(i,4);
int unknown4 = readNormalNr(i,4); i+=4; //TODO use me
SEntries[totalEntries+j].offset = readNormalNr(i,4); i+=4;
}
//totalEntries+=totalInBlock;
for(int hh=0; hh<totalInBlock; ++hh)
{
++totalEntries;
}
}
for(j=0; j<SEntries.size(); ++j)
{
SEntries[j].name = SEntries[j].name.substr(0, SEntries[j].name.find('.')+4);
frameGroups[group] = frameIDs;
}
//init vars
@ -130,22 +108,12 @@ int CCreatureAnimation::nextFrameMiddle(SDL_Surface *dest, int x, int y, bool at
}
void CCreatureAnimation::incrementFrame()
{
curFrame++;
curFrame = frameGroups[type][(internalFrame++)%frameGroups[type].size()];
if(type!=-1)
{
if(curFrame==SEntries.size() || SEntries[curFrame].group!=type) //rewind
if(internalFrame == frameGroups[type].size()) //rewind
{
int j=-1; //first frame in displayed group
for(size_t g=0; g<SEntries.size(); ++g)
{
if(SEntries[g].group==type)
{
j = g;
break;
}
}
if(curFrame!=-1)
curFrame = j;
curFrame = frameGroups[type][0];
}
}
else
@ -264,13 +232,9 @@ int CCreatureAnimation::nextFrame(SDL_Surface *dest, int x, int y, bool attacker
int CCreatureAnimation::framesInGroup(int group) const
{
int ret = 0; //number of frames in given group
for(size_t g=0; g<SEntries.size(); ++g)
{
if(SEntries[g].group == group)
++ret;
}
return ret;
if(frameGroups.find(group) == frameGroups.end())
return 0;
return frameGroups.find(group)->second.size();
}
CCreatureAnimation::~CCreatureAnimation()
@ -286,8 +250,8 @@ inline void CCreatureAnimation::putPixel(
const BMPPalette & color,
const unsigned char & palc,
const bool & yellowBorder
) const {
) const
{
if(palc!=0)
{
Uint8 * p = (Uint8*)dest->pixels + ftcp*3;

View File

@ -15,7 +15,6 @@ private:
int * RLEntries;
struct SEntry
{
std::string name;
int offset;
int group;
} ;
@ -33,8 +32,9 @@ private:
////////////
unsigned char * FDef; //animation raw data
int curFrame; //number of currently displayed frame
int curFrame, internalFrame; //number of currently displayed frame
unsigned int frames; //number of frames
std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
public:
int type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
int fullWidth, fullHeight; //read-only, please!

View File

@ -26,7 +26,7 @@ BATTLE OBSTACLES
7 OBDRK02.DEF LXX 1111110000000010000000100
8 OBDRK03.DEF X 1111110000000010000000100
9 OBDRK04.DEF LXX 1111110000000010000000100
10 OBDSH01.DEF XX 1111110000000010000000100
10 OBDSH01.DEF LXX 1111110000000010000000100
93 OBDSM01.DEF NXXLNXXLNNXX 1100000000000000000000000
17 OBDSM02.DEF XXLNX 1111100000000010000000100
18 OBDSS17.DEF XXLNXXX 1111100000000010000000100

View File

@ -1005,7 +1005,10 @@ upgend:
ChangeSpells cs;
cs.learn = 1;
for(int i=0;i<VLC->spellh->spells.size();i++)
cs.spells.insert(i);
{
if(!VLC->spellh->spells[i].creatureAbility)
cs.spells.insert(i);
}
sm.hid = cs.hid = gs->players[*players.begin()].currentSelection;
sm.val = 999;
if(gs->getHero(cs.hid))