bool MapGenTrapezohedronLvl::specificRun() { eng->map->clearMap(); for(int y = 0; y < MAP_Y_CELLS; y++) { for(int x = 0; x < MAP_X_CELLS; x++) { eng->featureFactory->spawnFeatureAt(feature_stoneWall, Pos(x, y)); dynamic_cast<Wall*>(eng->map->featuresStatic[x][y])->wallType = wall_cave; } } makePathByRandomWalk( eng->player->pos.x, eng->player->pos.y, 150, feature_caveFloor, true); makePathByRandomWalk( MAP_X_CELLS_HALF, MAP_Y_CELLS_HALF, 800, feature_caveFloor, true); makeStraightPathByPathfinder( eng->player->pos, Pos(MAP_X_CELLS_HALF, MAP_Y_CELLS_HALF), feature_caveFloor, false, true); bool blockers[MAP_X_CELLS][MAP_Y_CELLS]; eng->mapTests->makeMoveBlockerArrayForBodyTypeFeaturesOnly( actorBodyType_normal, blockers); vector<Pos> spawnCandidates; spawnCandidates.resize(0); for(int y = 0; y < MAP_Y_CELLS; y++) { for(int x = 0; x < MAP_X_CELLS; x++) { if(blockers[x][y] == false && Pos(x, y) != eng->player->pos) { spawnCandidates.push_back(Pos(x, y)); } } } const int ELEMENT = eng->dice.range(0, spawnCandidates.size() - 1); eng->itemFactory->spawnItemOnMap( item_trapezohedron, spawnCandidates.at(ELEMENT)); return true; }
void MapBuild::makeStraightPathByPathfinder(const coord origin, const coord target, Feature_t feature, const bool SMOOTH, const bool TUNNEL_THROUGH_ANY_FEATURE) { bool blockers[MAP_X_CELLS][MAP_Y_CELLS]; eng->basicUtils->resetBoolArray(blockers, false); vector<coord> path = eng->pathfinder->findPath(origin, blockers, target); for(unsigned int i = 0; i < path.size(); i++) { const coord c = path.at(i); if(eng->map->featuresStatic[c.x][c.y]->canHaveStaticFeature() || TUNNEL_THROUGH_ANY_FEATURE) { eng->featureFactory->spawnFeatureAt(feature, c); if(SMOOTH == false && eng->dice(1, 100) < 33) { makePathByRandomWalk(c.x, c.y, eng->dice(1, 6), feature, true); } } } }