/**
   * Method activate.
   *
   * @param player Player
   * @param item ItemInstance
   */
  public void activate(Player player, ItemInstance item) {
    if ((player == null) || player.isInOlympiadMode()) {
      return;
    }

    CursedWeapon cw = _cursedWeaponsMap.get(item.getId());

    if (cw == null) {
      return;
    }

    if (player.isCursedWeaponEquipped()) {
      if (player.getCursedWeaponEquippedId() != item.getId()) {
        CursedWeapon cw2 = _cursedWeaponsMap.get(player.getCursedWeaponEquippedId());
        cw2.setNbKills(cw2.getStageKills() - 1);
        cw2.increaseKills();
      }

      endOfLife(cw);
      player.getInventory().destroyItem(item, 1);
    } else if (cw.getTimeLeft() > 0) {
      cw.activate(player, item);
      saveData(cw);
      announce(
          new SystemMessage(SystemMessage.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION)
              .addZoneName(player.getLoc())
              .addString(cw.getName()));
    } else {
      endOfLife(cw);
      player.getInventory().destroyItem(item, 1);
    }
  }
  /**
   * Method dropAttackable.
   *
   * @param attackable NpcInstance
   * @param killer Player
   */
  public void dropAttackable(NpcInstance attackable, Player killer) {
    if (killer.isInOlympiadMode()
        || killer.isCursedWeaponEquipped()
        || (_cursedWeapons.length == 0)
        || (killer.getReflection() != ReflectionManager.DEFAULT)) {
      return;
    }

    synchronized (_cursedWeapons) {
      CursedWeapon[] cursedWeapons = new CursedWeapon[0];

      for (CursedWeapon cw : _cursedWeapons) {
        if (cw.isActive()) {
          continue;
        }

        cursedWeapons = ArrayUtils.add(cursedWeapons, cw);
      }

      if (cursedWeapons.length > 0) {
        CursedWeapon cw = cursedWeapons[Rnd.get(cursedWeapons.length)];

        if (Rnd.get(100000000) <= cw.getDropRate()) {
          cw.create(attackable, killer);
        }
      }
    }
  }
示例#3
0
 /**
  * Method doSupportMagic.
  *
  * @param npc NpcInstance
  * @param player Player
  * @param servitor boolean
  */
 public static void doSupportMagic(NpcInstance npc, Player player, boolean servitor) {
   if (player.isCursedWeaponEquipped()) {
     return;
   }
   int lvl = player.getLevel();
   if (servitor && (player.getSummonList().getFirstServitor() == null)) {
     show("default/newbie_nosupport_servitor.htm", player, npc);
     return;
   }
   if (lvl < minSupLvl) {
     show("default/newbie_nosupport_min.htm", player, npc);
     return;
   }
   if (lvl > maxSupLvl) {
     show("default/newbie_nosupport_max.htm", player, npc);
     return;
   }
   List<Creature> target = new ArrayList<>();
   if (servitor) {
     for (Summon summon : player.getSummonList()) {
       target.add(summon);
       for (int[] buff : _summonBuff) {
         if ((lvl >= buff[0]) && (lvl <= buff[1])) {
           npc.broadcastPacket(new MagicSkillUse(npc, summon, buff[2], buff[3], 0, 0));
           npc.callSkill(SkillTable.getInstance().getInfo(buff[2], buff[3]), target, true);
         }
       }
     }
   } else {
     target.add(player);
     if (!player.isMageClass() || (player.getTemplate().getRace() == Race.orc)) {
       for (int[] buff : _warrBuff) {
         if ((lvl >= buff[0]) && (lvl <= buff[1])) {
           npc.broadcastPacket(new MagicSkillUse(npc, player, buff[2], buff[3], 0, 0));
           npc.callSkill(SkillTable.getInstance().getInfo(buff[2], buff[3]), target, true);
         }
       }
     } else {
       for (int[] buff : _mageBuff) {
         if ((lvl >= buff[0]) && (lvl <= buff[1])) {
           npc.broadcastPacket(new MagicSkillUse(npc, player, buff[2], buff[3], 0, 0));
           npc.callSkill(SkillTable.getInstance().getInfo(buff[2], buff[3]), target, true);
         }
       }
     }
   }
 }
示例#4
0
 /**
  * Method canDuel0.
  *
  * @param requestor Player
  * @param target Player
  * @return IStaticPacket
  */
 protected IStaticPacket canDuel0(Player requestor, Player target) {
   IStaticPacket packet = null;
   if (target.isInCombat()) {
     packet =
         new SystemMessage2(SystemMsg.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_ENGAGED_IN_BATTLE)
             .addName(target);
   } else if (target.isDead()
       || target.isAlikeDead()
       || (target.getCurrentHpPercents() < 50)
       || (target.getCurrentMpPercents() < 50)
       || (target.getCurrentCpPercents() < 50)) {
     packet =
         new SystemMessage2(SystemMsg.C1_CANNOT_DUEL_BECAUSE_C1S_HP_OR_MP_IS_BELOW_50)
             .addName(target);
   } else if (target.getEvent(DuelEvent.class) != null) {
     packet =
         new SystemMessage2(SystemMsg.C1_CANNOT_DUEL_BECAUSE_C1_IS_ALREADY_ENGAGED_IN_A_DUEL)
             .addName(target);
   } else if ((target.getEvent(ClanHallSiegeEvent.class) != null)
       || (target.getEvent(ClanHallNpcSiegeEvent.class) != null)) {
     packet =
         new SystemMessage2(
                 SystemMsg.C1_CANNOT_DUEL_BECAUSE_C1_IS_PARTICIPATING_IN_A_CLAN_HALL_WAR)
             .addName(target);
   } else if (target.getEvent(SiegeEvent.class) != null) {
     packet =
         new SystemMessage2(SystemMsg.C1_CANNOT_DUEL_BECAUSE_C1_IS_PARTICIPATING_IN_A_SIEGE_WAR)
             .addName(target);
   } else if (target.isInOlympiadMode()) {
     packet =
         new SystemMessage2(SystemMsg.C1_CANNOT_DUEL_BECAUSE_C1_IS_PARTICIPATING_IN_THE_OLYMPIAD)
             .addName(target);
   } else if (target.isCursedWeaponEquipped()
       || (target.isChaotic())
       || (target.getPvpFlag() > 0)) {
     packet =
         new SystemMessage2(SystemMsg.C1_CANNOT_DUEL_BECAUSE_C1_IS_IN_A_CHAOTIC_STATE)
             .addName(target);
   } else if (target.isInStoreMode()) {
     packet =
         new SystemMessage2(
                 SystemMsg
                     .C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_ENGAGED_IN_A_PRIVATE_STORE_OR_MANUFACTURE)
             .addName(target);
   } else if (target.isMounted() || target.isInBoat()) {
     packet =
         new SystemMessage2(
                 SystemMsg.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_RIDING_A_BOAT_STEED_OR_STRIDER)
             .addName(target);
   } else if (target.isFishing()) {
     packet =
         new SystemMessage2(SystemMsg.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_FISHING)
             .addName(target);
   } else if (target.isInCombatZone()
       || target.isInPeaceZone()
       || target.isInWater()
       || target.isInZone(Zone.ZoneType.no_restart)) {
     packet =
         new SystemMessage2(
                 SystemMsg
                     .C1_CANNOT_MAKE_A_CHALLENGE_TO_A_DUEL_BECAUSE_C1_IS_CURRENTLY_IN_A_DUELPROHIBITED_AREA_PEACEFUL_ZONE__SEVEN_SIGNS_ZONE__NEAR_WATER__RESTART_PROHIBITED_AREA)
             .addName(target);
   } else if (!requestor.isInRangeZ(target, 1200)) {
     packet =
         new SystemMessage2(
                 SystemMsg.C1_CANNOT_RECEIVE_A_DUEL_CHALLENGE_BECAUSE_C1_IS_TOO_FAR_AWAY)
             .addName(target);
   } else if (target.getTransformation() != 0) {
     packet =
         new SystemMessage2(SystemMsg.C1_CANNOT_DUEL_BECAUSE_C1_IS_CURRENTLY_POLYMORPHED)
             .addName(target);
   }
   return packet;
 }