Skip to content

Commit

Permalink
Merge pull request #138 from wheybags/lvlgen3
Browse files Browse the repository at this point in the history
level generation for level 3 dungeons
  • Loading branch information
wheybags committed Jul 20, 2015
2 parents d82e3be + b9b7b0c commit 13d7a36
Show file tree
Hide file tree
Showing 9 changed files with 796 additions and 123 deletions.
479 changes: 367 additions & 112 deletions apps/freeablo/falevelgen/levelgen.cpp

Large diffs are not rendered by default.

140 changes: 133 additions & 7 deletions apps/freeablo/falevelgen/tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,67 @@ namespace FALevelGen
blank = pt.get<size_t>("Basic.blank");
fillTile(blank, pt, "Blank");

xWallEnd = pt.get<size_t>("Basic.xWallEnd");
fillTile(xWallEnd, pt, "XWallEnd");

yWallEnd = pt.get<size_t>("Basic.yWallEnd");
fillTile(yWallEnd, pt, "YWallEnd");

xDoor = pt.get<size_t>("Basic.xDoor");
fillTile(xDoor, pt, "XDoor");

yDoor = pt.get<size_t>("Basic.yDoor");
fillTile(yDoor, pt, "YDoor");

insideXWall = pt.get<size_t>("Basic.insideXWall");
fillTile(insideXWall, pt, "InsideXWall");
insideXWallEnd = pt.get<size_t>("Basic.insideXWallEnd");
fillTile(insideXWallEnd, pt, "InsideXWallEnd");
insideXWallEndBack = pt.get<size_t>("Basic.insideXWallEndBack");
fillTile(insideXWallEndBack, pt, "InsideXWallEndBack");
insideYWall = pt.get<size_t>("Basic.insideYWall");
fillTile(insideYWall, pt, "InsideYWall");
insideYWallEnd = pt.get<size_t>("Basic.insideYWallEnd");
fillTile(insideYWallEnd, pt, "InsideYWallEnd");
insideYWallEndBack = pt.get<size_t>("Basic.insideYWallEndBack");
fillTile(insideYWallEndBack, pt, "InsideYWallEndBack");
insideLeftCorner = pt.get<size_t>("Basic.insideLeftCorner");
fillTile(insideLeftCorner, pt, "InsideLeftCorner");
insideRightCorner = pt.get<size_t>("Basic.insideRightCorner");
fillTile(insideRightCorner, pt, "InsideRightCorner");
insideBottomCorner = pt.get<size_t>("Basic.insideBottomCorner");
fillTile(insideBottomCorner, pt, "InsideBottomCorner");
insideTopCorner = pt.get<size_t>("Basic.insideTopCorner");
fillTile(insideTopCorner, pt, "InsideTopCorner");

joinY = pt.get<size_t>("Basic.joinY");
fillTile(joinY, pt, "JoinY");
joinYRightCorner = pt.get<size_t>("Basic.joinYRightCorner");
fillTile(joinYRightCorner, pt, "JoinYRightCorner");
joinRightCorner = pt.get<size_t>("Basic.joinRightCorner");
fillTile(joinRightCorner, pt, "JoinRightCorner");
joinOutXRightCorner = pt.get<size_t>("Basic.joinOutXRightCorner");
fillTile(joinOutXRightCorner, pt, "JoinOutXRightCorner");
joinOutX = pt.get<size_t>("Basic.joinOutX");
fillTile(joinOutX, pt, "JoinOutX");
joinOutXTopCorner = pt.get<size_t>("Basic.joinOutXTopCorner");
fillTile(joinOutXTopCorner, pt, "JoinOutXTopCorner");
joinTopCorner = pt.get<size_t>("Basic.joinTopCorner");
fillTile(joinTopCorner, pt, "JoinTopCorner");
joinOutYTopCorner = pt.get<size_t>("Basic.joinOutYTopCorner");
fillTile(joinOutYTopCorner, pt, "JoinOutYTopCorner");
joinOutY = pt.get<size_t>("Basic.joinOutY");
fillTile(joinOutY, pt, "JoinOutY");
joinOutYLeftCorner = pt.get<size_t>("Basic.joinOutYLeftCorner");
fillTile(joinOutYLeftCorner, pt, "JoinOutYLeftCorner");
joinLeftCorner = pt.get<size_t>("Basic.joinLeftCorner");
fillTile(joinLeftCorner, pt, "JoinLeftCorner");
joinXLeftCorner = pt.get<size_t>("Basic.joinXLeftCorner");
fillTile(joinXLeftCorner, pt, "JoinXLeftCorner");
joinX = pt.get<size_t>("Basic.joinX");
fillTile(joinX, pt, "JoinX");
joinXBottomCorner = pt.get<size_t>("Basic.joinXBottomCorner");
fillTile(joinXBottomCorner, pt, "JoinXBottomCorner");
joinBottomCorner = pt.get<size_t>("Basic.joinBottomCorner");
fillTile(joinBottomCorner, pt, "JoinBottomCorner");
joinYBottomCorner = pt.get<size_t>("Basic.joinYBottomCorner");
fillTile(joinYBottomCorner, pt, "JoinYBottomCorner");


upStairs1 = pt.get<size_t>("Basic.upStairs1");
upStairs2 = pt.get<size_t>("Basic.upStairs2");
upStairs3 = pt.get<size_t>("Basic.upStairs3");
Expand Down Expand Up @@ -146,7 +195,7 @@ namespace FALevelGen
size_t i = 0;
for(; i < tileVec.size() && random > tileVec[i].second; i++)
random -= tileVec[i].second;

return tileVec[i].first;
}

Expand All @@ -171,4 +220,81 @@ namespace FALevelGen
mDoorMap[second] = first;
}
}

size_t TileSet::convert(TileSetEnum::TileSetEnum val)
{
switch(val)
{
case TileSetEnum::xWall: return xWall;
case TileSetEnum::outsideXWall: return outsideXWall;
case TileSetEnum::yWall: return yWall;
case TileSetEnum::outsideYWall: return outsideYWall;
case TileSetEnum::bottomCorner: return bottomCorner;
case TileSetEnum::outsideBottomCorner: return outsideBottomCorner;
case TileSetEnum::rightCorner: return rightCorner;
case TileSetEnum::outsideRightCorner: return outsideRightCorner;
case TileSetEnum::leftCorner: return leftCorner;
case TileSetEnum::outsideLeftCorner: return outsideLeftCorner;
case TileSetEnum::topCorner: return topCorner;
case TileSetEnum::outsideTopCorner: return outsideTopCorner;
case TileSetEnum::floor: return floor;
case TileSetEnum::blank: return blank;
case TileSetEnum::xDoor: return xDoor;
case TileSetEnum::yDoor: return yDoor;

case TileSetEnum::upStairs1: return upStairs1;
case TileSetEnum::upStairs2: return upStairs2;
case TileSetEnum::upStairs3: return upStairs3;

case TileSetEnum::upStairs4: return upStairs4;
case TileSetEnum::upStairs5: return upStairs5;
case TileSetEnum::upStairs6: return upStairs6;

case TileSetEnum::upStairs7: return upStairs7;
case TileSetEnum::upStairs8: return upStairs8;
case TileSetEnum::upStairs9: return upStairs9;

case TileSetEnum::downStairs1: return downStairs1;
case TileSetEnum::downStairs2: return downStairs2;
case TileSetEnum::downStairs3: return downStairs3;

case TileSetEnum::downStairs4: return downStairs4;
case TileSetEnum::downStairs5: return downStairs5;
case TileSetEnum::downStairs6: return downStairs6;

case TileSetEnum::downStairs7: return downStairs7;
case TileSetEnum::downStairs8: return downStairs8;
case TileSetEnum::downStairs9: return downStairs9;

case TileSetEnum::insideXWall: return insideXWall;
case TileSetEnum::insideXWallEnd: return insideXWallEnd;
case TileSetEnum::insideXWallEndBack: return insideXWallEndBack;
case TileSetEnum::insideYWall: return insideYWall;
case TileSetEnum::insideYWallEnd: return insideYWallEnd;
case TileSetEnum::insideYWallEndBack: return insideYWallEndBack;
case TileSetEnum::insideLeftCorner: return insideLeftCorner;
case TileSetEnum::insideRightCorner: return insideRightCorner;
case TileSetEnum::insideBottomCorner: return insideBottomCorner;
case TileSetEnum::insideTopCorner: return insideTopCorner;

case TileSetEnum::joinY: return joinY;
case TileSetEnum::joinYRightCorner: return joinYRightCorner;
case TileSetEnum::joinRightCorner: return joinRightCorner;
case TileSetEnum::joinOutXRightCorner: return joinOutXRightCorner;
case TileSetEnum::joinOutX: return joinOutX;
case TileSetEnum::joinOutXTopCorner: return joinOutXTopCorner;
case TileSetEnum::joinTopCorner: return joinTopCorner;
case TileSetEnum::joinOutYTopCorner: return joinOutYTopCorner;
case TileSetEnum::joinOutY: return joinOutY;
case TileSetEnum::joinOutYLeftCorner: return joinOutYLeftCorner;
case TileSetEnum::joinLeftCorner: return joinLeftCorner;
case TileSetEnum::joinXLeftCorner: return joinXLeftCorner;
case TileSetEnum::joinX: return joinX;
case TileSetEnum::joinXBottomCorner: return joinXBottomCorner;
case TileSetEnum::joinBottomCorner: return joinBottomCorner;
case TileSetEnum::joinYBottomCorner: return joinYBottomCorner;
}

return val;
}
}
120 changes: 119 additions & 1 deletion apps/freeablo/falevelgen/tileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,93 @@

namespace FALevelGen
{

namespace TileSetEnum
{
enum TileSetEnum
{
// this block and the block after it are related
// eg insideYWall MUST be equal to yWall + insideXWall
xWall,
yWall,
leftCorner,
rightCorner,
bottomCorner,
topCorner,

insideXWall,
insideYWall,
insideLeftCorner,
insideRightCorner,
insideBottomCorner,
insideTopCorner,

insideXWallEnd,
insideXWallEndBack,
insideYWallEnd,
insideYWallEndBack,



outsideXWall,
outsideYWall,
outsideBottomCorner,
outsideRightCorner,
outsideLeftCorner,
outsideTopCorner,
floor,
blank,
xDoor,
yDoor,


joinY,
joinYRightCorner,
joinRightCorner,
joinOutXRightCorner,
joinOutX,
joinOutXTopCorner,
joinTopCorner,
joinOutYTopCorner,
joinOutY,
joinOutYLeftCorner,
joinLeftCorner,
joinXLeftCorner,
joinX,
joinXBottomCorner,
joinBottomCorner,
joinYBottomCorner,

upStairs1,
upStairs2,
upStairs3,

upStairs4,
upStairs5,
upStairs6,

upStairs7,
upStairs8,
upStairs9,

downStairs1,
downStairs2,
downStairs3,

downStairs4,
downStairs5,
downStairs6,

downStairs7,
downStairs8,
downStairs9,

// these two just used internally in levelgen.cpp, not loaded from a file like the rest
upStairs,
downStairs
};
}

class TileSet
{
public:
Expand All @@ -31,7 +118,9 @@ namespace FALevelGen
size_t floor;
size_t blank;
size_t xWallEnd;
size_t xWallEndBack;
size_t yWallEnd;
size_t yWallEndBack;
size_t xDoor;
size_t yDoor;

Expand Down Expand Up @@ -59,8 +148,38 @@ namespace FALevelGen
size_t downStairs8;
size_t downStairs9;

size_t insideXWall;
size_t insideXWallEnd;
size_t insideXWallEndBack;
size_t insideYWall;
size_t insideYWallEnd;
size_t insideYWallEndBack;
size_t insideLeftCorner;
size_t insideRightCorner;
size_t insideBottomCorner;
size_t insideTopCorner;

size_t joinY;
size_t joinYRightCorner;
size_t joinRightCorner;
size_t joinOutXRightCorner;
size_t joinOutX;
size_t joinOutXTopCorner;
size_t joinTopCorner;
size_t joinOutYTopCorner;
size_t joinOutY;
size_t joinOutYLeftCorner;
size_t joinLeftCorner;
size_t joinXLeftCorner;
size_t joinX;
size_t joinXBottomCorner;
size_t joinBottomCorner;
size_t joinYBottomCorner;

size_t getRandomTile(size_t tile);
std::map<size_t, size_t> getDoorMap();

size_t convert(TileSetEnum::TileSetEnum val);

private:
std::map<size_t, std::pair<std::vector<std::pair<size_t, size_t> >, size_t> > mAlternatives;
Expand All @@ -70,7 +189,6 @@ namespace FALevelGen
void fillTile(size_t tile, boost::property_tree::ptree& pt, const std::string& str);

void loadDoorMap(boost::property_tree::ptree& pt);

};

}
Expand Down
4 changes: 2 additions & 2 deletions apps/freeablo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Level::Level* getLevel(size_t dLvl, const DiabloExe::DiabloExe& exe)
return new Level::Level(Level::Dun::getTown(sector1, sector2, sector3, sector4), "levels/towndata/town.til",
"levels/towndata/town.min", "levels/towndata/town.sol", "levels/towndata/town.cel", std::make_pair(25,29), std::make_pair(75,68), std::map<size_t, size_t>());
}
else if(dLvl < 9)
else if(dLvl < 13)
{
return FALevelGen::generate(100, 100, dLvl, exe);
}
Expand Down Expand Up @@ -377,7 +377,7 @@ void runGameLoop(const bpo::variables_map& variables)

FALevelGen::FAsrand(time(NULL));

std::vector<Level::Level*> levels(9);
std::vector<Level::Level*> levels(13);

int32_t currentLevel = variables["level"].as<int32_t>();

Expand Down
2 changes: 2 additions & 0 deletions components/cel/celfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ namespace Cel
palFilename = Misc::StringUtils::replaceEnd("l1.cel", "l1.pal", filename);
else if (Misc::StringUtils::startsWith(filename, "levels") && Misc::StringUtils::endsWith(filename, "l2.cel"))
palFilename = Misc::StringUtils::replaceEnd("l2.cel", "l2.pal", filename);
else if(Misc::StringUtils::endsWith(filename, "l3.cel"))
palFilename = Misc::StringUtils::replaceEnd("l3.cel", "l3.pal", filename);
else if (Misc::StringUtils::startsWith(Misc::StringUtils::lowerCase(filename), "gendata"))
palFilename = Misc::StringUtils::replaceEnd(".cel", ".pal", filename);
else
Expand Down
5 changes: 4 additions & 1 deletion components/diabloexe/diabloexe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ namespace DiabloExe

for(std::map<std::string, Monster>::const_iterator it = mMonsters.begin(); it != mMonsters.end(); ++it)
{
if(levelNum >= it->second.minDunLevel && levelNum <= it->second.maxDunLevel)
if(levelNum >= it->second.minDunLevel && levelNum <= it->second.maxDunLevel &&
it->second.monsterName != "Wyrm" && it->second.monsterName != "Cave Slug") // Exception, these monster's CEL files don't exist
{
retval.push_back(&(it->second));
}
}

return retval;
Expand Down
30 changes: 30 additions & 0 deletions resources/tilesets/l1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,36 @@ yWallEnd = 16
xDoor = 26
yDoor = 25


insideXWall = 2
insideXWallEnd = 17
insideXWallEndBack = 7
insideYWall = 1
insideYWallEnd = 16
insideYWallEndBack = 6
insideLeftCorner = 7
insideRightCorner = 6
insideBottomCorner = 3
insideTopCorner = 4

joinY = 4
joinYRightCorner = 4
joinRightCorner = 4
joinOutXRightCorner = 6
joinOutX = 19
joinOutXTopCorner = 21
joinTopCorner = 21
joinOutYTopCorner = 21
joinOutY = 18
joinOutYLeftCorner = 7
joinLeftCorner = 4
joinXLeftCorner = 4
joinX = 4
joinXBottomCorner = 6
joinBottomCorner = 4
joinYBottomCorner = 2


# upStairs values define a 3x3 block of tiles representing stairs up
upStairs1 = 22
upStairs2 = 66
Expand Down
Loading

0 comments on commit 13d7a36

Please sign in to comment.