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

Partial support for random wandering stacks. Well, they are not 'that' random as don't use global ran() function.

This commit is contained in:
DjWarmonger 2010-08-22 07:11:46 +00:00
parent 205126e7e6
commit f6b97704c7
5 changed files with 53 additions and 4 deletions

View File

@ -1167,6 +1167,12 @@ int CGameState::getDate(int mode) const
case 3: //current month
return ((day-1)/28)+1;
break;
case 4: //day of month
temp = (day)%28;
if (temp)
return temp;
else return 28;
break;
}
return 0;
}

View File

@ -164,6 +164,30 @@ void IGameCallback::getAllTiles (std::set<int3> &tiles, int player/*=-1*/, int l
}
}
void IGameCallback::getFreeTiles (std::vector<int3> &tiles)
{
std::vector<int> floors;
for (int b=0; b<gs->map->twoLevel + 1; ++b) //if gs->map->twoLevel is false then false (0) + 1 is 1, if it's true (1) then we have 2
{
floors.push_back(b);
}
TerrainTile *tinfo;
for (std::vector<int>::const_iterator i = floors.begin(); i!= floors.end(); i++)
{
register int zd = *i;
for (int xd = 0; xd < gs->map->width; xd++)
{
for (int yd = 0; yd < gs->map->height; yd++)
{
tinfo = getTile (int3 (xd,yd,zd));
if (tinfo->tertype != 8 && !tinfo->blocked) //land and free
tiles.push_back (int3 (xd,yd,zd));
}
}
}
}
bool IGameCallback::isAllowed( int type, int id )
{
switch(type)

View File

@ -59,6 +59,7 @@ public:
virtual int getHeroCount(int player, bool includeGarrisoned);
virtual void getTilesInRange(std::set<int3> &tiles, int3 pos, int radious, int player=-1, int mode=0); //mode 1 - only unrevealed tiles; mode 0 - all, mode -1 - only unrevealed
virtual void getAllTiles (std::set<int3> &tiles, int player=-1, int level=-1, int surface=0); //returns all tiles on given level (-1 - both levels, otherwise number of level); surface: 0 - land and water, 1 - only land, 2 - only water
virtual void getFreeTiles (std::vector<int3> &tiles); //used for random spawns
virtual bool isAllowed(int type, int id); //type: 0 - spell; 1- artifact; 2 - secondary skill
virtual ui16 getRandomArt (int flags);
virtual ui16 getArtSync (ui32 rand, int flags); //synchronic

View File

@ -544,6 +544,17 @@ DLL_EXPORT void NewObject::applyGs( CGameState *gs )
case 8:
o = new CGBoat();
break;
case 54: //probably more options will be needed
o = new CGCreature();
{
CStackInstance hlp;
CGCreature *cre = static_cast<CGCreature*>(o);
cre->slots[0] = hlp;
cre->notGrowingTeam = cre->neverFlees = 0;
cre->character = 2;
cre->gainedArtifact = -1;
}
break;
default:
o = new CGObjectInstance();
break;
@ -555,11 +566,17 @@ DLL_EXPORT void NewObject::applyGs( CGameState *gs )
id = o->id = gs->map->objects.size();
o->hoverName = VLC->generaltexth->names[ID];
if(ID == 124) // hole
switch(ID)
{
const TerrainTile &t = gs->map->getTile(pos);
o->defInfo = VLC->dobjinfo->gobjs[ID][t.tertype];
assert(o->defInfo);
case 54: //cfreature
o->defInfo = VLC->dobjinfo->gobjs[ID][subID];
assert(o->defInfo);
break;
case 124://hole
const TerrainTile &t = gs->map->getTile(pos);
o->defInfo = VLC->dobjinfo->gobjs[ID][t.tertype];
assert(o->defInfo);
break;
}
gs->map->objects.push_back(o);

View File

@ -27,6 +27,7 @@ LibClasses * VLC = NULL;
DLL_EXPORT CLodHandler *bitmaph = NULL,
*spriteh = NULL;
DLL_EXPORT CLogger tlog0(0);
DLL_EXPORT CLogger tlog1(1);
DLL_EXPORT CLogger tlog2(2);