/*
	     * The config to remove roofs is 1270
	     * The door is 6713
	     * 
	     * Random door configs 
	     * CONFIG = 452    0
           CONFIG = 452    32
           CONFIG = 452    96
           CONFIG = 452    16480
           CONFIG = 452    278624
           CONFIG = 452    802912
           CONFIG = 452    2900064
           CONFIG = 452    2637920
           CONFIG = 452    2638944
           CONFIG = 452    2640992
           CONFIG = 452    2645088
           CONFIG = 452    2653280
           CONFIG = 452    2649184
	     */
	
	
	
	    public static bool enterCrypt(Player p) {
		    for (int i = 0; i < MOUND_COORDS.Length; i++) {
			    for (int j = 0; j < MOUND_COORDS[i].Length; j++) {
                    if (p.getLocation().inArea(MOUND_COORDS[i][0], MOUND_COORDS[i][1], MOUND_COORDS[i][2], MOUND_COORDS[i][3]) && p.getLocation().getZ() == 0)
                    {
                        p.teleport(new Location(STAIR_COORDS[i][0], STAIR_COORDS[i][1], 3));
					    if (p.getBarrowTunnel() == -1) {
						    p.setBarrowTunnel(misc.random(5));
					    }
					    return true;
				    }
			    }
		    }
		    return false;
	    }
	    protected static void getBarrowReward(Player p) {
		    int barrowChance = misc.random(BARROWS_CHANCE);
		    int killCount = p.getBarrowKillCount();
		    if (barrowChance == 0) {
			    int reward = BARROW_REWARDS[misc.random(BARROW_REWARDS.Length - 1)];
			    p.getInventory().addItemOrGround(reward);
		    }
		    if (misc.random(20) == 0) {
			    p.getInventory().addItemOrGround(1149); // Dragon med helm.
		    } else if (misc.random(15) == 0) {
			    int halfKey = misc.random(1) == 0 ? 985 : 987; 
			    p.getInventory().addItemOrGround(halfKey); // Half key.
		    }
		    if (misc.random(3) == 0 || p.getBarrowTunnel() == KARIL) { // Bolt racks.
			    int amount = getAmountOfReward(4740, killCount);
			    p.getInventory().addItemOrGround(4740, amount);
		    }
		    if (misc.random(3) == 0) { // Blood runes
			    int amount = getAmountOfReward(565, killCount);
			    p.getInventory().addItemOrGround(565, amount);
		    }
		    if (misc.random(2) == 0) { // Death runes
			    int amount = getAmountOfReward(560, killCount);
			    p.getInventory().addItemOrGround(560, amount);
		    }
		    if (misc.random(1) == 0) { // Chaos runes
			    int amount = getAmountOfReward(562, killCount);
			    p.getInventory().addItemOrGround(562, amount);
		    }
		    if (misc.random(1) == 0) { // Coins
			    int amount = getAmountOfReward(995, killCount);
			    p.getInventory().addItemOrGround(995, amount);
		    }
		    if (misc.random(1) == 0) {
			    int amount = getAmountOfReward(558, killCount); // Mind runes.
			    p.getInventory().addItemOrGround(558, amount);
		    }
	    }
	    public static bool openCoffin(Player p, int objectId) {
		    if (objectId != 6823 && objectId != 6771 && objectId != 6821 && objectId != 6773 && objectId != 6822 && objectId != 6772) {
			    return false;
		    }
		    int cryptIndex = getCryptIndex(p);
		    if (cryptIndex == -1) {
			    return false;
		    }
		    if (p.getBarrowBrothersKilled(cryptIndex)) {
			    p.getPackets().sendMessage("You don't find anything.");
			    return true;
		    }
		    if (p.getBarrowTunnel() == cryptIndex){
			    p.getPackets().modifyText("You find a hidden tunnel, do you want to enter?", 210, 1);
			    p.getPackets().sendChatboxInterface(210);
			    p.setTemporaryAttribute("barrowTunnel", 1);
			    return true;
		    }
		    foreach(Npc n in Server.getNpcList()) {
			    if (n.getId() == BROTHER_ID[cryptIndex]) {
				    if (n.getOwner().Equals(p)) {
					    p.getPackets().sendMessage("You don't find anything.");
					    return true;
				    }
			    }
		    }
		    Npc npc = new Npc(BROTHER_ID[cryptIndex]);
		    npc.setLocation(p.getLocation());
		    npc.setEntityFocus(p.getClientIndex());
		    npc.setOwner(p);
		    npc.setTarget(p);
		    npc.setCombatTurns(npc.getAttackSpeed());
		    Server.getNpcList().Add(npc);
		    p.getPackets().setArrowOnEntity(1, npc.getClientIndex());
		    return true;
	    }