void test_nextRoom(FILE* out, struct Map* map)
{
  int i;
  int j;
  fprintf(out, "Testing nextRoom function...\n");
  for(i = 0; i < map->rooms; ++i)
  {
    fprintf(out, "  Exits for room %d:", i);
    for(j = 0; j < map->exitsPerRoom; ++j)
    {
      fprintf(out, " %d", nextRoom(map, i, j));
    }
    fprintf(out, "\n");
  }
}
Example #2
0
void Weave::ShowWeave(CHAR_DATA & ch, const ROOM_INDEX_DATA & room)
{
    // Check for skill
    bool hasGraven(is_affected(&ch, gsn_gravenmind));
    bool gravenOnly(false);
    if (number_percent() > get_modifier(ch.affected, gsn_weavesense) && !is_an_avatar(&ch))
    {
        if (hasGraven) gravenOnly = true;
        else return;
    }

    // Check for sundered weave
    if (area_is_affected(room.area, gsn_sunderweave))
        return;

    // Check for a fount
    check_improve(&ch, NULL, gsn_weavesense, TRUE, 4);
    std::ostringstream mess;
    mess << std::hex;
    bool anyWeave(false);
    if (room.ley_group != NULL)
    {
        if (room.ley_group->HasFount() && (!gravenOnly || room.ley_group->FountOrderPower() > 0))
        {
            anyWeave = true;
            long attunedID(room.ley_group->AttunedID());
            if (attunedID != LeyGroup::Unattuned)
                mess << ((attunedID == ch.id) ? "[{WResonant{x] " : "[{WDissonant{x] ");
            
            if (gravenOnly)
               mess << "A sense of deep, humming power fills this place, marking it as a nexus of order.";
            else
            {
                // Note that founts don't get modified by normal ley modifiers
                mess << GenerateFountDescription(room.ley_group->FountOrderPower(), room.ley_group->FountPositivePower(), AdjacentLeyRooms(room, &room));
                if (IS_IMMORTAL((&ch)))
                    mess << " {c[ID: " << reinterpret_cast<unsigned long>(&room) << "]{x";
            }
            mess << "\n";
        }

        // Check for ley lines
        if (!gravenOnly)
        {
            for (unsigned int i(0); i < room.ley_group->LineCount(); ++i)
            {
                anyWeave = true;
                const LeyInfo & leyLine(room.ley_group->Line(i));
                mess << GenerateLineDescription(ApplyOrderModifiers(leyLine.OrderPower, room), ApplyPositiveModifiers(leyLine.PositivePower, room), AdjacentLeyRooms(room, leyLine.ID));
                if (IS_IMMORTAL((&ch)))
                    mess << " {c[ID: " << reinterpret_cast<unsigned long>(leyLine.ID) << "]{x";
                mess << "\n";
            }
        }
    }

    if (hasGraven)
    {
        // Graven mind can sense order founts in adjacent rooms
        for (unsigned int i(0); i < Direction::Max; ++i)
        {
            Direction::Value direction(static_cast<Direction::Value>(i));
            ROOM_INDEX_DATA * nextRoom(Direction::Adjacent(room, direction));
            if (nextRoom != NULL && nextRoom->ley_group != NULL && nextRoom->ley_group->HasFount() && nextRoom->ley_group->FountOrderPower() > 0)
            {
                anyWeave = true;
                mess << "The deep, steady thrum of an order nexus resonates " << Direction::SourceNameFor(direction) << ".\n";
            }
        }
    }

    if (anyWeave)
    {
        mess << "\n";
        send_to_char(mess.str().c_str(), &ch);
    }
}
Example #3
0
int Level::execute(Player *player, int room_no, sf::RenderWindow* window){
	current_map = load.getMap();
	load.drawMap(window);
	if (isDead(player)){
		player->dead_sound.play();
		dialogue = "DEAD"; game_state = 0;
	}
	interact_state = collision.isInteractionMap(player->characterImage.getPosition(), player->source.y);
	tile_location = collision.tile_location;
	if (interact_state != 13)
		in_contact = false;

	if (interact_state + 1 != 0){
		if (interact_state == 13){
			if (player->is_mattock){
				if (!in_contact){
					clock.restart();
					in_contact = true;
				}
				if (clock.getElapsedTime().asSeconds() > 3.5){
					count++;
					changeTile(player->source.y, sf::Vector2i(16, 0));
					if (count == 2){
						player->is_mattock = false;
						dialogue = "the mattock broke, find another tool to dig";
					}
				}
				if (count == 4){
					dialogue = "Destroy the corpse";
					changeTile(player->source.y, sf::Vector2i(12, 1));
					//game_state = 5; 

				}
			}
			else
				dialogue = "Find some tool to dig and stand still !!";
		}
		else{
			if (sf::Keyboard::isKeyPressed(sf::Keyboard::Return)){
				switch (interact_state){
				case 0:
					player->object_sound.play();
					if (room_no == 3){
						dialogue = "Drawer:\n\tKey found !!\n\n\n\n\n\n\t\t\t\t\t*Press spacebar to dismiss*";
						player->room4_lock = false;
					}
					else if (room_no == 2){
						dialogue = "june 26 1953\n\tA man killed 10 innocent people including\n\twomen and children and then committed suicide.\n\tThe Mansion has never found peace after that !\n\n\tUnfortunate things keep happening.....\n\n\t\t\t\t\t*Press spacebar to dismiss*";
					}
					else
						dialogue = "Drawer : \n\tDrawer is empty.";
					break;
				case 1:
					player->object_sound.play();
					if (room_no == 5){
						player->room6_lock = false;
					}
					if (room_no == 4)
						player->room5_lock = false;
					dialogue = "Chest:\n\tKey found !!";
					changeTile(player->source.y, sf::Vector2i(2, 1));
					break;
				case 2:
					player->object_sound.play();
					break;
				case 3:
					player->object_sound.play();
					if (room_no == 6)
						dialogue = "Police, Priest, Investigator all tried to solve \nthe mystery but none could restore the harmony.\nSome even lost their lives in doing so.\n.\n.\nSome say a Devil lives here !! ";
					break;
				case 4:
					return nextRoom(room_no, 1, player);
					break;
				case 5:
					return nextRoom(room_no, 2, player);
					break;
				case 6:
					return nextRoom(room_no, 3, player);
					break;
				case 7:
					return nextRoom(room_no, 4, player);
					break;
				case 8:
					return nextRoom(room_no, 5, player);
					break;
				case 9:
					return nextRoom(room_no, 6, player);
					break;
				case 10:
					player->object_sound.play();
					if (room_no == 3)
						dialogue = "Diary:\n\tThere are dead souls wandering in the Mansion\n\t.\n\t.\n\tSome force is stopping them to leave the place";
					else if (room_no == 4)
						dialogue = "A hint to open chest.";
					else if (room_no == 7)
						dialogue = "All attempts to save the house has failed.\nThe Devil is strongest in the next room !!\n\nI could either take petrol and burn the \nwhole house down and wish things to be alright.\n\nOr take courage and FIGHT THE DEVIL !!";
					break;
				case 11:
					player->object_sound.play();
					dialogue = "Laltern picked";
					player->is_laltern = true;
					player->room2_lock = false;
					changeTile(player->source.y, sf::Vector2i(-1, -1));
					break;
				case 12:
					player->end_sound.play();
					game_state = 5;
					break;
				case 15:
					player->object_sound.play();
					if (!player->is_mattock){
						dialogue = "Picked Mattock \nUse it to dig the ground!!";
						changeTile(player->source.y, sf::Vector2i(-1, -1));
						player->is_mattock = true;
					}
					else
						dialogue = "Bruce\n\tI already have this tool";
					break;
				case 16:
					player->object_sound.play();
					dialogue = "Picked sword !!";
					changeTile(player->source.y, sf::Vector2i(-1, -1));
					player->room8_lock = false;
					break;
				case 17:
					player->object_sound.play();
					dialogue = "Lever pulled !!";
					for (int i = 0; i < load.map.size(); i++){
						for (int j = 0; j < load.map[i].size(); j++){
							if (load.map[i][j].x == 21){
								load.map[i][j] = sf::Vector2i(21, 0);
							}
						}
					}
					changeTile(player->source.y, sf::Vector2i(17, 2));
					break;
				case 18:
					player->object_sound.play();
					dialogue = "Key Found!!";
					if (room_no == 6)player->room7_lock = false;
					changeTile(player->source.y, sf::Vector2i(-1, -1));
					break;
				case 19:
					player->object_sound.play();
					if (room_no == 7)
						dialogue = "Take your decision wisely as it may result in different endings !!";
					else if (room_no == 8)
						dialogue = "Devil's corpse is burried in the center.\n\nTake the digging tool and stand still to dig.";
					else
						dialogue = "Hint !!";
					changeTile(player->source.y, sf::Vector2i(-1, -1));
					break;
				case 20:
					player->object_sound.play();
					dialogue = "Petrol Picked !!";
					game_state = 6;

					break;
				case 21:
					dialogue = "Dead !!";
					break;
				case 22:
					dialogue = "Dead !!";
					break;
				default:dialogue = "I don't need this.";
					break;
				}
			}
		}
	}
	return room_no;
}