@Override
 public void handle(Player player, Packet packet) {
   if (player.getAttribute("cutScene") != null) {
     return;
   }
   if (player.getInterfaceAttribute("fightPitOrbs") != null) {
     return;
   }
   switch (packet.getOpcode()) {
     case OPTION_1:
       handleOption1(player, packet);
       break;
     case OPTION_2:
       handleOption2(player, packet);
       break;
     case OPTION_3:
       handleOption3(player, packet);
       break;
     case OPTION_ATTACK:
       handleOptionAttack(player, packet);
       break;
     case OPTION_SPELL:
       handleOptionSpell(player, packet);
       break;
     case OPTION_EXAMINE:
       handleOptionExamine(player, packet);
       break;
   }
 }
  /**
   * 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);
    }
  }
コード例 #3
0
ファイル: MilkCow.java プロジェクト: Octav23/OSRemake
 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;
             }
           });
 }
コード例 #4
0
 @Override
 public void handle(Player player, Packet packet) {
   int privateBefore = player.getInterfaceState().getPrivateChat();
   player.getInterfaceState().setPublicChat(packet.get());
   player.getInterfaceState().setPrivateChat(packet.get());
   player.getInterfaceState().setTrade(packet.get());
   if (privateBefore
       != player.getInterfaceState().getPrivateChat()) { // private chat has been toggled
     player.getPrivateChat().updateFriendList(true);
   }
 }
 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);
 }
 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);
 }
  /**
   * 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());
    }
  }
コード例 #8
0
 @Override
 public void handle(Player player, boolean overlay) {
   player
       .getTutorialIsland()
       .sendStartInfo(
           "To start the tutorial use your left mouse-button to click on the",
           "'2009Remade Guide' in this room. He is indicated by a flashing",
           "yellow arrow above his head. If you can't find him, use your",
           "keyboard's arrow keys to rotate the view.",
           "Getting Started");
   //	player.getActionSender().sendHintArrow(NPC, height, position);
 }
  /**
   * 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 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();
              }
            });
  }
コード例 #11
0
ファイル: PlayerTickTask.java プロジェクト: kewle003/hyperion
  @Override
  public void execute(GameEngine context) {
    Queue<ChatMessage> messages = player.getChatMessageQueue();
    if (messages.size() > 0) {
      player.getUpdateFlags().flag(UpdateFlag.CHAT);
      ChatMessage message = player.getChatMessageQueue().poll();
      player.setCurrentChatMessage(message);
    } else {
      player.setCurrentChatMessage(null);
    }

    if (player.getCombatState().getAttackDelay() > 0) {
      player.getCombatState().decreaseAttackDelay(1);
    }
    if (player.getCombatState().getSpellDelay() > 0) {
      player.getCombatState().decreaseSpellDelay(1);
    }
    if (player.getCombatState().getWeaponSwitchTimer() > 0) {
      player.getCombatState().decreaseWeaponSwitchTimer(1);
    }
    if (player.getCombatState().getSkullTicks() > 0) {
      player.getCombatState().decreaseSkullTicks(1);
    }

    /*
     * Gets the next two hits from the queue.
     */
    List<Hit> hits = player.getHitQueue();
    Hit first = null;
    if (hits.size() > 0) {
      for (int i = 0; i < hits.size(); i++) {
        Hit hit = hits.get(i);
        if (hit.getDelay() < 1) {
          first = hit;
          hits.remove(hit);
          break;
        }
      }
    }
    if (first != null) {
      player.setPrimaryHit(first);
      player.getUpdateFlags().flag(UpdateFlag.HIT);
    }
    Hit second = null;
    if (hits.size() > 0) {
      for (int i = 0; i < hits.size(); i++) {
        Hit hit = hits.get(i);
        if (hit.getDelay() < 1) {
          second = hit;
          hits.remove(hit);
          break;
        }
      }
    }
    if (second != null) {
      player.setSecondaryHit(second);
      player.getUpdateFlags().flag(UpdateFlag.HIT_2);
    }
    if (hits.size() > 0) { // tells us we still have more hits
      Iterator<Hit> hitIt = hits.iterator();
      while (hitIt.hasNext()) {
        Hit hit = hitIt.next();
        if (hit.getDelay() > 0) {
          hit.setDelay(hit.getDelay() - 1);
        }
        if (hit.getHitPriority() == HitPriority.LOW_PRIORITY) {
          hitIt.remove();
        }
      }
    }

    player.getWalkingQueue().processNextMovement();
  }
コード例 #12
0
  @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 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 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 handleInterfaceButtons(Player player, int button) {
   int amount = 0;
   Bar bar = null;
   switch (button) {
     case 16:
     case 15:
     case 14:
       amount = amounts[16 - button];
       bar = Bar.BRONZE;
       break;
     case 20:
     case 19:
     case 18:
       amount = amounts[20 - button];
       bar = Bar.BLURITE;
       break;
     case 24:
     case 23:
     case 22:
       amount = amounts[24 - button];
       bar = Bar.IRON;
       break;
     case 28:
     case 27:
     case 26:
       amount = amounts[28 - button];
       bar = Bar.SILVER;
       break;
     case 32:
     case 31:
     case 30:
       amount = amounts[32 - button];
       bar = Bar.STEEL;
       break;
     case 36:
     case 35:
     case 34:
       amount = amounts[36 - button];
       bar = Bar.GOLD;
       break;
     case 40:
     case 39:
     case 38:
       amount = amounts[40 - button];
       bar = Bar.MITHRIL;
       break;
     case 44:
     case 43:
     case 42:
       amount = amounts[44 - button];
       bar = Bar.ADAMANTITE;
       break;
     case 48:
     case 47:
     case 46:
       amount = amounts[48 - button];
       bar = Bar.RUNITE;
       break;
     case 13:
       bar = Bar.BRONZE;
       break;
     case 17:
       bar = Bar.BLURITE;
       break;
     case 21:
       bar = Bar.IRON;
       break;
     case 25:
       bar = Bar.SILVER;
       break;
     case 29:
       bar = Bar.STEEL;
       break;
     case 33:
       bar = Bar.GOLD;
       break;
     case 37:
       bar = Bar.MITHRIL;
       break;
     case 41:
       bar = Bar.ADAMANTITE;
       break;
     case 45:
       bar = Bar.RUNITE;
       break;
   }
   if (bar != null && amount != 0) {
     new Smelting(player, bar, amount).begin();
   } else {
     player.getAttributes().put("smelting_bar", bar);
     // player.getInterfaceState().openEnterAmountInterface(INTERFACE);
     // player.getInterfaceState().openEnterAmountInterface(interfaceId, slot, id);
   }
 }
 @Override
 public void handle(Player player, Packet packet) {
   player
       .getActionSender()
       .sendMessage("Your dragonfire shield currently has: " + player.dfsCharges + " charge(s)");
 }