Room build_room(IntPoint tl, IntPoint br, dungeon_meta& dm) { set_wall_if_not_path(tl.row, tl.col, dm); set_wall_if_not_path(tl.row, br.col, dm); set_wall_if_not_path(br.row, tl.col, dm); set_wall_if_not_path(br.row, br.col, dm); //draw top and bottom rows for(int i = tl.col + 1; i <= br.col - 1; i++) { set_wall_if_not_path(tl.row, i, dm); set_wall_if_not_path(br.row, i, dm); } //draw left and right ROOM_WALLs for(int i = tl.row + 1; i <= br.row - 1; i++) { set_wall_if_not_path(i, tl.col, dm); set_wall_if_not_path(i, br.col, dm); } std::unordered_map<std::string, Tile>* tileset = &Tileset::instance()->get_tileset(); for(int i = tl.row + 1; i <= br.row - 1; i++) { for(int j = tl.col + 1; j <= br.col - 1; j++) { dm.main_dungeon->set_tile(i, j, (*tileset)["DIRT"]); } } dm.main_dungeon->rooms[dm.num_rooms] = Room(tl, br); dm.num_rooms++; return Room(tl, br); }
Room Pickup::CurrentRoom::get() { NON_EXISTING_CHECK(Room(0,0)); //Scripting::eInterior ii; u32 rk; //Scripting::GetInteriorFromPickup(pHandle,&ii); Scripting::GetRoomKeyFromPickup(pHandle,&rk); return Room(force_cast<int>(rk),force_cast<int>(0)); }
bool SimpleDungeonMapGenerator::CreateRoom(Map* theMap,Vec2i location,Vec2i halfSize) { Vec2f aabbMin = Vec2f( (float)(location.x - halfSize.x), (float)(location.y - halfSize.y)); Vec2f aabbMax = Vec2f( (float)(location.x + halfSize.x), (float)(location.y + halfSize.y)); AABB2 newRoom(aabbMin,aabbMax); for(size_t index = 0; index < m_roomList.size(); index++) { Room currentRoom = m_roomList[index]; if(currentRoom.m_aabb.isOverlap(&newRoom))// && currentRoom.m_overlapTime > m_overlapLimit) return false; } m_roomList.push_back(Room(newRoom,0)); for(int x = location.x - halfSize.x; x < location.x + halfSize.x; x++) { for(int y = location.y - halfSize.y; y < location.y + halfSize.y; y++) { theMap->SetCellType(x,y,AIR); } } return true; }
bool can_pkill( char_data* ch, char_data* victim, bool msg ) { room_data* room = Room( ch->array->where ); if( room != NULL ) { if( is_set( &room->room_flags, RFLAG_ARENA ) ) return TRUE; if( is_set( &room->room_flags, RFLAG_NO_PKILL ) ) { if( msg ) send( ch, "You can't kill players here.\r\n" ); return FALSE; } } if( victim == NULL ) return TRUE; if( ch->shdata->race <= RACE_LIZARD && victim->shdata->race <= RACE_LIZARD ) { if( msg ) { const char* race = plyr_race_table[ victim->shdata->race ].name; send( ch, "You would never kill a%s %s.\r\n", isvowel( *race ) ? "n" : "", race ); } return FALSE; } return TRUE; }
TEST(movePlayerTest, textGameLoop){ Player myPlayer = Player("steve"); textGameLoop tGL = textGameLoop(&myPlayer); Room r = Room("test room", "a big spooky dungeon"); tGL.movePlayer("test room"); CHECK_EQUAL("test room", myPlayer.pGetCurrentLocation()->getName()); };
bool in_sanctuary( char_data* ch, bool msg ) { room_data* room = Room( ch->array->where ); if( room != NULL && is_set( &room->room_flags, RFLAG_SAFE ) ) { if( msg ) send( ch, "You are in a sanctuary.\r\n" ); return TRUE; } return FALSE; }
TEST(getRoomTest, textGAmeLoop){ Player myPlayer = Player("steve"); textGameLoop tGL = textGameLoop(&myPlayer); Room r = Room("test room", "a big spooky dungeon"); myPlayer.goTo(&r); tGL.addRoom(&r); Room* s = tGL.getRoom("test room"); CHECK_EQUAL("a big spooky dungeon", s->getPrompt()); };
void MapGenerator::CreateRoom(const Position &a, const Position &b) { // add the room to the rooms list rooms.push_back(Room()); rooms.back().a = a; rooms.back().b = b; // carve out the floorspace int x; for (x = a.x; x < b.x; x++) { memset(&map[x][a.y], '.', b.y-a.y); } }
TEST(textGameLoopRoomPromptTest, textGameLoop){ Player myPlayer = Player("steve"); textGameLoop tGL = textGameLoop(&myPlayer); Room r = Room("test room", "a big spooky dungeon"); myPlayer.goTo(&r); CHECK_EQUAL("test room", myPlayer.pGetCurrentLocation()->getName()); r.addCommand("func1", tglFunc); r.addCommand("func2", tglFunc2); r.addCommand("func3", tglFunc3); //tGL.outputRoomPrompt(); //a big spooky dungeon //tGL.outputRoomCommands(); //func1\nfunc2\nfunc3\n };
void death_cry( char_data* ch ) { room_data* room; char* msg; if( ( room = Room( ch->array->where ) ) == NULL ) return; msg = ch->species ? "You hear something's death cry.\n\r" : "You hear someone's death cry.\n\r"; for( int i = 0; i < room->exits; i++ ) send( room->exits[i]->to_room->contents, msg ); if( is_set( &ch->status, STAT_FAMILIAR ) && ch->leader != NULL ) send( ch->leader, "You sense your familiars death!\n\r" ); }
void register_death( char_data* victim, char_data* ch, char* dt ) { char tmp1 [ TWO_LINES ]; char tmp2 [ TWO_LINES ]; mprog_data* mprog; int exp; if( victim->species != NULL ) { if( is_set( &victim->status, STAT_PET ) && victim->leader != NULL && victim->leader->pcdata != NULL ) { sprintf( tmp1, "%s killed by %s at %s. (Pet)", victim->Name( ), ch == NULL ? dt : ch->Name( ), victim->array->where->Location( ) ); player_log( victim->leader, tmp1 ); } for( mprog = victim->species->mprog; mprog != NULL; mprog = mprog->next ) if( mprog->trigger == MPROG_TRIGGER_DEATH ) { var_mob = victim; var_ch = ch; var_room = Room( victim->array->where ); execute( mprog ); } return; } sprintf( tmp1, "%s killed by %s.", victim->Name( ), ch == NULL ? dt : ch->Name( ) ); sprintf( tmp2, "%s killed by %s at %s.", victim->Name( ), ch == NULL ? dt : ch->Name( ), victim->array->where->Location( ) ); info( tmp1, LEVEL_APPRENTICE, tmp2, IFLAG_DEATHS, 1, victim ); exp = death_exp( victim, ch ); add_exp( victim, -exp, "You lose %d exp for dying.\n\r" ); sprintf( tmp1, "Killed by %s at %s.", ch == NULL ? dt : ch->real_name( ), victim->array->where->Location( ) ); player_log( victim, tmp1 ); if( ch != NULL && ch->pcdata != NULL ) { sprintf( tmp1, "Pkilled %s at %s.", victim->real_name( ), victim->array->where->Location( ) ); player_log( ch, tmp1 ); } }
TEST(textGameLoopInitTest, textGameLoop){ Player myPlayer = Player("steve"); textGameLoop tGL = textGameLoop(&myPlayer); Room r = Room("test room", "a big spooky dungeon"); myPlayer.goTo(&r); CHECK_EQUAL("test room", myPlayer.pGetCurrentLocation()->getName()); r.addCommand("func1", tglFunc); r.addCommand("func2", tglFunc2); r.addCommand("func3", tglFunc3); fptr command1pointer = myPlayer.pGetCurrentLocation()->getCommand("func1"); (*command1pointer)(); CHECK_EQUAL("tglFunc called.", tglFuncOutput); };
thing_data* Char_Data :: From( int ) { room_data* room; in_room = NULL; if( ( room = Room( array->where ) ) != NULL ) { if( pcdata != NULL ) room->area->nplayer--; stop_fight( this ); stop_events( this, execute_drown ); } Thing_Data :: From( ); return NULL; }
void gameLogic() { if (gameState == GAME_LOADING) { systemSound->endLevel(); cout << "loading" << endl; room = Room(); room.setLevel(gameLevel); ruskoBounds->setRoom(&room); collisions = new RuskoCollisions(&room); plights.clear(); setTorchLight(xpos, ypos, zpos, ruskoTorchRadius); gameState = GAME_LSCREEN; } else if (gameState == GAME_RUNNING) { if(dead) { livesLeft--; respawn(); } collisions->checkForCollisions(); renderList.push_back((Renderable *)&room); if (collisions->torchesAllLit) { gameLevel++; gameState = GAME_LOADING; } } else if (gameState == GAME_LSCREEN) { if (firstLoad){ loadscreen->renderWelcomeScreen(); } else if (livesLeft == 0) { loadscreen->renderGameOver(); } else { resetGameVariables(); loadscreen->render(gameLevel, room.getNumTorches()); } } }
// return a memory node of size n halfword_t GetAvail(halfword_t n) { halfword_t x; Room(n); /* while (Avail!=NADA) { // first, search in the list of freed nodes of size n x=Avail; Avail=Mem[Avail].ll.link; if (Mem[x].ll.info==n) return x; } // if not found, then allocate a new one */ x=LoMemMax; LoMemMax+=n; return x; }
void ChunkLayer::clear() { rooms = std::vector<Room>(MAX_ROOMS, Room(IntPoint(-6, -6), IntPoint(-6, -6))); num_rooms=0; down_stairs = std::vector<IntPoint>(); up_stairs = std::vector<IntPoint>(); items = std::vector<Item*>(); spawners = std::vector<Spawner>(); plants = std::vector<Plant>(); buildings = std::vector<Building>(); characters = std::vector<Character*>(); tileset = &Tileset::instance()->get_tileset(); for(int i = 0; i < height; i++) { for(int j = 0; j < width; j++) { ground[i][j] = (*tileset)["BLOCK_WALL"]; } } }
ChunkLayer::ChunkLayer(int _width, int _height) { tileset = &Tileset::instance()->get_tileset(); width = _width; height = _height; ground = TileMatrix(height, std::vector<Tile>(width, (*tileset)["EMPTY"])); rooms = std::vector<Room>(MAX_ROOMS, Room(IntPoint(-6, -6), IntPoint(-6, -6))); num_rooms = 0; items = std::vector<Item*>(); spawners = std::vector<Spawner>(); plants = std::vector<Plant>(); buildings = std::vector<Building>(); characters = std::vector<Character*>(); for(int i = 0; i < _height; i++) { for(int j = 0; j < _width; j++) { ground[i][j] = (*tileset)["BLOCK_WALL"]; } } }
TEST(textGameLoopBeginTest, textGameLoop){ Player myPlayer = Player("steve"); textGameLoop tGL = textGameLoop(&myPlayer); Room r = Room("test room", "a big spooky dungeon"); tGL.addRoom(&r); tGL.movePlayer("test room"); CHECK_EQUAL("test room", myPlayer.pGetCurrentLocation()->getName()); r.addCommand("func1", tglFunc); r.addCommand("func2", tglFunc2); r.addCommand("func3", tglFunc3); fptr command1pointer; command1pointer = myPlayer.pGetCurrentLocation()->getCommand("func1"); tGL.begin(); };
void Lobby::Init(const short lobbyIndex, const short maxLobbyUserCount, const short maxRoomCountByLobby, const short maxRoomUserCount) { m_LobbyIndex = lobbyIndex; m_MaxUserCount = (short)maxLobbyUserCount; for (int i = 0; i < maxLobbyUserCount; ++i) { LobbyUser lobbyUser; lobbyUser.Index = (short)i; lobbyUser.pUser = nullptr; m_UserList.push_back(lobbyUser); } for (int i = 0; i < maxRoomCountByLobby; ++i) { m_RoomList.emplace_back(Room()); m_RoomList[i].Init((short)i, maxRoomUserCount); } }
World::World(int minRooms, int maxRooms, int minRoomArea, int maxRoomArea, int minMonstersPerRoom, int maxMonstersPerRoom, int rows, int cols) { int roomCount=rand()%(maxRooms-minRooms+1)+minRooms; for(int i=1; i<=roomCount; i++) { int roomArea=rand()%(maxRoomArea-minRoomArea+1)+minRoomArea; //Generating exact measures from area int roomRowDivisor=roomArea/4-4; //4=2 wall and 2 floor tiles //Making roomRows minimum 4, maximum roomArea/4 (so that roomCols can be at least 4 as well) int roomRows=4; if(roomRowDivisor!=0) { roomRows+=rand()%roomRowDivisor; } int roomCols=roomArea/roomRows; /*clear(); printw((to_string(roomRows)+ " " +to_string(roomCols)+ " " +to_string(roomArea)).c_str()); refresh();*/ int monsterCount=rand()%(maxMonstersPerRoom-minMonstersPerRoom+1)+minMonstersPerRoom; int y; int x; do { y=rand()%(rows-roomRows); x=rand()%(cols-roomCols); roomOverlaps(y, x, roomRows, roomCols); } while(roomOverlaps(y, x, roomRows, roomCols)); rooms_.push_back(Room(y, x, roomRows, roomCols, monsterCount)); } //clear(); //printw("DONE"); }
void Obj_Data :: To( content_array* where ) { event_data* event; room_data* room; char_data* ch; obj_data* obj; int i; if( array != NULL ) { roach( "Adding object somewhere which isn't nowhere." ); roach( "-- Obj = %s", this ); From( number ); } if( ( room = Room( where->where ) ) != NULL ) { if( pIndexData->item_type == ITEM_CORPSE && value[0] > 0 ) { event = new event_data( execute_decay, this ); add_queue( event, value[0] ); } } if( ( ch = character( where->where ) ) != NULL && where == &ch->wearing ) { equip( ch, this ); for( i = 0; i < ch->wearing; i++ ) { obj = (obj_data*) ch->wearing[i]; if( obj->position > position || ( obj->position == position && obj->layer > layer ) ) break; } insert( *where, this, i ); array = where; } Thing_Data :: To( where ); }
void ChunkLayer::swap(const ChunkLayer& l) { ground = l.ground; width = l.width; height = l.height; down_stairs = l.down_stairs; up_stairs = l.up_stairs; /** * \todo this is weird as balls */ rooms = std::vector<Room>(MAX_ROOMS, Room(IntPoint(-6, -6), IntPoint(-6, -6))); num_rooms = l.num_rooms; spawners = l.spawners; items = l.items; /// \todo There was a segfault here. This may have fixed it, but maybe not. plants = std::vector<Plant>(l.plants.size()); buildings = l.buildings; characters = l.characters; for(int i = 0; i < l.plants.size(); i++) { plants[i] = l.plants[i]; } for(int i = 0; i < l.num_rooms; i++) { this->rooms[i] = l.rooms[i]; } }
void Semester::AddRoom(string name){ rooms.push_back(Room(name)); }
bool Map::addNextConnectingRoom(bool first, queue<int> & connectionsX, queue<int> & connectionsY, queue<int> & connectionsDir){ if(!first && connectionsX.empty()) return false; // make initial estimates of size and position int roomW = FLOOR_TILE_SIZE*(3+rand()%15); int roomH = FLOOR_TILE_SIZE*(3+rand()%15); int roomX = first ? -roomW/2 : connectionsX.front(); int roomY = first ? -roomH/2 : connectionsY.front(); // pick type of room and doorway locations int tileX = rand()%2; int tileH = (tileX) ? 4 : 6; int doorways[4]; for(int i=0; i<4; ++i) doorways[i] = (i==DIRECTION_UP || i==DIRECTION_DOWN) ? rand()%(roomW/FLOOR_TILE_SIZE-2)+1 : rand()%(roomH/FLOOR_TILE_SIZE-2)+1; // adjust position based on where connection with previous room is int dir = -1; if(!first){ int offset; switch(dir = connectionsDir.front()){ case DIRECTION_RIGHT: offset = rand()%(roomH/FLOOR_TILE_SIZE-2) + 1; roomY -= offset*FLOOR_TILE_SIZE; doorways[DIRECTION_LEFT] = -1;//offset; break; case DIRECTION_LEFT: roomX -= roomW; offset = rand()%(roomH/FLOOR_TILE_SIZE-2) + 1; roomY -= offset*FLOOR_TILE_SIZE; doorways[DIRECTION_RIGHT] = -1;//offset; break; case DIRECTION_DOWN: roomY -= roomH; offset = rand()%(roomW/FLOOR_TILE_SIZE-2) + 1; roomX -= offset*FLOOR_TILE_SIZE; doorways[DIRECTION_UP] = -1;//offset; break; case DIRECTION_UP: offset = rand()%(roomW/FLOOR_TILE_SIZE-2) + 1; roomX -= offset*FLOOR_TILE_SIZE; doorways[DIRECTION_DOWN] = -1;//offset; break; } connectionsX.pop(); connectionsY.pop(); connectionsDir.pop(); } static int numRooms=0; // make room unless it overlaps a prior room if(!thoroughIsInMap(roomX, roomY, roomW, roomH)){ rooms.push_back(Room(roomX, roomY, roomW, roomH, "floor.bmp", tileX, 0, 1, tileH, doorways)); ++numRooms; // add some actual doorways if(doorways[DIRECTION_UP]>0 && rand()%2==0){ Entity tmp(roomX+doorways[DIRECTION_UP]*FLOOR_TILE_SIZE, roomY+roomH-FLOOR_TILE_SIZE, DOORWAY_WIDTH, DOORWAY_HEIGHT, 5, string("door.bmp"), 1, 2, false); rooms.back().addObject(tmp); } if(doorways[DIRECTION_DOWN]>0 && rand()%2==0){ Entity tmp(roomX+doorways[DIRECTION_DOWN]*FLOOR_TILE_SIZE, roomY, DOORWAY_WIDTH, DOORWAY_HEIGHT, 5, string("door.bmp"), 1, 2, false); rooms.back().addObject(tmp); } // prepare for next rooms (save location of doorways) for(int i=0; i<4; ++i){ if(doorways[i] >= 0 && (((i==DIRECTION_RIGHT || i==DIRECTION_LEFT) && doorways[i]<roomH/FLOOR_TILE_SIZE) || ((i==DIRECTION_UP || i==DIRECTION_DOWN) && doorways[i]<roomW/FLOOR_TILE_SIZE))){ connectionsX.push(i==DIRECTION_RIGHT ? roomX+roomW : (i==DIRECTION_LEFT ? roomX : roomX+FLOOR_TILE_SIZE*doorways[i])); connectionsY.push(i==DIRECTION_UP ? roomY+roomH : (i==DIRECTION_DOWN ? roomY : roomY+FLOOR_TILE_SIZE*doorways[i])); connectionsDir.push(i); } } } if(numRooms>20 || connectionsX.empty()){ //cout<<numRooms<<endl; return false; } else return true; }
void Level::addRoom() { int centerX, centerY, locX, locY, sizeX, sizeY; bool invalidRoom; Coord location,center; Dimension size; do { invalidRoom = false; //Create random room size sizeX = (rand() % (MAX_ROOM_SIZE - MIN_ROOM_SIZE) + MIN_ROOM_SIZE); sizeY = (rand() % (MAX_ROOM_SIZE - MIN_ROOM_SIZE) + MIN_ROOM_SIZE); size = Dimension(sizeX,sizeY); //Create random room location locX = (rand() % (LEVEL_SIZE_X - sizeX)+1); locY = (rand() % (LEVEL_SIZE_Y - sizeY)+1); location = Coord(locX,locY); //Pick a square in the room to be the "Center" of the room. May be anywhere in the room centerX = (rand() % sizeX) + locX; centerY = (rand() % sizeY) + locY; center = Coord(centerX,centerY); //Check to see if the room is on the edge of the map if ((location.x + size.x + 2) >= levelSizeX) { invalidRoom = true; } if ((location.y + size.y + 2) >= levelSizeY) { invalidRoom = true; } //Make sure a room isn't smashed into another room for (int i = location.x-1; i < (location.x+size.x+1); i++) { for (int j = location.y-1; j < (location.y+size.y+1); j++) { if (squares[i][j].getType() == FLOOR) invalidRoom = true; } } } while (invalidRoom); //When we've found a valid place and size to put a room, add it. rooms.push_back(Room(center,size,location)); //Convert squares that are in the new room into floor squares for (int i = location.x; i < (location.x+size.x); i++) { for (int j = location.y; j < (location.y+size.y); j++) { squares[i][j].setType(FLOOR); } } //Testing where the room centers are /* for (int i = 0; i < rooms.size(); i++) { squares[rooms[i].centerX][rooms[i].centerY].setType(DOOR_CLOSED); } */ }
int Dungeon::Step() { int count = static_cast<int>(m_Rooms.size()); if (m_State == State::CreateRooms) { if (count < RoomCount) { float radius = 150.0f; Vector2i position; GetPositionInCircle(radius, position); Vector2i dimensions; dimensions.X = m_Random.NextInt(4, 12); dimensions.Y = m_Random.NextInt(4, 12); m_Rooms.push_back(Room( position, dimensions, m_Random.NextInt(50, 250), m_Random.NextInt(50, 250), m_Random.NextInt(50, 250) )); } else { m_State = State::SeparateRooms; } } else if (m_State == State::SeparateRooms) { bool hasCollisions = false; for (int i = 0; i < count; ++i) { for (int j = 0; j < count; ++j) { if (i == j) continue; const Vector2i& positionA = m_Rooms[i].GetPosition(); const Vector2i& dimensionsA = m_Rooms[i].GetDimensions(); const Vector2i& positionB = m_Rooms[j].GetPosition(); const Vector2i& dimensionsB = m_Rooms[j].GetDimensions(); Vector2i vector; if (Math::Intersect(positionA, dimensionsA, positionB, dimensionsB, vector)) { int size = static_cast<int>(fmaxl(vector.X, vector.Y)) / Tile::Size; int adj = (size % 2 != 0) ? 1 : 0; if (vector.X != 0) { m_Rooms[i].Move((size / 2) * Tile::Size, 0); m_Rooms[j].Move((size / 2 + adj) * -Tile::Size, 0); } else if (vector.Y != 0) { m_Rooms[i].Move(0, (size / 2) * Tile::Size); m_Rooms[j].Move(0, (size / 2 + adj) * -Tile::Size); } hasCollisions = true; } } } if (!hasCollisions) { m_State = State::PickRooms; } } else if (m_State == State::PickRooms) { } else if (m_State == State::Triangulation) { } else if (m_State == State::MinimumSpanningTree) { } else if (m_State == State::CreateHallways) { } return 0; }
void Char_Data :: To( content_array* where ) { room_data* room; wizard_data* imm; char_data* rch; if( array != NULL ) { roach( "Adding character somewhere which isn't nowhere." ); roach( "-- Ch = %s", this ); From( number ); } Thing_Data :: To( where ); /* CHARACTER TO ROOM */ if( ( room = Room( where->where ) ) != NULL ) { room_position = -1; in_room = room; if( pcdata != NULL ) room->area->nplayer++; if( ( imm = wizard( this ) ) != NULL ) { imm->custom_edit = 0; imm->room_edit = NULL; imm->action_edit = NULL; imm->exit_edit = NULL; } if( water_logged( room ) ) { remove_bit( &status, STAT_SNEAKING ); remove_bit( &status, STAT_HIDING ); remove_bit( &status, STAT_CAMOUFLAGED ); remove_bit( affected_by, AFF_HIDE ); remove_bit( affected_by, AFF_CAMOUFLAGE ); } if( is_submerged( this ) ) enter_water( this ); for( int i = 0; i < room->contents; i++ ) { if( ( rch = character( room->contents[i] ) ) == NULL || rch == this ) continue; if( rch->species != NULL && species != NULL && rch->species->group == species->group && rch->species->group != GROUP_NONE ) { share_enemies( this, rch ); share_enemies( rch, this ); } if( is_aggressive( this, rch ) ) init_attack( this, rch ); if( is_aggressive( rch, this ) ) init_attack( rch, this ); } return; } roach( "Attempted transfer of character to non-room object." ); }
void RoomManager::RoomCreate(string name, int stage, int id) { if (CurrentRoomCount < 100) { RoomVector.push_back(Room(name, stage, id)); CurrentRoomCount++; } }
void TileGrid::SpawnRooms(std::vector<std::vector<TileStatus>> &tiles) { tiles.resize(WORLDSIZE); for (int y = 0; y < WORLDSIZE; y++) { tiles.at(y).resize(WORLDSIZE, WALL); } // level-sides are unbuildable for (int x = 0; x < WORLDSIZE; x++) { tiles.at(0).at(x) = UNBUILDABLE; } for (int y = 1; y < WORLDSIZE - 1; y++) { tiles.at(y).at(0) = UNBUILDABLE; tiles.at(y).at(WORLDSIZE - 1) = UNBUILDABLE; } for (int x = 0; x < WORLDSIZE; x++) { tiles.at(WORLDSIZE - 1).at(x) = UNBUILDABLE; } // Randomly choose how many rooms to place int numberOfRooms = (rand() % 20) + 20; // Start spawning rooms for (int room = 0; room < numberOfRooms; room++) { int roomSize = (rand() % 3) + 2; int tries = 0; bool success; // Try to place a room 10 times or until successful, whatever comes first do { success = true; int midX = (rand() % (WORLDSIZE - roomSize * 2 - 2)) + roomSize + 1; int midY = (rand() % (WORLDSIZE - roomSize * 2 - 2)) + roomSize + 1; for (int y = midY - roomSize; y <= midY + roomSize; y++) { for (int x = midX - roomSize; x <= midX + roomSize; x++) { if (tiles.at(y).at(x) != WALL) { success = false; break; } } } if (success) { //Make the corners of the room unbuildable tiles.at(midY - roomSize - 1).at(midX - roomSize - 1) = UNBUILDABLE; tiles.at(midY - roomSize - 1).at(midX + roomSize + 1) = UNBUILDABLE; tiles.at(midY + roomSize + 1).at(midX - roomSize - 1) = UNBUILDABLE; tiles.at(midY + roomSize + 1).at(midX + roomSize + 1) = UNBUILDABLE; //Make the walls //Northen and southern walls for (int x = midX - roomSize; x <= midX + roomSize; x++) { if (tiles.at(midY - roomSize - 1).at(x) != UNBUILDABLE) { tiles.at(midY - roomSize - 1).at(x) = ROOMWALL; } if (tiles.at(midY + roomSize + 1).at(x) != UNBUILDABLE) { tiles.at(midY + roomSize + 1).at(x) = ROOMWALL; } } //Side walls for (int y = midY - roomSize; y < midY + roomSize + 1; y++) { if (tiles.at(y).at(midX - roomSize - 1) != UNBUILDABLE) { tiles.at(y).at(midX - roomSize - 1) = ROOMWALL; } if (tiles.at(y).at(midX + roomSize + 1) != UNBUILDABLE) { tiles.at(y).at(midX + roomSize + 1) = ROOMWALL; } } //Room for (int y = midY - roomSize; y <= midY + roomSize; y++) { for (int x = midX - roomSize; x <= midX + roomSize; x++) { tiles.at(y).at(x) = ROOM; } } m_rooms.push_back(Room(midX, midY, roomSize)); m_connected.push_back(false); } else { tries++; } } while (tries < 10 && !success); } }
bool can_die( char_data* victim ) { obj_data* obj; room_data* room; if( victim->species != NULL ) return TRUE; if( ( room = Room( victim->array->where ) ) != NULL && is_set( &room->room_flags, RFLAG_ARENA ) ) { send( *victim->array, "In a flash of light %s disappears.\n\r", victim ); victim->hit = 1; update_pos( victim ); victim->From( ); victim->To( get_temple( victim ) ); dismount( victim ); victim->position = POS_RESTING; return FALSE; } if( victim->shdata->level >= LEVEL_BUILDER ) { fsend_seen( victim, "The body of %s slowly fades out of existence.", victim ); fsend( *victim->array, "A swirling mist appears and %s slowly reforms.", victim ); send( victim, "You find yourself alive again.\n\r" ); victim->hit = victim->max_hit; update_max_move( victim ); update_pos( victim ); return FALSE; } for( int i = 0 ; ; i++ ) { if( i >= victim->affected ) { for( int j = 0; ; j++ ) { if( j >= victim->wearing ) return TRUE; obj = (obj_data*) victim->wearing[j]; if( is_set( obj->pIndexData->affect_flags, AFF_LIFE_SAVING ) ) break; } fsend( *victim->array, "%s that %s was wearing starts to glow a deep purple!", obj, victim ); fsend_seen( victim, "The body of %s slowly disappears!", victim ); obj->Extract( 1 ); break; } if( victim->affected[i]->type == AFF_LIFE_SAVING && number_range( 0, 100 ) > 60-2*victim->affected[i]->level ) { send_seen( victim, "%s disappears in an explosion of light and energy.\n\r", victim ); break; } } victim->From( ); remove_affect( victim ); remove_leech( victim ); rejuvenate( victim ); victim->To( get_temple( victim ) ); dismount( victim ); victim->position = POS_RESTING; send_seen( victim, "%s slowly materializes.\n\rFrom %s appearance\ %s obviously came close to death.\n\r", victim, victim->His_Her( ), victim->He_She( ) ); send( victim, "You wake up confused and dazed, but seem alive despite\ your memories.\n\r" ); return FALSE; }