mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-27 21:49:10 +02:00
* [feature] giving starting hero
* [feature] VCMI will try to use files from /Data folder instead of those from h3bitmap.lod * [feature] picked artifacts are added to hero's backpack
This commit is contained in:
parent
96734fafa1
commit
a89b4e2c59
@ -281,6 +281,20 @@ void CTerrainRect::clickLeft(tribool down)
|
|||||||
{ //move
|
{ //move
|
||||||
CPath sended(*currentPath); //temporary path - engine will operate on it
|
CPath sended(*currentPath); //temporary path - engine will operate on it
|
||||||
mres = LOCPLINT->cb->moveHero( ((const CGHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID,&sended,1,0);
|
mres = LOCPLINT->cb->moveHero( ((const CGHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID,&sended,1,0);
|
||||||
|
if(!mres)
|
||||||
|
{
|
||||||
|
delete currentPath;
|
||||||
|
currentPath = NULL;
|
||||||
|
int i=0;
|
||||||
|
for(;i<LOCPLINT->adventureInt->heroList.items.size();i++)
|
||||||
|
{
|
||||||
|
if(LOCPLINT->adventureInt->heroList.items[i].first->subID == ((const CGHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID)
|
||||||
|
{
|
||||||
|
LOCPLINT->adventureInt->heroList.items[i].second = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -609,6 +609,32 @@ void CScriptCallback::stopHeroVisitCastle(CGObjectInstance * ob, int heroID)
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
void CScriptCallback::giveHeroArtifact(int artid, int hid, int position) //pos==-1 - first free slot in backpack
|
||||||
|
{
|
||||||
|
CGHeroInstance* h = gs->getHero(hid,0);
|
||||||
|
if(position<0)
|
||||||
|
{
|
||||||
|
for(int i=0;i<h->artifacts.size();i++)
|
||||||
|
{
|
||||||
|
if(!h->artifacts[i])
|
||||||
|
{
|
||||||
|
h->artifacts[i] = &CGI->arth->artifacts[artid];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
h->artifacts.push_back(&CGI->arth->artifacts[artid]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(h->artifWorn[position]) //slot is occupied
|
||||||
|
{
|
||||||
|
giveHeroArtifact(h->artifWorn[position]->id,hid,-1);
|
||||||
|
}
|
||||||
|
h->artifWorn[position] = &CGI->arth->artifacts[artid];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CLuaCallback::registerFuncs(lua_State * L)
|
void CLuaCallback::registerFuncs(lua_State * L)
|
||||||
{
|
{
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
@ -111,7 +111,7 @@ public:
|
|||||||
void showCompInfo(int player, SComponent * comp);
|
void showCompInfo(int player, SComponent * comp);
|
||||||
void heroVisitCastle(CGObjectInstance * ob, int heroID);
|
void heroVisitCastle(CGObjectInstance * ob, int heroID);
|
||||||
void stopHeroVisitCastle(CGObjectInstance * ob, int heroID);
|
void stopHeroVisitCastle(CGObjectInstance * ob, int heroID);
|
||||||
|
void giveHeroArtifact(int artid, int hid, int position); //pos==-1 - first free slot in backpack
|
||||||
|
|
||||||
//friends
|
//friends
|
||||||
friend void initGameState(CGameInfo * cgi);
|
friend void initGameState(CGameInfo * cgi);
|
||||||
|
5
CLua.cpp
5
CLua.cpp
@ -478,6 +478,11 @@ void CPickable::onHeroVisit(CGObjectInstance *os, int heroID)
|
|||||||
{
|
{
|
||||||
switch(os->ID)
|
switch(os->ID)
|
||||||
{
|
{
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
cb->giveHeroArtifact(os->subID,heroID,-1); //TODO: na pozycje
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 79:
|
case 79:
|
||||||
{
|
{
|
||||||
//TODO: handle guards (when battles are finished)
|
//TODO: handle guards (when battles are finished)
|
||||||
|
13
CMT.cpp
13
CMT.cpp
@ -120,7 +120,7 @@ void initGameState(CGameInfo * cgi)
|
|||||||
//*vhi=*(cgi->heroh->heroInstances[i]);
|
//*vhi=*(cgi->heroh->heroInstances[i]);
|
||||||
CGHeroInstance * vhi = (cgi->heroh->heroInstances[i]);
|
CGHeroInstance * vhi = (cgi->heroh->heroInstances[i]);
|
||||||
vhi->subID = vhi->type->ID;
|
vhi->subID = vhi->type->ID;
|
||||||
if (!vhi->level)
|
if (vhi->level<1)
|
||||||
{
|
{
|
||||||
vhi->exp=40+rand()%50;
|
vhi->exp=40+rand()%50;
|
||||||
vhi->level = 1;
|
vhi->level = 1;
|
||||||
@ -760,6 +760,17 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
initTable[ss] = mapstr[ss];
|
initTable[ss] = mapstr[ss];
|
||||||
}
|
}
|
||||||
std::cout<<"done."<<std::endl;
|
std::cout<<"done."<<std::endl;
|
||||||
|
|
||||||
|
for(int pru=0;pru<cgi->scenarioOps.playerInfos.size();pru++)
|
||||||
|
{
|
||||||
|
if(cgi->scenarioOps.playerInfos[pru].castle<0)
|
||||||
|
cgi->scenarioOps.playerInfos[pru].castle = rand()%F_NUMBER;
|
||||||
|
if(cgi->scenarioOps.playerInfos[pru].hero<0)
|
||||||
|
cgi->scenarioOps.playerInfos[pru].hero= cgi->scenarioOps.playerInfos[pru].castle*HEROES_PER_TYPE*2+(rand()%(HEROES_PER_TYPE*2));//cgi->scenarioOps.playerInfos[pru].hero = cgi->
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define CHOOSE
|
#define CHOOSE
|
||||||
#ifdef CHOOSE
|
#ifdef CHOOSE
|
||||||
CAmbarCendamo * ac = new CAmbarCendamo(initTable); //4gryf
|
CAmbarCendamo * ac = new CAmbarCendamo(initTable); //4gryf
|
||||||
|
@ -261,12 +261,12 @@ SDL_Surface * CSDL_Ext::hFlip(SDL_Surface * toRot)
|
|||||||
for(int j=0; j<ret->h; ++j)
|
for(int j=0; j<ret->h; ++j)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j -1) * toRot->pitch + i * toRot->format->BytesPerPixel-2;
|
Uint8 *p = (Uint8 *)toRot->pixels + (ret->h - j -1) * toRot->pitch + i * toRot->format->BytesPerPixel;
|
||||||
int k=2;
|
//int k=2;
|
||||||
#if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
#if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||||
CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2], k);
|
CSDL_Ext::SDL_PutPixel(ret, i, j, p[0], p[1], p[2]);
|
||||||
#else
|
#else
|
||||||
CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0], k);
|
CSDL_Ext::SDL_PutPixel(ret, i, j, p[2], p[1], p[0]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -452,6 +452,9 @@ SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src)
|
|||||||
case 100:
|
case 100:
|
||||||
shadow.unused = 100+64;
|
shadow.unused = 100+64;
|
||||||
break;
|
break;
|
||||||
|
case 125:
|
||||||
|
shadow.unused = 125+64;
|
||||||
|
break;
|
||||||
case 128:
|
case 128:
|
||||||
shadow.unused = 128+64;
|
shadow.unused = 128+64;
|
||||||
break;
|
break;
|
||||||
|
@ -259,6 +259,11 @@ CGObjectInstance::~CGObjectInstance()
|
|||||||
// delete state;
|
// delete state;
|
||||||
//state=NULL;
|
//state=NULL;
|
||||||
}
|
}
|
||||||
|
CGHeroInstance::CGHeroInstance()
|
||||||
|
{
|
||||||
|
level = exp = -1;
|
||||||
|
moveDir=4;
|
||||||
|
}
|
||||||
|
|
||||||
CGHeroInstance::~CGHeroInstance()
|
CGHeroInstance::~CGHeroInstance()
|
||||||
{
|
{
|
||||||
|
@ -367,6 +367,7 @@ public:
|
|||||||
bool canWalkOnSea() const;
|
bool canWalkOnSea() const;
|
||||||
int getCurrentLuck() const;
|
int getCurrentLuck() const;
|
||||||
int getCurrentMorale() const;
|
int getCurrentMorale() const;
|
||||||
|
CGHeroInstance();
|
||||||
virtual ~CGHeroInstance();
|
virtual ~CGHeroInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,11 +19,12 @@ void CTownHandler::loadNames()
|
|||||||
ins.str(CGI->bitmaph->getTextFile("TOWNTYPE.TXT"));
|
ins.str(CGI->bitmaph->getTextFile("TOWNTYPE.TXT"));
|
||||||
names.str(CGI->bitmaph->getTextFile("TOWNNAME.TXT"));
|
names.str(CGI->bitmaph->getTextFile("TOWNNAME.TXT"));
|
||||||
int si=0;
|
int si=0;
|
||||||
|
char bufname[50];
|
||||||
while (!ins.eof())
|
while (!ins.eof())
|
||||||
{
|
{
|
||||||
CTown town;
|
CTown town;
|
||||||
ins >> town.name;
|
ins.getline(bufname,50);
|
||||||
char bufname[50];
|
town.name = std::string(bufname);
|
||||||
for (int i=0; i<NAMES_PER_TOWN; i++)
|
for (int i=0; i<NAMES_PER_TOWN; i++)
|
||||||
{
|
{
|
||||||
names.getline(bufname,50);
|
names.getline(bufname,50);
|
||||||
|
28
map.h
28
map.h
@ -63,11 +63,6 @@ struct DefInfo //information from def declaration
|
|||||||
bool isOnDefList;
|
bool isOnDefList;
|
||||||
bool isVisitable();
|
bool isVisitable();
|
||||||
};
|
};
|
||||||
struct Location
|
|
||||||
{
|
|
||||||
int x, y;
|
|
||||||
bool z; // underground
|
|
||||||
};
|
|
||||||
struct SheroName //name of starting hero
|
struct SheroName //name of starting hero
|
||||||
{
|
{
|
||||||
int heroID;
|
int heroID;
|
||||||
@ -86,19 +81,16 @@ struct PlayerInfo
|
|||||||
std::vector<SheroName> heroesNames;
|
std::vector<SheroName> heroesNames;
|
||||||
bool hasMainTown;
|
bool hasMainTown;
|
||||||
bool generateHeroAtMainTown;
|
bool generateHeroAtMainTown;
|
||||||
Location posOfMainTown;
|
int3 posOfMainTown;
|
||||||
int team;
|
int team;
|
||||||
bool generateHero;
|
bool generateHero;
|
||||||
};
|
};
|
||||||
struct LossCondition
|
struct LossCondition
|
||||||
{
|
{
|
||||||
ElossCon typeOfLossCon;
|
ElossCon typeOfLossCon;
|
||||||
union
|
int3 castlePos;
|
||||||
{
|
int3 heroPos;
|
||||||
Location castlePos;
|
int timeLimit; // in days
|
||||||
Location heroPos;
|
|
||||||
int timeLimit; // in days
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
struct CspecificVictoryConidtions
|
struct CspecificVictoryConidtions
|
||||||
{
|
{
|
||||||
@ -121,26 +113,26 @@ struct VicCon2 : public CspecificVictoryConidtions // accumulate resources
|
|||||||
};
|
};
|
||||||
struct VicCon3 : public CspecificVictoryConidtions // upgrade specific town
|
struct VicCon3 : public CspecificVictoryConidtions // upgrade specific town
|
||||||
{
|
{
|
||||||
Location posOfCity;
|
int3 posOfCity;
|
||||||
int councilNeededLevel; //0 - town; 1 - city; 2 - capitol
|
int councilNeededLevel; //0 - town; 1 - city; 2 - capitol
|
||||||
int fortNeededLevel;// 0 - fort; 1 - citadel; 2 - castle
|
int fortNeededLevel;// 0 - fort; 1 - citadel; 2 - castle
|
||||||
};
|
};
|
||||||
struct VicCon4 : public CspecificVictoryConidtions // build grail structure
|
struct VicCon4 : public CspecificVictoryConidtions // build grail structure
|
||||||
{
|
{
|
||||||
bool anyLocation;
|
bool anyLocation;
|
||||||
Location whereBuildGrail;
|
int3 whereBuildGrail;
|
||||||
};
|
};
|
||||||
struct VicCon5 : public CspecificVictoryConidtions // defeat a specific hero
|
struct VicCon5 : public CspecificVictoryConidtions // defeat a specific hero
|
||||||
{
|
{
|
||||||
Location locationOfHero;
|
int3 locationOfHero;
|
||||||
};
|
};
|
||||||
struct VicCon6 : public CspecificVictoryConidtions // capture a specific town
|
struct VicCon6 : public CspecificVictoryConidtions // capture a specific town
|
||||||
{
|
{
|
||||||
Location locationOfTown;
|
int3 locationOfTown;
|
||||||
};
|
};
|
||||||
struct VicCon7 : public CspecificVictoryConidtions // defeat a specific monster
|
struct VicCon7 : public CspecificVictoryConidtions // defeat a specific monster
|
||||||
{
|
{
|
||||||
Location locationOfMonster;
|
int3 locationOfMonster;
|
||||||
};
|
};
|
||||||
/*struct VicCon8 : public CspecificVictoryConidtions // flag all creature dwellings
|
/*struct VicCon8 : public CspecificVictoryConidtions // flag all creature dwellings
|
||||||
{
|
{
|
||||||
@ -151,7 +143,7 @@ struct VicCon9 : public CspecificVictoryConidtions // flag all mines
|
|||||||
struct VicCona : public CspecificVictoryConidtions //transport specific artifact
|
struct VicCona : public CspecificVictoryConidtions //transport specific artifact
|
||||||
{
|
{
|
||||||
int artifactID;
|
int artifactID;
|
||||||
Location destinationPlace;
|
int3 destinationPlace;
|
||||||
};
|
};
|
||||||
struct Rumor
|
struct Rumor
|
||||||
{
|
{
|
||||||
|
190
mapHandler.cpp
190
mapHandler.cpp
@ -197,7 +197,7 @@ void CMapHandler::randomizeObject(CGObjectInstance *cur)
|
|||||||
t->defInfo->handler = CGI->spriteh->giveDef(t->defInfo->name);
|
t->defInfo->handler = CGI->spriteh->giveDef(t->defInfo->name);
|
||||||
alphaTransformDef(t->defInfo);
|
alphaTransformDef(t->defInfo);
|
||||||
}
|
}
|
||||||
CGI->townh->townInstances.push_back(t);
|
//CGI->townh->townInstances.push_back(t);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//we have to replace normal random object
|
//we have to replace normal random object
|
||||||
@ -218,6 +218,8 @@ void CMapHandler::randomizeObjects()
|
|||||||
for(int no=0; no<CGI->objh->objInstances.size(); ++no)
|
for(int no=0; no<CGI->objh->objInstances.size(); ++no)
|
||||||
{
|
{
|
||||||
randomizeObject(CGI->objh->objInstances[no]);
|
randomizeObject(CGI->objh->objInstances[no]);
|
||||||
|
if(CGI->objh->objInstances[no]->ID==26)
|
||||||
|
CGI->objh->objInstances[no]->defInfo->handler=NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CMapHandler::prepareFOWDefs()
|
void CMapHandler::prepareFOWDefs()
|
||||||
@ -611,54 +613,66 @@ void CMapHandler::initObjectRects()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CDefHandler * curd = CGI->objh->objInstances[f]->defInfo->handler;
|
CDefHandler * curd = CGI->objh->objInstances[f]->defInfo->handler;
|
||||||
for(int fx=0; fx<curd->ourImages[0].bitmap->w>>5; ++fx) //curd->ourImages[0].bitmap->w/32
|
if(curd)
|
||||||
{
|
{
|
||||||
for(int fy=0; fy<curd->ourImages[0].bitmap->h>>5; ++fy) //curd->ourImages[0].bitmap->h/32
|
for(int fx=0; fx<curd->ourImages[0].bitmap->w>>5; ++fx) //curd->ourImages[0].bitmap->w/32
|
||||||
{
|
{
|
||||||
SDL_Rect cr;
|
for(int fy=0; fy<curd->ourImages[0].bitmap->h>>5; ++fy) //curd->ourImages[0].bitmap->h/32
|
||||||
cr.w = 32;
|
|
||||||
cr.h = 32;
|
|
||||||
cr.x = fx<<5; //fx*32
|
|
||||||
cr.y = fy<<5; //fy*32
|
|
||||||
std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> toAdd = std::make_pair(CGI->objh->objInstances[f], std::make_pair(cr, std::vector<std::list<int3>>()));
|
|
||||||
///initializing places that will be coloured by blitting (flag colour / player colour positions)
|
|
||||||
if(toAdd.first->defInfo->isVisitable())
|
|
||||||
{
|
{
|
||||||
toAdd.second.second.resize(toAdd.first->defInfo->handler->ourImages.size());
|
SDL_Rect cr;
|
||||||
for(int no = 0; no<toAdd.first->defInfo->handler->ourImages.size(); ++no)
|
cr.w = 32;
|
||||||
|
cr.h = 32;
|
||||||
|
cr.x = fx<<5; //fx*32
|
||||||
|
cr.y = fy<<5; //fy*32
|
||||||
|
std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> toAdd = std::make_pair(CGI->objh->objInstances[f], std::make_pair(cr, std::vector<std::list<int3>>()));
|
||||||
|
///initializing places that will be coloured by blitting (flag colour / player colour positions)
|
||||||
|
if(toAdd.first->defInfo->isVisitable())
|
||||||
{
|
{
|
||||||
bool breakNow = true;
|
SDL_Rect cr;
|
||||||
for(int dx=0; dx<32; ++dx)
|
cr.w = 32;
|
||||||
|
cr.h = 32;
|
||||||
|
cr.x = fx*32;
|
||||||
|
cr.y = fy*32;
|
||||||
|
std::pair<CGObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3> > > > toAdd = std::make_pair(CGI->objh->objInstances[f], std::make_pair(cr, std::vector<std::list<int3>>()));
|
||||||
|
///initializing places that will be coloured by blitting (flag colour / player colour positions)
|
||||||
|
if(toAdd.first->defInfo->isVisitable() && toAdd.first->defInfo->handler->ourImages[0].bitmap->format->BitsPerPixel!=8)
|
||||||
{
|
{
|
||||||
for(int dy=0; dy<32; ++dy)
|
toAdd.second.second.resize(toAdd.first->defInfo->handler->ourImages.size());
|
||||||
|
for(int no = 0; no<toAdd.first->defInfo->handler->ourImages.size(); ++no)
|
||||||
{
|
{
|
||||||
SDL_Surface * curs = toAdd.first->defInfo->handler->ourImages[no].bitmap;
|
bool breakNow = true;
|
||||||
Uint32* point = (Uint32*)( (Uint8*)curs->pixels + curs->pitch * (fy*32+dy) + curs->format->BytesPerPixel*(fx*32+dx));
|
for(int dx=0; dx<32; ++dx)
|
||||||
Uint8 r, g, b, a;
|
|
||||||
SDL_GetRGBA(*point, curs->format, &r, &g, &b, &a);
|
|
||||||
if(r==255 && g==255 && b==0)
|
|
||||||
{
|
{
|
||||||
toAdd.second.second[no].push_back(int3((fx*32+dx), (fy*32+dy), 0));
|
for(int dy=0; dy<32; ++dy)
|
||||||
breakNow = false;
|
{
|
||||||
|
SDL_Surface * curs = toAdd.first->defInfo->handler->ourImages[no].bitmap;
|
||||||
|
Uint32* point = (Uint32*)( (Uint8*)curs->pixels + curs->pitch * (fy*32+dy) + curs->format->BytesPerPixel*(fx*32+dx));
|
||||||
|
Uint8 r, g, b, a;
|
||||||
|
SDL_GetRGBA(*point, curs->format, &r, &g, &b, &a);
|
||||||
|
if(r==255 && g==255 && b==0)
|
||||||
|
{
|
||||||
|
toAdd.second.second[no].push_back(int3((fx*32+dx), (fy*32+dy), 0));
|
||||||
|
breakNow = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if(breakNow)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(breakNow)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
|
||||||
if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
|
{
|
||||||
{
|
//TerrainTile2 & curt =
|
||||||
//TerrainTile2 & curt =
|
// ttiles
|
||||||
// ttiles
|
// [CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32]
|
||||||
// [CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32]
|
//[CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32]
|
||||||
//[CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32]
|
//[CGI->objh->objInstances[f]->pos.z];
|
||||||
//[CGI->objh->objInstances[f]->pos.z];
|
ttiles[CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1][CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1][CGI->objh->objInstances[f]->pos.z].objects.push_back(toAdd);
|
||||||
ttiles[CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1][CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1][CGI->objh->objInstances[f]->pos.z].objects.push_back(toAdd);
|
}
|
||||||
}
|
} // for(int fy=0; fy<curd->ourImages[0].bitmap->h/32; ++fy)
|
||||||
|
} //for(int fx=0; fx<curd->ourImages[0].bitmap->w/32; ++fx)
|
||||||
} // for(int fy=0; fy<curd->ourImages[0].bitmap->h/32; ++fy)
|
}//if curd
|
||||||
} //for(int fx=0; fx<curd->ourImages[0].bitmap->w/32; ++fx)
|
|
||||||
} // for(int f=0; f<CGI->objh->objInstances.size(); ++f)
|
} // for(int f=0; f<CGI->objh->objInstances.size(); ++f)
|
||||||
for(int ix=0; ix<ttiles.size()-Woff; ++ix)
|
for(int ix=0; ix<ttiles.size()-Woff; ++ix)
|
||||||
{
|
{
|
||||||
@ -717,6 +731,7 @@ void CMapHandler::init()
|
|||||||
|
|
||||||
timeHandler th;
|
timeHandler th;
|
||||||
th.getDif();
|
th.getDif();
|
||||||
|
|
||||||
randomizeObjects();//randomizing objects on map
|
randomizeObjects();//randomizing objects on map
|
||||||
std::cout<<"\tRandomizing objects: "<<th.getDif()<<std::endl;
|
std::cout<<"\tRandomizing objects: "<<th.getDif()<<std::endl;
|
||||||
|
|
||||||
@ -733,9 +748,28 @@ void CMapHandler::init()
|
|||||||
borderAndTerrainBitmapInit();
|
borderAndTerrainBitmapInit();
|
||||||
std::cout<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDif()<<std::endl;
|
std::cout<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDif()<<std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
for(int i=0;i<PLAYER_LIMIT;i++)
|
||||||
|
{
|
||||||
|
if(reader->map.players[i].generateHeroAtMainTown && reader->map.players[i].hasMainTown)
|
||||||
|
{
|
||||||
|
int3 hpos = reader->map.players[i].posOfMainTown;
|
||||||
|
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;
|
||||||
|
CGHeroInstance * nnn = (CGHeroInstance*)createObject(34,CGI->scenarioOps.playerInfos[j].hero,hpos,i);
|
||||||
|
nnn->defInfo->handler = CGI->heroh->flags1[0];
|
||||||
|
CGI->heroh->heroInstances.push_back(nnn);
|
||||||
|
CGI->objh->objInstances.push_back(nnn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
initObjectRects();
|
initObjectRects();
|
||||||
std::cout<<"\tMaking object rects: "<<th.getDif()<<std::endl;
|
std::cout<<"\tMaking object rects: "<<th.getDif()<<std::endl;
|
||||||
|
|
||||||
calculateBlockedPos();
|
calculateBlockedPos();
|
||||||
std::cout<<"\tCalculating blockmap: "<<th.getDif()<<std::endl;
|
std::cout<<"\tCalculating blockmap: "<<th.getDif()<<std::endl;
|
||||||
}
|
}
|
||||||
@ -812,9 +846,9 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
|||||||
int imgVal = 8;
|
int imgVal = 8;
|
||||||
SDL_Surface * tb;
|
SDL_Surface * tb;
|
||||||
|
|
||||||
if(((CHeroObjInfo*)themp->info)->myInstance->type==NULL)
|
if(themp->type==NULL)
|
||||||
continue;
|
continue;
|
||||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)themp->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
std::vector<Cimage> & iv = themp->type->heroClass->moveAnim->ourImages;
|
||||||
switch(themp->moveDir)
|
switch(themp->moveDir)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -960,9 +994,9 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
|||||||
int imgVal = 8;
|
int imgVal = 8;
|
||||||
SDL_Surface * tb;
|
SDL_Surface * tb;
|
||||||
|
|
||||||
if(((CHeroObjInfo*)themp->info)->myInstance->type==NULL)
|
if(themp->type==NULL)
|
||||||
continue;
|
continue;
|
||||||
std::vector<Cimage> & iv = ((CHeroObjInfo*)themp->info)->myInstance->type->heroClass->moveAnim->ourImages;
|
std::vector<Cimage> & iv = themp->type->heroClass->moveAnim->ourImages;
|
||||||
switch(themp->moveDir)
|
switch(themp->moveDir)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -1589,65 +1623,61 @@ std::vector < CGObjectInstance * > CMapHandler::getVisitableObjs(int3 pos)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGObjectInstance * CMapHandler::createObject(int id, int subid, int3 pos)
|
CGObjectInstance * CMapHandler::createObject(int id, int subid, int3 pos, int owner)
|
||||||
{
|
{
|
||||||
CGObjectInstance * nobj;
|
CGObjectInstance * nobj;
|
||||||
switch(id)
|
switch(id)
|
||||||
{
|
{
|
||||||
case 43: //hero
|
case 34: //hero
|
||||||
nobj = new CGHeroInstance;
|
{
|
||||||
break;
|
CGHeroInstance * nobj;
|
||||||
|
nobj = new CGHeroInstance();
|
||||||
|
nobj->pos = pos;
|
||||||
|
nobj->tempOwner = owner;
|
||||||
|
nobj->defInfo = new CGDefInfo();
|
||||||
|
nobj->defInfo->id = 34;
|
||||||
|
nobj->defInfo->subid = subid;
|
||||||
|
nobj->type = CGI->heroh->heroes[subid];
|
||||||
|
for(int i=0;i<6;i++)
|
||||||
|
{
|
||||||
|
nobj->defInfo->blockMap[i]=1;
|
||||||
|
nobj->defInfo->visitMap[i]=0;
|
||||||
|
}
|
||||||
|
nobj->ID = id;
|
||||||
|
nobj->subID = subid;
|
||||||
|
nobj->defInfo->handler=NULL;
|
||||||
|
nobj->defInfo->blockMap[5] = 0x7f;
|
||||||
|
nobj->defInfo->visitMap[5] = 0x80;
|
||||||
|
nobj->artifWorn.resize(20);
|
||||||
|
nobj->artifacts.resize(20);
|
||||||
|
nobj->artifWorn[16] = &CGI->arth->artifacts[3];
|
||||||
|
return nobj;
|
||||||
|
}
|
||||||
case 98: //town
|
case 98: //town
|
||||||
nobj = new CGTownInstance;
|
nobj = new CGTownInstance;
|
||||||
break;
|
break;
|
||||||
default: //rest of objects
|
default: //rest of objects
|
||||||
nobj = new CGObjectInstance;
|
nobj = new CGObjectInstance;
|
||||||
|
nobj->defInfo = CGI->dobjinfo->gobjs[id][subid];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nobj->ID = id;
|
nobj->ID = id;
|
||||||
nobj->subID = subid;
|
nobj->subID = subid;
|
||||||
nobj->defInfo = CGI->dobjinfo->gobjs[id][subid];
|
|
||||||
if(!nobj->defInfo)
|
if(!nobj->defInfo)
|
||||||
std::cout <<"No def declaration for " <<id <<" "<<subid<<std::endl;
|
std::cout <<"No def declaration for " <<id <<" "<<subid<<std::endl;
|
||||||
/*new CGDefInfo;
|
|
||||||
int defObjInfoNumber = -1;
|
|
||||||
for(int f=0; f<CGI->dobjinfo->objs.size(); ++f)
|
|
||||||
{
|
|
||||||
if(CGI->dobjinfo->objs[f].type==id && CGI->dobjinfo->objs[f].subtype == subid)
|
|
||||||
{
|
|
||||||
defObjInfoNumber = f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nobj->defInfo->name = CGI->dobjinfo->objs[defObjInfoNumber].defName;
|
|
||||||
for(int g=0; g<6; ++g)
|
|
||||||
nobj->defInfo->blockMap[g] = CGI->dobjinfo->objs[defObjInfoNumber].blockMap[g];
|
|
||||||
for(int g=0; g<6; ++g)
|
|
||||||
nobj->defInfo->visitMap[g] = CGI->dobjinfo->objs[nobj->defObjInfoNumber].visitMap[g];
|
|
||||||
nobj->defInfo->printPriority = CGI->dobjinfo->objs[nobj->defObjInfoNumber].priority;*/
|
|
||||||
nobj->pos = pos;
|
nobj->pos = pos;
|
||||||
//nobj->state = NULL;//new CLuaObjectScript();
|
//nobj->state = NULL;//new CLuaObjectScript();
|
||||||
nobj->tempOwner = 254;
|
nobj->tempOwner = owner;
|
||||||
nobj->info = NULL;
|
nobj->info = NULL;
|
||||||
nobj->defInfo->id = id;
|
nobj->defInfo->id = id;
|
||||||
nobj->defInfo->subid = subid;
|
nobj->defInfo->subid = subid;
|
||||||
|
|
||||||
//assigning defhandler
|
//assigning defhandler
|
||||||
|
if(nobj->ID==34 || nobj->ID==98)
|
||||||
std::string ourName = getDefName(id, subid);
|
return nobj;
|
||||||
std::transform(ourName.begin(), ourName.end(), ourName.begin(), (int(*)(int))toupper);
|
nobj->defInfo = CGI->dobjinfo->gobjs[id][subid];
|
||||||
nobj->defInfo->name = ourName;
|
if(!nobj->defInfo->handler)
|
||||||
|
nobj->defInfo->handler = CGI->spriteh->giveDef(nobj->defInfo->name);
|
||||||
if(loadedDefs[ourName] == NULL)
|
|
||||||
{
|
|
||||||
nobj->defInfo->handler = CGI->spriteh->giveDef(ourName);
|
|
||||||
loadedDefs[ourName] = nobj->defInfo->handler;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nobj->defInfo->handler = loadedDefs[ourName];
|
|
||||||
}
|
|
||||||
|
|
||||||
return nobj;
|
return nobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
int getCost(int3 & a, int3 & b, const CGHeroInstance * hero);
|
int getCost(int3 & a, int3 & b, const CGHeroInstance * hero);
|
||||||
std::vector< std::string > getObjDescriptions(int3 pos); //returns desriptions of objects blocking given position
|
std::vector< std::string > getObjDescriptions(int3 pos); //returns desriptions of objects blocking given position
|
||||||
std::vector< CGObjectInstance * > getVisitableObjs(int3 pos); //returns vector of visitable objects at certain position
|
std::vector< CGObjectInstance * > getVisitableObjs(int3 pos); //returns vector of visitable objects at certain position
|
||||||
CGObjectInstance * createObject(int id, int subid, int3 pos); //creates a new object with a certain id and subid
|
CGObjectInstance * createObject(int id, int subid, int3 pos, int owner=254); //creates a new object with a certain id and subid
|
||||||
std::string getDefName(int id, int subid); //returns name of def for object with given id and subid
|
std::string getDefName(int id, int subid); //returns name of def for object with given id and subid
|
||||||
bool printObject(CGObjectInstance * obj); //puts appropriate things to ttiles, so obj will be visible on map
|
bool printObject(CGObjectInstance * obj); //puts appropriate things to ttiles, so obj will be visible on map
|
||||||
bool hideObject(CGObjectInstance * obj); //removes appropriate things from ttiles, so obj will be no longer visible on map (but still will exist)
|
bool hideObject(CGObjectInstance * obj); //removes appropriate things from ttiles, so obj will be no longer visible on map (but still will exist)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user