1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

* given hero is placed in the town entrance

Wspólne zmiany
* some objects such as river delta won't be blitted "on" hero
* tiles under FoW are inaccessible
* giving random hero on RoE maps
* improved protection against hero duplication
* fixed starting values of primary abilities of random heroes on RoE/AB maps
This commit is contained in:
mateuszb 2008-02-23 19:20:41 +00:00
parent dbf3b8d08e
commit 0c2cf02ca6
9 changed files with 54 additions and 37 deletions

View File

@ -618,8 +618,9 @@ void CScriptCallback::stopHeroVisitCastle(CGObjectInstance * ob, int heroID)
CGTownInstance * n;
if(n = dynamic_cast<CGTownInstance*>(ob))
{
if(n->visitingHero->type->ID == heroID)
if(n->visitingHero && n->visitingHero->type->ID == heroID)
n->visitingHero = NULL;
return;
}
else
return;

View File

@ -55,6 +55,7 @@ private:
}
public:
friend CCallback;
friend CPathfinder;;
friend CLuaCallback;
friend int _tmain(int argc, _TCHAR* argv[]);
friend void initGameState(CGameInfo * cgi);

View File

@ -62,7 +62,7 @@
CGameInfo* CGI;
#endif
#define CHUNK 16384
const char * NAME = "VCMI 0.53c \"Tirion\" Techdemo";
const char * NAME = "VCMI 0.54 \"Tirion\" Techdemo";
SDL_Color playerColorPalette[256]; //palette to make interface colors good

View File

@ -4,6 +4,7 @@
#include "CGameInfo.h"
#include "hch\CAmbarCendamo.h"
#include "mapHandler.h"
#include "CGameState.h"
using namespace boost::logic;
int3 CPath::startPos()
{
@ -64,6 +65,8 @@ CPath * CPathfinder::getPath(int3 src, int3 dest, const CGHeroInstance * hero, u
graph[i][j].accesible = false;
else if ((!blockLandSea) && (CGI->mh->ttiles[i][j][src.z].terType!=EterrainType::water))
graph[i][j].accesible = false;
if(graph[i][j].accesible)
graph[i][j].accesible = CGI->state->players[hero->tempOwner].fogOfWarMap[i][j][src.z];
}
}

View File

@ -843,33 +843,33 @@ void CPlayerInterface::yourTurn()
for(;makingTurn;) // main loop
{
//updating water tiles
int wnumber = -1;
for(int s=0; s<CGI->mh->reader->defs.size(); ++s)
{
if(CGI->mh->reader->defs[s]->defName==std::string("WATRTL.DEF"))
{
wnumber = s;
break;
}
}
if(wnumber>=0)
{
for(int g=0; g<CGI->mh->reader->defs[wnumber]->ourImages.size(); ++g)
{
SDL_Color tab[32];
for(int i=0; i<32; ++i)
{
tab[i] = CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[224 + (i+1)%32];
}
//SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t1.bmp");
for(int i=0; i<32; ++i)
{
CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[224 + i] = tab[i];
}
//SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t2.bmp");
CSDL_Ext::update(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap);
}
}
//int wnumber = -1;
//for(int s=0; s<CGI->mh->reader->defs.size(); ++s)
//{
// if(CGI->mh->reader->defs[s]->defName==std::string("WATRTL.DEF"))
// {
// wnumber = s;
// break;
// }
//}
//if(wnumber>=0)
//{
// for(int g=0; g<CGI->mh->reader->defs[wnumber]->ourImages.size(); ++g)
// {
// SDL_Color tab[32];
// for(int i=0; i<32; ++i)
// {
// tab[i] = CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[160 + (i+1)%32];
// }
// //SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t1.bmp");
// for(int i=0; i<32; ++i)
// {
// CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[160 + i] = tab[i];
// }
// //SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t2.bmp");
// CSDL_Ext::update(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap);
// }
//}
//water tiles updated
CGI->screenh->updateScreen();
int tv = th.getDif();

View File

@ -194,7 +194,7 @@ void CAmbarCendamo::deh3m()
map.players[pom].AITactic = bufor[i++];
if(map.version == Eformat::SoD || map.version == Eformat::WoG)
i++;
map.players[pom].p7= bufor[i++];
map.players[pom].allowedFactions = 0;
map.players[pom].allowedFactions += bufor[i++];
@ -1012,7 +1012,13 @@ void CAmbarCendamo::deh3m()
spec->power = -1;
spec->knowledge = -1;
}
}
else
{
spec->attack = -1;
spec->defence = -1;
spec->power = -1;
spec->knowledge = -1;
}
i+=16;
nobj->info = spec;

View File

@ -127,6 +127,10 @@ bool CGObjectInstance::operator<(const CGObjectInstance & cmp) const //screen p
return true;
if(this->pos.y>cmp.pos.y)
return false;
if(cmp.ID==34 && ID!=34)
return true;
if(cmp.ID!=34 && ID==34)
return false;
if(!defInfo->isVisitable() && cmp.defInfo->isVisitable())
return true;
if(!cmp.defInfo->isVisitable() && defInfo->isVisitable())

2
map.h
View File

@ -70,7 +70,7 @@ struct SheroName //name of starting hero
};
struct PlayerInfo
{
int p8, p9;
int p7, p8, p9;
bool canHumanPlay;
bool canComputerPlay;
unsigned int AITactic; //(00 - random, 01 - warrior, 02 - builder, 03 - explorer)

View File

@ -786,21 +786,21 @@ void CMapHandler::init()
borderAndTerrainBitmapInit();
std::cout<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDif()<<std::endl;
//giving starting hero
for(int i=0;i<PLAYER_LIMIT;i++)
{
if(reader->map.players[i].generateHeroAtMainTown && reader->map.players[i].hasMainTown)
if((reader->map.players[i].generateHeroAtMainTown && reader->map.players[i].hasMainTown) || (reader->map.players[i].hasMainTown && reader->map.version==RoE))
{
int3 hpos = reader->map.players[i].posOfMainTown;
hpos.x+=1; hpos.y+=1;
hpos.x+=1;// hpos.y+=1;
int j;
for(j=0;j<CGI->scenarioOps.playerInfos.size();j++)
if(CGI->scenarioOps.playerInfos[j].color==i)
break;
if(j==CGI->scenarioOps.playerInfos.size())
continue;
int h = CGI->scenarioOps.playerInfos[j].hero;
if(h<0)
int h; //= CGI->scenarioOps.playerInfos[j].hero;
//if(h<0)
h=pickHero(i);
CGHeroInstance * nnn = (CGHeroInstance*)createObject(34,h,hpos,i);
nnn->defInfo->handler = CGI->heroh->flags1[0];
@ -808,6 +808,7 @@ void CMapHandler::init()
CGI->objh->objInstances.push_back(nnn);
}
}
std::cout<<"\tGiving starting heroes: "<<th.getDif()<<std::endl;
initObjectRects();
std::cout<<"\tMaking object rects: "<<th.getDif()<<std::endl;
@ -1371,6 +1372,7 @@ CGObjectInstance * CMapHandler::createObject(int id, int subid, int3 pos, int ow
nobj->defInfo = new CGDefInfo();
nobj->defInfo->id = 34;
nobj->defInfo->subid = subid;
nobj->defInfo->printPriority = 0;
nobj->type = CGI->heroh->heroes[subid];
for(int i=0;i<6;i++)
{