/** * Handles npc attack option. * * @param player The player. * @param packet The packet. */ private void handleOptionAttack(final Player player, Packet packet) { final int id = packet.getLEShort() & 0xFFFF; if (id < 0 || id >= Constants.MAX_NPCS) { return; } if (player.getCombatState().isDead()) { return; } player.getActionQueue().clearRemovableActions(); final NPC npc = (NPC) World.getWorld().getNPCs().get(id); for (int[] element : SlayerTasks.SLAYER_LEVELS_TO_ATTACK_NPCS) { if (element[0] == npc.getDefinition().getId()) { if (player.getSkills().getLevel(18) < element[1]) { player .getActionSender() .sendMessage("You need a Slayer level of " + element[1] + " to attack this npc."); return; } } } player .getActionSender() .sendDebugPacket( packet.getOpcode(), "NpcAttack", new Object[] {"ID: " + npc.getDefinition().getId(), "Index: " + id}); if (npc != null) { player.getCombatState().setQueuedSpell(null); player.getCombatState().startAttacking(npc, false); } }
public void begin() { player.getActionSender().removeChatboxInterface(); String message = ""; if (bar.getPrimaryOre() != null && !player.getInventory().contains(bar.getPrimaryOre())) message = "You do not have enough " + bar.getPrimaryOre().getDefinition().getName().toLowerCase() + " to smelt this bar."; else if (bar.getSecondaryOre() != null && !player.getInventory().contains(bar.getSecondaryOre())) message = "You do not have enough " + bar.getSecondaryOre().getDefinition().getName().toLowerCase() + " to smelt this bar."; if (message != "") { player.getActionSender().sendMessage(message); return; } if (player.getSkills().getLevel(Skills.SMITHING) < bar.getRequiredLevel()) { player.getActionSender().sendMessage("Your smithing level is too low to make this bar."); return; } player.playAnimation(ANIMATION); player.getActionQueue().addAction(this); }
@Override public void handle(Player player, Packet packet) { if (player.getSkills().getLevel(Skills.HITPOINTS) < 1) { return; } int size = packet.getLength(); if (packet.getOpcode() == 11) { size -= 14; } if (player.getInterfaceAttribute("fightPitOrbs") != null) { return; } if (packet.getOpcode() != 59) { // force walking player.getCombatState().setQueuedSpell(null); player.resetInteractingEntity(); player.getActionQueue().clearAllActions(); player.getActionSender().removeAllInterfaces(); } player.getWalkingQueue().reset(); if (!player.getCombatState().canMove()) { if (packet.getOpcode() != 59) { // force walking player.getActionSender().sendMessage("A magical force stops you from moving."); } return; } if (!player.canEmote()) { return; // stops walking during skillcape animations. } final int steps = (size - 5) / 2; final int[][] path = new int[steps][2]; for (int i = 0; i < steps; i++) { final int byte1 = packet.getByte(); final int byteS = packet.getByteS(); path[i][0] = byte1; path[i][1] = byteS; } final int firstX = packet.getShortA(); final int firstY = packet.getLEShort(); final boolean runSteps = packet.get() == 1; player.getWalkingQueue().setRunningQueue(runSteps); player.getWalkingQueue().addStep(firstX, firstY); for (int i = 0; i < steps; i++) { path[i][0] += firstX; path[i][1] += firstY; player.getWalkingQueue().addStep(path[i][0], path[i][1]); } player.getWalkingQueue().finish(); // Boothes.outBooth(player); }
/** * Handles npc spell option. * * @param player The player. * @param packet The packet. */ private void handleOptionSpell(final Player player, Packet packet) { packet.getShort(); int interfaceValue = packet.getLEInt(); // int interfaceId = interfaceValue >> 16; final int childButton = interfaceValue & 0xFFFF; int id = packet.getLEShortA(); if (id < 0 || id >= Constants.MAX_NPCS) { return; } if (player.getCombatState().isDead()) { return; } player.getActionQueue().clearRemovableActions(); NPC npc = (NPC) World.getWorld().getNPCs().get(id); player .getActionSender() .sendDebugPacket( packet.getOpcode(), "NpcSpell", new Object[] { "ID: " + npc.getDefinition().getId(), "Index: " + id, "Button: " + childButton }); Spell spell = Spell.forId(childButton, SpellBook.forId(player.getCombatState().getSpellBook())); if (npc != null && spell != null) { if (spell.getSpellType() == SpellType.NON_COMBAT) { return; } MagicCombatAction.setAutocast(player, null, -1, false); player.getCombatState().setQueuedSpell(spell); player.getCombatState().startAttacking(npc, false); } }
public static void milkCow(final Player player, final GameObject object) { player.getWalkingQueue().reset(); if (!player.getInventory().hasItem(new Item(1925))) { player.playAnimation(Animation.create(-1)); player.getActionSender().sendMessage("You have no buckets to fill."); player.getWalkingQueue().reset(); player.inEvent = false; return; } if (player.inEvent == true) { // player.getActionSender().sendMessage("COWSS"); return; } player.inEvent = true; player.face(object.getLocation()); player.playAnimation(MILKING); World.getWorld() .submit( new Event(2000) { public void execute() { if (!player.getInventory().hasItem(new Item(1925))) { player.getActionSender().sendMessage("You have no more buckets to fill."); player.inEvent = false; stop(); return; } player.playAnimation(MILKING); player.getInventory().remove(new Item(1925)); player.getInventory().add(new Item(1927)); player.inEvent = true; } }); }
/** * Handles npc option examine. * * @param player The player. * @param packet The packet. */ private void handleOptionExamine(Player player, Packet packet) { int id = packet.getShortA() & 0xFFFF; if (id < 0 || id >= Constants.MAX_NPCS) { return; } if (player.getCombatState().isDead()) { return; } player .getActionSender() .sendDebugPacket(packet.getOpcode(), "NpcExamine", new Object[] {"ID: " + id}); NPCDefinition npcDef = NPCDefinition.forId(id); if (npcDef != null) { player.getActionSender().sendMessage(npcDef.getDescription()); } }
public static void sail( final Player player, final NPC npc, final Location location, final String locationName) { player.setTeleportTarget(location); player .getActionSender() .sendDialogue( "Sailing", DialogueType.MESSAGE_MODEL_LEFT, 795, FacialAnimation.DEFAULT, npc.getDefinition().getName() + " sails you to " + locationName + "."); player.getInterfaceState().setNextDialogueId(0, 97); }
@Override public void execute() { if (!player.getInventory().contains(bar.getPrimaryOre()) || (bar.getSecondaryOre() != null && !player.getInventory().contains(bar.getSecondaryOre())) || productionAmount < 1) { this.stop(); Animation.create(-1); return; } fourTickDelay++; animationTick++; if (animationTick % 5 == 0) { player.playAnimation(ANIMATION); fourTickDelay = 1; if (bar == Bar.GOLD) player.getActionSender().sendMessage("You place a lump of gold in the furnace."); } if (fourTickDelay % 5 != 0) { return; } if (bar == Bar.IRON && random.nextBoolean() && !player.getEquipment().contains(2568)) { player.getInventory().remove(bar.primary); player.getActionSender().sendMessage("The ore is too impure and you fail to refine it."); } else { player.getInventory().remove(bar.getPrimaryOre()); player.getInventory().remove(bar.getSecondaryOre()); String message = bar.toString().toLowerCase(); message = bar == Bar.GOLD ? "You retrieve a lump of gold from the furnace" : "You smelt the " + message + " in the furnace."; player.getInventory().add(bar.getProduct()); player.getActionSender().sendMessage(message); player.getSkills().addExperience(Skills.SMITHING, bar.getExperience()); } productionAmount--; }
public static void openInterface(final Player player) { for (int i = 0; i < 9; i++) { int itemId = i == 1 ? 9467 : 2349 + (i * 2); String color = player.getSkills().getLevel(Skills.SMITHING) < REQUIRED_LEVELS[i] ? "<col=#FF0000>" : ""; String move = "<br><br><br><br>"; player .getActionSender() .sendString(INTERFACE, 16 + (i * 4), move + color + ITEM_NAMES[i]) .sendInterfaceModel(INTERFACE, i + 4, 150, itemId); } World.getWorld() .submit( new Event(600) { @Override public void execute() { player.getActionSender().sendChatboxInterface(INTERFACE); this.stop(); } }); }
/** * Handles npc option 1. * * @param player The player. * @param packet The packet. */ private void handleOption1(final Player player, Packet packet) { final int id = packet.getShort() & 0xFFFF; if (id < 0 || id >= Constants.MAX_NPCS) { return; } if (player.getCombatState().isDead()) { return; } player.getActionQueue().clearRemovableActions(); final NPC npc = (NPC) World.getWorld().getNPCs().get(id); player .getActionSender() .sendDebugPacket( packet.getOpcode(), "NpcOpt1", new Object[] {"ID: " + npc.getDefinition().getId(), "Index: " + id}); if (npc != null) { player.setInteractingEntity(InteractionMode.TALK, npc); Action action = new Action(player, 0) { @Override public void execute() { if (player.getCombatState().isDead()) { stop(); return; } if (npc.getDefinition().getInteractionMenu()[0].startsWith("Talk")) { if (npc.getDefinition().getId() == 905) { DialogueManager.openDialogue(player, 222); } else if (npc.getDefinition().getId() == 198) { DialogueManager.openDialogue(player, 258); } else if (npc.getDefinition().getId() == 1597) { DialogueManager.openDialogue(player, 241); } else { } if (npc.getDefinition().getName().toLowerCase().contains("banker")) { DialogueManager.openDialogue(player, 0); } else { String scriptName = "talkTo" + npc.getDefinition().getId(); if (!ScriptManager.getScriptManager() .invokeWithFailTest(scriptName, player, npc)) { // player.getActionSender().sendMessage(npc.getDefinedName() + " does not want // to talk."); } } npc.setInteractingEntity(InteractionMode.TALK, player); } stop(); } @Override public AnimationPolicy getAnimationPolicy() { return AnimationPolicy.RESET_ALL; } @Override public CancelPolicy getCancelPolicy() { return CancelPolicy.ALWAYS; } @Override public StackPolicy getStackPolicy() { return StackPolicy.NEVER; } }; int distance = 1; if (npc.getDefinition().getName().toLowerCase().contains("banker") || npc.getDefinition().getName().toLowerCase().contains("emily") || npc.getDefinition().getName().toLowerCase().contains("zambo")) { distance = 2; } player.addCoordinateAction( player.getWidth(), player.getHeight(), npc.getLocation(), npc.getWidth(), npc.getHeight(), distance, action); } }
@Override public void handle(Player player, Packet packet) { player .getActionSender() .sendMessage("Your dragonfire shield currently has: " + player.dfsCharges + " charge(s)"); }