예제 #1
0
  @Override
  public boolean customContainerAttack(Character entity, Character victim) {
    NPC lakra = (NPC) entity;
    if (victim.getConstitution() <= 0) {
      return true;
    }
    if (lakra.isChargingAttack()) {
      return true;
    }
    lakra.setChargingAttack(true);
    lakra.performAnimation(new Animation((13770)));
    final CombatType attkType = Misc.getRandom(5) <= 2 ? CombatType.RANGED : CombatType.MAGIC;
    lakra
        .getCombatBuilder()
        .setContainer(
            new CombatContainer(
                lakra, victim, 1, 4, attkType, Misc.getRandom(5) <= 1 ? false : true));
    TaskManager.submit(
        new Task(1, lakra, false) {
          int tick = 0;

          @Override
          public void execute() {
            if (tick == 2) {
              new Projectile(
                      lakra, victim, (attkType == CombatType.RANGED ? 605 : 473), 44, 3, 43, 43, 0)
                  .sendProjectile();
              lakra.setChargingAttack(false);
              stop();
            }
            tick++;
          }
        });
    return true;
  }
예제 #2
0
 public static boolean handleButton(Player player, int button) {
   if (!(button >= -28531 && button <= -28425)) {
     return false;
   }
   int index = -1;
   if (button >= -28531 && button <= -28502) {
     index = 28531 + button;
   } else if (button >= -28499 && button <= -28469) {
     index = 30 + 28499 + button;
   } else if (button >= -28466 && button <= -28435) {
     index = 61 + 28466 + button;
   } else if (button >= -28432 && button <= -28425) {
     index = 93 + 28432 + button;
   }
   if (index >= 0 && index < AchievementData.values().length) {
     AchievementData achievement = AchievementData.values()[index];
     if (player.getAchievementAttributes().getCompletion()[achievement.ordinal()]) {
       player
           .getPacketSender()
           .sendMessage(
               "<img=10> <col=339900>You have completed the achievement: "
                   + achievement.interfaceLine
                   + ".");
     } else if (achievement.progressData == null) {
       player
           .getPacketSender()
           .sendMessage(
               "<img=10> <col=660000>You have not started the achievement: "
                   + achievement.interfaceLine
                   + ".");
     } else {
       int progress = player.getAchievementAttributes().getProgress()[achievement.progressData[0]];
       int requiredProgress = achievement.progressData[1];
       if (progress == 0) {
         player
             .getPacketSender()
             .sendMessage(
                 "<img=10> <col=660000>You have not started the achievement: "
                     + achievement.interfaceLine
                     + ".");
       } else if (progress != requiredProgress) {
         player
             .getPacketSender()
             .sendMessage(
                 "<img=10> <col=FFFF00>Your progress for this achievement is currently at: "
                     + Misc.insertCommasToNumber("" + progress)
                     + "/"
                     + Misc.insertCommasToNumber("" + requiredProgress)
                     + ".");
       }
     }
   }
   return true;
 }
예제 #3
0
  public static void finishAchievement(Player player, AchievementData achievement) {
    if (player.getAchievementAttributes().getCompletion()[achievement.ordinal()]) return;
    player.getAchievementAttributes().getCompletion()[achievement.ordinal()] = true;
    player
        .getPacketSender()
        .sendString(achievement.interfaceFrame, ("@gre@") + achievement.interfaceLine)
        .sendMessage(
            "<img=10> <col=339900>You have completed the achievement "
                + Misc.formatText(achievement.toString().toLowerCase() + "."))
        .sendString(
            37001,
            "Achievements: "
                + player.getPointsHandler().getAchievementPoints()
                + "/"
                + AchievementData.values().length);

    if (achievement.getDifficulty() == Difficulty.HARD) {
      doProgress(player, AchievementData.COMPLETE_ALL_HARD_TASKS);
    }

    player.getPointsHandler().setAchievementPoints(1, true);
  }
예제 #4
0
 @Override
 public boolean customContainerAttack(Character entity, Character victim) {
   NPC zilyana = (NPC) entity;
   if (victim.getConstitution() <= 0) {
     return true;
   }
   if (Locations.goodDistance(zilyana.getPosition().copy(), victim.getPosition().copy(), 1)
       && Misc.getRandom(5) <= 3) {
     zilyana.performAnimation(new Animation(zilyana.getDefinition().getAttackAnimation()));
     zilyana
         .getCombatBuilder()
         .setContainer(new CombatContainer(zilyana, victim, 1, 1, CombatType.MELEE, true));
   } else {
     zilyana.performAnimation(attack_anim);
     zilyana.performGraphic(new Graphic(1220));
     zilyana
         .getCombatBuilder()
         .setContainer(new CombatContainer(zilyana, victim, 2, 3, CombatType.MAGIC, true));
     zilyana.getCombatBuilder().setAttackTimer(7);
   }
   return true;
 }
예제 #5
0
  @Override
  public boolean customContainerAttack(Character entity, Character victim) {
    NPC cB = (NPC) entity;
    if (cB.isChargingAttack() || cB.getConstitution() <= 0) {
      return true;
    }
    Player target = (Player) victim;
    boolean stomp = false;
    for (Player t : Misc.getCombinedPlayerList(target)) {
      if (t == null || t.getLocation() != Location.CORPOREAL_BEAST) continue;
      if (Locations.goodDistance(t.getPosition(), cB.getPosition(), 1)) {
        stomp = true;
        cB.getCombatBuilder().setVictim(t);
        new CombatHitTask(
                cB.getCombatBuilder(), new CombatContainer(cB, t, 1, CombatType.MAGIC, true))
            .handleAttack();
      }
    }
    if (stomp) {
      cB.performAnimation(attack_anim);
      cB.performGraphic(attack_graphic);
    }

    int attackStyle = Misc.getRandom(4);
    if (attackStyle == 0 || attackStyle == 1) { // melee
      int distanceX = target.getPosition().getX() - cB.getPosition().getX();
      int distanceY = target.getPosition().getY() - cB.getPosition().getY();
      if (distanceX > 4 || distanceX < -1 || distanceY > 4 || distanceY < -1) attackStyle = 4;
      else {

        cB.performAnimation(new Animation(attackStyle == 0 ? 10057 : 10058));
        if (target.getLocation() == Location.CORPOREAL_BEAST)
          cB.getCombatBuilder()
              .setContainer(new CombatContainer(cB, target, 1, 1, CombatType.MELEE, true));
        return true;
      }
    } else if (attackStyle == 2) { // powerfull mage spiky ball
      cB.performAnimation(attack_anim2);
      cB.getCombatBuilder()
          .setContainer(new CombatContainer(cB, target, 1, 2, CombatType.MAGIC, true));
      new Projectile(cB, target, 1825, 44, 3, 43, 43, 0).sendProjectile();
    } else if (attackStyle == 3) { // translucent ball of energy
      cB.performAnimation(attack_anim2);
      if (target.getLocation() == Location.CORPOREAL_BEAST)
        cB.getCombatBuilder()
            .setContainer(new CombatContainer(cB, target, 1, 2, CombatType.MAGIC, true));
      new Projectile(cB, target, 1823, 44, 3, 43, 43, 0).sendProjectile();
      TaskManager.submit(
          new Task(1, target, false) {
            @Override
            public void execute() {
              int skill = Misc.getRandom(4);
              Skill skillT = Skill.forId(skill);
              Player player = (Player) target;
              int lvl = player.getSkillManager().getCurrentLevel(skillT);
              lvl -= 1 + Misc.getRandom(4);
              player
                  .getSkillManager()
                  .setCurrentLevel(
                      skillT,
                      player.getSkillManager().getCurrentLevel(skillT) - lvl <= 0 ? 1 : lvl);
              target
                  .getPacketSender()
                  .sendMessage("Your " + skillT.getFormatName() + " has been slighly drained!");
              stop();
            }
          });
    }
    if (attackStyle == 4) {
      cB.performAnimation(attack_anim2);
      for (Player t : Misc.getCombinedPlayerList(target)) {
        if (t == null || t.getLocation() != Location.CORPOREAL_BEAST) continue;
        new Projectile(cB, target, 1824, 44, 3, 43, 43, 0).sendProjectile();
      }
      TaskManager.submit(
          new Task(1, target, false) {
            @Override
            public void execute() {
              for (Player t : Misc.getCombinedPlayerList(target)) {
                if (t == null || t.getLocation() != Location.CORPOREAL_BEAST) continue;
                cB.getCombatBuilder().setVictim(t);
                new CombatHitTask(
                        cB.getCombatBuilder(),
                        new CombatContainer(cB, t, 1, CombatType.RANGED, true))
                    .handleAttack();
              }
              stop();
            }
          });
    }
    return true;
  }