public static void interactWithAliMorissaae(Player p, Npc n) { p.setEntityFocus(n.getClientIndex()); AreaEvent interactWithAliMorissaaeAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1); interactWithAliMorissaaeAreaEvent.setAction(() => { n.setFaceLocation(p.getLocation()); p.setFaceLocation(n.getLocation()); p.setEntityFocus(65535); showAliDialogue(p, 205); }); Server.registerCoordinateEvent(interactWithAliMorissaaeAreaEvent); }
public static bool interactWithBoatNPC(Player p, Npc n) { int id = n.getId(); if (id != 4540 && id != 1304 && id != 2436 && id != 3781 && id != 1361 && id != 4962) { return false; } p.setEntityFocus(n.getClientIndex()); AreaEvent interactWithBoatNPCAreaEvent = new AreaEvent(p, n.getLocation().getX() - 1, n.getLocation().getY() - 1, n.getLocation().getX() + 1, n.getLocation().getY() + 1); interactWithBoatNPCAreaEvent.setAction(() => { n.setFaceLocation(p.getLocation()); p.setFaceLocation(n.getLocation()); p.setEntityFocus(65535); switch(n.getId()) { case 4540: // Home boat showBentleyDialogue(p, 240); break; case 1304: // Canifis sailor showCanifisSailorDialogue(p, 280); break; case 2436: // Waterbirth isle showJarvaldDialogue(p, 300); break; case 3781: // Pest control squire showSquireDialogue(p, 340); break; case 1361: // Warrior guild showArnorDialogue(p, 370); break; case 4962: // fremmenik shore showCaptainBarnabyDialogue(p, 410); break; } }); Server.registerCoordinateEvent(interactWithBoatNPCAreaEvent); return true; }
public static void talkToBob(Player p, Npc npc, int item, int option) { p.setEntityFocus(npc.getClientIndex()); AreaEvent talkToBobAreaEvent = new AreaEvent(p, npc.getLocation().getX() - 1, npc.getLocation().getY() - 1, npc.getLocation().getX() + 1, npc.getLocation().getY() + 1); talkToBobAreaEvent.setAction(() => { npc.setFaceLocation(p.getLocation()); p.setFaceLocation(npc.getLocation()); p.setEntityFocus(65535); if (option == 0) { // use item on bob if (item > 0) { p.setTemporaryAttribute("bobsAxesBarrowItem", item); showBobDialogue(p, 101); } } else if (option == 1) { // talk showBobDialogue(p, 107); } else if (option == 2) { // trade p.setShopSession(new ShopSession(p, 4)); } }); Server.registerCoordinateEvent(talkToBobAreaEvent); }
public bool equipItem(int itemID, int slot) { ItemData.EQUIP equipType = ItemData.getItemType(itemID); int amount = player.getInventory().getAmountInSlot(slot); bool stackable = ItemData.forId(itemID).isStackable(); bool twoHanded = ItemData.isTwoHanded(itemID); if (equipType == ItemData.EQUIP.NOTHING) { player.getPackets().sendMessage("Unable to find an item slot for item : " + itemID + " , please report this to a staff member."); return(false); } if (duelRuleActive(equipType)) { return(true); } if (twoHanded) { if (player.getInventory().getTotalFreeSlots() < getNeeded2HSlots()) { player.getPackets().sendMessage("Not enough space in your inventory."); return(false); } } if (!player.getInventory().deleteItem(itemID, slot, amount)) { return(false); } if (twoHanded && getItemInSlot(ItemData.EQUIP.SHIELD) != -1) { if (!unequipItem(ItemData.EQUIP.SHIELD)) { return(false); } } if (equipType == ItemData.EQUIP.SHIELD) { if (getItemInSlot(ItemData.EQUIP.WEAPON) != -1) { if (ItemData.isTwoHanded(slots[3].getItemId())) { if (!unequipItem(ItemData.EQUIP.WEAPON)) { return(false); } } } } int equipSlot = Convert.ToInt32(equipType); if (slots[equipSlot].getItemId() != itemID && slots[equipSlot].getItemId() > 0) { if (!player.getInventory().addItem(slots[equipSlot].getItemId(), slots[equipSlot].getItemAmount(), slot)) { return(false); } if (equipType == ItemData.EQUIP.HAT) { RuneCraft.toggleRuin(player, slots[equipSlot].getItemId(), false); if (RuneCraft.getTiaraIndex(itemID) != -1) // switching from tiara to tiara. { RuneCraft.toggleRuin(player, itemID, true); } } } else if (stackable && slots[equipSlot].getItemId() == itemID) { amount = slots[equipSlot].getItemAmount() + amount; } else if (slots[equipSlot].getItemId() != -1) { player.getInventory().addItem(slots[equipSlot].getItemId(), slots[equipSlot].getItemAmount(), slot); } slots[equipSlot].setItemId(itemID); slots[equipSlot].setItemAmount(amount); player.getPackets().refreshEquipment(); player.getUpdateFlags().setAppearanceUpdateRequired(true); if (equipType == ItemData.EQUIP.HAT) { RuneCraft.toggleRuin(player, itemID, RuneCraft.wearingTiara(player)); } if (equipType == ItemData.EQUIP.WEAPON) { setWeapon(); MagicData.cancelAutoCast(player, true); } refreshBonuses(); player.setEntityFocus(65535); return(true); }