/**
   * 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);
    }
  }
  /**
   * 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 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);
 }
コード例 #4
0
ファイル: CombatFormulae.java プロジェクト: kewle003/hyperion
  /** Calculates a mob's melee max hit. */
  public static int calculateMeleeMaxHit(Mob mob, boolean special) {
    if (mob.isNPC()) {
      NPC npc = (NPC) mob;
      return npc.getCombatDefinition().getMaxHit();
    }
    int maxHit = 0;
    double specialMultiplier = 1;
    double prayerMultiplier = 1;
    double otherBonusMultiplier = 1;
    // TODO: void melee = 1.2, slayer helm = 1.15, salve amulet = 1.15, salve amulet(e) = 1.2
    Item helm = mob.getEquipment().get(Equipment.SLOT_HELM);

    int strengthLevel = mob.getSkills().getLevel(Skills.STRENGTH);
    int combatStyleBonus = 0;

    if (mob.isWerewolf()) {
      prayerMultiplier = 1.40;
      prayerMultiplier = 1.60;
      otherBonusMultiplier = 1.80;
    }

    if (mob.getCombatState().getPrayer(Prayers.BURST_OF_STRENGTH)) {
      prayerMultiplier = 1.05;
    } else if (mob.getCombatState().getPrayer(Prayers.SUPERHUMAN_STRENGTH)) {
      prayerMultiplier = 1.1;
    } else if (mob.getCombatState().getPrayer(Prayers.ULTIMATE_STRENGTH)) {
      prayerMultiplier = 1.15;
    } else if (mob.getCombatState().getPrayer(Prayers.CHIVALRY)) {
      prayerMultiplier = 1.18;
    } else if (mob.getCombatState().getPrayer(Prayers.PIETY)) {
      prayerMultiplier = 1.23;
    }

    switch (mob.getCombatState().getCombatStyle()) {
      case AGGRESSIVE_1:
      case AGGRESSIVE_2:
        combatStyleBonus = 3;
        break;
      case CONTROLLED_1:
      case CONTROLLED_2:
      case CONTROLLED_3:
        combatStyleBonus = 1;
        break;
    }

    if (fullVoidMelee(mob)) {
      otherBonusMultiplier = 1.1;
    }

    int effectiveStrengthDamage =
        (int) ((strengthLevel * prayerMultiplier * otherBonusMultiplier) + combatStyleBonus);
    double baseDamage =
        1.3
            + (effectiveStrengthDamage / 10)
            + (mob.getCombatState().getBonus(10) / 80)
            + ((effectiveStrengthDamage * mob.getCombatState().getBonus(10)) / 640);

    if (special) {
      if (mob.getEquipment().get(Equipment.SLOT_WEAPON) != null) {
        switch (mob.getEquipment().get(Equipment.SLOT_WEAPON).getId()) {
          case 11694:
            specialMultiplier = 1.34375;
            break;
          case 11696:
            specialMultiplier = 1.1825;
            break;
          case 11698:
          case 11700:
            specialMultiplier = 1.075;
            break;
          case 3101:
          case 3204:
          case 1215:
          case 1231:
          case 5680:
          case 5698:
            specialMultiplier = 1.1;
            break;
          case 1305:
            specialMultiplier = 1.15;
            break;
          case 1434:
            specialMultiplier = 1.45;
            break;
        }
      }
    }

    maxHit = (int) (baseDamage * specialMultiplier);

    if (fullDharok(mob)) {
      int hpLost =
          mob.getSkills().getLevelForExperience(Skills.HITPOINTS)
              - mob.getSkills().getLevel(Skills.HITPOINTS);
      maxHit += hpLost * 0.35;
    }
    return maxHit;
  }
コード例 #5
0
ファイル: CombatFormulae.java プロジェクト: kewle003/hyperion
  /** Calculates a mob's range max hit. */
  public static int calculateRangeMaxHit(Mob mob, boolean special) {
    if (mob.isNPC()) {
      NPC npc = (NPC) mob;
      return npc.getCombatDefinition().getMaxHit();
    }
    int maxHit = 0;
    double specialMultiplier = 1;
    double prayerMultiplier = 1;
    double otherBonusMultiplier = 1;
    int rangedStrength = mob.getCombatState().getBonus(12);
    Item weapon = mob.getEquipment().get(Equipment.SLOT_WEAPON);
    BowType bow = weapon.getEquipmentDefinition().getBowType();

    if (bow == BowType.CRYSTAL_BOW) {
      /** Crystal Bow does not use arrows, so we don't use the arrows range strength bonus. */
      rangedStrength =
          mob.getEquipment().get(Equipment.SLOT_WEAPON).getEquipmentDefinition().getBonus(12);
    }

    int rangeLevel = mob.getSkills().getLevel(Skills.RANGE);
    int combatStyleBonus = 0;

    switch (mob.getCombatState().getCombatStyle()) {
      case ACCURATE:
        combatStyleBonus = 3;
        break;
    }

    if (fullVoidRange(mob)) {
      otherBonusMultiplier = 1.1;
    }

    int effectiveRangeDamage =
        (int) ((rangeLevel * prayerMultiplier * otherBonusMultiplier) + combatStyleBonus);
    double baseDamage =
        1.3
            + (effectiveRangeDamage / 10)
            + (rangedStrength / 80)
            + ((effectiveRangeDamage * rangedStrength) / 640);

    if (special) {
      if (mob.getEquipment().get(Equipment.SLOT_ARROWS) != null) {
        switch (mob.getEquipment().get(Equipment.SLOT_ARROWS).getId()) {
          case 11212:
            specialMultiplier = 1.5;
            break;
          case 9243:
            specialMultiplier = 1.15;
            break;
          case 9244:
            specialMultiplier = 1.45;
            break;
          case 9245:
            specialMultiplier = 1.15;
            break;
          case 9236:
            specialMultiplier = 1.25;
            break;
          case 882:
          case 884:
          case 886:
          case 888:
          case 890:
          case 892:
            if (mob.getEquipment().get(Equipment.SLOT_WEAPON) != null
                && mob.getEquipment().get(Equipment.SLOT_WEAPON).getId() == 11235) {
              specialMultiplier = 1.3;
            }
            break;
        }
      }
    }

    maxHit = (int) (baseDamage * specialMultiplier);

    return maxHit;
  }
  /**
   * 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);
    }
  }
コード例 #7
0
ファイル: YtMejKot.java プロジェクト: kewle003/hyperion
  @Override
  public void hit(final Mob attacker, final Mob victim) {
    super.hit(attacker, victim);
    // System.out.println("In hit ytmejkot");

    if (!attacker.isNPC()) {
      return; // this should be an NPC!
    }

    NPC npc = (NPC) attacker;

    CombatStyle style = CombatStyle.MELEE;

    int maxHit;
    int damage;
    int randomHit;
    int hitDelay;
    boolean blockAnimation;
    final int hit;

    switch (style) {
      default:
      case MELEE:
        Animation anim = attacker.getAttackAnimation();
        attacker.playAnimation(anim);

        hitDelay = 1;
        blockAnimation = true;
        maxHit = npc.getCombatDefinition().getMaxHit();
        damage =
            damage(
                maxHit,
                attacker,
                victim,
                attacker.getCombatState().getAttackType(),
                Skills.ATTACK,
                Prayers.PROTECT_FROM_MELEE,
                false,
                false);
        randomHit = random.nextInt(damage < 1 ? 1 : damage + 1);
        if (randomHit > victim.getSkills().getLevel(Skills.HITPOINTS)) {
          randomHit = victim.getSkills().getLevel(Skills.HITPOINTS);
        }
        hit = randomHit;
        break;
    }

    attacker.getCombatState().setAttackDelay(5);
    attacker.getCombatState().setSpellDelay(5);

    World.getWorld()
        .submit(
            new Tickable(hitDelay) {
              @Override
              public void execute() {
                victim.inflictDamage(new Hit(hit), attacker);
                smite(attacker, victim, hit);
                recoil(attacker, victim, hit);
                this.stop();
              }
            });
    vengeance(attacker, victim, hit, 1);

    victim.getActiveCombatAction().defend(attacker, victim, blockAnimation);
  }