1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

* fixed bug with disappearing head of a hero in adventure map

* some objects are no longer accessible from the top
* minor fixes
This commit is contained in:
mateuszb 2008-09-18 14:18:08 +00:00
parent 70673674dc
commit 5ee37eeb3d
7 changed files with 108 additions and 8 deletions

View File

@ -6,6 +6,7 @@
#include "mapHandler.h"
#include "CGameState.h"
#include "hch/CObjectHandler.h"
#include "hch/CDefObjInfoHandler.h"
using namespace std;
@ -168,9 +169,85 @@ void CPathfinder::AddNeighbors(vector<Coordinate>* branch)
if(c.g != -1 && c.h != -1)
{
vector<Coordinate> toAdd = *branch;
toAdd.push_back(c);
Open.push(toAdd);
bool pass = true; //checking for allowed visiting direction
for(int b=0; b<CGI->mh->ttiles[i][j][node.z].tileInfo->visitableObjects.size(); ++b) //checking destination tile
{
CGDefInfo * di = CGI->mh->ttiles[i][j][node.z].tileInfo->visitableObjects[b]->defInfo;
if( (i == node.x-1 && j == node.y-1) && !(di->visitDir & (1<<4)) )
{
pass = false; break;
}
if( (i == node.x && j == node.y-1) && !(di->visitDir & (1<<5)) )
{
pass = false; break;
}
if( (i == node.x+1 && j == node.y-1) && !(di->visitDir & (1<<6)) )
{
pass = false; break;
}
if( (i == node.x+1 && j == node.y) && !(di->visitDir & (1<<7)) )
{
pass = false; break;
}
if( (i == node.x+1 && j == node.y+1) && !(di->visitDir & (1<<0)) )
{
pass = false; break;
}
if( (i == node.x && j == node.y+1) && !(di->visitDir & (1<<1)) )
{
pass = false; break;
}
if( (i == node.x-1 && j == node.y+1) && !(di->visitDir & (1<<2)) )
{
pass = false; break;
}
if( (i == node.x-1 && j == node.y) && !(di->visitDir & (1<<3)) )
{
pass = false; break;
}
}
for(int b=0; b<CGI->mh->ttiles[node.x][node.y][node.z].tileInfo->visitableObjects.size(); ++b) //checking source tile
{
CGDefInfo * di = CGI->mh->ttiles[node.x][node.y][node.z].tileInfo->visitableObjects[b]->defInfo;
if( (i == node.x-1 && j == node.y-1) && !(di->visitDir & (1<<0)) )
{
pass = false; break;
}
if( (i == node.x && j == node.y-1) && !(di->visitDir & (1<<1)) )
{
pass = false; break;
}
if( (i == node.x+1 && j == node.y-1) && !(di->visitDir & (1<<2)) )
{
pass = false; break;
}
if( (i == node.x+1 && j == node.y) && !(di->visitDir & (1<<3)) )
{
pass = false; break;
}
if( (i == node.x+1 && j == node.y+1) && !(di->visitDir & (1<<4)) )
{
pass = false; break;
}
if( (i == node.x && j == node.y+1) && !(di->visitDir & (1<<5)) )
{
pass = false; break;
}
if( (i == node.x-1 && j == node.y+1) && !(di->visitDir & (1<<6)) )
{
pass = false; break;
}
if( (i == node.x-1 && j == node.y) && !(di->visitDir & (1<<7)) )
{
pass = false; break;
}
}
if(pass)
{
vector<Coordinate> toAdd = *branch;
toAdd.push_back(c);
Open.push(toAdd);
}
}
//delete c;
}

View File

@ -1519,6 +1519,16 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
delObjRect(hp.x, hp.y-1, hp.z, ho->id);
delObjRect(hp.x, hp.y, hp.z, ho->id);
}
//restoring good order of objects
std::stable_sort(CGI->mh->ttiles[details.dst.x-2][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-2][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin);
std::stable_sort(CGI->mh->ttiles[details.dst.x-1][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-1][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin);
std::stable_sort(CGI->mh->ttiles[details.dst.x][details.dst.y-1][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x][details.dst.y-1][details.dst.z].objects.end(), ocmptwo_cgin);
std::stable_sort(CGI->mh->ttiles[details.dst.x-2][details.dst.y][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-2][details.dst.y][details.dst.z].objects.end(), ocmptwo_cgin);
std::stable_sort(CGI->mh->ttiles[details.dst.x-1][details.dst.y][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x-1][details.dst.y][details.dst.z].objects.end(), ocmptwo_cgin);
std::stable_sort(CGI->mh->ttiles[details.dst.x][details.dst.y][details.dst.z].objects.begin(), CGI->mh->ttiles[details.dst.x][details.dst.y][details.dst.z].objects.end(), ocmptwo_cgin);
ho->isStanding = true;
//move finished
adventureInt->minimap.draw();

View File

@ -12,9 +12,9 @@
49 151
49 100 151
15 83 117 185
17 49 100 151 185
17 49 83 117 151 185
17 49 83 100 117 151 185
15 49 100 151 185
15 49 83 117 151 185
15 49 83 100 117 151 185
//tight_formation
//atacker
86

View File

@ -5,6 +5,7 @@
#include "CLodHandler.h"
#include <sstream>
#include "../lib/VCMI_Lib.h"
#include <set>
extern CLodHandler * bitmaph;
bool CGDefInfo::isVisitable()
{
@ -26,6 +27,7 @@ void CDefObjInfoHandler::load()
std::istringstream inp(bitmaph->getTextFile("ZOBJCTS.TXT"));
int objNumber;
inp>>objNumber;
std::set<int> ids;
for(int hh=0; hh<objNumber; ++hh)
{
CGDefInfo* nobj = new CGDefInfo();
@ -65,6 +67,13 @@ void CDefObjInfoHandler::load()
inp>>nobj->id;
inp>>nobj->subid;
inp>>nobj->type;
if(nobj->type == 2 || nobj->type == 3 || nobj->type == 4 || nobj->type == 5 || nobj->id == 111) //creature, hero, artifact, resource or whripool
{
nobj->visitDir = 0xff;
ids.insert(nobj->id);
}
else
nobj->visitDir = (8|16|32|64|128); //disabled visiting from the top
inp>>nobj->printPriority;
gobjs[nobj->id][nobj->subid] = nobj;
if(nobj->id==98)

View File

@ -91,7 +91,7 @@ public:
int portrait; //may be custom
int mana; // remaining spell points
std::vector<int> primSkills; //0-attack, 1-defence, 2-spell power, 3-knowledge
std::vector<std::pair<int,int> > secSkills; //first - ID of skill, second - level of skill (0 - basic, 1 - adv., 2 - expert)
std::vector<std::pair<int,int> > secSkills; //first - ID of skill, second - level of skill (1 - basic, 2 - adv., 3 - expert)
int movement; //remaining movement points
int identifier; //from the map file
bool sex;

View File

@ -1725,6 +1725,10 @@ void Mapa::readDefInfo( unsigned char * bufor, int &i)
vinya->visitMap[zi] = reverse(bytes[6+zi]);
}
i+=16;
if(vinya->id!=34)
vinya->visitDir = VLC->dobjinfo->gobjs[vinya->id][vinya->subid]->visitDir;
else
vinya->visitDir = 0xff;
defy.push_back(vinya); // add this def to the vector
}
}

View File

@ -211,7 +211,7 @@ void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs)
for(int i=0;i<SKILL_QUANTITY;i++) none.insert(i);
for(unsigned i=0;i<hero->secSkills.size();i++)
{
if(hero->secSkills[i].second < 2)
if(hero->secSkills[i].second < 3)
basicAndAdv.insert(hero->secSkills[i].first);
else
expert.insert(hero->secSkills[i].first);