Exemplo n.º 1
0
        public void handlePacket(Player player, Packet packet) {
		    int size = packet.getLength();
		    if(packet.getPacketId() == PacketHandlers.PacketId.WALK_2) {
			    size -= 14;
		    }
            player.getWalkingQueue().resetWalkingQueue();
		    int steps = (size - 5) / 2;

            if (steps > WalkingQueue.MAX_WALKING_WAYPOINTS)
            {
                misc.WriteError("Warning: Walk command contains too many steps (" + steps + ") currently set to 50 [maybe need increase?]");
                return;
            }

            player.getWalkingQueue().setIsRunning(packet.readByteA() == 1);
		    bool following = false;
            if (!canWalk(player, packet, following))
            {
                player.getPackets().clearMapFlag();
                player.getWalkingQueue().resetWalkingQueue();
                return;
            }

            int firstX = packet.readUShort() - (player.getLocation().getRegionX() - 6) * 8;
            int firstY = packet.readShortA() - (player.getLocation().getRegionY() - 6) * 8;
		    player.getWalkingQueue().addToWalkingQueue(firstX, firstY);

            for (int i = 0; i < steps; i++) //all the waypoints.
                player.getWalkingQueue().addToWalkingQueue((packet.readByteA() + firstX), (packet.readByteS() + firstY));

            if (player.getTeleportTo() != null) //is teleporting?
                player.getWalkingQueue().resetWalkingQueue();


		    if (player.getTemporaryAttribute("homeTeleporting") != null) {
			    player.removeTemporaryAttribute("homeTeleporting");
		    }
		    SkillHandler.resetAllSkills(player);
		    if (player.getTrade() != null)
			    player.getTrade().decline();
            if (player.getDuel() != null) {
                if (player.getDuel().getStatus() < 4)
                    player.getDuel().declineDuel();
                else if (player.getDuel().getStatus() == 8)
                    player.getDuel().recieveWinnings(player);
            }
			if (player.getTarget() != null) {
				if (!following && player.getTarget().getAttacker() != null && player.getTarget().getAttacker().Equals(player))
					player.getTarget().setAttacker(null);
			}		    
            
            if (!following) {
			    player.getFollow().setFollowing(null);
				player.setTarget(null);
				player.removeTemporaryAttribute("autoCasting");
			    if (player.getEntityFocus() != 65535)
				    player.setEntityFocus(65535);
		    }
		    player.getPackets().closeInterfaces();
	    }
Exemplo n.º 2
0
        private bool duelRuleActive(ItemData.EQUIP equipType)
        {
            if (player.getDuel() == null)
            {
                return(false);
            }
            if (player.getDuel().getStatus() == 5 || player.getDuel().getStatus() == 6)
            {
                ItemData.EQUIP[] slot = { ItemData.EQUIP.HAT,    ItemData.EQUIP.CAPE,  ItemData.EQUIP.AMULET,
                                          ItemData.EQUIP.WEAPON, ItemData.EQUIP.CHEST, ItemData.EQUIP.SHIELD,
                                          ItemData.EQUIP.LEGS,   ItemData.EQUIP.HANDS, ItemData.EQUIP.FEET,
                                          ItemData.EQUIP.RING,   ItemData.EQUIP.ARROWS };

                DuelSession.RULE[] rule = { DuelSession.RULE.HAT,    DuelSession.RULE.CAPE,   DuelSession.RULE.AMULET,
                                            DuelSession.RULE.WEAPON, DuelSession.RULE.BODY,   DuelSession.RULE.SHIELD,
                                            DuelSession.RULE.LEGS,   DuelSession.RULE.GLOVES, DuelSession.RULE.BOOTS,
                                            DuelSession.RULE.RING,   DuelSession.RULE.ARROWS };
                for (int j = 0; j < rule.Length; j++)
                {
                    if (player.getDuel().ruleEnabled(rule[j]))
                    {
                        if (equipType == slot[j])
                        {
                            player.getPackets().sendMessage("You cannot equip that item in this duel.");
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
	    private void handleEnterAmount(Player player, Packet packet) {
		    if (player.getTemporaryAttribute("interfaceVariable") == null) {
			    player.getPackets().sendMessage("An error occured, please try again.");
			    return;
		    }
		    EnterVariable var = (EnterVariable) player.getTemporaryAttribute("interfaceVariable");
		    int craftType = (int) (player.getTemporaryAttribute("craftType") == null ? -1 : (int) player.getTemporaryAttribute("craftType")); // 'Category' of item to craft
		    int amount = packet.readInt();
		    switch(var.getInterfaceId()) {
			    case 675: // Jewellery crafting
				    Jewellery.makeJewellery(player, var.getSlot(), amount, true);
				    break;
				
			    case 304: // Dragonhide crafting.
				    int leatherType = (int) (player.getTemporaryAttribute("leatherCraft") == null ? -1 : (int) player.getTemporaryAttribute("leatherCraft")); // Type of leather to craft.
				    switch (var.getSlot()) {
					    case 0:
						    if (leatherType != -1) {
							    Leather.craftDragonHide(player, 1, 0, leatherType, true); // Body
							    break;
						    } else if (craftType == 6) { // Ball of wool
							    Spinning.craftSpinning(player, amount, 0, true);
							    break;
						    }
						    break;
						
					    case 1:
						    if (craftType == 6) { // Bowstring
							    Spinning.craftSpinning(player, amount, 1, true);
							    break;
						    }
						    break;
						
					    case 2:
						     if (craftType == 6) { // Crossbow string
							    Spinning.craftSpinning(player, amount, 2, true);
							    break;
						    }
						     break;
						
					    case 4:
						    Leather.craftDragonHide(player, 1, 4, leatherType, true); // Vambraces
						    break;
						
					    case 8:
						    Leather.craftDragonHide(player, 1, 8, leatherType, true); // Chaps
						    break;
				    }
				    break;
				
			    case 303:
				    switch(var.getSlot()) {
					    case 120: // Unholy symbol
						    Silver.newSilverItem(player, amount, var.getSlot(), true);
						    break;
						
					    case 121: // Tiara
						    Silver.newSilverItem(player, amount, var.getSlot(), true);
						    break;
				    }
				    break;
				
			    case 154: // Craft normal leather.
				    if (var.getSlot() >= 28 && var.getSlot() <= 34) {
					    Leather.craftNormalLeather(player, var.getSlot(), amount, true);
					    break;
				    }
				    break;
			
			    case 542: // Glassblowing.
				    switch(var.getSlot()) {
					    case 40: // Make X beer glass.
						    Glass.craftGlass(player, amount, 0, true);
						    break;
						
					    case 41: // Make X candle lantern.
						    Glass.craftGlass(player, amount, 1, true);
						    break;
						
					    case 42: // Make X oil lamp.
						    Glass.craftGlass(player, amount, 2, true);
						    break;
						
					    case 38: // Make X vial.
						    Glass.craftGlass(player, amount, 3, true);
						    break;
						
					    case 44: // Make X Fishbowl
						    Glass.craftGlass(player, amount, 4, true);
						    break;
						
					    case 39: // Make X orb.
						    Glass.craftGlass(player, amount, 5, true);
						    break;
						
					    case 43: // Make X lantern lens
						    Glass.craftGlass(player, amount, 6, true);
						    break;
						
					    case 45: // Make X dorgeshuun light orb.
						    Glass.craftGlass(player, amount, 7, true);
						    break;
				    }
				    break;
			
			    case 763: // Bank inventory - X.
				    player.getBank().setLastXAmount(amount);
				    player.getBank().deposit(var.getSlot(), amount);
				    player.getBank().refreshBank();
				    break;
				
			    case 762: // Bank - X.
				    player.getBank().setLastXAmount(amount);
				    player.getBank().withdraw(var.getSlot(), amount);
				    player.getBank().refreshBank();
				    break;
				
 			    case 336: // Trade/stake inventory - trade X.
 				    if (player.getTrade() != null) {
	 				    player.getTrade().tradeItem(var.getSlot(), amount);
	 				    break;
				    }
 				    if (player.getDuel() != null) {
 					    player.getDuel().stakeItem(var.getSlot(), amount);
 					    break;
 				    }
 				    break;
 				
 			    case 631:
 				    if (player.getDuel() != null) {
 					    player.getDuel().removeItem(var.getSlot(), amount);
 					    break;
 				    }
 				    break; 
 				
 			    case 335: // Trade/stake interface - remove X.
 				    player.getTrade().removeItem(var.getSlot(), amount);
 				    break;
 				
			    case 620: // Shop - buy X.
 				    player.getShopSession().buyItem(var.getSlot(), amount);
 				    break;

                case 105: //Grand Exchange custom quantity and price inputs.
                    switch(var.getSlot()) {
                        case 0: //custom enter quantity
                            player.getGESession().setCustomAmount(amount);
                            break;
                        case 1: //custom enter per price
                            player.getGESession().setCustomPrice(amount);
                            break;
                    }
                    break;

			    case 305: // What would you like to make? - 4 options
				    if (player.getTemporaryAttribute("fletchType") == null) {
					    return;
				    }
				    int logType = (int) player.getTemporaryAttribute("fletchType");
				    switch(var.getSlot()) {
					    case 0:
						    MakeBows.cutLog(player, amount, logType, 0, (player.getTemporaryAttribute("stringingBow") == null ? false : (bool)player.getTemporaryAttribute("stringingBow")), true);
						    break;
						
					    case 1:
						    MakeBows.cutLog(player, amount, logType, 1, (player.getTemporaryAttribute("stringingBow") == null ? false : (bool)player.getTemporaryAttribute("stringingBow")), true);
						    break;
						
					    case 2:
						    MakeBows.cutLog(player, amount, 0, 2, false, true);
						    break;
						
					    case 3:
						    MakeBows.cutLog(player, amount, 0, 3, false, true);
						    break;
				    }
				    break;
				
			    case 306: // What would you like to make? - 5 options
				    switch(var.getSlot()) {
					    case 0:
						    Clay.craftClay(player, amount, craftType, var.getSlot(), true);
						    break;
						
					    case 1:
						    Clay.craftClay(player, amount, craftType, var.getSlot(), true);
						    break;
						
					    case 2:
						    Clay.craftClay(player, amount, craftType, var.getSlot(), true);
						    break;
						
					    case 3:
						    Clay.craftClay(player, amount, craftType, var.getSlot(), true);
						    break;
						
					    case 4:
						    Clay.craftClay(player, amount, craftType, var.getSlot(), true);
						    break;
				    }
				    break;
				
			    case 309: // What would you like to make - 1 option
				    if (var.getSlot() >= 50 && var.getSlot() <= 60) { // Cut gem
					    Jewellery.cutGem(player, craftType, amount, true);
					    break;
				    } else if (var.getSlot() >= 100 && var.getSlot() <= 110) { // String amulet
					    Jewellery.stringAmulet(player, craftType, amount, true);
					    break;
				    }
				    switch(var.getSlot()) {
					    case 0:
						    MakeXbow.createXbow(player, amount, (int) (player.getTemporaryAttribute("bowType2") == null ? -1 : (int) player.getTemporaryAttribute("bowType2")), (bool) (player.getTemporaryAttribute("stringingBow") == null ? false :(bool) player.getTemporaryAttribute("stringingBow")), true);
						    break;
						
					    case 1:
						    MakeBows.cutLog(player, amount, (int) (player.getTemporaryAttribute("fletchType") == null ? -1 : (int) player.getTemporaryAttribute("fletchType")), (int) (player.getTemporaryAttribute("bowType") == null ? -1 : (int) player.getTemporaryAttribute("bowType")), true, true);
						    break;
						
					    case 2:
						    Herblore.grindIngredient(player, amount, true);
						    break;
						
					    case 3:
						    Herblore.makeUnfinishedPotion(player, amount, true);
						    break;
						
					    case 4:
						    Herblore.completePotion(player, amount, true);
						    break;
						
					    case 5:
						    Cooking.cookItem(player, amount, true, player.getTemporaryAttribute("cookingFireLocation") != null);
						    break;
						
					    case 6:
						    MakeAmmo.makeBoltTip(player, (int) (player.getTemporaryAttribute("boltTips") == null ? -1 : (int) player.getTemporaryAttribute("boltTips")), amount, true);
						    break;
				    }
				    break;
				
			    case 311: // Smelting interface
				    switch(var.getSlot()) {
					    case 13: // Bronze
						    Smelting.smeltOre(player, var.getSlot(), true, amount);
						    break;
						
					    case 17: // Blurite
						    Smelting.smeltOre(player, var.getSlot(), true, amount);
						    break;
						
					    case 21: // Iron
						    Smelting.smeltOre(player, var.getSlot(), true, amount);
						    break;
						
					    case 25: // Silver
						    Smelting.smeltOre(player, var.getSlot(), true, amount);
						    break;
						
					    case 29: // Steel
						    Smelting.smeltOre(player, var.getSlot(), true, amount);
						    break;
						
					    case 33: // Gold
						    Smelting.smeltOre(player, var.getSlot(), true, amount);
						    break;
						
					    case 37: // Mithril
						    Smelting.smeltOre(player, var.getSlot(), true, amount);
						    break;
						
					    case 41: // Adamant
						    Smelting.smeltOre(player, var.getSlot(), true, amount);
						    break;
						
					    case 45: // Rune
						    Smelting.smeltOre(player, var.getSlot(), true, amount);
						    break;
				    }
				    break;
				
			    case 300: // Smithing interface.
				    if (player.getTemporaryAttribute("smithingItem") == null) {
					    return;
				    }
				    SmithBar item = (SmithBar) player.getTemporaryAttribute("smithingItem");
				    if (item != null) {
					    item.setAmount(amount);
				    }
				    Smithing.smithItem(player, var.getSlot(), amount, false);
				    break;
			    }
			    player.removeTemporaryAttribute("interfaceVariable");
	    }
	    private void handleClickFive(Player player, Packet packet) {
		    int interfaceId = packet.readUShort();
		    int child = packet.readUShort();
		    int slot = packet.readUShort();
		    Console.WriteLine("InterfaceOption 5: interfaceId: " + interfaceId);
		    switch(interfaceId) {
			    case 763: // Bank inventory - X.
				    player.getPackets().displayEnterAmount();
				    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
				    break;
				
			    case 762: // Bank - X.
				    player.getPackets().displayEnterAmount();
				    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
				    break;
				
			    case 336: // Trade inventory - trade X.
				    player.getPackets().displayEnterAmount();
				    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
				    break;
				
			    case 335: // Trade interface - remove X.
				    player.getPackets().displayEnterAmount();
				    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
				    break;
				
 			    case 631: // Duel interface - remove All
 				    if (player.getDuel() != null) {
 					    player.getPackets().displayEnterAmount();
 					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
					    break;
 				    }
 				    break;
			
			    case 620: // Shop - buy X/buy 50.
				    if (player.getShopSession().isInMainStock()) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(interfaceId, slot));
				    } else {
					    player.getShopSession().buyItem(slot, 50);
				    }
				    break;
				
 			    case 621: // Shop - Sell 50.
 				    player.getShopSession().sellItem(slot, 50);
 				    break;
 				
 			    case 590: // Clan chat setup
 				    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
				    if (clan == null) {
					    player.getPackets().sendMessage("Please create your clan chat before changing settings.");
					    break;
				    }
 				    switch(child) {
	 				    case 23: // "Who can enter chat" - sergeant.
                            clan.setEnterRights(Clan.ClanRank.SERGEANT);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
	 					    break;
	 					
	 				    case 24: // "Who can talk in chat" - sergeant.
                            clan.setTalkRights(Clan.ClanRank.SERGEANT);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
	 					    break;
	 					
	 				    case 25: // // "Who can kick in chat" - sergeant.
                            clan.setKickRights(Clan.ClanRank.SERGEANT);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25);
	 					    break;
	 					
	 				    case 26: // "Who can share loot" - sergeant.
                            clan.setLootRights(Clan.ClanRank.SERGEANT);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
	 					    break;
 				    }
 				    break;
		    }	
	    }
	    private void handleClickFour(Player player, Packet packet) {
		    int interfaceId = packet.readUShort();
		    int child = packet.readUShort();
		    int slot = packet.readUShort();
		    Console.WriteLine("InterfaceOption 4: interfaceId: " + interfaceId);
		    switch(interfaceId) {
			    case 763: // Bank inventory - Custom amount.
				    player.getBank().deposit(slot, player.getBank().getLastXAmount());
				    player.getBank().refreshBank();
				    break;
				
			    case 762: // Bank - Custom amount.
				    player.getBank().withdraw(slot, player.getBank().getLastXAmount());
				    player.getBank().refreshBank();
				    break;
			
			    case 154: // Craft normal leather.
				    player.getPackets().displayEnterAmount();
				    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(154, child));
				    break;
				
			    case 542: // Glassblowing.
				    switch(child) {
					    case 40: // Make X beer glass.
					    case 41: // Make X candle lantern.
					    case 42: // Make X oil lamp.
					    case 38: // Make X vial.
					    case 44: // Make X Fishbowl
					    case 39: // Make X orb.
					    case 43: // Make X lantern lens
					    case 45: // Make X dorgeshuun light orb.
						    player.getPackets().displayEnterAmount();
						    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(542, child));
						    break;
				    }
				    break;
			    case 336: // Trade/stake inventory - trade all.
				    if (player.getTrade() != null) {
					    player.getTrade().tradeItem(slot, player.getInventory().getItemAmount(player.getInventory().getItemInSlot(slot)));
					    break;
				    }
				    if (player.getDuel() != null) {
					    player.getDuel().stakeItem(slot, player.getInventory().getItemAmount(player.getInventory().getItemInSlot(slot)));
					    break;
				    }
				    break;
				
			    case 335: // Trade interface - remove all.
				    player.getTrade().removeItem(slot, player.getTrade().getItemAmount(player.getTrade().getItemInSlot(slot)));
				    break;
				
 			    case 631: // Duel interface - remove All
 				    if (player.getDuel() != null) {
					    player.getDuel().removeItem(slot, player.getDuel().getItemAmount(player.getDuel().getItemInSlot(slot)));
					    break;
 				    }
 				    break;
				
 			    case 620: // Shop - buy 10.
 				    player.getShopSession().buyItem(slot, 10);
 				    break;
 				
 			    case 621: // Shop - sell 10.
 				    player.getShopSession().sellItem(slot, 10);
 				    break;
 				
 			    case 590: // Clan chat setup
 				    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
				    if (clan == null) {
					    player.getPackets().sendMessage("Please create your clan chat before changing settings.");
					    break;
				    }
 				    switch(child) {
	 				    case 23: // "Who can enter chat" - corporal.
                            clan.setEnterRights(Clan.ClanRank.CORPORAL);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
	 					    break;
	 					
	 				    case 24: // "Who can talk in chat" - corporal.
                            clan.setTalkRights(Clan.ClanRank.CORPORAL);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
	 					    break;
	 					
	 				    case 25: // // "Who can kick in chat" - corporal.
                            clan.setKickRights(Clan.ClanRank.CORPORAL);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getKickRights()), 590, 25);
	 					    break;
	 					
	 				    case 26: // "Who can share loot" - corporal.
                            clan.setLootRights(Clan.ClanRank.CORPORAL);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
	 					    break;
 				    }
 				    break;
		    }
	    }
	    private void handleClickThree(Player player, Packet packet) {
		    int interfaceId = packet.readUShort();
		    int child = packet.readUShort();
		    int slot = packet.readUShort();
		    Console.WriteLine("InterfaceOption 3: interfaceId: " + interfaceId);
		    switch(interfaceId) {
			    case 154: // Craft normal leather.
				    Leather.craftNormalLeather(player, child, player.getInventory().getItemAmount(1741), true);
				    break;
			
			    case 542: // Glassblowing.
				    int totalGlass = player.getInventory().getItemAmount(1775);
				    switch(child) {
					    case 40: // Make all beer glass.
						    Glass.craftGlass(player, totalGlass, 0, true);
						    break;
						
					    case 41: // Make all candle lantern.
						    Glass.craftGlass(player, totalGlass, 1, true);
						    break;
						
					    case 42: // Make all oil lamp.
						    Glass.craftGlass(player, totalGlass, 2, true);
						    break;
						
					    case 38: // Make all vial.
						    Glass.craftGlass(player, totalGlass, 3, true);
						    break;
						
					    case 44: // Make all Fishbowl
						    Glass.craftGlass(player, totalGlass, 4, true);
						    break;
						
					    case 39: // Make all orb.
						    Glass.craftGlass(player, totalGlass, 5, true);
						    break;
						
					    case 43: // Make all lantern lens
						    Glass.craftGlass(player, totalGlass, 6, true);
						    break;
						
					    case 45: // Make all dorgeshuun light orb.
						    Glass.craftGlass(player, totalGlass, 7, true);
						    break;
				    }
				    break;
				
			    case 763: // Bank inventory - 10.
				    player.getBank().deposit(slot, 10);
				    player.getBank().refreshBank();
				    break;
				
			    case 762: // Bank - 10.
				    player.getBank().withdraw(slot, 10);
				    player.getBank().refreshBank();
				    break;
				
 			    case 336: // Trade/stake inventory - trade 10.
 				    if (player.getTrade() != null) {
 					    player.getTrade().tradeItem(slot, 10);
 					    break;
 				    }
 				    if (player.getDuel() != null) {
 					    player.getDuel().stakeItem(slot, 10);
 					    break;
 				    }
 				    break;
 				
 			    case 335: // Trade interface - remove 10.
 				    player.getTrade().removeItem(slot, 10);
 				    break;
 				
 			    case 631: // Duel interface - remove 10.
 				    if (player.getDuel() != null) {
					    player.getDuel().removeItem(slot, 5);
					    break;
 				    }
 				    break;
 				
 			    case 620: // Shop - buy 5.
 				    player.getShopSession().buyItem(slot, 5);
 				    break;
 				
 			    case 621: // Shop - sell 5.
 				    player.getShopSession().sellItem(slot, 5);
 				    break;
 				
 			    case 590: // Clan chat setup
 				    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
				    if (clan == null) {
					    player.getPackets().sendMessage("Please create your clan chat before changing settings.");
					    break;
				    }
 				    switch(child) {
	 				    case 23: // "Who can enter chat" - recruit.
                            clan.setEnterRights(Clan.ClanRank.RECRUIT);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
	 					    break;
	 					
	 				    case 24: // "Who can talk in chat" - recruit.
                            clan.setTalkRights(Clan.ClanRank.RECRUIT);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
	 					    break;
	 					
	 				    case 26: // "Who can share loot" - recruit.
                            clan.setLootRights(Clan.ClanRank.RECRUIT);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
	 					    break;
 				    }
 				    break;
		    }
	    }
	    private void handleClickTwo(Player player, Packet packet) {
		    int interfaceId = packet.readUShort();
		    int child = packet.readUShort();
		    int slot = packet.readUShort();
            Console.WriteLine("InterfaceOption 2: interfaceId: " + interfaceId);
		    switch(interfaceId) {
			    case 105: // GE Interface
				    switch(child) {
					    case 209: // "Collect" and "Collect-items" option
						    player.getGESession().collectSlot1(false);
						    break;
						
					    case 211: // Left box "Collect" option (coins)
						    player.getGESession().collectSlot2();
						    break;
				    }
				    break;
		
			    case 154: // Craft normal leather.
				    Leather.craftNormalLeather(player, child, 5, true);
				    break;
			
			    case 542: // Glassblowing.
				    switch(child) {
					    case 40: // Make 5 beer glass.
						    Glass.craftGlass(player, 5, 0, true);
						    break;
						
					    case 41: // Make 5 candle lantern.
						    Glass.craftGlass(player, 5, 1, true);
						    break;
						
					    case 42: // Make 5 oil lamp.
						    Glass.craftGlass(player, 5, 2, true);
						    break;
						
					    case 38: // Make 5 vial.
						    Glass.craftGlass(player, 5, 3, true);
						    break;
						
					    case 44: // Make 5 Fishbowl
						    Glass.craftGlass(player, 5, 4, true);
						    break;
						
					    case 39: // Make 5 orb.
						    Glass.craftGlass(player, 5, 5, true);
						    break;
						
					    case 43: // Make 5 lantern lens
						    Glass.craftGlass(player, 5, 6, true);
						    break;
						
					    case 45: // Make 5 dorgeshuun light orb.
						    Glass.craftGlass(player, 5, 7, true);
						    break;
				    }
				    break;
			
			    case 763: // Bank inventory - 5.
				    player.getBank().deposit(slot, 5);
				    player.getBank().refreshBank();
				    break;
				
			    case 762: // Bank - 5.
				    player.getBank().withdraw(slot, 5);
				    player.getBank().refreshBank();
				    break;
				
 			    case 336: // Trade/stake inventory - trade 5.
 				    if (player.getTrade() != null) {
 					    player.getTrade().tradeItem(slot, 5);
 					    break;
 				    }
 				    if (player.getDuel() != null) {
 					    player.getDuel().stakeItem(slot, 5);
 					    break;
 				    }
 				    break;
 				
 			    case 631: // Duel interface - remove 5
 				    if (player.getDuel() != null) {
					    player.getDuel().removeItem(slot, 5);
					    break;
 				    }
 				    break;
 				
 			    case 335: // Trade interface - remove 5.
 				    player.getTrade().removeItem(slot, 5);
 				    break;
 				
 			    case 620: // Shop - buy 1.
 				    player.getShopSession().buyItem(slot, 1);
 				    break;
 				
 			    case 621: // Shop - sell 1.
 				    player.getShopSession().sellItem(slot, 1);
 				    break;
 				
 			    case 590: // Clan chat setup
 				    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
				    if (clan == null) {
					    player.getPackets().sendMessage("Please create your clan chat before changing settings.");
					    break;
				    }
 				    switch(child) {
	 				    case 23: // "Who can enter chat" - any friends.
	 					    clan.setEnterRights(Clan.ClanRank.FRIEND);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
	 					    break;
	 					
	 				    case 24: // "Who can talk in chat" - any friends.
                            clan.setTalkRights(Clan.ClanRank.FRIEND);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
	 					    break;
	 					
	 				    case 26: // "Who can share loot" - any friends.
	 					    clan.setLootRights(Clan.ClanRank.FRIEND);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
	 					    break;
 				    }
 				    break;
		    }
	    }
	    private void handleAttackPlayer(Player player, Packet packet) {
		    int index = packet.readLEShortA();
		    if(index < 0 || index >= Constants.MAX_PLAYERS || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
			    return;
		    }
		    SkillHandler.resetAllSkills(player);
		    Player p2 = Server.getPlayerList()[index];
		    if (p2 == null)
			    return;

		    player.setFaceLocation(p2.getLocation());
		    player.getPackets().closeInterfaces();
		    if (Location.atDuelArena(player.getLocation())) {
			    if(player.getDuel() != null) {
				    if (player.getDuel().getStatus() < 4) {
					    player.getDuel().declineDuel();
					    return;
				    } else if (player.getDuel().getStatus() == 5 && player.getDuel().getPlayer2().Equals(p2)) {
					    player.getPackets().sendMessage("The duel has not yet started!");
					    return;
				    } else if ((player.getDuel().getStatus() == 5 || player.getDuel().getStatus() == 6) && !player.getDuel().getPlayer2().Equals(p2)) {
					    return;
				    } else if (player.getDuel().getStatus() == 6) {
					    Combat.newAttack(player, p2);
					    return;
				    }
			    }
			    if (!player.getLocation().withinDistance(p2.getLocation(), 1)) {
				    int x = p2.getLocation().getX();
				    int y = p2.getLocation().getY();
                    AreaEvent attackAreaEvent = new AreaEvent(player, x-1, y-1, x+1, y+1);
				    attackAreaEvent.setAction(() => {
                        player.getWalkingQueue().resetWalkingQueue();
						player.getPackets().clearMapFlag();
						if (p2.getGESession() != null || (p2.getDuel() != null && !p2.getDuel().getPlayer2().Equals(player)) || p2.getTrade() != null || p2.getShopSession() != null || p2.getBank().isBanking()) {
                            player.getPackets().sendMessage("That player is busy at the moment.");
							return;
						}
						if (p2.wantsToDuel(player)) {
							p2.setFaceLocation(player.getLocation());
							player.getPackets().closeInterfaces();
							p2.getPackets().closeInterfaces();
							player.setDuelSession(new DuelSession(player, p2));
							p2.setDuelSession(new DuelSession(p2, player));
							return;
						}
						player.setFaceLocation(p2.getLocation());
						p2.getPackets().sendMessage(player.getLoginDetails().getUsername() + ":duelstake:");
						player.getPackets().sendMessage("Sending duel request...");
						player.newDuelRequest(p2);
				    });
                    Server.registerCoordinateEvent(attackAreaEvent);
				    return;
			    }
			    if (p2.getGESession() != null || (p2.getDuel() != null && !p2.getDuel().getPlayer2().Equals(player)) || p2.getTrade() != null || p2.getShopSession() != null || p2.getBank().isBanking()) {
				    player.getPackets().sendMessage("That player is busy at the moment.");
				    return;
			    }
			    if (p2.wantsToDuel(player)) {
				    player.getPackets().closeInterfaces();
				    p2.getPackets().closeInterfaces();
				    p2.setFaceLocation(player.getLocation());
				    player.setDuelSession(new DuelSession(player, p2));
				    p2.setDuelSession(new DuelSession(p2, player));
				    return;
			    }
			    player.newDuelRequest(p2);
			    p2.getPackets().sendMessage(player.getLoginDetails().getUsername() + ":duelstake:");
			    player.getPackets().sendMessage("Sending duel request...");
			    return;
		    }
		    Combat.newAttack(player, p2);
	    }
Exemplo n.º 9
0
        public bool doSpecialAttack(Entity killer, Entity target)
        {
            int  weapon       = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON);
            int  currentPower = specialAmount;
            int  neededPower  = getRequiredAmount(weapon);
            bool rangeWeapon  = false;

            if (!usingSpecial)
            {
                return(false);
            }
            if (p.getDuel() != null)
            {
                if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_SPECIAL_ATTACKS))
                {
                    p.getPackets().sendMessage("Special attacks have been disabled for this duel!");
                    usingSpecial = false;
                    refreshBar();
                    return(false);
                }
            }
            if (neededPower > currentPower)
            {
                ((Player)killer).getPackets().sendMessage("You don't have enough special power left.");
                usingSpecial = false;
                refreshBar();
                return(false);
            }
            double damage          = -1;
            double damage2         = -1;
            double damage3         = -1;
            double damage4         = -1;
            bool   doubleHit       = false;
            int    increasedMaxHit = 0;

            damage  = CombatFormula.getSpecialMeleeHit((Player)killer, target, weapon);
            damage2 = CombatFormula.getSpecialMeleeHit((Player)killer, target, weapon);
            int  hitDelay         = killer.getHitDelay();
            int  usingBow         = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.WEAPON);
            int  usingArrows      = ((Player)killer).getEquipment().getItemInSlot(ItemData.EQUIP.ARROWS);
            bool usingRangePrayer = false;

            if (target is Player)
            {
                usingRangePrayer = ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_RANGED);
            }
            switch (weapon)
            {
            case 4151:             // Whip.
                killer.setLastAnimation(new Animation(1658));
                target.setLastGraphics(new Graphics(341, 0, 100));
                if (misc.random(3) == 0 && damage > 0)
                {
                    damage = p.getMaxHit();
                }
                else
                {
                    damage = 0;
                }
                if (target is Player)
                {
                    int energy = ((Player)target).getRunEnergy() / 4;
                    ((Player)killer).setRunEnergy(((Player)killer).getRunEnergy() + energy);
                    ((Player)target).setRunEnergy(((Player)target).getRunEnergy() - energy);
                    if (((Player)killer).getRunEnergy() > 100)
                    {
                        ((Player)killer).setRunEnergy(100);
                    }
                    if (((Player)target).getRunEnergy() < 0)
                    {
                        ((Player)target).setRunEnergy(0);
                    }
                }
                break;

            case 1215:             // Dragon daggers.
            case 1231:
            case 5680:
            case 5698:
                if (damage > 0)
                {
                    damage  = p.getMaxHit(20);
                    damage2 = p.getMaxHit(20);
                }
                killer.setLastAnimation(new Animation(1062));
                killer.setLastGraphics(new Graphics(252, 0, 100));
                doubleHit = true;

                /*if (misc.random(3) == 0 && CombatFormula.getMeleeHit(p, target) > 0) {
                 * if (damage <= (CombatFormula.getPlayerMaxHit(p, 20) / 2) && damage2 <= (CombatFormula.getPlayerMaxHit(p, 20) / 2))
                 * {
                 * damage = (CombatFormula.getPlayerMaxHit(p, 20) / 2) + (misc.randomDouble(CombatFormula.getPlayerMaxHit(p, 20)) / 2);
                 * damage2 = (CombatFormula.getPlayerMaxHit(p, 20) / 2) + (misc.randomDouble(CombatFormula.getPlayerMaxHit(p, 20)) / 2);
                 *      }
                 * } else if (misc.random(2) == 0) {
                 *      damage = 0;
                 *      damage2 = 0;
                 * }*/
                double a = damage + damage2;
                if (damage > target.getHp())
                {
                    damage = target.getHp();
                }
                a -= damage;
                if (damage2 > a)
                {
                    damage2 = a;
                }

                /*if (damage > target.getHp()) {
                 *      int randomHp = misc.random(target.getHp());
                 *      damage = randomHp;
                 *      damage2 = target.getHp() - randomHp;
                 * } else {
                 *      int hpRemaining = target.getHp() - damage;
                 *      if (damage2 > hpRemaining) {
                 *              damage2 = hpRemaining;
                 *      }
                 * }*/
                break;

            case 1305:             // Dragon longsword.
                killer.setLastAnimation(new Animation(1058));
                killer.setLastGraphics(new Graphics(248, 0, 100));
                damage = p.getMaxHit(30);
                break;

            case 11694:             // Armadyl godsword.
                killer.setLastGraphics(new Graphics(1222, 0, 100));
                killer.setLastAnimation(new Animation(7074));
                damage += p.getMaxHit() * 0.25;                 //25% decrease.
                break;

            case 11696:             // Bandos godsword.
                killer.setLastGraphics(new Graphics(1223, 0, 100));
                killer.setLastAnimation(new Animation(7073));
                damage += p.getMaxHit() * 0.10;     //10% decrease.
                break;

            case 11698:             // Saradomin godsword.
                killer.setLastGraphics(new Graphics(1220, 0, 100));
                killer.setLastAnimation(new Animation(7071));
                int newHp     = (int)(damage * 0.50);              //50% decrease.
                int newPrayer = (int)(damage * 0.25);              //25% decrease
                if (newHp < 10)
                {
                    newHp = 10;
                }
                if (newPrayer < 5)
                {
                    newPrayer = 5;
                }
                ((Player)killer).heal(newHp);
                ((Player)killer).getSkills().setCurLevel(Skills.SKILL.PRAYER, ((Player)killer).getSkills().getCurLevel(Skills.SKILL.PRAYER) + newPrayer);
                if (((Player)killer).getSkills().getCurLevel(Skills.SKILL.PRAYER) > ((Player)killer).getSkills().getMaxLevel(Skills.SKILL.PRAYER))
                {
                    ((Player)killer).getSkills().setCurLevel(Skills.SKILL.PRAYER, ((Player)killer).getSkills().getMaxLevel(Skills.SKILL.PRAYER));
                }
                break;

            case 11700:             // Zamorak godsword
                killer.setLastGraphics(new Graphics(1221, 0, 100));
                killer.setLastAnimation(new Animation(7070));
                target.setLastGraphics(new Graphics(369));
                MagicCombat.freezeTarget(31, target);
                break;

            case 11730:             // Saradomin sword
                target.setLastGraphics(new Graphics(1207, 0, 100));
                killer.setLastAnimation(new Animation(7072));
                increasedMaxHit = 16;
                break;

            case 1434:             // Dragon mace
                hitDelay = 700;
                killer.setLastGraphics(new Graphics(251, 0, 75));
                killer.setLastAnimation(new Animation(1060));
                damage = p.getMaxHit(60);
                break;

            case 3204:             // Dragon halberd
                // TODO halberd
                break;

            case 4587:             // Dragon scimitar
                killer.setLastGraphics(new Graphics(347, 0, 100));
                killer.setLastAnimation(new Animation(451));
                if (target is Player)
                {
                    if (((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_MELEE) ||
                        ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_MAGIC) ||
                        ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.PROTECT_FROM_RANGED) ||
                        ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.RETRIBUTION) ||
                        ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.REDEMPTION) ||
                        ((Player)target).getPrayers().isPrayerActive(PrayerData.Prayer.SMITE))
                    {
                        ((Player)target).getPackets().sendMessage("The Dragon scimitar slashes through your prayer protection!");
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_MELEE);
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_MAGIC);
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.PROTECT_FROM_RANGED);
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.RETRIBUTION);
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.REDEMPTION);
                        Prayer.forcePrayerOff((Player)target, PrayerData.Prayer.SMITE);
                    }
                }
                break;

            case 14484:             // Dragon claws
                doubleHit = true;
                killer.setLastGraphics(new Graphics(1950));
                killer.setLastAnimation(new Animation(10961));
                if (misc.random(1) == 0 && damage > 0)
                {
                    if (damage < p.getMaxHit(20) * 0.75)
                    {
                        damage = (p.getMaxHit(20) * 0.75 + (misc.randomDouble((p.getMaxHit(20) * 0.25))));
                    }
                }
                damage  = Math.Floor(damage);
                damage2 = Math.Floor(damage * 0.50);                 //50% decrease
                damage3 = Math.Floor(damage2 * 0.50);                //50% decrease
                damage4 = Math.Floor(damage3 + 1);
                break;

            case 1249:             // Dragon spear
                //TODO leave due to noclipping?
                break;

            case 6739:             // Dragon axe
                //TODO find emote and graphic
                break;

            case 7158:             // Dragon 2h
                killer.setLastAnimation(new Animation(3157));
                killer.setLastGraphics(new Graphics(559));
                //TODO multi combat
                break;

            case 3101:             // Rune claws
                killer.setLastGraphics(new Graphics(274));
                break;

            case 4153:             // Granite maul
                killer.setLastAnimation(new Animation(1667));
                killer.setLastGraphics(new Graphics(340, 0, 100));
                //doubleHit = true;
                break;

            case 10887:             // Barrelchest anchor
                break;

            case 11061:             // Ancient mace
                break;

            case 13902:             // Statius' warhammer
                killer.setLastAnimation(new Animation(10505));
                killer.setLastGraphics(new Graphics(1840));
                damage += killer.getMaxHit() * 0.25;                 //25% decrease
                if (target is Player)
                {
                    int defenceLevel = ((Player)target).getSkills().getCurLevel(Skills.SKILL.DEFENCE);
                    int newDefence   = (int)(defenceLevel * 0.30);                   //30% decrease.
                    if (newDefence < 1)
                    {
                        newDefence = 1;
                    }

                    ((Player)target).getSkills().setCurLevel(Skills.SKILL.DEFENCE, defenceLevel - newDefence);
                    ((Player)target).getPackets().sendSkillLevel(Skills.SKILL.DEFENCE);
                }
                break;

            case 13899:                              // Vesta's longsword
                killer.setLastAnimation(new Animation(10502));
                damage += killer.getMaxHit() * 0.20; //20% decrease
                break;

            case 13905:             // Vesta's spear
                killer.setLastAnimation(new Animation(10499));
                killer.setLastGraphics(new Graphics(1835));
                break;

            case 13883:             // Morrigans throwing axe
                break;

            case 13879:            // Morrigans javelin

            case 8880:             // Dorgeshuun crossbow
                break;

            case 861:             // Magic shortbow
            case 859:             // Magic longbow
            case 10284:           // Magic composite bow
                rangeWeapon = true;
                if (p.getEquipment().getAmountInSlot(ItemData.EQUIP.ARROWS) < 2)
                {
                    p.getPackets().sendMessage("You need 2 arrows to use the Magic bow special attack!");
                    return(false);
                }
                damage   = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                damage2  = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                damage  *= 1.05;                //5% increase.
                damage2 *= 1.05;                //5% increase.
                if (usingRangePrayer)
                {
                    damage  *= 0.60;                    //60% decrease.
                    damage2 *= 0.60;                    //60% decrease.
                }
                double a1 = damage + damage2;
                if (damage > target.getHp())
                {
                    damage = target.getHp();
                }
                a1 -= damage;
                if (damage2 > a1)
                {
                    damage2 = a1;
                }

                /*if (damage >= target.getHp()) {
                 *      int randomHp = misc.random(target.getHp());
                 *      damage = randomHp;
                 *      damage2 = target.getHp() - randomHp;
                 * } else {
                 *      int hpRemaining = target.getHp() - damage;
                 *      if (damage2 > hpRemaining) {
                 *              damage2 = hpRemaining;
                 *      }
                 * }*/
                p.setLastAnimation(new Animation(1074));
                p.setLastGraphics(new Graphics(256, 0, 90));
                RangeCombat.deductArrow(killer);
                RangeCombat.deductArrow(killer);
                int arrowType = RangeCombat.getArrowType(killer);
                hitDelay = 1000;
                int   MSpecCounter = 0;
                Event displayMSpecProjectileEvent = new Event(0);
                displayMSpecProjectileEvent.setAction(() => {
                    RangeCombat.displayMSpecProjectile(killer, target);
                    MSpecCounter++;
                    if (MSpecCounter == 1)
                    {
                        displayMSpecProjectileEvent.setTick(500);
                        p.setLastGraphics(new Graphics(256, 0, 90));
                        Event doMSpecHitEvent = new Event(900);
                        doMSpecHitEvent.setAction(() => {
                            doMSpecHitEvent.stop();
                            target.hit(damage2);
                            RangeCombat.createGroundArrow(killer, target, arrowType);
                        });
                        Server.registerEvent(doMSpecHitEvent);
                    }
                    else
                    {
                        displayMSpecProjectileEvent.stop();
                        return;
                    }
                    MSpecCounter++;
                });
                Server.registerEvent(displayMSpecProjectileEvent);
                break;

            case 805:             // Rune thrownaxe
                rangeWeapon = true;
                break;

            case 6724:             // Seercull
                rangeWeapon = true;
                break;

            case 11235:             // Dark bow
                rangeWeapon = true;
                if (p.getEquipment().getAmountInSlot(ItemData.EQUIP.ARROWS) < 2)
                {
                    p.getPackets().sendMessage("You need 2 arrows to use the Dark bow!");
                    return(false);
                }
                int minHit = 8;
                damage  = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                damage2 = CombatFormula.getRangeHit((Player)killer, target, usingBow, usingArrows);
                if (usingBow == 11235)                   // Dark bow
                {
                    if (usingArrows == 11212)            // Dragon arrows
                    {
                        minHit   = usingRangePrayer ? 4 : 8;
                        damage  *= 1.50;                        //50% increase.
                        damage2 *= 1.50;                        //50% increase.
                        if (damage < minHit)
                        {
                            damage = minHit;
                        }
                        if (damage2 < minHit)
                        {
                            damage2 = minHit;
                        }
                    }
                    else                         // Other arrow
                    {
                        minHit   = usingRangePrayer ? 3 : 5;
                        damage  *= 1.30;                        //30% increase.
                        damage2 *= 1.30;                        //30% increase.
                        if (damage < minHit)
                        {
                            damage = minHit;
                        }
                        if (damage2 < minHit)
                        {
                            damage2 = minHit;
                        }
                    }
                }
                if (usingRangePrayer)
                {
                    damage  *= 0.60;                    //60% decrease.
                    damage2 *= 0.60;                    //60% decrease.
                }
                double a2 = damage + damage2;
                if (damage > target.getHp())
                {
                    damage = target.getHp();
                }
                a2 -= damage;
                if (damage2 > a2)
                {
                    damage2 = a2;
                }

                /*if (damage >= target.getHp()) {
                 *      int randomHp = misc.random(target.getHp());
                 *      damage = randomHp;
                 *      damage2 = target.getHp() - randomHp;
                 * } else {
                 *      int hpRemaining = target.getHp() - damage;
                 *      if (damage2 > hpRemaining) {
                 *              damage2 = hpRemaining;
                 *      }
                 * }*/
                p.setLastGraphics(new Graphics(RangeCombat.getDrawbackGraphic(killer), 0, 90));
                RangeCombat.deductArrow(killer);
                RangeCombat.deductArrow(killer);
                hitDelay = RangeCombat.getHitDelay(killer, target);
                int delayHit = hitDelay;
                hitDelay = 1200;
                int   arrowType1       = RangeCombat.getArrowType(killer);
                int   DBSpecCounter    = 0;
                Event DBSpecProjectile = new Event(0);
                DBSpecProjectile.setAction(() => {
                    RangeCombat.displayDBSpecProjectile(killer, target);
                    DBSpecCounter++;
                    if (DBSpecCounter == 1)
                    {
                        DBSpecProjectile.setTick(200);
                        Event rangeHitEvent = new Event(delayHit + 600);
                        rangeHitEvent.setAction(() => {
                            target.hit(damage2);
                            rangeHitEvent.stop();
                            RangeCombat.createGroundArrow(killer, target, arrowType1);
                        });
                        Server.registerEvent(rangeHitEvent);
                    }
                    else
                    {
                        DBSpecProjectile.stop();
                        return;
                    }
                    DBSpecCounter++;
                });
                Server.registerEvent(DBSpecProjectile);
                break;
            }
            specialAmount -= neededPower;
            p.setSpecialAmount(specialAmount);
            usingSpecial = false;
            refreshBar();
            killer.resetCombatTurns();
            bool hitDouble = doubleHit;

            if (target is Player)
            {
                if (!rangeWeapon)
                {
                    if (((Player)target).getPrayers().getHeadIcon() == PrayerData.PrayerHeadIcon.MELEE)
                    {
                        damage = (damage * 0.60);                 //60% decrease.
                    }
                }
                else
                {
                    if (((Player)target).getPrayers().getHeadIcon() == PrayerData.PrayerHeadIcon.RANGE)
                    {
                        damage = (damage * 0.60);                 //60% decrease
                    }
                }
            }
            damage  = ((weapon == 4151) ? damage : misc.randomDouble(damage));
            damage2 = misc.randomDouble(damage2);
            double d  = ((damage == 0 && weapon != 11730) ? 0 : (damage + increasedMaxHit));
            double d2 = damage2;
            double d3 = damage3; // only used for d claws
            double d4 = damage4; // only used for d claws

            if (canPoison(weapon))
            {
                if (!target.isPoisoned() && misc.random(5) == 0 && (hitDouble ? (d2 > 0 || d > 0) : d > 0))
                {
                    Server.registerEvent(new PoisonEvent(target, POISON_AMOUNT));
                }
            }
            int    hhitDelay   = hitDelay;
            double totalDamage = (damage + damage2 + damage3 + damage4);

            Combat.checkIfWillDie(target, totalDamage);
            Event hitEvent = new Event(hhitDelay);

            hitEvent.setAction(() => {
                hitEvent.stop();
                if (!target.isDead())
                {
                    target.setLastAnimation(new Animation(target.getDefenceAnimation()));
                }
                target.hit(d);
                if (hitDouble)
                {
                    target.hit(d2);
                }
                if (d3 != -1 || d4 != -1)
                {
                    target.hit(d3);
                    target.hit(d4);
                }
                Combat.checkRecoilRing(killer, target, totalDamage);
                Combat.checkSmite(killer, target, totalDamage);
                Combat.checkVengeance(killer, target, totalDamage);
                Combat.addXp(killer, target, totalDamage);
            });
            Server.registerEvent(hitEvent);
            return(true);
        }
	    private void handleActionButton(Player player, Packet packet) {
		    int interfaceId = packet.readUShort();
            ushort buttonId = packet.readUShort();
            ushort buttonId2 = 0;
		    if(packet.getLength() >= 6) {
                buttonId2 = packet.readUShort();
		    }
		    if(buttonId2 == 65535) {
			    buttonId2 = 0;
		    }
		    Console.WriteLine("button = " + interfaceId + " " +buttonId + " " +buttonId2);
		    switch(interfaceId) {
			    case 751: 
                    switch(buttonId) {
                        case 27: // Report Abuse button click
                            //This is just a test. (you need to code a Static Handler for ReportAbuse.
                            player.getPackets().displayInterface(553); //Opens Report Abuse box
				            break;
                    }
                    break;
			    case 374: // Tzhaar fight pits viewing orb
				    Server.getMinigames().getFightPits().useOrb(player, buttonId);
				    break;

                case 389: // GE Item Search "X" for closing it.
                    player.getPackets().sendInterface(0, 752, 6, 137); // Removes the item search
                    break;

			    case 107: // GE Sell inventory.
				    if (player.getGESession() == null) {
					    break;
				    }
				    switch(buttonId) {
					    case 18: // Offer
						    player.getGESession().offerSellItem(buttonId2);
						    break;
				    }
				    break;
			
			    case 105: // GE interface
				    if (player.getGESession() == null) {
					    break;
				    }
				    switch(buttonId) {
					    case 209: // Collect-notes
						    player.getGESession().collectSlot1(true);
						    break;
				
					    case 203: // Abort offer
						    player.getGESession().abortOffer();
						    break;
						
					    case 31: // Sell, box 1
						    player.getGESession().newSellOffer(0);
						    break;
				
					    case 30: // Buy, box 1
						    player.getGESession().newBuyOffer(0);
						    break;
						
					    case 18: // Check status, box 1
						    player.getGESession().checkOffer(0);
						    break;
						
					    case 46: // Buy, box 2
						    player.getGESession().newBuyOffer(1);
						    break;
						
					    case 47: // Sell, box 2
						    player.getGESession().newSellOffer(1);
						    break;
						
					    case 34: // Check status, box 2
						    player.getGESession().checkOffer(1);
						    break;
						
					    case 62: // Buy, box 3
						    player.getGESession().newBuyOffer(2);
						    break;
						
					    case 63: // Sell, box 3
						    player.getGESession().newSellOffer(2);
						    break;
						
					    case 50: // Check status, box 3
						    player.getGESession().checkOffer(2);
						    break;
						
					    case 81: // Buy, box 4
						    player.getGESession().newBuyOffer(3);
						    break;
						
					    case 82: // Sell, box 4
						    player.getGESession().newSellOffer(3);
						    break;
						
					    case 69: // Check status, box 4
						    player.getGESession().checkOffer(3);
						    break;
						
					    case 100: // Buy, box 5
						    player.getGESession().newBuyOffer(4);
						    break;
						
					    case 101: // Sell, box 5
						    player.getGESession().newSellOffer(4);
						    break;
						
					    case 88: // Check status, box 5
						    player.getGESession().checkOffer(4);
						    break;
						
					    case 119: // Buy, box 6
						    player.getGESession().newBuyOffer(5);
						    break;
						
					    case 120: // Sell, box 6
						    player.getGESession().newSellOffer(5);
						    break;
						
					    case 107: // Check status, box 6
						    player.getGESession().checkOffer(5);
						    break;
						
					    case 127: // The "back" button
                            player.getGESession().goBackToGrandExchange();
						    break;
						
					    case 194: // Search for item
						    player.getGESession().openItemSearch();
						    break;
						
					    case 159: // Increment amount by 1
						    player.getGESession().incrementAmount(1, false);
						    break;
						
					    case 157: // Decrease amount by 1
						    player.getGESession().decreaseAmount(1);
						    break;
						
					    case 162: // Increase amount by +1
                            player.getGESession().incrementAmount(1, true);
						    break;
						
					    case 164: // Increase amount by +10
                            player.getGESession().incrementAmount(10, true);
						    break;
						
					    case 166: // Increase amount by +100
                            player.getGESession().incrementAmount(100, true);
						    break;
						
					    case 168: // Increase amount by +1k (or All if selling)
						    player.getGESession().incrementAmount(1000, true);
						    break;
						case 170: //custom enter quantity
                            player.getPackets().displayEnterAmount();
                            player.setTemporaryAttribute("interfaceVariable", new EnterVariable(105, 0));
                            break;
                        case 185: //custom enter per price
                            player.getPackets().displayEnterAmount();
                            player.setTemporaryAttribute("interfaceVariable", new EnterVariable(105, 1));
                            break;

					    case 177: // Set price to minimum
						    player.getGESession().setPrice(0);
						    break;
						
					    case 180: // Set price to medium
						    player.getGESession().setPrice(1);
						    break;
						
					    case 183: // Set price to maximum
						    player.getGESession().setPrice(2);
						    break;
						
					    case 171: // Set price -1
						    player.getGESession().setPrice(3);
						    break;
						
					    case 173: // Set price +1
						    player.getGESession().setPrice(4);
						    break;
						
					    case 190: // Confirm offer
						    player.getGESession().confirmOffer();
						    break;
				    }
				    break;
			
			    case 161: // Slayer points interfaces
			    case 163:
			    case 164:
				    Slayer.handlePointsInterface(player, interfaceId, buttonId);
				    break;
			
		
			    case 675: // Craft jewellery:
				    player.getPackets().displayEnterAmount();
				    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(675, buttonId));
				    break;
		
			    case 154: // Craft normal leather.
				    Leather.craftNormalLeather(player, buttonId, 1, true);
				    break;
				
			    case 542: // Craft glass.
				    switch (buttonId) {
					    case 40: // Make 1 beer glass.
						    Glass.craftGlass(player, 1, 0, true);
						    break;
						
					    case 41: // Make 1 candle lantern.
						    Glass.craftGlass(player, 1, 1, true);
						    break;
						
					    case 42: // Make 1 oil lamp.
						    Glass.craftGlass(player, 1, 2, true);
						    break;
						
					    case 38: // Make 1 vial.
						    Glass.craftGlass(player, 1, 3, true);
						    break;
						
					    case 44: // Make 1 Fishbowl
						    Glass.craftGlass(player, 1, 4, true);
						    break;
						
					    case 39: // Make 1 orb.
						    Glass.craftGlass(player, 1, 5, true);
						    break;
						
					    case 43: // Make 1 lantern lens
						    Glass.craftGlass(player, 1, 6, true);
						    break;
						
					    case 45: // Make 1 dorgeshuun light orb.
						    Glass.craftGlass(player, 1, 7, true);
						    break;
				    }
				    break;
			
			    case 271 : // Prayer tab.
				    if (!Prayer.canUsePrayer(player, buttonId)) {
					    Prayer.deactivateAllPrayers(player);
					    break;
				    }
				    switch(buttonId) {
					    case 5: // Thick skin.
						    Prayer.togglePrayer(player, PrayerData.Prayer.THICK_SKIN);
						    break;
						
					    case 15: // Rock skin.
                            Prayer.togglePrayer(player, PrayerData.Prayer.ROCK_SKIN);
						    break;
						
					    case 31: // Steel skin.
                            Prayer.togglePrayer(player, PrayerData.Prayer.STEEL_SKIN);
						    break;
						
					    case 7: // Burst of strength.
                            Prayer.togglePrayer(player, PrayerData.Prayer.BURST_OF_STRENGTH);
						    break;
						
					    case 17: // Superhuman strength.
                            Prayer.togglePrayer(player, PrayerData.Prayer.SUPERHUMAN_STRENGTH);
						    break;
						
					    case 33: // Ultimate strength.
                            Prayer.togglePrayer(player, PrayerData.Prayer.ULTIMATE_STRENGTH);
						    break;
						
					    case 9: // Clarity of thought.
                            Prayer.togglePrayer(player, PrayerData.Prayer.CLARITY_OF_THOUGHT);
						    break;
						
					    case 19: // Improved reflexes.
                            Prayer.togglePrayer(player, PrayerData.Prayer.IMPROVED_REFLEXES);
						    break;
						
					    case 35: // Incredible reflexes.
						    Prayer.togglePrayer(player, PrayerData.Prayer.INCREDIBLE_REFLEXES);
						    break;
						
					    case 37: // Magic protect.
                            Prayer.togglePrayer(player, PrayerData.Prayer.PROTECT_FROM_MAGIC);
						    break;
						
					    case 39: // Ranged protect.
                            Prayer.togglePrayer(player, PrayerData.Prayer.PROTECT_FROM_RANGED);
						    break;
						
					    case 41: // Melee protect.
                            Prayer.togglePrayer(player, PrayerData.Prayer.PROTECT_FROM_MELEE);
						    break;
						
					    case 47: // Retribution.
                            Prayer.togglePrayer(player, PrayerData.Prayer.RETRIBUTION);
						    break;
						
					    case 49: // Redemption.
                            Prayer.togglePrayer(player, PrayerData.Prayer.REDEMPTION);
						    break;
						
					    case 51: // Smite.
                            Prayer.togglePrayer(player, PrayerData.Prayer.SMITE);
						    break;
						
					    case 55: // Chivalry.
                            Prayer.togglePrayer(player, PrayerData.Prayer.CHIVALRY);
						    break;
						
					    case 57: // Piety.
                            Prayer.togglePrayer(player, PrayerData.Prayer.PIETY);
						    break;
						
					    case 25: // Protect item.
                            Prayer.togglePrayer(player, PrayerData.Prayer.PROTECT_ITEM);
						    break;
						
					    case 21: // Rapid restore
                            Prayer.togglePrayer(player, PrayerData.Prayer.RAPID_RESTORE);
						    break;
						
					    case 23: // Rapid heal.
                            Prayer.togglePrayer(player, PrayerData.Prayer.RAPID_HEAL);
						    break;
						
					    case 11: // Sharp eye.
                            Prayer.togglePrayer(player, PrayerData.Prayer.SHARP_EYE);
						    break;
						
					    case 27: // Hawk Eye.
                            Prayer.togglePrayer(player, PrayerData.Prayer.HAWK_EYE);
						    break;
						
					    case 43: // Eagle Eye.
                            Prayer.togglePrayer(player, PrayerData.Prayer.EAGLE_EYE);
						    break;
						
					    case 13: // Mystic will.
                            Prayer.togglePrayer(player, PrayerData.Prayer.MYSTIC_WILL);
						    break;
						
					    case 29: // Mystic Lore.
                            Prayer.togglePrayer(player, PrayerData.Prayer.MYSTIC_LORE);
						    break;
						
					    case 45: // Mystic Might.
                            Prayer.togglePrayer(player, PrayerData.Prayer.MYSTIC_MIGHT);
						    break;
				    }
				    break;
				
			    case 90: // Staff attack interface.
				    switch(buttonId) {
					    case 5: // Select spell (Magic XP)
						    MagicData.configureSelectSpellInterface(player);
						    break;
						
					    case 9: // Auto retaliate.
						    player.toggleAutoRetaliate();
						    break;
						
 					    default:
 						    MagicData.cancelAutoCast(player, true);
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
				    }
				    break;
				
			    case 388: // Ancient magic autocast select spell.
				    switch(buttonId) {
					    case 0: // Smoke rush.
						    MagicData.setAutoCastSpell(player, 16, 8, true);
						    break;
						
					    case 1: // Shadow rush.
						    MagicData.setAutoCastSpell(player, 17, 12, true);
						    break;
						
					    case 2: // Blood rush.
						    MagicData.setAutoCastSpell(player, 18, 4, true);
						    break;
						
					    case 3: // Ice rush.
						    MagicData.setAutoCastSpell(player, 19, 0, true);
						    break;
											
					    case 4: // Smoke burst.
						    MagicData.setAutoCastSpell(player, 20, 10, true);
						    break;
						
					    case 5: // Shadow burst.
						    MagicData.setAutoCastSpell(player, 21, 14, true);
						    break;
						
					    case 6: // Blood burst.
						    MagicData.setAutoCastSpell(player, 22, 6, true);
						    break;
						
					    case 7: // Ice burst.
						    MagicData.setAutoCastSpell(player, 23, 2, true);
						    break;
						
					    case 8: // Smoke blitz.
						    MagicData.setAutoCastSpell(player, 24, 9, true);
						    break;
						
					    case 9: // Shadow blitz.
						    MagicData.setAutoCastSpell(player, 25, 13, true);
						    break;
						
					    case 10: // Blood blitz.
						    MagicData.setAutoCastSpell(player, 26, 5, true);
						    break;
						
					    case 11: // Ice blitz.
						    MagicData.setAutoCastSpell(player, 27, 1, true);
						    break;

					    case 12: // Smoke barrage.
						    MagicData.setAutoCastSpell(player, 28, 11, true);
						    break;
						
					    case 13: // Shadow barrage.
						    MagicData.setAutoCastSpell(player, 29, 15, true);
						    break;
						
					    case 14: // Blood barrage.
						    MagicData.setAutoCastSpell(player, 30, 7, true);
						    break;
						
					    case 15: // Ice barrage.
						    MagicData.setAutoCastSpell(player, 31, 3, true);
						    break;

					    case 16: // Cancel.
                            MagicData.cancelAutoCast(player, false);
						    break;
				    }
				    break;
				
			    case 406: // Void knight mace autocast select spell.
				    switch(buttonId) {
					    case 0: // Crumble undead.
						    MagicData.setAutoCastSpell(player, 32, 22, false);
						    break;
						
					    case 1: // Guthix claws.
						    MagicData.setAutoCastSpell(player, 34, 42, false);
						    break;
						
					    case 2: // Wind wave.
						    MagicData.setAutoCastSpell(player, 12, 45, false);
						    break;
						
					    case 3: // Water wave.
						    MagicData.setAutoCastSpell(player, 13, 48, false);
						    break;
						
					    case 4: // Earth wave.
						    MagicData.setAutoCastSpell(player, 14, 52, false);
						    break;
						
					    case 5: // Fire wave.
						    MagicData.setAutoCastSpell(player, 15, 55, false);
						    break;
					
					    case 6: // Cancel.
						    MagicData.cancelAutoCast(player, false);
						    break;
			    }
			    break;
				
			    case 310: // Slayer staff autocast select spell.
				    switch(buttonId) {
					    case 0: // Crumble undead.
						    MagicData.setAutoCastSpell(player, 32, 22, false);
						    break;
						
					    case 1: // Slayer dart.
						    MagicData.setAutoCastSpell(player, 33, 31, false);
						    break;
						
					    case 2: // Wind wave.
                            MagicData.setAutoCastSpell(player, 12, 45, false);
						    break;
						
					    case 3: // Water wave.
                            MagicData.setAutoCastSpell(player, 13, 48, false);
						    break;
						
					    case 4: // Earth wave.
                            MagicData.setAutoCastSpell(player, 14, 52, false);
						    break;
						
					    case 5: // Fire wave.
                            MagicData.setAutoCastSpell(player, 15, 55, false);
						    break;
					
					    case 6: // Cancel.
                            MagicData.cancelAutoCast(player, false);
						    break;
				    }
				    break;
				
			    case 319: // Normal magic autocast select spell.
				    switch(buttonId) {
					    case 0: // Wind strike.
                            MagicData.setAutoCastSpell(player, 0, 1, false);
						    break;
						
					    case 1: // Water strike.
                            MagicData.setAutoCastSpell(player, 1, 4, false);
						    break;
						
					    case 2: // Earth strike.
                            MagicData.setAutoCastSpell(player, 2, 6, false);
						    break;
						
					    case 3: // Fire strike.
                            MagicData.setAutoCastSpell(player, 3, 8, false);
						    break;
						
					    case 4: // Wind bolt.
                            MagicData.setAutoCastSpell(player, 4, 10, false);
						    break;
						
					    case 5: // Water bolt.
                            MagicData.setAutoCastSpell(player, 5, 14, false);
						    break;
						
					    case 6: // Earth bolt.
                            MagicData.setAutoCastSpell(player, 6, 17, false);
						    break;
						
					    case 7: // Fire bolt.
                            MagicData.setAutoCastSpell(player, 7, 20, false);
						    break;
						
					    case 8: // Wind blast.
                            MagicData.setAutoCastSpell(player, 8, 24, false);
						    break;
						
					    case 9: // Water blast.
                            MagicData.setAutoCastSpell(player, 9, 27, false);
						    break;
						
					    case 10: // Earth blast.
                            MagicData.setAutoCastSpell(player, 10, 33, false);
						    break;
						
					    case 11: // Fire blast.
                            MagicData.setAutoCastSpell(player, 11, 38, false);
						    break;

					    case 12: // Wind wave.
                            MagicData.setAutoCastSpell(player, 12, 45, false);
						    break;
						
					    case 13: // Water wave.
                            MagicData.setAutoCastSpell(player, 13, 48, false);
						    break;
						
					    case 14: // Earth wave.
                            MagicData.setAutoCastSpell(player, 14, 52, false);
						    break;
						
					    case 15: // Fire wave.
                            MagicData.setAutoCastSpell(player, 15, 55, false);
						    break;
						
					    case 16: // Cancel.
                            MagicData.cancelAutoCast(player, false);
						    break;
				    }
				    break;
		
			    case 182: // Logout tab.
				    player.getPackets().logout();
				    break;
			
			    case 261: // Settings tab.
				    switch(buttonId) {
					    case 16: // Display settings.
						    player.getPackets().displayInterface(742);
						    break;
						
					    case 18: // Audio settings.
						    player.getPackets().displayInterface(743);
						    break;
		
					    case 3: // Run toggle.
						    if(!player.getWalkingQueue().isRunToggled()) {
							    player.getWalkingQueue().setRunToggled(true);
							    player.getPackets().sendConfig(173, 1);
						    } else {
							    player.getWalkingQueue().setRunToggled(false);
							    player.getPackets().sendConfig(173, 0);
						    }
						    break;
						
					    case 4: // Chat effect toggle.
						    if(!player.isChatEffectsEnabled()) {
							    player.setChatEffectsEnabled(true);
							    player.getPackets().sendConfig(171, 0);
						    } else {
							    player.setChatEffectsEnabled(false);
							    player.getPackets().sendConfig(171, 1);
						    }
						    break;
						
					    case 5: // Split private chat toggle.
						    if(!player.isPrivateChatSplit()) {
							    player.setPrivateChatSplit(true);
							    player.getPackets().sendConfig(287, 1);
						    } else {
							    player.setPrivateChatSplit(false);
							    player.getPackets().sendConfig(287, 0);
						    }
						    break;
						
					    case 7: // Accept aid toggle.
						    if(!player.isAcceptAidEnabled()) {
							    player.setAcceptAidEnabled(true);
							    player.getPackets().sendConfig(427, 1);
						    } else {
							    player.setAcceptAidEnabled(false);
							    player.getPackets().sendConfig(427, 0);
						    }
						    break;
						
					    case 6: // Mouse buttons toggle.
						    if(!player.isMouseTwoButtons()) {
							    player.setMouseTwoButtons(true);
							    player.getPackets().sendConfig(170, 0);
						    } else {
							    player.setMouseTwoButtons(false);
							    player.getPackets().sendConfig(170, 1);
						    }
						    break;
				    }
				    break;
				
			    case 589: // Clan chat 
				    if (buttonId == 9) {
					    foreach(long friend in player.getFriends().getFriendsList()) {
						    player.getPackets().sendFriend(friend, player.getFriends().getWorld(friend));
					    }
					    Server.getClanManager().openClanSetup(player);
					    break;
				    }
				    break;
				
			    case 590: // Clan chat setup
 				    Clan clan = Server.getClanManager().getClanByOwner(player.getLoginDetails().getUsername());
				    if (clan == null) {
					    break;
				    }
				    switch(buttonId) {
					    case 22: // Clan name
						    player.getPackets().displayEnterText("Enter clan name :");
						    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(590, 0));
						    break;
						
	 				    case 23: // "Who can enter chat" - anyone.
                            clan.setEnterRights(Clan.ClanRank.NO_RANK);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getEnterRights()), 590, 23);
	 					    break;
	 					
	 				    case 24: // "Who can talk in chat" - anyone.
                            clan.setTalkRights(Clan.ClanRank.NO_RANK);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getTalkRights()), 590, 24);
	 					    break;
	 					
	 				    case 26: // "Who can share loot" - anyone.
                            clan.setLootRights(Clan.ClanRank.NO_RANK);
	 					    player.getPackets().modifyText(clan.getRankString(clan.getLootRights()), 590, 26);
	 					    break;
				    }
				    break;
				
			    case 763: // Bank inventory
				    switch(buttonId) {
					    case 0: // Deposit 1.
						    player.getBank().deposit(buttonId2, 1);
						    player.getBank().refreshBank();
						    break;
				    }
				    break;
				
			    case 762: // Bank
				    switch(buttonId) {		
					    case 73: // withdraw 1.
						    player.getBank().withdraw(buttonId2, 1);
						    player.getBank().refreshBank();
						    break;
						
					    case 16: // Note item.
						    player.getBank().asNote();
						    break;
						
					    case 41: // first (main) bank tab
						    player.getBank().setCurrentTab(10);
						    break;
						
					    case 39: // first bank tab
						    player.getBank().setCurrentTab(2);
						    break;
						
					    case 37: // second bank tab
						    player.getBank().setCurrentTab(3);
						    break;
						
					    case 35: // third bank tab
						    player.getBank().setCurrentTab(4);
						    break;
						
					    case 33: // fourth bank tab
						    player.getBank().setCurrentTab(5);
						    break;
						
					    case 31: // fifth bank tab
						    player.getBank().setCurrentTab(6);
						    break;
						
					    case 29: // sixth bank tab
						    player.getBank().setCurrentTab(7);
						    break;
						
					    case 27: // seventh bank tab
						    player.getBank().setCurrentTab(8);
						    break;
						
					    case 25: // eighth bank tab
						    player.getBank().setCurrentTab(9);
						    break;
				    }
				    break;
				
			    case 626: // Stake duel confirmation interface.
				    if (buttonId == 53) {
					    if (player.getDuel() != null) {
						    player.getDuel().acceptDuel();
						    break;
					    }
				    }
				    break;
				
			    case 631: // Stake duel first interface.
				    if (player.getDuel() != null) {
					    if (buttonId == 103) {
						    player.getDuel().removeItem(buttonId2, 1);
						    break;
					    } else {
						    player.getDuel().toggleDuelRules(buttonId);
						    break;
					    }
				    }
				    break;
				
			    case 387: // Equipment tab. 
				    switch(buttonId) {
					    case 55: // Character display.
						    player.getEquipment().displayEquipmentScreen();
						    break;
						
					    case 52: // Items kept on death.
						    ProtectedItems.displayItemsInterface(player);
						    break;
				    }
				    break;
				
			    case 274: // Quest tab.
				    switch(buttonId) {
					    case 3: // Achievment diary toggle.
						    player.getPackets().sendTab(85, 259);
						    player.setAchievementDiaryTab(true);
						    break;
				    }
				    break;
				
			    case 259: // Achievment diary tab.
				    switch(buttonId) {
					    case 8: // Quest tab toggle.
						    player.getPackets().sendTab(85, 274);
						    player.setAchievementDiaryTab(false);
						    break;
				    }
				    break;
				
			    case 620: // Shop interface.
				    if (player.getShopSession() == null) {
					    return;
				    }
				    switch(buttonId) {
					    case 26: // Player stock tab.
						    player.getShopSession().openPlayerShop();
						    break;
						
					    case 25: // Main stock tab.
						    player.getShopSession().openMainShop();
						    break;
						
					    case 23: // Value (main stock)	
					    case 24: // Value (player stock)
						    player.getShopSession().valueItem(buttonId2, false);
						    break;
				    }
				    break;
				
			    case 621: // Shop inventory.
				    if (player.getShopSession() == null) {
					    return;
				    }
				    switch(buttonId) {
					    case 0: // Value (player stock)
						    player.getShopSession().valueItem(buttonId2, true);
						    break;
				    }
				    break;
				
			    case 192: // Normal Magic tab.
				    switch(buttonId) {
					    case 0: // Home Teleport.
						    Teleport.homeTeleport(player);
						    break;
						
					    case 15: // Varrock teleport.
						    Teleport.teleport(player, 0);
						    break;
						
					    case 18: // Lumbridge teleport.
						    Teleport.teleport(player, 1);
						    break;
						
					    case 21: // Falador teleport.
						    Teleport.teleport(player, 2);
						    break;
						
					    case 23: // POH teleport.
						    player.getPackets().sendMessage("This teleport is unavailable.");
						    break;
						
					    case 26: // Camelot teleport.
						    Teleport.teleport(player, 3);
						    break;
						
					    case 32: // Ardougne teleport.
						    Teleport.teleport(player, 4);
						    break;
						
					    case 37: // Watchtower teleport.
						    player.getPackets().sendMessage("This teleport is unavailable.");
						    //Teleport.teleport(player, 5);
						    break;
						
					    case 44: // Trollheim teleport.
						    Teleport.teleport(player, 6);
						    break;
						
					    case 47: // Ape Atoll teleport.
						    player.getPackets().sendMessage("This teleport is unavailable.");
						    break;
						
					    case 58: // Charge.
						    MagicCombat.castCharge(player);
						    break;
				    }
				    break;
				
			    case 193: // Ancient magic tab.
				    switch(buttonId) {
					    case 20: // Paddewwa teleport.
						    Teleport.teleport(player, 7);
						    break;
						
					    case 21: // Senntisten teleport.
						    Teleport.teleport(player, 8);
						    break;
						
					    case 22: // Kharyrll teleport.
						    Teleport.teleport(player, 9);
						    break;
						
					    case 23: // Lassar teleport.
						    Teleport.teleport(player, 10);
						    break;
						
					    case 24: // Dareeyak teleport.
						    Teleport.teleport(player, 11);
						    break;
						
					    case 25: // Carrallanger teleport.
						    Teleport.teleport(player, 12);
						    break;
						
					    case 27: // Ghorrock teleport.
						    Teleport.teleport(player, 14);
						    break;
						
					    case 26: // Annakarl teleport.
						    Teleport.teleport(player, 13);
						    break;
						
					    case 28: // Ancients Home teleport.
						    Teleport.homeTeleport(player);
						    break;
				    }
				    break;
				
			    case 13: // Bank pin buttons.
				    if (buttonId == 29) {
					    player.getBank().forgotPin();
					    break;
				    }
				    player.getBank().handleEnterPin(buttonId);
				    break;
				
			    case 14: // Bank pin settings.
				    switch(buttonId) {
					    case 60: // Set new bank pin.
						    player.getBank().displayFirstConfirmation();
						    break;
					
					    case 61: // Change recovery delay.
						    player.getBank().changePinDelay();
						    break;
						
					    case 91: // "No, I might forget it!".
						    if (player.getBank().isPinPending()) {
							    player.getBank().cancelPendingPin();
							    break;
						    }
						    player.getBank().openPinSettings(2);
						    break;
						
					    case 89: // Yes i want to set a pin.
						    if (player.getBank().isPinPending()) {
							    player.getBank().verifyPin(true);
							    break;
						    }
						    player.getBank().openEnterPin();
						    break;
						
					    case 65: // Cancel pin that's pending.
						    player.getBank().openPinSettings(4);
						    break;
						
					    case 62: // Change pin.
						    player.getBank().changePin();
						    break;
						
					    case 63: // Delete pin.
						    player.getBank().deletePin();
						    break;
				    }
				    break;
				
			    case 464: // Emote tab.
				    Emotes.emote(player, buttonId);
				    break;
				
 			    case 320: // Skills Tab.
				    SkillMenu.display(player, buttonId);
				    break;
				
 			    case 499: // Skill menu side menu.
 				    SkillMenu.subMenu(player, buttonId);
 				    break;

 			    case 336: // Trade/duel inventory - trade 1.
 				    if (player.getTrade() != null) {
 					    player.getTrade().tradeItem(buttonId2, 1);
 					    break;
 				    }
 				    if (player.getDuel() != null) {
 					    player.getDuel().stakeItem(buttonId2, 1);
 					    break;
 				    }
 				    break;
 				
 			    case 335: // Trade interface.
 				    if (player.getTrade() == null) {
 					    break;
 				    }
				    switch(buttonId) {
					    case 16: // Accept trade.
						    player.getTrade().accept();
						    break;
						
					    case 18: // Decline trade.
						    player.getTrade().decline();
						    break;
						
					    case 30: // Offer 1
						    player.getTrade().removeItem(buttonId2, 1);
						    break;
				    }
 				    break;
 				
 			    case 334: // Trade confirmation.
 				    if (player.getTrade() == null) {
 					    break;
 				    }
 				    switch(buttonId) {
	 				    case 21: // Decline trade.
	 					    player.getTrade().decline();
						    break;
						
	 				    case 20: // Accept trade.
	 					    player.getTrade().accept();
	 					    break;
	 			    }
 				    break;
 				
 			    case 750: // Run button
				    if(!player.getWalkingQueue().isRunToggled()) {
					    player.getWalkingQueue().setRunToggled(true);
					    player.getPackets().sendConfig(173, 1);
				    } else {
					    player.getWalkingQueue().setRunToggled(false);
					    player.getPackets().sendConfig(173, 0);
				    }
				    break;
				
 			    case 667: // Equipment/bonuses interface.
 				    if (buttonId == 14) {
                        player.getEquipment().unequipItem((ItemData.EQUIP)buttonId2);
 					    break;
 				    }
 				    break;
				
 			    case 771: // Character design interface.
 				    ConfigureAppearance.sortButton(player, buttonId);
 				    break;
 				
 			    case 311: // Smelt interface.
 				    Smelting.smeltOre(player, buttonId, true, -1);
 				    break;
 				
 			    case 300: // Bar smithing interface.
 				    Smithing.smithItem(player, buttonId, 1, true);
 				    break;
 				
 			    case 92: // Unarmed attack interface.
 				    switch(buttonId) {			
 					    case 24: // Auto retaliate.
 						    player.toggleAutoRetaliate();
 						    break;
 						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 85: // Spear attack interface.
 				    switch(buttonId) {
					    case 8: // Special attack.
						    player.getSpecialAttack().toggleSpecBar();
						    break;
						
					    case 24: // Auto retaliate.
						    player.toggleAutoRetaliate();
						    break;
						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 93: // Whip attack interface.
 				    switch(buttonId) {
 					    case 8: // Special attack.
 						    player.getSpecialAttack().toggleSpecBar();
 						    break;
 						
 					    case 24: // Auto retaliate.
 						    player.toggleAutoRetaliate();
 						    break;
 						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 89: // Dagger attack interface.
 				    switch(buttonId) {					
 					    case 10: // Special attack.
 						    player.getSpecialAttack().toggleSpecBar();
 						    break;
 						
 					    case 26: // Auto retaliate.
 						    player.toggleAutoRetaliate();
 						    break;
 						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 82: // Longsword/scimitar attack interface.
 				    switch(buttonId) {					
 					    case 10: // Special attack.
 						    player.getSpecialAttack().toggleSpecBar();
 						    break;
 						
 					    case 26: // Auto retaliate.
 						    player.toggleAutoRetaliate();
 						    break;
 						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 78: // Claw attack interface.
 				    switch(buttonId) {
 					    case 10: // Special attack.
 						    player.getSpecialAttack().toggleSpecBar();
 						    break;
 						
 					    case 26: // Auto retaliate.
 						    player.toggleAutoRetaliate();
 						    break;
 						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 81: // Godsword attack interface.
 				    switch(buttonId) {
 					    case 10: // Special attack.
 						    player.getSpecialAttack().toggleSpecBar();
 						    break;
 						
 					    case 26: // Auto retaliate.
 						    player.toggleAutoRetaliate();
 						    break;
 						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 88: // Mace attack interface.
 				    switch(buttonId) {
 					    case 10: // Special attack.
 						    player.getSpecialAttack().toggleSpecBar();
 						    break;
 						
 					    case 26: // Auto retaliate.
 						    player.toggleAutoRetaliate();
 						    break;
 						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 76: // Granite maul attack interface.
 				    switch(buttonId) {
 					    case 8: // Special attack.
 						    player.getSpecialAttack().toggleSpecBar();
 						    break;
 						
 					    case 24: // Auto retaliate.
 						    player.toggleAutoRetaliate();
 						    break;
 						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 77: // Bow attack interface.
 				    switch(buttonId) {					
 					    case 11: // Special attack.
 						    player.getSpecialAttack().toggleSpecBar();
 						    break;
 						
 					    case 27: // Auto retaliate.
 						    player.toggleAutoRetaliate();
 						    break;
 						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 75: // Battleaxe attack interface.
 				    switch(buttonId) {
 					    case 10: // Special attack.
 						    player.getSpecialAttack().toggleSpecBar();
 						    player.getSpecialAttack().dragonBattleaxe();
 						    break;
 						
 					    case 26: // Auto retaliate.
 						    player.toggleAutoRetaliate();
 						    break;
 						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
 				    }
 				    break;
 				
 			    case 91: // Thrown weapon
 				    switch(buttonId) {
					    case 24: // Auto retaliate.
						    player.toggleAutoRetaliate();
						    break;
						
 					    default: 
 						    AttackInterface.configureButton(player, interfaceId, buttonId);
 						    break;
				    }
 				    break;
 				
 			    case 430: // Lunar interface
 				    switch(buttonId) {	
	 				    case 14: // Vengeance
	 					    Lunar.castLunarSpell(player, buttonId);
	 					    break;
 				    }
 				    break;
 				
 			    case 102: // Items on death interface
 				    if (buttonId == 18)
 					    player.getPackets().sendMessage("You will keep this item if you should you die.");
 				    else
 					    player.getPackets().sendMessage("You will lose this item if you should you die.");
 				    break;
 				
			    default:
				    if (interfaceId != 548 && interfaceId != 751) {
					    Console.WriteLine("Unhandled ActionButton : " + interfaceId + " " + buttonId + " " + buttonId2);
				    }
				    break;
		    }
	    }
	    private void handleCloseButton(Player player, Packet packet) {
            if (player.getTrade() != null)
                player.getTrade().decline();
            if (player.getDuel() != null)
            {
                if (player.getDuel().getStatus() < 4)
                {
                    player.getDuel().declineDuel();
                    return;
                }
                else if (player.getDuel().getStatus() == 8 && player.getDuel().getWinner().Equals(player))
                        player.getDuel().recieveWinnings(player);
            }
            player.getPackets().closeInterfaces();
	    }
	    private void handleActionButton3(Player player, Packet packet) {
		    int id = packet.readUShort();
		    int interfaceId = packet.readUShort();
		    int junk = packet.readLEShort();
		
		    int logType = (int) (player.getTemporaryAttribute("fletchType") == null ? -1 : (int) player.getTemporaryAttribute("fletchType")); // Bows (Fletching).
		    int ammoType = (int) (player.getTemporaryAttribute("ammoType") == null ? -1 : (int) player.getTemporaryAttribute("ammoType")); // Arrows (Fletching).
		    int boltType = (int) (player.getTemporaryAttribute("ammoType2") == null ? -1 : (int) player.getTemporaryAttribute("ammoType2")); // Bolts (Fletching).
		    int xbowType = (int) (player.getTemporaryAttribute("bowType2") == null ? -1 : (int) player.getTemporaryAttribute("bowType2")); // Xbows (Fletching).
		    int bowType = (int)  (player.getTemporaryAttribute("bowType") == null ? -1 : (int) player.getTemporaryAttribute("bowType")); // Longbow/Shortbow stringing (Fletching).
		    int grindItem = (int) (player.getTemporaryAttribute("herbloreGrindItem") == null ? -1 : (int) player.getTemporaryAttribute("herbloreGrindItem")); // item to be grinded (Herblore)
		    bool stringingBow = (bool) (player.getTemporaryAttribute("stringingBow") == null ? false : (bool) player.getTemporaryAttribute("stringingBow")); // Stringing bow/xbow (Fletching)
		    int unfinishedPotion = (int) (player.getTemporaryAttribute("unfinishedPotion") == null ? -1 : (int) player.getTemporaryAttribute("unfinishedPotion")); // unfinished potion to make (Herblore)
		    int completePotion = (int) (player.getTemporaryAttribute("completePotion") == null ? -1 : (int) player.getTemporaryAttribute("completePotion")); // unfinished potion to make (Herblore)
		    int cookItem = (int) (player.getTemporaryAttribute("meatItem") == null ? -1 : (int) player.getTemporaryAttribute("meatItem")); // item to cook (Cooking)
		    int dialogueStatus = (int) (player.getTemporaryAttribute("dialogue") == null ? -1 : (int) player.getTemporaryAttribute("dialogue")); // Dialogue status
		    int craftType = (int) (player.getTemporaryAttribute("craftType") == null ? -1 : (int) player.getTemporaryAttribute("craftType")); // 'Category' of item to craft
		    int leatherCraft = (int) (player.getTemporaryAttribute("leatherCraft") == null ? -1 : (int) player.getTemporaryAttribute("leatherCraft")); // Type of leather item to craft (high lvl hides)
		    int boltTips = (int) (player.getTemporaryAttribute("boltTips") == null ? -1 : (int) player.getTemporaryAttribute("boltTips")); // Type of bolt tips to cut
            JewelleryTeleport.JewellerySlot js = (JewelleryTeleport.JewellerySlot)player.getTemporaryAttribute("jewelleryTeleport") == null ? null : (JewelleryTeleport.JewellerySlot)player.getTemporaryAttribute("jewelleryTeleport");
		    Console.WriteLine("ACTIONBUTTON-3 "+ id);
		    if (JewelleryTeleport.teleport(player, id, js)) {
			    return;
		    }
		    switch(id) {
			    case 2:
				    if (player.getDuel() != null) {
					    if (player.getDuel().getStatus() == 6) {
						    player.getDuel().finishDuel(true, true);
						    player.getPackets().sendMessage("You climb through the trapdoor and forfeit the duel.");
						    break;
					    }
					    break;
				    } else
				    if (player.getTemporaryAttribute("barrowTunnel") != null) {
					    Barrows.verifyEnterTunnel(player);
					    return;
				    } else if (dialogueStatus == 1005) {
					    Slayer.doDialogue(player, 1006);
					    break;
				    } else if (dialogueStatus == 1009) {
					    Slayer.doDialogue(player, 1010);
					    break;
				    } else if (dialogueStatus == 1002) {
					    Slayer.doDialogue(player, 1013);
					    break;
				    } else if (dialogueStatus == 1017) {
					    Slayer.doDialogue(player, 1019);
					    break;
				    } else if (dialogueStatus == 1029) {
					    Slayer.doDialogue(player, 1029);
					    break;
				    } else if (dialogueStatus == 1053) {
					    Slayer.doDialogue(player, 1055);
					    break;
				    } else if (dialogueStatus > 1000) {
					    Slayer.doDialogue(player, 1006);
					    break;
				    } else if (dialogueStatus == 7) {
					    AgilityArena.doDialogue(player, 7);
					    break;
				    }  else if (dialogueStatus == 29) {
					    AgilityArena.doDialogue(player, 29);
					    break;
				    }  else if (dialogueStatus == 37) {
					    AgilityArena.doDialogue(player, 37);
					    break;
				    }  else if (dialogueStatus == 46) {
					    AgilityArena.doDialogue(player, 46);
					    break;
				    } else if (dialogueStatus == 79) {
					    WarriorGuild.talkToKamfreena(player, 79);
					    break;
				    } else if (dialogueStatus == 103) {
					    BrokenBarrows.showBobDialogue(player, 103);
					    break;
				    } else if (dialogueStatus == 109) {
					    BrokenBarrows.showBobDialogue(player, 109);
					    break;
				    } else if(dialogueStatus == 159) {
					    HomeArea.showAliDialogue(player, 159);
					    break;
				    } else if(dialogueStatus == 207) {
					    AlKharid.showAliDialogue(player, 207);
					    break;
				    } else if(dialogueStatus == 242) {
					    BoatOptions.showBentleyDialogue(player, 242);
					    break;
				    } else if (dialogueStatus == 450) {
					    FarmingAmulet.displayAllotmentOptions(player);
					    break;
				    } else if (dialogueStatus == 451) {
					    FarmingAmulet.teleportToPatch(player, 0);
					    break;
				    } else if (dialogueStatus == 452) {
					    FarmingAmulet.teleportToPatch(player, 4);
					    break;
				    } else if (dialogueStatus == 453) {
					    FarmingAmulet.teleportToPatch(player, 8);
					    break;
				    }
				    break;
		
			    case 13:
				    if (logType != -1) {
					    MakeBows.cutLog(player, 1, logType, 0, stringingBow, true);
					    break;
				    } else  if (craftType == 1 || craftType == 2) { // Clay pie dish
					    Clay.craftClay(player, 5, craftType, 1, true);
					    break;
				    } else if (leatherCraft != -1) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(304, 8));
					    break;
				    } else if (craftType == 6) {// Crossbow string
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(304, 2));
					    break;
				    }
				    break;
				
			    case 12:
				    if (logType == 0) {
					    MakeBows.cutLog(player, 5, logType, 0, stringingBow, true);
					    break;
				    } else if (logType > 0){
					    MakeBows.cutLog(player, 1, logType, 1, stringingBow, true);
					    break;
				    } else  if (craftType == 1 || craftType == 2) { // Clay pie dish
					    Clay.craftClay(player, 10, craftType, 1, true);
					    break;
				    } else if (leatherCraft != -1) {
					    Leather.craftDragonHide(player, 1, 4, leatherCraft, true); // Vambraces
					    break;
				    } else if (craftType == 6) {// Bowstring
					    Spinning.craftSpinning(player, 1, 1, true);
					    break;
				    }
				    break;
				
			    case 11:
				    if (logType == 0) {
					    MakeBows.cutLog(player, 10, logType, 0, stringingBow, true);
					    break;
				    } else if (logType > 0){
					    MakeBows.cutLog(player, 1, logType, 1, stringingBow, true);
					    break;
				    }  else  if (craftType == 1 || craftType == 2) { // Clay pie dish
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(306, 1));
					    break;
				    } else if (leatherCraft != -1) {
					    Leather.craftDragonHide(player, 5, 4, leatherCraft, true); // Vambraces
					    break;
				    } else if (craftType == 6) {// Bowstring
					    Spinning.craftSpinning(player, 5, 1, true);
					    break;
				    } else if (craftType >= 120 && craftType <= 130) { // Tiara
					    Silver.newSilverItem(player, 1, 121, true);
					    break;
				    }
				    break;
				
			    case 10:
				    if (logType == 0) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(305, 0));
					    break;
				    } else if (logType > 0){
					    MakeBows.cutLog(player, 5, logType, 1, stringingBow, true);
					    break;
				    } else if (craftType == 1 || craftType == 2) { // Clay pot
					    Clay.craftClay(player, 1, craftType, 0, true);
					    break;
				    } else if (leatherCraft != -1) {
					    Leather.craftDragonHide(player, 10, 4, leatherCraft, true); // Vambraces
					    break;
				    } else if (craftType == 6) {// Bowstring
					    Spinning.craftSpinning(player, 10, 1, true);
					    break;
				    } else if (craftType >= 120 && craftType <= 130) { // Tiara
					    Silver.newSilverItem(player, 5, 121, true);
					    break;
				    }
				    break;
				
			    case 17:
				    if (logType != -1) {
					    MakeBows.cutLog(player, 1, logType, 1, stringingBow, true);
					    break;
				    } else if (craftType == 1 || craftType == 2) { // Clay Bowl
					    Clay.craftClay(player, 5, craftType, 2, true);
				    }
				    break;
				
			    case 16:
				    if (logType != -1) {
					    MakeBows.cutLog(player, 5, logType, 1, stringingBow, true);
					    break;
				    } else if (craftType == 1 || craftType == 2) { // Clay Bowl
					    Clay.craftClay(player, 10, craftType, 2, true);
				    } else if (leatherCraft != -1) {
					    Leather.craftDragonHide(player, 1, 8, leatherCraft, true); // Chaps
					    break;
				    } else if (craftType == 6) {// Crossbow string
					    Spinning.craftSpinning(player, 1, 2, true);
					    break;
				    }
				    break;
				
			    case 15:
				    if (logType != -1) {
					    MakeBows.cutLog(player, 10, logType, 1, stringingBow, true);
					    break;
				    } else if (craftType == 1 || craftType == 2) { // Clay Bowl
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(306, 2));
				    } else if (leatherCraft != -1) {
					    Leather.craftDragonHide(player, 5, 8, leatherCraft, true); // Chaps
					    break;
				    } else if (craftType == 6) {// Crossbow string
					    Spinning.craftSpinning(player, 5, 2, true);
					    break;
				    }
				    break;
				
			    case 14:
				        if (craftType == 1 || craftType == 2) { // Clay pie dish
					    Clay.craftClay(player, 1, craftType, 1, true);
					    break;
				        } else if (logType == 0 && !stringingBow) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(305, 1));
					    break;
				    } else if (logType > 0){
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(305, 1));
					    break;
				    } else if (leatherCraft != -1) {
					    Leather.craftDragonHide(player, 10, 8, leatherCraft, true); // Chaps
					    break;
				    } else if (craftType == 6) {// Crossbow string
					    Spinning.craftSpinning(player, 10, 2, true);
					    break;
				    }
				    break;
				
			    case 9:
				    if (logType == 0) {
					    MakeBows.cutLog(player, 1, logType, 2, false, true);
					    break;
				    } else if (logType > 0){
					    MakeBows.cutLog(player, 10, logType, 1, stringingBow, true);
					    break;
				    }  else if (craftType == 1 || craftType == 2) { // Clay pot
					    Clay.craftClay(player, 5, craftType, 0, true);
					    break;
				    }  else if (leatherCraft != -1) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(304, 4));
					    break;
				    } else if (craftType == 6) {// Bowstring
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(304, 1));
					    break;
				    } else if (craftType >= 120 && craftType <= 130) { // Tiara
					    Silver.newSilverItem(player, 10, 121, true);
					    break;
				    }
				    break;
				
			    case 8:
				    if (logType == 0) {
					    MakeBows.cutLog(player, 5, logType, 2, false, true);
					    break;
				    } else if (logType > 0){
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(305, 1));
					    break;
				    } else if (craftType == 1 || craftType == 2) { // Clay pot
					    Clay.craftClay(player, 10, craftType, 0, true);
					    break;
				    } else if (leatherCraft != -1) {
					    Leather.craftDragonHide(player, 1, 0, leatherCraft, true); // Body
					    break;
				    } else if (craftType == 6) {// Ball of wool
					    Spinning.craftSpinning(player, 1, 0, true);
					    break;
				    } else if (craftType >= 120 && craftType <= 130) { // Tiara
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(303, 121));
					    break;
				    } else if (dialogueStatus < 1000) {
					    Dialogue.doDialogue(player, dialogueStatus);
					    break;
				    }
				    break;
				
			    case 7:
				    if (logType == 0) {
					    MakeBows.cutLog(player, 10, logType, 2, false, true);
					    break;
				    } else if (logType > 0){
					    MakeBows.cutLog(player, 1, logType, 0, stringingBow, true);
					    break;
				    } else if (craftType == 1 || craftType == 2) { // Clay pot
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(306, 0));
					    break;
				    } else if (leatherCraft != -1) {
					    Leather.craftDragonHide(player, 5, 0, leatherCraft, true); // Body
					    break;
				    } else if (craftType == 6) {// Ball of wool
					    Spinning.craftSpinning(player, 5, 0, true);
					    break;
				    } else if (craftType >= 120 && craftType <= 130) { // Unholy symbol
					    Silver.newSilverItem(player, 1, 120, true);
					    break;
				    } else if (dialogueStatus > 1000) {
					    Slayer.doDialogue(player, dialogueStatus);
					    break;
				    } else if (dialogueStatus < 1000) {
					    Dialogue.doDialogue(player, dialogueStatus);
					    break;
				    }
				    break;
				
			    case 6:
				    if (logType == 0 && !stringingBow) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(305, 2));
					    break;
				    } else if (stringingBow && bowType != -1) {
					    MakeBows.cutLog(player, 1, logType, bowType, true, true);
					    break;
				    } else if (boltTips > -1) {
					    MakeAmmo.makeBoltTip(player, boltTips, 1, true);
					    break;
				    } else if (xbowType != -1) {
					    MakeXbow.createXbow(player, 1, xbowType, stringingBow, true);
					    break;
				    } else if (grindItem != -1) {
					    Herblore.grindIngredient(player, 1, true);
					    break;
				    } else if (unfinishedPotion != -1) {
					    Herblore.makeUnfinishedPotion(player, 1, true);
					    break;
				    } else if (completePotion != -1) {
					    Herblore.completePotion(player, 1, true);
					    break;
				    } else if (cookItem != -1) {
					    Cooking.cookItem(player, 1, true, player.getTemporaryAttribute("cookingFireLocation") != null);
					    break;
				    } else if (logType > 0){
					    MakeBows.cutLog(player, 5, logType, 0, false, true);
					    break;
				    } else if (leatherCraft != -1) {
					    Leather.craftDragonHide(player, 10, 0, leatherCraft, true); // Body
					    break;
				    } else if (craftType == 6) {// Ball of wool
					    Spinning.craftSpinning(player, 10, 0, true);
					    break;
				    } else if (craftType >= 50 && craftType <= 60) { // Cut gem
					    Jewellery.cutGem(player, craftType, 1, true);
					    break;
				    } else if (craftType >= 100 && craftType <= 110) { // String amulet
					    Jewellery.stringAmulet(player, craftType, 1, true);
					    break;
				    } else if (craftType >= 120 && craftType <= 130) { // Unholy symbol
					    Silver.newSilverItem(player, 5, 120, true);
					    break;
				    } else if (dialogueStatus > 1000) {
					    Slayer.doDialogue(player, dialogueStatus);
					    break;
				    } else if (dialogueStatus == 7) {
					    AgilityArena.doDialogue(player, 41);
					    break;
				    } else if(dialogueStatus == 242) {
					    BoatOptions.showBentleyDialogue(player, 246);
					    break;
				    } else if (dialogueStatus == 451 || dialogueStatus == 452 || dialogueStatus == 453) {
					    FarmingAmulet.showOptions(player, 12622);
					    break;
				    } else if (dialogueStatus < 1000) {
					    Dialogue.doDialogue(player, dialogueStatus);
					    break;
				    }
				    break;
				
			    case 5:
				    if (ammoType != -1) {
					    MakeAmmo.createAmmo(player, 1, ammoType, false, true);
					    break;
				    } else if (stringingBow && bowType != -1) {
					    MakeBows.cutLog(player, 5, logType, bowType, true, true);
					    break;
				    } else if (boltType != -1) {
					    MakeAmmo.createAmmo(player, 1, boltType, true, true);
					    break;
				    } else if (xbowType != -1) {
					    MakeXbow.createXbow(player, 5, xbowType, stringingBow, true);
					    break;
				    } else if (grindItem != -1) {
					    Herblore.grindIngredient(player, 5, true);
					    break;
				    } else if (unfinishedPotion != -1) {
					    Herblore.makeUnfinishedPotion(player, 5, true);
					    break;
				    } else if (completePotion != -1) {
					    Herblore.completePotion(player, 5, true);
					    break;
				    } else if (cookItem != -1) {
					    Cooking.cookItem(player, 5, true, player.getTemporaryAttribute("cookingFireLocation") != null);
					    break;
				    } else if (logType != -1) {
					    MakeBows.cutLog(player, 10, logType, 0, false, true);
					    break;
				    } else if (dialogueStatus == 1002) {
					    Slayer.doDialogue(player, 1024);
					    break;
				    } else if (dialogueStatus == 1053) {
					    Slayer.doDialogue(player, 1061);
					    break;
				    } else if (dialogueStatus > 1000) {
					    Slayer.doDialogue(player, dialogueStatus);
					    break;
				    } else if (dialogueStatus == 7) {
					    AgilityArena.doDialogue(player, 34);
					    break;
				    } else if (leatherCraft != -1) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(304, 0));
					    break;
				    } else if (craftType == 6) {// Ball of wool
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(304, 0));
					    break;
				    } else if (craftType >= 50 && craftType <= 60) { // Cut gem
					    Jewellery.cutGem(player, craftType, 5, true);
					    break;
				    } else if (craftType >= 100 && craftType <= 110) { // String amulet
					    Jewellery.stringAmulet(player, craftType, 5, true);
					    break;
				    } else if (craftType >= 120 && craftType <= 130) { // Unholy symbol
					    Silver.newSilverItem(player, 10, 120, true);
					    break;
				    }  else if (dialogueStatus == 46) {
					    AgilityArena.doDialogue(player, 54);
					    break;
				    } else if(dialogueStatus == 242) {
					    BoatOptions.showBentleyDialogue(player, 245);
					    break;
				    } else if (dialogueStatus == 451) {
					    FarmingAmulet.teleportToPatch(player, 3);
					    break;
				    } else if (dialogueStatus == 452) {
					    FarmingAmulet.teleportToPatch(player, 7);
					    break;
				    } else if (dialogueStatus == 453) {
					    FarmingAmulet.teleportToPatch(player, 11);
					    break;
				    } else if (dialogueStatus == 450) {
					    player.getPackets().closeInterfaces();
					    break;
				    } else if (dialogueStatus != -1 && dialogueStatus < 1000){
					    Dialogue.doDialogue(player, dialogueStatus);
					    break;
				    } else if (boltTips > -1) {
					    MakeAmmo.makeBoltTip(player, boltTips, 5, true);
					    break;
				    }
				    break;
				
			    case 4:
				    if (ammoType != -1) {
					    MakeAmmo.createAmmo(player, 5, ammoType, false, true);
					    break;
				    } else if (boltType != -1) {
					    MakeAmmo.createAmmo(player, 5, boltType, true, true);
					    break;
				    } else if (xbowType != -1) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(309, 0));
					    break;
				    } else if (stringingBow && bowType != -1) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(309, 1));
					    break;
				    } else if (grindItem != -1) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(309, 2));
					    break;
				    } else if (unfinishedPotion != -1) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(309, 3));
					    break;
				    } else if (completePotion != -1) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(309, 4));
					    break;
				    } else if (cookItem != -1) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(309, 5));
					    break;
				    } else if (logType != -1){
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(305, 0));
					    break;
				    } else if (craftType >= 50 && craftType <= 60) { // Cut gem
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(309, craftType));
					    break;
				    } else if (craftType >= 100 && craftType <= 110) { // String amulet
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(309, craftType));
					    break;
				    } else if (craftType >= 120 && craftType <= 130) { // Unholy symbol
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(303, 120));
					    break;
				    } else if (dialogueStatus == 1053) {
					    Slayer.doDialogue(player, 1059);
					    break;
				    } else if (dialogueStatus == 1002) {
					    Slayer.doDialogue(player, 1025);
					    break;
				    } else if (dialogueStatus == 7) {
					    AgilityArena.doDialogue(player, 24);
					    break;
				    }  else if (dialogueStatus == 46) {
					    AgilityArena.doDialogue(player, 51);
					    break;
				    } else if (dialogueStatus == 109) {
					    BrokenBarrows.showBobDialogue(player, 114);
					    break;
				    } else if (dialogueStatus == 140 || dialogueStatus == 141) {
					    player.getPackets().closeInterfaces();
					    break;
				    } else if(dialogueStatus == 159) {
					    HomeArea.showAliDialogue(player, 177);
					    break;
				    } else if(dialogueStatus == 242) {
					    BoatOptions.showBentleyDialogue(player, 244);
					    break;
				    } else if (boltTips > -1) { // Cut bolt tips
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(309, 6));
					    break;
				    } else if (dialogueStatus == 451) {
					    FarmingAmulet.teleportToPatch(player, 2);
					    break;
				    } else if (dialogueStatus == 452) {
					    FarmingAmulet.teleportToPatch(player, 6);
					    break;
				    } else if (dialogueStatus == 450) {
					    FarmingAmulet.displayFruitTreeOptions(player);
					    break;
				    } else if (dialogueStatus == 453) {
					    FarmingAmulet.teleportToPatch(player, 10);
					    break;
				    }
				    break;
				
			    case 3:
				    if (player.getDuel() != null) {
					    player.getPackets().closeChatboxInterface();
					    break;
				    } else if (ammoType != -1) {
					    MakeAmmo.createAmmo(player, 10, ammoType, false, true);
					    break;
				    } else if (boltType != -1) {
					    MakeAmmo.createAmmo(player, 10, boltType, true, true);
					    break;
				    } else if (stringingBow && bowType != -1) {
					    MakeBows.cutLog(player, player.getInventory().getItemAmount(1777), logType, bowType, true, true);
					    break;
				    } else if (xbowType != -1) {
					    MakeXbow.createXbow(player, player.getInventory().getItemAmount(9438), xbowType, stringingBow, true);
					    break;
				    } else if (grindItem != -1) {
					    Herblore.grindIngredient(player, 28, true);
					    break;
				    } else if (unfinishedPotion != -1) {
					    Herblore.makeUnfinishedPotion(player, 28, true);
					    break;
				    } else if (completePotion != -1) {
					    Herblore.completePotion(player, 28, true);
					    break;
				    } else if (cookItem != -1) {
					    Cooking.cookItem(player, 28, true, player.getTemporaryAttribute("cookingFireLocation") != null);
					    break;
				    } else if (bowType != -1 && logType != -1) {
					    MakeBows.cutLog(player, 10, logType, bowType, false, true);
					    break;
				    } else if (craftType >= 50 && craftType <= 60) { // Cut gem
					    Jewellery.cutGem(player, craftType, 27, true);
					    break;
				    } else if (craftType >= 100 && craftType <= 110) { // String amulet
					    Jewellery.stringAmulet(player, craftType, 27, true);
					    break;
				    } else if (craftType >= 120 && craftType <= 130) { // Unholy symbol
					    Silver.newSilverItem(player, 27, 120, true);
					    break;
				    } else if (dialogueStatus == 1017) {
					    Slayer.doDialogue(player,  1017);
					    break;
				    } else if (dialogueStatus == 1053) {
					    Slayer.doDialogue(player, 1057);
					    break;
				    } else if (dialogueStatus == 1002) {
					    Slayer.doDialogue(player, 1021);
					    break;
				    } else if (dialogueStatus > 1000) {
					    Slayer.doDialogue(player, dialogueStatus);
					    break;
				    } else if (dialogueStatus == 7) {
					    AgilityArena.doDialogue(player, 17);
					    break;
				    }  else if (dialogueStatus == 29) {
					    AgilityArena.doDialogue(player, 33);
					    break;
				    }  else if (dialogueStatus == 37) {
					    AgilityArena.doDialogue(player, 39);
					    break;
				    }  else if (dialogueStatus == 46) {
					    AgilityArena.doDialogue(player, 48);
					    break;
				    } else if (dialogueStatus == 79) {
					    WarriorGuild.talkToKamfreena(player, 80);
					    break;
				    } else if (dialogueStatus == 103) {
					    BrokenBarrows.showBobDialogue(player, 105);
					    break;
				    } else if (dialogueStatus == 109) {
					    BrokenBarrows.showBobDialogue(player, 111);
					    break;
				    } else if(dialogueStatus == 159) {
					    HomeArea.showAliDialogue(player, 162);
					    break;
				    } else if(dialogueStatus == 207) {
					    AlKharid.showAliDialogue(player, 210);
					    break;
				    } else if(dialogueStatus == 242) {
					    BoatOptions.showBentleyDialogue(player, 243);
					    break;
				    } else if (boltTips > -1) {
					    MakeAmmo.makeBoltTip(player, boltTips, player.getInventory().getItemAmount((int)FletchingData.GEMS[boltTips][0]), true);
					    break;
				    } else if (dialogueStatus == 451) {
					    FarmingAmulet.teleportToPatch(player, 1);
					    break;
				    } else if (dialogueStatus == 450) {
					    FarmingAmulet.displayTreeOptions(player);
					    break;
				    } else if (dialogueStatus == 452) {
					    FarmingAmulet.teleportToPatch(player, 5);
					    break;
				    } else if (dialogueStatus == 453) {
					    FarmingAmulet.teleportToPatch(player, 9);
					    break;
				    }
				    break;
				
			    case 21:
				    if (logType == 0) {
					    MakeBows.cutLog(player, 1, logType, 3, false, true);
					    break;
				    } else if (craftType == 1 || craftType == 2) { // Clay plant pot
					    Clay.craftClay(player, 5, craftType, 3, true);
					    break;
				    }
				    break;
				
			    case 20:
				    if (logType == 0) {
					    MakeBows.cutLog(player, 5, logType, 3, false, true);
					    break;
				    } else if (craftType == 1 || craftType == 2) { // Clay plant pot
					    Clay.craftClay(player, 10, craftType, 3, true);
					    break;
				    }
				    break;

			    case 19:
				    if (logType == 0) {
					    MakeBows.cutLog(player, 10, logType, 3, false, true);
					    break;
				    } else if (craftType == 1 || craftType == 2) { // Clay plant pot
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(306, 3));
					    break;
				    }
				    break;
	
			    case 18:
				    if (logType == 0) {
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(305, 3));
					    break;
				    } else if (craftType == 1 || craftType == 2) { // Clay Bowl
					    Clay.craftClay(player, 1, craftType, 2, true);
					    break;
				    }
				    break;
				
			    case 22:
				        if (craftType == 1 || craftType == 2) { // Clay plant pot
					    Clay.craftClay(player, 1, craftType, 3, true);
					    break;
				    }
				    break;
				
			    case 26:
				        if (craftType == 1 || craftType == 2) { // Clay lid
					    Clay.craftClay(player, 1, craftType, 4, true);
					    break;
				    }
				    break;
				
			    case 25:
				        if (craftType == 1 || craftType == 2) { // Clay lid
					    Clay.craftClay(player, 5, craftType, 4, true);
					    break;
				    }
				    break;
				
			    case 24:
				        if (craftType == 1 || craftType == 2) { // Clay lid
					    Clay.craftClay(player, 10, craftType, 4, true);
					    break;
				    }
				    break;
				
			    case 23:
				    if (craftType == 1 || craftType == 2) { // Clay lid
					    player.getPackets().displayEnterAmount();
					    player.setTemporaryAttribute("interfaceVariable", new EnterVariable(306, 4));
					    break;
				    }
				    break;
				
			    case 1:
				    switch(id) {
					    case 1:
						    if (dialogueStatus == 1002) {
							    Slayer.doDialogue(player, dialogueStatus);
							    break;
						    } else if (dialogueStatus == 1053) {
							    Slayer.doDialogue(player, dialogueStatus);
							    break;
						    }
						    break;
				    }
				    break;
				
			    default:
				    Console.WriteLine("ACTIONBUTTON3 = " + id);
				    break;
		    }
		    if (dialogueStatus == -1) {
			    player.getPackets().closeInterfaces();
		    }
	    }
Exemplo n.º 13
0
        /**
         * Unregister a player.
         * @param p as Player
         */
        public static void unregister(Player p)
        {
            if (p.getTrade() != null)
            {
                p.getTrade().decline();
                p.setTrade(null);
            }
            minigames.getFightPits().removeWaitingPlayer(p);
            minigames.getFightPits().removePlayingPlayer(p);
            if (p.getTemporaryAttribute("cantDoAnything") != null && Location.inFightPits(p.getLocation()))
            {
                minigames.getFightPits().useOrb(p, 5);
                return;
            }
            if (Location.inFightPits(p.getLocation()))
            {
                Server.getMinigames().getFightPits().teleportToWaitingRoom(p, false);
                return;
            }
            if (p.getFightCave() != null)
            {
                if (!p.getFightCave().isGamePaused())
                {
                    p.getFightCave().teleFromCave(true);
                    return;
                }
                else
                {
                    p.setLocation(new Location(2439, 5169, 0));
                }
            }
            if (!Combat.isXSecondsSinceCombat(p, p.getLastAttacked(), 10000) || p.isDead() || p.getTemporaryAttribute("unmovable") != null)
            {
                return;
            }
            if (p.getDuel() != null)
            {
                if (p.getDuel().getStatus() == 8)
                {
                    if (p.getDuel().getWinner().Equals(p))
                    {
                        p.getDuel().recieveWinnings(p);
                    }
                }
                else
                {
                    if (p.getDuel().getStatus() == 5 || p.getDuel().getStatus() == 6)
                    {
                        p.getDuel().finishDuel(true, true);
                    }
                }
            }
            removeAllPlayersNPCs(p);

           
            foreach(Player p2 in players) {
                if(p == p2) continue;
                //Remove me from anyone who has Seen me.. or attempting to see me (new players).
                if (p2.getLocalEnvironment().getSeenPlayers().Contains(p) || p2.getLocalEnvironment().getNewPlayers().Contains(p))
                    p2.getLocalEnvironment().getRemovedPlayers().Add(p);
            }

            clanManager.leaveChannel(p);
            loginHandler.addSavePlayer(p);
            players.Remove(p);
            p.getFriends().unregistered();
            Console.WriteLine("Unregistered " + p.getLoginDetails().getUsername() + " [online = " + players.Count + "]");
        }
Exemplo n.º 14
0
	    private static void drinkPotion(Player p, int i, int j, int slot) {
		    //TODO antipoisons/antifire
		    int lastPotion = -1;
		    int delay = 500;
		    long lastDrink = 0;
		    if (p.isDead() || p.getTemporaryAttribute("willDie") != null) {
			    return;
		    }
		    if (p.getDuel() != null) {
			    if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_DRINKS))  {
				    p.getPackets().sendMessage("Drinks have been disabled for this duel!");
				    return;
			    }
		    }
		    if (p.getTemporaryAttribute("lastDrankPotion") != null) {
			    lastPotion = (int) p.getTemporaryAttribute("lastDrankPotion");
		    }
		    if (p.getTemporaryAttribute("drinkPotionTimer") != null) {
			    lastDrink = (int) p.getTemporaryAttribute("drinkPotionTimer");
		    }
		    int time = (j == lastPotion) ? 1000 : 500;
		    if (Environment.TickCount - lastDrink < time) {
			    return;
		    }
		    p.getPackets().closeInterfaces();
		    p.setTemporaryAttribute("drinkPotionTimer", Environment.TickCount);
		    p.setTemporaryAttribute("lastDrankPotion", j);
		    p.setTarget(null);
		    p.resetCombatTurns();
		    p.setEntityFocus(65535);
		    p.removeTemporaryAttribute("autoCasting");

            Event drinkPotionEvent = new Event(delay);
            drinkPotionEvent.setAction(() => {		
				drinkPotionEvent.stop();
				if (p.isDead() || p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) <= 0) {
					return;
				}
                int item = i != 0 && POTIONS[i - 1][j] != -1 ? POTIONS[i - 1][j] : 229;
				if (!p.getInventory().replaceItemSlot(POTIONS[i][j],  item, slot)) {
					return;
				}
                string drinkPotion = ItemData.forId(POTIONS[0][j]).getName().Replace("(", "").Replace(")", "").Replace("3", "").Replace("2", "").Replace("1", "").ToLower();
                p.getPackets().sendMessage("You drink some of your " + drinkPotion + ".");
                p.getPackets().sendMessage("You have " + (i == 0 ? "no" : i.ToString()) + " doses of potion left.");
				switch(j) {
					case 0: //Attack potion [+3 and 10% of max attack]
						statBoost(p, Skills.SKILL.ATTACK, 0.10, 3, false); 
                        break;
					case 1: //Antipoison potion
						p.setPoisonAmount(0);
						break;
						
					case 2: //Strength potion [+3 and 10% of max strength]
						statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
						break;
						
					case 3: //Restore potion [restores randomly between 10-39 points]
                        restorePotion(p, Skills.SKILL.DEFENCE, 10, 39);
                        restorePotion(p, Skills.SKILL.ATTACK, 10, 39);
                        restorePotion(p, Skills.SKILL.STRENGTH, 10, 39);
                        restorePotion(p, Skills.SKILL.RANGE, 10, 39);
                        restorePotion(p, Skills.SKILL.HITPOINTS, 10, 39);
						break;
						
					case 4: //Energy potion [restores 20% energy]
                        double newEnergy = p.getRunEnergy() * 0.20;
                        p.setRunEnergy(((p.getRunEnergy() + (int)newEnergy >= 100) ? 100 : (p.getRunEnergy() + (int)newEnergy)));
						break;
						
					case 5: //Defence potion [Should be +3 and 10% of max defence]
                        statBoost(p, Skills.SKILL.DEFENCE, 0.10, 3, false);
						break;
						
					case 6: //Agility potion [restores 2 or 3 agility points]
                        int newAgility = misc.random(2, 3) + p.getSkills().getCurLevel(Skills.SKILL.AGILITY);
                        if (newAgility < p.getSkills().getMaxLevel(Skills.SKILL.AGILITY))
                            p.getSkills().setCurLevel(Skills.SKILL.AGILITY, newAgility);
						break;
						
					case 7: //Combat potion [Should be 10% of attack+strength and +3 to each].
                        statBoost(p, Skills.SKILL.ATTACK, 0.10, 3, false);
                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
						break;
						
					case 8: //Prayer potion, [heals 7-31, formula = 7+floor(prayerlevel/4)]
                        int newPrayer = 7 + (int)Math.Floor((double)(p.getSkills().getMaxLevel(Skills.SKILL.PRAYER) / 4)) + p.getSkills().getCurLevel(Skills.SKILL.PRAYER);
                        if (newPrayer < p.getSkills().getCurLevel(Skills.SKILL.PRAYER))
                            p.getSkills().setCurLevel(Skills.SKILL.PRAYER, newPrayer);
                        checkOverdose(p, Skills.SKILL.PRAYER);
						break;
						
					case 9: //Summoning potion [25% of players summoning + 7]
                        int newSummoning = (7 + (int)((double)p.getSkills().getMaxLevel(Skills.SKILL.SUMMONING) * 0.25)) + p.getSkills().getCurLevel(Skills.SKILL.SUMMONING);
                        if (newSummoning < p.getSkills().getCurLevel(Skills.SKILL.SUMMONING))
                            p.getSkills().setCurLevel(Skills.SKILL.SUMMONING, newSummoning);

                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 3, false);
						break;
						
					case 10: //Super attack potion [15% of players attack + 5]
                        statBoost(p, Skills.SKILL.ATTACK, 0.15, 5, false);
						break;
						
					case 11: // super antipoison
						p.setPoisonAmount(0);
						p.setSuperAntipoisonCycles(20);
						break;
						
					case 12: //Fishing potion [fishing +3]
                        if (p.getSkills().getCurLevel(Skills.SKILL.FISHING) < (p.getSkills().getMaxLevel(Skills.SKILL.FISHING) + 3))
                            p.getSkills().setCurLevel(Skills.SKILL.FISHING, p.getSkills().getCurLevel(Skills.SKILL.FISHING) + 3);
						break;
						
					case 13:
						p.setRunEnergy(p.getRunEnergy() + 20);
						if (p.getRunEnergy() >= 100) {
							p.setRunEnergy(100);
						}
						break;
						
					case 14: //Hunter potion [hunting + 3]
                        if (p.getSkills().getCurLevel(Skills.SKILL.HUNTER) < (p.getSkills().getMaxLevel(Skills.SKILL.HUNTER) + 3))
                            p.getSkills().setCurLevel(Skills.SKILL.HUNTER, p.getSkills().getCurLevel(Skills.SKILL.HUNTER) + 3);
						break;
						
					case 15: //Super strength [strength 15% +5]
						statBoost(p, Skills.SKILL.STRENGTH, 0.15, 5, false);
						break;
						
					case 16: //restores all skills by 33%.
                        foreach (Skills.SKILL skill in Enum.GetValues(typeof(Skills.SKILL)))
                            superRestorePotion(p, skill, 0.33);
						break;

                    case 17://Super defence [defence 15% +5]
						statBoost(p, Skills.SKILL.DEFENCE, 0.15, 5, false);
						break;
						
					case 18: // Antifire potion
						p.setAntifireCycles(20);
						break;

                    case 19: //Ranging potions
						statBoost(p, Skills.SKILL.RANGE, 0.10, 4, false);
						break;
						
					case 20: //Magic potion.
                        if (p.getSkills().getCurLevel(Skills.SKILL.MAGIC) < (p.getSkills().getMaxLevel(Skills.SKILL.MAGIC) + 4))
                            p.getSkills().setCurLevel(Skills.SKILL.MAGIC, p.getSkills().getCurLevel(Skills.SKILL.MAGIC) + 4);
						break;
						
					case 21: //Zamorak brew potion. [Attack %20+2][Strength %12 +2][Defense -10% + -2][hitpoints -10% + 20]
                        statBoost(p, Skills.SKILL.ATTACK, 0.20, 2, false);
                        statBoost(p, Skills.SKILL.STRENGTH, 0.12, 2, false);
                        statBoost(p, Skills.SKILL.DEFENCE, 0.10, 2, true);
                        statBoost(p, Skills.SKILL.HITPOINTS, 0.10, 20, true);
						break;

                    case 22: //Saradomin brew potion. [Hitpoints +%15][Defense +25%][Strength, Attack, Magic and Ranged -10%]
                        statBoost(p, Skills.SKILL.HITPOINTS, 0.15, 0, false);
                        statBoost(p, Skills.SKILL.DEFENCE, 0.25, 0, false);
                        statBoost(p, Skills.SKILL.STRENGTH, 0.10, 0, true);
                        statBoost(p, Skills.SKILL.ATTACK, 0.10, 0, true);
                        statBoost(p, Skills.SKILL.MAGIC, 0.10, 0, true);
                        statBoost(p, Skills.SKILL.RANGE, 0.10, 0, true);
						break;
				}
				p.setLastAnimation(new Animation(829));
				p.getPackets().sendSkillLevels();
		    });
            Server.registerEvent(drinkPotionEvent);
	    }		
Exemplo n.º 15
0
	    private static void eatFood(Player p, int i, int j, int slot) {
            //delay at which you eat food 0.5 seconds (half a second per eat).
		    int delay = 500;
            //If you are dead or yourHp is zero (this should be enough), also if variable is set to die from next attack
            if (p.isDead() || p.getHp() <= 0 || p.getTemporaryAttribute("willDie") != null)
			    return;

            //Last time you ate timer was previously set.
		    if (p.getTemporaryAttribute("eatFoodTimer") != null) {
                //Check if the timer has passed the time of 1.2 seconds
			    if (Environment.TickCount - (int) p.getTemporaryAttribute("eatFoodTimer") < 1200) {
				    return;
			    }
		    }
            //if you are in a duel
		    if (p.getDuel() != null) {
                //dueling with No Food rule enabled
			    if (p.getDuel().ruleEnabled(DuelSession.RULE.NO_FOOD))  {
				    p.getPackets().sendMessage("Food has been disabled for this duel!");
				    return;
			    }
		    }
            //Set timer right now because you are eating some food.
		    p.setTemporaryAttribute("eatFoodTimer", Environment.TickCount);
            //while you are eating the target you are attacking gets reset.
		    p.setTarget(null);
		    p.resetCombatTurns();
		    p.setEntityFocus(65535);
		    p.getPackets().closeInterfaces();
		    p.removeTemporaryAttribute("autoCasting");

            //start eating the food at delay which is 0.5 of a second / half a second.
            Event eatFoodEvent = new Event(delay);
            eatFoodEvent.setAction(() => {
                //make the food eating event stop after this time.
				eatFoodEvent.stop();
                //if you are dead or your hp is zero aka dead.
				if (p.isDead() || p.getHp() <= 0) {
					return;
				}
				int newHealth = p.getSkills().getCurLevel(Skills.SKILL.HITPOINTS) + FOOD_HEAL[j];
                int item = i != 2 && FOOD[i + 1][j] != -1 ? FOOD[i + 1][j] : -1;
                if (!p.getInventory().replaceItemSlot(FOOD[i][j], item, slot))
                {
					return;
				}
                p.getPackets().sendMessage("You eat the " + ItemData.forId(FOOD[i][j]).getName().ToLower() + ".");
				p.getSkills().setCurLevel(Skills.SKILL.HITPOINTS, newHealth > p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) ? p.getSkills().getMaxLevel(Skills.SKILL.HITPOINTS) : newHealth);
				p.setLastAnimation(new Animation(829));
				p.getPackets().sendSkillLevel(Skills.SKILL.HITPOINTS);
		    });
            Server.registerEvent(eatFoodEvent);
	    }
Exemplo n.º 16
0
 private bool canWalk(Player player, Packet packet, bool following)
 {
     if (player.getTemporaryAttribute("smeltingBar") != null) {
         Smelting.setAmountToZero(player);
         return false;
     } else if (player.getTemporaryAttribute("teleporting") != null && player.getTemporaryAttribute("homeTeleporting") == null) {
         return false;
     } else if (player.isFrozen()) {
         player.getPackets().sendMessage("A magic force prevents you from moving!");
         return false;
     } else if (player.getDuel() != null) {
         if (player.getDuel().ruleEnabled(DuelSession.RULE.NO_MOVEMENT)) {
             if (player.getDuel().getStatus() == 5 || player.getDuel().getStatus() == 6) {
                 if(player.getTarget() == null)
                     player.getPackets().sendMessage("Movement is disabled for this duel.");
                 return false;
             }
         }
     } else if (player.getTemporaryAttribute("unmovable") != null || player.getTemporaryAttribute("cantDoAnything") != null) {
         return false;
     } else if (player.isDead()) {
         return false;
     }
     else if (player.getTeleportTo() != null)
     {
         return false;
     }
     return true;
 }
        /*
         * NOTE: Anything that goes in here and varies between HD and LD, 
         * reset the variable in ActionSender.configureGameScreen
         */
        public void updateVariables(Player p)
        {
            int currentLevel = p.getLocation().wildernessLevel();
            if (currentLevel != -1)
            { //Is in wilderness.
                int lastWildLevel = (p.getTemporaryAttribute("wildLvl") == null) ? -1 : (int)p.getTemporaryAttribute("wildLvl");

                if (currentLevel != lastWildLevel)
                {
                    if (currentLevel > 0)
                    {
                        p.setTemporaryAttribute("wildLvl", currentLevel);
                        if (p.getTemporaryAttribute("inWild") == null)
                        {
                            p.getPackets().sendPlayerOption("Attack", 1, 1);
                            p.getPackets().sendOverlay(381);
                            p.setTemporaryAttribute("inWild", true);
                        }
                    }
                    else
                    {
                        if (p.getTemporaryAttribute("inWild") != null)
                        {
                            p.getPackets().sendPlayerOption("null", 1, 1);
                            p.getPackets().sendRemoveOverlay();
                            p.removeTemporaryAttribute("wildLvl");
                            p.removeTemporaryAttribute("inWild");
                        }
                    }
                }
            }
            if (Location.inMultiCombat(p.getLocation()))
            {
                if (p.getTemporaryAttribute("inMulti") == null)
                {
                    p.getPackets().displayMultiIcon();
                    p.setTemporaryAttribute("inMulti", true);
                }
            }
            else
            {
                if (p.getTemporaryAttribute("inMulti") != null)
                {
                    p.getPackets().removeMultiIcon();
                    p.removeTemporaryAttribute("inMulti");
                }
            }
            if (Location.atDuelArena(p.getLocation()))
            {
                if (p.getDuel() != null)
                {
                    if (p.getDuel().getStatus() == 5 || p.getDuel().getStatus() == 6)
                    {
                        p.getPackets().sendPlayerOption("Fight", 1, 1);
                    }
                }
                if (p.getTemporaryAttribute("challengeUpdate") != null)
                {
                    p.getPackets().sendPlayerOption("Challenge", 1, 0);
                    p.removeTemporaryAttribute("challengeUpdate");
                }
                if (p.getTemporaryAttribute("atDuelArea") == null)
                {
                    p.getPackets().sendPlayerOption("Challenge", 1, 0);
                    p.getPackets().sendOverlay(638);
                    p.setTemporaryAttribute("atDuelArea", true);
                }
            }
            else
            {
                if (p.getTemporaryAttribute("atDuelArea") != null)
                {
                    p.getPackets().sendPlayerOption("null", 1, 0);
                    p.getPackets().sendRemoveOverlay();
                    p.removeTemporaryAttribute("atDuelArea");
                }
            }
            if (Location.atBarrows(p.getLocation()))
            {
                if (p.getTemporaryAttribute("atBarrows") == null)
                {
                    p.getPackets().sendOverlay(24);
                    p.getPackets().setMinimapStatus(2);
                    p.getPackets().sendConfig(452, 2652256); // doors
                    if (p.getTemporaryAttribute("betweenDoors") == null)
                    {
                        if (Barrows.betweenDoors(p))
                        {
                            p.setTemporaryAttribute("betweenDoors", true);
                            p.getPackets().sendConfig(1270, 1);
                        }
                    }
                    p.getPackets().modifyText("Kill Count: " + p.getBarrowKillCount(), 24, 0);
                    p.setTemporaryAttribute("atBarrows", true);
                    Barrows.prayerDrainEvent(p);
                    bool allBrothersKilled = true;
                    for (int i = 0; i < 6; i++)
                    {
                        if (!p.getBarrowBrothersKilled(i))
                        {
                            allBrothersKilled = false;
                        }
                    }
                    if (allBrothersKilled)
                    {
                        Barrows.startEarthQuake(p);
                    }
                }
            }
            else
            {
                if (p.getTemporaryAttribute("atBarrows") != null)
                {
                    bool allBrothersKilled = true;
                    for (int i = 0; i < 6; i++)
                    {
                        if (!p.getBarrowBrothersKilled(i))
                        {
                            allBrothersKilled = false;
                        }
                    }
                    if (allBrothersKilled)
                    {
                        for (int i = 0; i < 6; i++)
                        {
                            p.setBarrowBrothersKilled(i, false);

                            p.setBarrowTunnel(-1);
                            p.setBarrowKillCount(0);
                            p.getPackets().resetCamera();
                            p.removeTemporaryAttribute("lootedBarrowChest");
                        }
                        p.getPackets().resetCamera();
                        p.getPackets().sendRemoveOverlay();
                        p.removeTemporaryAttribute("atBarrows");
                        p.removeTemporaryAttribute("barrowTunnel");
                        p.getPackets().setMinimapStatus(0);
                        Barrows.removeBrotherFromGame(p);
                    }
                }
                if (Location.atGodwars(p.getLocation()))
                {
                    if (p.getTemporaryAttribute("atGodwars") == null)
                    {
                        p.getPackets().sendOverlay(601);
                        p.setTemporaryAttribute("atGodwars", true);
                    }
                }
                else
                {
                    if (p.getTemporaryAttribute("atGodwars") != null)
                    {
                        p.getPackets().sendRemoveOverlay();
                        p.removeTemporaryAttribute("atGodwars");
                    }
                }
                if (Location.atAgilityArena(p.getLocation()))
                {
                    if (p.getTemporaryAttribute("atAgilityArena") == null)
                    {
                        p.getPackets().sendOverlay(5);
                        AgilityArena.updatePillarForPlayer(p);
                        p.setTemporaryAttribute("atAgilityArena", true);
                    }
                    if (p.getLocation().getZ() == 0)
                    {
                        p.removeTemporaryAttribute("atAgilityArena");
                        p.getPackets().sendRemoveOverlay();
                        p.setAgilityArenaStatus(0);
                        p.setTaggedLastAgilityPillar(false);
                    }
                }
                else
                {
                    if (p.getTemporaryAttribute("atAgilityArena") != null)
                    {
                        p.getPackets().sendRemoveOverlay();
                        p.setAgilityArenaStatus(0);
                        p.setTaggedLastAgilityPillar(false);
                        p.removeTemporaryAttribute("atAgilityArena");
                    }
                }
                /*
                 * We check the cantDoAnything variable to determine whether they're using the orb.
                 */
                if (Location.inFightPitsWaitingArea(p.getLocation()))
                {
                    if (p.getTemporaryAttribute("waitingForFightPits") == null)
                    {
                        Server.getMinigames().getFightPits().addWaitingPlayer(p);
                        p.setTemporaryAttribute("waitingForFightPits", true);
                    }
                }
                else
                {
                    if (p.getTemporaryAttribute("waitingForFightPits") != null && p.getTemporaryAttribute("cantDoAnything") == null)
                    {
                        Server.getMinigames().getFightPits().removeWaitingPlayer(p);
                        p.removeTemporaryAttribute("waitingForFightPits");
                    }
                }
                if (Location.inFightPits(p.getLocation()))
                {
                    if (p.getTemporaryAttribute("cantDoAnything") == null)
                    {
                        if (p.getTemporaryAttribute("inFightPits") == null)
                        {
                            p.getPackets().sendPlayerOption("Attack", 1, 1);
                            Server.getMinigames().getFightPits().displayFightPitsInterface(p);
                            p.setTemporaryAttribute("inFightPits", true);
                        }
                    }
                }
                else
                {
                    if (p.getTemporaryAttribute("inFightPits") != null)
                    {
                        p.getPackets().sendPlayerOption("null", 1, 1);
                        p.getPackets().sendRemoveOverlay();
                        p.removeTemporaryAttribute("inFightPits");
                    }
                }
                if (Location.onWaterbirthIsle(p.getLocation()))
                {
                    if (p.getTemporaryAttribute("snowInterface") == null)
                    {
                        p.getPackets().sendOverlay(370);
                        p.setTemporaryAttribute("snowInterface", true);
                    }
                }
                else
                {
                    if (p.getTemporaryAttribute("snowInterface") != null)
                    {
                        p.getPackets().sendRemoveOverlay();
                        p.removeTemporaryAttribute("snowInterface");
                    }
                }
            }
        }
	    private static bool canTeleport(Player p, JewellerySlot js) {
		    if (p.getTemporaryAttribute("teleporting") != null) {
			    return false;
		    }
		    if (p.getDuel() != null) {
			    if (p.getDuel().getStatus() < 4) {
				    p.getDuel().declineDuel();
			    } else if (p.getDuel().getStatus() == 5 || p.getDuel().getStatus() == 6) {
				    p.getPackets().sendMessage("You cannot teleport whilst in a duel.");
				    return false;
			    } else if (p.getDuel().getStatus() == 8) {
				    p.getDuel().recieveWinnings(p);
			    }
		    }
		    int wildLvl = js.index == 1 || js.index == 2 ? 30 : 20;
            if (Location.inWilderness(p.getLocation()) && p.getLocation().wildernessLevel() >= wildLvl)
            {
                p.getPackets().sendMessage("You cannot teleport above level " + wildLvl + " wilderness!");
			    return false;
		    }
		    if (Location.inFightCave(p.getLocation())) {
			    FightCave.antiTeleportMessage(p);
			    return false;
		    }
		    if (p.getTemporaryAttribute("teleblocked") != null) {
			    p.getPackets().sendMessage("A magical force prevents you from teleporting!");
			    return false;
		    }
		    if (Location.inFightPits(p.getLocation())) {
                p.getPackets().sendMessage("You are unable to teleport from the fight pits.");
			    return false;
		    }
		    if (p.getTemporaryAttribute("unmovable") != null) {
			    return false;
		    }
		    return true;
	    }
	    private void handleFirstClickObject(Player player, Packet packet) {
		    int objectX = packet.readLEShort();
            ushort objectId = (ushort)packet.readShortA();
		    int objectY = packet.readUShort();
		    if (objectX < 1000 || objectY < 1000 || player.isDead() || player.getTemporaryAttribute("cantDoAnything") != null) {
			    return;
		    }
		    SkillHandler.resetAllSkills(player);
		    player.getPackets().closeInterfaces();
		    Console.WriteLine("First object click = " + objectId + " " + objectX + " " + objectY);
		    if (RuneCraft.wantToRunecraft(player, objectId, objectX, objectY)) {
			    return;
		    } else if (RuneCraft.enterRift(player, objectId, objectX, objectY)) {
			    return;
		    } else if (RuneCraft.enterViaTiara(player, objectId, objectX, objectY)) {
			    player.setFaceLocation(new Location(objectX, objectY, player.getLocation().getZ()));
			    return;
		    } else if (RuneCraft.leaveAltar(player, objectId, objectX, objectY)) {
			    return;
		    } else if (Barrows.leaveCrypt(player, objectId, objectX, objectY)) {
			    return;
		    } else if (Barrows.tryOpenCoffin(player, objectId)) {
			    return;
		    } else if (Barrows.openTunnelDoor(player, objectId, objectX, objectY)) {
			    return;
		    } else if (Thieving.wantToThieveChest(player, objectId, objectX, objectY)) {
			    return;
		    } else if (Agility.doAgility(player, objectId, objectX, objectY)) {
			    return;
		    } else if (Farming.interactWithPatch(player, objectId, objectX, objectY, -1)) {
			    return;
		    } else if (Server.getGlobalObjects().getDoors().useDoor(player, objectId, objectX, objectY, player.getLocation().getZ())) {
			    return;
		    } else if (LaddersAndStairs.useObject(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 1)) {
			    return;
		    } else if (WildernessObelisks.useWildernessObelisk(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()))) {
			    return;
		    }
		    if (player.getTemporaryAttribute("unmovable") != null) {
			    return;
		    }
		    player.setFaceLocation(new Location(objectX, objectY, player.getLocation().getZ()));
		    switch(objectId) {
			    case 2492: // essence mine portals
				    RuneCraft.leaveEssMine(player, new Location(objectX, objectY, player.getLocation().getZ()));
				    break;
		
			    case 5959:
			    case 5960:
				    Wilderness.handleLever(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()));
				    break;
			
			    case 733: // Wilderness web
				    Wilderness.slashWeb(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()));
				    break;
			
			    case 28089: // GE desk
				    Server.getGrandExchange().clickDesk(player, objectX, objectY, 1);
				    break;
		
			    case 9359: // Tzhaar main exit
				    TzHaar.exitTzhaar(player);
				    break;
				
			    case 31284: // Tzhaar entrance
				    TzHaar.enterTzhaar(player);
				    break;
		
			    case 9357: // Fight cave exit
				    FightCave.exitCave(player, objectX, objectY);
				    break;
				
			    case 9356: // Fight cave entrance
				    FightCave.enterCave(player);
				    break;
		
			    case 9391: // Tzhaar fight pits viewing orb
				    Server.getMinigames().getFightPits().useOrb(player, -1);
				    break;
		
			    case 9369: // Tzhaar pits main entrance
			    case 9368: // Tzhaar pits game door
				    Server.getMinigames().getFightPits().useDoor(player, objectId);
				    break;
			
			    case 3617: // Agility arena ladder
				    AgilityArena.enterArena(player, objectX, objectY);
				    break;
				
			    case 3618:
				    if (Location.atAgilityArena(player.getLocation())) {
					    AgilityArena.exitArena(player, objectX, objectY);
				    }
				    break;

                case 6: // Dwarf multicannon
				    DwarfCannon cannon = player.getCannon();
				    Location l = new Location(objectX, objectY, player.getLocation().getZ());
                    if (cannon == null || (cannon != null & !l.withinDistance(cannon.getLocation(), 2))) {
					    player.getPackets().sendMessage("This isn't your cannon!");
					    break;
				    }
				    cannon.fireCannon();
				    break;
		        case 7: //Cannon base only
                case 8: //Cannon stand
                case 9: //Cannon barrels
                    DwarfCannon cannonPickup = player.getCannon();
				    Location cannonLocation = new Location(objectX, objectY, player.getLocation().getZ());
                    if (cannonPickup == null || (cannonPickup != null & !cannonLocation.withinDistance(cannonPickup.getLocation(), 2)))
                    {
					    player.getPackets().sendMessage("This isn't your cannon!");
					    break;
				    }
                    cannonPickup.pickupCannon();
                    break;

			    case 11601: // Clay oven
				    player.getPackets().modifyText("Please use the item on the oven.", 210, 1);
				    player.getPackets().sendChatboxInterface(210);
				    break;
		
			    case 10284: // Barrows chest
				    Barrows.openChest(player);
				    break;
				
			    case 4483: // Castle wars bank chest.
			    case 21301: // Neitiznot bank chest
				    player.getBank().openBank(false, objectX, objectY);
				    break;
				
			    case 1276: // Normal tree
			    case 1278: // Normal tree
			    case 2409: // Normal tree
			    case 1277: // Normal tree with but different coloured stump
			    case 3034: // Normal tree with dark stump
			    case 3033: // Normal tree with dark stump
			    case 10041: // Normal tree
			    case 1282: // Dead tree
			    case 1283: // Dead tree
			    case 1284: // Dead tree
			    case 1285: // Dead tree
			    case 1286: // Dead tree 
			    case 1289: // Dead tree
			    case 1290: // Dead tree
			    case 1365: // Dead tree
			    case 1383: // Dead tree
			    case 1384: // Dead tree
			    case 1291: // Dead tree
			    case 3035: // Dead tree
			    case 3036: // Dead tree
			    case 1315: // Evergreen
			    case 1316: // Evergreen
			    case 1318: // Snowy Evergreen
			    case 1319: // Snowy Evergreen
			    case 1330: // Snow covered tree
			    case 1331: // Snow covered tree
			    case 1332: // Snow covered tree
			    case 3879: // Evergreen from elf land
			    case 3881: // Evergreen from elf land (slightly bigger than one above)
			    case 3882: // Evergreen from elf land (slightly bigger than one above)
			    case 3883: // Small Evergreen from elf land
			    case 1280: // Normal tree orange stump
			    case 14309: // PC game island tree 
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 0, true);
				    break;
				
			    case 1281: // Normal Oak tree
			    case 3037: // Oak tree dark stump
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 1, true);
				    break;
				
			    case 1308: // Normal Willow tree
			    case 5551: // Normal Willow tree
			    case 5552: // Normal Willow tree
			    case 5553: // Normal Willow tree
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 2, true);
				    break;
				
			    case 2023: // Achey tree
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 3, true);
				    break;
				
			    case 9036: // Normal Teak tree
			    case 15062: // Normal Teak tree (same as above?)
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 4, true);
				    break;
				
			    case 1307: // Normal Maple tree
			    case 4674:// Exactly same as above
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 5, true);
				    break;
				
			    case 2289: // Normal Hollow tree
			    case 4060: // Normal Hollow tree (bigger than above)
				    Woodcutting.tryCutTree(player, objectId,  new Location(objectX, objectY, player.getLocation().getZ()), 6, true);
				    break;
				
			    case 9034: // Normal Mahogany tree
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 7, true);
				    break;
				
			    case 21273: // Normal Arctic pine
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 8, true);
				    break;
				
			    case 28951: // Normal Eucalyptus tree
			    case 28952: // Normal Eucalyptus tree (smaller)
			    case 28953: // Normal Eucalyptus tree (smallest)
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 9, true);
				    break;
				
			    case 1309: // Yew tree
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 10, true);
				    break;
				
			    case 1306: // Normal Magic tree
				    Woodcutting.tryCutTree(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 11, true);
				    break;
			
			    case 3203: // Duel arena trapdoors.
				    if (player.getDuel() != null) {
					    player.getDuel().forfeitDuel(objectX, objectY);
					    break;
				    }
				    break;
				
			    case 7152: // Abyss tendrils.
			    case 7144:
				    AbyssObstacles.chopTendrils(player, objectX, objectY);
				    break;
		
			    case 7147: // Abyss tunnel.
				    AbyssObstacles.useAgilityTunnel(player, objectX, objectY);
				    break;
				
			    case 7146: // Abyss eyes.
			    case 7150:
				    AbyssObstacles.passEyes(player, objectX, objectY);
				    break;
				
			    case 7151: // Abyss boil.
			    case 7145:
				    AbyssObstacles.burnBoil(player, objectX, objectY);
				    break;
			
			    case 7153: // Abyss mining rock.
			    case 7143:
				    AbyssObstacles.mineRock(player, objectX, objectY);
				    break;
				
			    case 2213: // Catherby bank booth.
			    case 11402: // Varrock bank booth.
			    case 11758: // Falador bank booth.
			    case 36786: // Lumbridge bank booth.
			    case 35647: // Al-Kharid bank booth.
			    case 25808: // Seers bank booth.
			    case 34752: // Ardougne bank booth.
			    case 26972: // Edgeville bank booth.
			    case 29085: // Ooglog bank booth.
				    player.getBank().openBank(true, objectX, objectY);
				    break;
				
			    case 2491: // Essence rock
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 0, true);
				    break;
				
			    case 11954: // Iron rocks
			    case 11955:
			    case 11956:
			    case 14856:
			    case 14857:
			    case 14858:
			    case 31071:
			    case 31072:
			    case 31073:
			    case 32441:
			    case 32442:
			    case 32443:
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 6, true);
				    break;
				
			    case 11948: // Silver rocks
			    case 11949:
			    case 11950:
			    case 11165:
			    case 11186:
			    case 11187:
			    case 11188:
			    case 31074:
			    case 31075:
			    case 31076:
			    case 32444:
			    case 32445:
			    case 32446:
			    case 15579:
			    case 15580:
			    case 15581:
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 8, true);
				    break;
				
			    case 15504: // Clay rocks
			    case 15503:
			    case 15505:
			    case 11189:
			    case 11190:
			    case 11191:
			    case 31062:
			    case 31063:
			    case 31064:
			    case 32429:
			    case 32430:
			    case 32431:
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 1, true);
				    break;
				
			    case 11960: // Copper rocks
			    case 11961:
			    case 11962:
			    case 11936:
			    case 11937:
			    case 11938:
			    case 31080:
			    case 31081:
			    case 31082:
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 2, true);
				    break;
				
			    case 11959: // Tin rocks
			    case 11958:
			    case 11957:
			    case 11933:
			    case 11934:
			    case 11935:
			    case 31077:
			    case 31078:
			    case 31079:
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 3, true);
				    break;
				
			    case 11930: // Coal rocks
			    case 11931:
			    case 11932:
			    case 14850:
			    case 14851:
			    case 14852:
			    case 31068:
			    case 31069:
			    case 31070:
			    case 32426:
			    case 32427:
			    case 32428:
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 9, true);
				    break;
				
			    case 11951: // Gold rocks
			    case 11952:
			    case 11953:
			    case 11183:
			    case 11184:
			    case 11185:
			    case 31065:
			    case 31066:
			    case 31067:
			    case 32432:
			    case 32433:
			    case 32434:
			    case 15576:
			    case 15577:
			    case 15578:
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 10, true);
				    break;
				
			    case 11945: // Mithril rocks
			    case 11946:
			    case 11947:
			    case 11942:
			    case 11943:
			    case 11944:
			    case 14853:
			    case 14854:
			    case 14855:
			    case 31086:
			    case 31087:
			    case 31088:
			    case 32438:
			    case 32439:
			    case 32440:
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 11, true);
				    break;
				
			    case 11963: // Adamant rocks
			    case 11964:
			    case 11965:
			    case 11939:
			    case 11940:
			    case 11941:
			    case 14862:
			    case 14863:
			    case 14864:
			    case 31083:
			    case 31084:
			    case 31085:
			    case 32435:
			    case 32436:
			    case 32437:
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 12, true);
				    break;
				
			    case 14859: // Rune rocks
			    case 14860:
			    case 14861:
				    Mining.tryMineRock(player, objectId, new Location(objectX, objectY, player.getLocation().getZ()), 13, true);
				    break;
				
			    case 11552: // Empty rocks
			    case 11553:
			    case 11554:	
			    case 11555:
			    case 11556:
			    case 31059:
			    case 31060:
			    case 31061:
			    case 14832:
			    case 14833:
			    case 14834:
			    case 33400:
			    case 33401:
			    case 33402:
			    case 15582:
			    case 15583:
			    case 15584:
				    Mining.displayEmptyRockMessage(player, new Location(objectX, objectY, player.getLocation().getZ()));
				    break;
				
			    case 23271: // Wilderness ditch
				    Wilderness.crossDitch(player, objectX, objectY);
				    break;
		    }
	    }