示例#1
0
  @Override
  public boolean checkCondition(
      final Creature activeChar,
      final Creature target,
      boolean forceUse,
      boolean dontMove,
      boolean first) {
    if (!activeChar.isPlayer()) return false;

    Player player = (Player) activeChar;

    if (_charges == 10
        && player.getSkillLevel(10301)
            != -1) // maybe something more practical? right now overrides any level of force before
                   // that.
    _charges = 15;

    // Камушки можно юзать даже если заряд > 7, остальное только если заряд < уровень скила
    if (getPower() <= 0 && getId() != 2165 && player.getIncreasedForce() >= _charges) {
      activeChar.sendPacket(SystemMsg.YOUR_FORCE_HAS_REACHED_MAXIMUM_CAPACITY_);
      return false;
    } else if (getId() == 2165) player.sendPacket(new MagicSkillUse(player, player, 2165, 1, 0, 0));

    return super.checkCondition(activeChar, target, forceUse, dontMove, first);
  }
 @Override
 public String onEvent(String event, QuestState st, NpcInstance npc) {
   Player player = st.getPlayer();
   String htmltext = event;
   if (event.equalsIgnoreCase("priest_wood_q10292_3.htm")) {
     st.setCond(1);
     st.setState(STARTED);
     st.playSound(SOUND_ACCEPT);
   } else if (event.equalsIgnoreCase("priest_wood_q10292_4.htm")) enterInstance(st, 145);
   else if (event.equalsIgnoreCase("witness_of_dawn_q10292_2.htm")) {
     st.setCond(2);
     st.playSound(SOUND_MIDDLE);
   } else if (event.equalsIgnoreCase("elcadia_abyssal_saintess_q10292_2.htm")) {
     st.setCond(3);
     st.playSound(SOUND_MIDDLE);
   } else if (event.equalsIgnoreCase("elcadia_abyssal_saintess_q10292_9.htm")) {
     st.setCond(7);
     st.playSound(SOUND_MIDDLE);
   } else if (event.equalsIgnoreCase("hardin_q10292_1.htm")) {
     st.setCond(8);
     st.playSound(SOUND_MIDDLE);
   } else if (event.equalsIgnoreCase("spawnTestMobs")) {
     int reflectId = player.getReflectionId();
     st.set("CreatureOfTheDusk1", 1);
     st.set("CreatureOfTheDusk2", 1);
     addSpawnToInstance(CREATURE_OF_THE_DUSK_1, 89416, -237992, -9632, 0, 0, reflectId);
     addSpawnToInstance(CREATURE_OF_THE_DUSK_2, 89416, -238136, -9632, 0, 0, reflectId);
     return null;
   }
   return htmltext;
 }
示例#3
0
 private void cleanUp() {
   startCollapseTimer(15 * 60 * 1000L);
   for (Player p : getPlayers())
     p.sendPacket(
         new SystemMessage(SystemMessage.THIS_DUNGEON_WILL_EXPIRE_IN_S1_MINUTES).addNumber(15));
   for (NpcInstance n : getNpcs()) n.deleteMe();
 }
  @Override
  protected void runImpl() {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    activeChar.setSellStoreName(_storename);
  }
 @Override
 public boolean checkStartCondition(Player player) {
   return (player.getLevel() >= minLevel
       && player.getLevel() <= maxLevel
       && player.getRace() == Race.ERTHEIA
       && player.getQuestState("_10779_LetterFromTheQueen_SeaOfSpores") == null);
 }
示例#6
0
  @Override
  public boolean useUserCommand(int id, Player activeChar) {
    if (id != COMMAND_IDS[0]) return false;

    GameObject objectTarget = Config.OLYMPIAD_OLDSTYLE_STAT ? activeChar : activeChar.getTarget();
    if (objectTarget == null || !objectTarget.isPlayer() || !objectTarget.getPlayer().isNoble()) {
      activeChar.sendPacket(SystemMsg.THIS_COMMAND_CAN_ONLY_BE_USED_BY_A_NOBLESSE);
      return true;
    }

    Player playerTarget = objectTarget.getPlayer();

    SystemMessage2 sm =
        new SystemMessage2(
            SystemMsg
                .FOR_THE_CURRENT_GRAND_OLYMPIAD_YOU_HAVE_PARTICIPATED_IN_S1_MATCHES_S2_WINS_S3_DEFEATS_YOU_CURRENTLY_HAVE_S4_OLYMPIAD_POINTS);
    sm.addInteger(Olympiad.getCompetitionDone(playerTarget.getObjectId()));
    sm.addInteger(Olympiad.getCompetitionWin(playerTarget.getObjectId()));
    sm.addInteger(Olympiad.getCompetitionLoose(playerTarget.getObjectId()));
    sm.addInteger(Olympiad.getNoblePoints(playerTarget.getObjectId()));

    activeChar.sendPacket(sm);

    int[] ar = Olympiad.getWeekGameCounts(playerTarget.getObjectId());
    sm =
        new SystemMessage2(
            SystemMsg
                .YOU_HAVE_S1_MATCHES_REMAINING_THAT_YOU_CAN_PARTICIPATE_IN_THIS_WEEK_S2_1_VS_1_CLASS_MATCHES_S3_1_VS_1_MATCHES__S4_3_VS_3_TEAM_MATCHES);
    sm.addInteger(ar[0]);
    sm.addInteger(ar[1]);
    sm.addInteger(ar[2]);
    sm.addInteger(0 /*ar[3]*/);
    activeChar.sendPacket(sm);
    return true;
  }
示例#7
0
 public GMViewItemList(Player cha, ItemInstance[] items, int size) {
   _size = size;
   _items = items;
   _name = cha.getName();
   _limit = cha.getInventoryLimit();
   _player = cha;
 }
  @Override
  protected void runImpl() {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    activeChar.sendPacket(new ExResponseCommissionItemList(activeChar));
  }
 @Override
 public void runImpl() throws Exception {
   _activeChar.sendActionFailed();
   _activeChar.clearCastVars(false);
   if (_activeChar.isDead() || _target.isDead()) return;
   _target.addAbsorber(_activeChar);
 }
示例#10
0
  @Override
  protected void thinkActive() {
    Player actor = getActor();
    // FPCInfo player	= FPCInfo.getInstance(actor);

    if (actor.isActionsDisabled()) {
      return;
    }

    if (_def_think) {
      if (doTask()) {
        clearTasks();
      }
      return;
    }

    // player.cancelShop();

    if (Rnd.chance(0.5)) {
      actor.standUp();
      if (Rnd.chance(20)) randomWalk(1000);
      else {
        List<GameObject> chars = World.getAroundObjects(actor, 2000, 500);
        if (chars.size() == 0) return;
        GameObject randomChar = chars.get(Rnd.get(chars.size()));
        if (!randomChar.isDoor()) actor.moveToLocation(randomChar.getLoc(), 50, true);
      }
    }
  }
  @Override
  protected void runImpl() throws Exception {
    Player player = getClient().getActiveChar();
    if (player == null) return;

    player.sendPacket(new ExReceiveShowPostFriend(player));
  }
  @Override
  protected void runImpl() {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    CategoryType cat = CategoryType.getCategoryById(_section, _subSection);
    if (cat == null) {
      _log.warn(
          "RequestWorldStatistics: Not found category for section: "
              + _section
              + " subsection: "
              + _subSection);
      return;
    }

    List<CharacterStatistic> generalStatisticList =
        WorldStatisticsManager.getInstance()
            .getStatisticTop(cat, true, WorldStatisticsManager.STATISTIC_TOP_PLAYER_LIMIT);
    List<CharacterStatistic> monthlyStatisticList =
        WorldStatisticsManager.getInstance()
            .getStatisticTop(cat, false, WorldStatisticsManager.STATISTIC_TOP_PLAYER_LIMIT);

    activeChar.sendPacket(
        new ExLoadStatWorldRank(_section, _subSection, generalStatisticList, monthlyStatisticList));
  }
示例#13
0
  public void deletePet(ItemInstance item, Creature owner) {
    int petObjectId = 0;

    Connection con = null;
    PreparedStatement statement = null;
    ResultSet rset = null;
    try {
      int itemObjId = item.getObjectId();
      con = DatabaseFactory.getInstance().getConnection();
      statement = con.prepareStatement(SELECT_SQL_QUERY);
      statement.setInt(1, itemObjId);
      rset = statement.executeQuery();
      while (rset.next()) petObjectId = rset.getInt("objId");

      DbUtils.close(statement, rset);

      Player player = owner.getPlayer();

      PetInstance pet = player.getPet();
      if (pet != null && pet.getObjectId() == petObjectId) pet.unSummon(false);

      if (player != null && player.isMounted() && player.getMountControlItemObjId() == itemObjId)
        player.getMount().onControlItemDelete();

      // if it's a pet control item, delete the pet
      statement = con.prepareStatement(DELETE_SQL_QUERY);
      statement.setInt(1, itemObjId);
      statement.execute();
    } catch (Exception e) {
      _log.error("CharNameTable.deletePet(ItemInstance, Creature): " + e, e);
    } finally {
      DbUtils.closeQuietly(con, statement, rset);
    }
  }
示例#14
0
 @Override
 public void runImpl() throws Exception {
   try {
     switch (_taskId) {
       case 1:
         blockAll(true);
         int _angle =
             Math.abs(
                 (strongScarlet.getHeading() < 32768 ? 180 : 540)
                     - (int) (strongScarlet.getHeading() / 182.044444444));
         showSocialActionMovie(strongScarlet, 300, _angle - 180, 5, 0, 7000, 0);
         showSocialActionMovie(strongScarlet, 200, _angle, 85, 4000, 10000, 0);
         ThreadPoolManager.getInstance().schedule(new Die(2), 7500);
         break;
       case 2:
         showSocialActionMovie(frintezza, 100, 120, 5, 0, 7000, 0);
         showSocialActionMovie(frintezza, 100, 90, 5, 5000, 15000, 0);
         ThreadPoolManager.getInstance().schedule(new Die(3), 6000);
         break;
       case 3:
         showSocialActionMovie(frintezza, 900, 90, 25, 7000, 10000, 0);
         frintezza.doDie(frintezza);
         frintezza = null;
         ThreadPoolManager.getInstance().schedule(new Die(4), 7000);
         break;
       case 4:
         for (Player pc : getPlayers()) pc.leaveMovieMode();
         cleanUp();
         break;
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
示例#15
0
 @Override
 public void runImpl() throws Exception {
   try {
     switch (_taskId) {
       case 1:
         int angle =
             Math.abs(
                 (weakScarlet.getHeading() < 32768 ? 180 : 540)
                     - (int) (weakScarlet.getHeading() / 182.044444444));
         for (Player pc : getPlayers()) pc.enterMovieMode();
         blockAll(true);
         showSocialActionMovie(weakScarlet, 500, angle, 5, 500, 15000, 0);
         ThreadPoolManager.getInstance().schedule(new SecondMorph(2), 2000);
         break;
       case 2:
         weakScarlet.broadcastPacket(new SocialActionPacket(weakScarlet.getObjectId(), 1));
         weakScarlet.setCurrentHp(weakScarlet.getMaxHp() * 3 / 4, false);
         weakScarlet.setRHandId(_frintezzasSwordId);
         weakScarlet.broadcastCharInfo();
         ThreadPoolManager.getInstance().schedule(new SecondMorph(3), 5500);
         break;
       case 3:
         weakScarlet.broadcastPacket(new SocialActionPacket(weakScarlet.getObjectId(), 4));
         blockAll(false);
         Skill skill = SkillTable.getInstance().getInfo(5017, 1);
         skill.getEffects(weakScarlet, weakScarlet, false, false);
         for (Player pc : getPlayers()) pc.leaveMovieMode();
         break;
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 @Override
 protected void runImpl() {
   Player activeChar = getClient().getActiveChar();
   if (activeChar != null) {
     activeChar.setEnchantScroll(null);
     activeChar.sendPacket(EnchantResult.CANCEL);
   }
 }
示例#17
0
 public void chargePlayer(Player player, Integer skillId) {
   if (player.getIncreasedForce() >= _charges) {
     player.sendPacket(SystemMsg.YOUR_FORCE_HAS_REACHED_MAXIMUM_CAPACITY_);
     return;
   }
   if (_fullCharge) player.setIncreasedForce(_charges);
   else player.setIncreasedForce(player.getIncreasedForce() + 1);
 }
示例#18
0
  public boolean enchanterFightTask(Creature target) {
    Player player = getActor();
    double distance = player.getDistance(target);

    if (canUseSkill(Dominator.SKILL_STEAL_ESSENCE, target, distance))
      return tryCastSkill(Dominator.SKILL_STEAL_ESSENCE, target, distance);

    return chooseTaskAndTargets(null, target, distance);
  }
示例#19
0
    @Override
    public void runImpl() throws Exception {
      if (isNowNight()) getInstance().getListenerEngine().onNight();
      else getInstance().getListenerEngine().onDay();

      for (Player player : GameObjectsStorage.getAllPlayersForIterate()) {
        player.checkDayNightMessages();
        player.sendPacket(new ClientSetTime());
      }
    }
示例#20
0
 @Override
 protected void onEvtThink() {
   Player actor = getActor();
   if (actor.isDead()) /* TODO or res your self */ {
     // return to village
     actor.teleToClosestTown();
     actor.doRevive();
   }
   thinkActive();
 }
  @Override
  public void onPlayerEnter(Player player) {
    if (player.getVarBoolean("@received_navari_letter_6th")) return;

    // System.out.println("Player enter");
    if (checkStartCondition(player)) {
      // System.out.println("Player enter and fit quest condition");
      Quest q = QuestManager.getQuest(10779);
      player.processQuestEvent(q.getName(), "start_quest_delay", null);
    }
  }
示例#22
0
 /**
  * Shows a movie to the players in the lair.
  *
  * @param target - L2NpcInstance target is the center of this movie
  * @param dist - int distance from target
  * @param yaw - angle of movie (north = 90, south = 270, east = 0 , west = 180)
  * @param pitch - pitch > 0 looks up / pitch < 0 looks down
  * @param time - fast ++ or slow -- depends on the value
  * @param duration - How long to watch the movie
  * @param socialAction - 1,2,3,4 social actions / other values do nothing
  */
 private void showSocialActionMovie(
     NpcInstance target, int dist, int yaw, int pitch, int time, int duration, int socialAction) {
   if (target == null) return;
   for (Player pc : getPlayers())
     if (pc.getDistance(target) <= 2550) {
       pc.enterMovieMode();
       pc.specialCamera(target, dist, yaw, pitch, time, duration);
     } else pc.leaveMovieMode();
   if (socialAction > 0 && socialAction < 5)
     target.broadcastPacket(new SocialActionPacket(target.getObjectId(), socialAction));
 }
 @Override
 public String onTalk(NpcInstance npc, QuestState st) {
   String htmltext = "noquest";
   int npcId = npc.getNpcId();
   int cond = st.getCond();
   int id = st.getState();
   Player player = st.getPlayer();
   if (!player.isBaseClassActive()) return "no_subclass_allowed.htm";
   switch (npcId) {
     case WOOD:
       if (cond == 0) {
         QuestState qs = player.getQuestState(_198_SevenSignsEmbryo.class);
         if (player.getLevel() >= 81 && qs != null && qs.isCompleted())
           htmltext = "priest_wood_q10292_0.htm";
         else {
           htmltext = "priest_wood_q10292_0n.htm";
           st.exitCurrentQuest(true);
         }
       } else if (cond == 1) htmltext = "priest_wood_q10292_3.htm";
       else if (cond > 1 && !st.isCompleted())
         htmltext = "priest_wood_q10292_5.htm"; // TODO: Отредактировать диалог по оффу
       else if (st.isCompleted()) htmltext = "priest_wood_q10292_6.htm";
       break;
     case FRANZ:
       if (cond == 1) htmltext = "witness_of_dawn_q10292_0.htm";
       else if (cond == 2) htmltext = "witness_of_dawn_q10292_4.htm";
       break;
     case ELCARDIA:
       if (cond == 2) htmltext = "elcadia_abyssal_saintess_q10292_0.htm";
       else if (cond == 3) htmltext = "elcadia_abyssal_saintess_q10292_2.htm";
       else if (cond == 4) {
         htmltext = "elcadia_abyssal_saintess_q10292_3.htm";
         st.takeItems(ELCARDIAS_MARK, -1);
         st.playSound(SOUND_MIDDLE);
         st.setCond(5);
       } else if (cond == 5) htmltext = "elcadia_abyssal_saintess_q10292_5.htm";
       else if (cond == 6) htmltext = "elcadia_abyssal_saintess_q10292_6.htm";
       else if (cond == 7) htmltext = "elcadia_abyssal_saintess_q10292_9.htm";
       else if (cond == 8) {
         htmltext = "elcadia_abyssal_saintess_q10292_10.htm";
         st.addExpAndSp(10000000, 1000000);
         st.setState(COMPLETED);
         st.exitCurrentQuest(false);
         st.playSound(SOUND_FINISH);
       }
       break;
     case HARDIN:
       if (cond == 7) htmltext = "hardin_q10292_0.htm";
       else if (cond == 8) htmltext = "hardin_q10292_2.htm";
       break;
   }
   return htmltext;
 }
  @Override
  public void onLevelChange(Player player, int oldLvl, int newLvl) {
    // System.out.println("level change oldLvl " + oldLvl + " newLvl " + newLvl +
    // "checkStartCondition " + checkStartCondition(player));
    if (oldLvl < minLevel && newLvl >= minLevel && checkStartCondition(player)) {
      // System.out.println("received_navari_letter_6th " +
      // player.getVarBoolean("@received_navari_letter_6th"));
      if (player.getVarBoolean("@received_navari_letter_6th")) return;

      Quest q = QuestManager.getQuest(10779);
      player.processQuestEvent(q.getName(), "start_quest", null);
    }
  }
示例#25
0
 public void showMonsterInfo(Player player) {
   int npcId = getNpcId();
   String filename, search;
   NpcHtmlMessage html = new NpcHtmlMessage(player, this);
   filename = getHtmlPath(npcId, 6, player);
   html.setFile(filename);
   for (int i = 0; i < 8; i++) {
     int n = i + 1;
     search = "Mob" + n;
     html.replace(search, MonsterRace.getInstance().getMonsters()[i].getTemplate().name);
   }
   player.sendPacket(html);
   player.sendActionFailed();
 }
示例#26
0
  /**
   * Проверяет возможность передачи вещи
   *
   * @param player
   * @param item
   * @return
   */
  public static final boolean checkIfCanDiscard(Player player, ItemInstance item) {
    if (item.isHeroItem()) return false;

    if (player.getMountControlItemObjId() == item.getObjectId()) return false;

    if (player.getPetControlItem() == item) return false;

    if (player.getEnchantScroll() == item) return false;

    if (item.isCursed()) return false;

    if (item.getTemplate().isQuest()) return false;

    return true;
  }
示例#27
0
 /** Depending on the song, returns the song's targets (either mobs or players) */
 private List<Creature> getSongTargets(int songId) {
   List<Creature> targets = new ArrayList<Creature>();
   if (songId < 4) // Target is the minions
   {
     if (weakScarlet != null && !weakScarlet.isDead()) targets.add(weakScarlet);
     if (strongScarlet != null && !strongScarlet.isDead()) targets.add(strongScarlet);
     for (int i = 0; i < 4; i++) {
       if (portraits[i] != null && !portraits[i].isDead()) targets.add(portraits[i]);
       if (demons[i] != null && !demons[i].isDead()) targets.add(demons[i]);
     }
   } else
     // Target is the players
     for (Player pc : getPlayers()) if (!pc.isDead()) targets.add(pc);
   return targets;
 }
示例#28
0
  @Override
  public void showChatWindow(Player player, int val, Object... replace) {
    NpcHtmlMessagePacket htmlMessage = new NpcHtmlMessagePacket(getObjectId());
    htmlMessage.setFile("default/33785.htm");
    if (player.getVar("Altar1") != null) {
      htmlMessage.setFile("default/33785-2.htm");
    }
    if (player.getVar("Altar2") != null) {
      htmlMessage.setFile("default/33785-3.htm");
    }
    if (player.getVar("Altar3") != null) {
      htmlMessage.setFile("default/33785-e.htm");
    }

    player.sendPacket(htmlMessage);
  }
示例#29
0
  @Override
  public boolean useVoicedCommand(String command, Player activeChar, String target) {
    if (!Config.ALLOW_VOICED_COMMANDS) return false;

    if (command.equals("rev") || command.equals("ver")) {
      activeChar.sendMessage("Project Revision: " + GameServer.PROJECT_REVISION);
      activeChar.sendMessage("Build Revision: beta.0.1");
      activeChar.sendMessage("Update: " + GameServer.UPDATE_NAME);
      activeChar.sendMessage("Build date: " + GameServer.getInstance().getVersion().getBuildDate());
    } else if (command.equals("date") || command.equals("time")) {
      activeChar.sendMessage(DATE_FORMAT.format(new Date(System.currentTimeMillis())));
      return true;
    }

    return false;
  }
示例#30
0
  @Override
  public void useSkill(Creature activeChar, List<Creature> targets) {
    double percent = _power;

    for (Creature target : targets) {
      if (target.isPlayer()) {
        Player player = target.getPlayer();
        int points = (int) (Player.MAX_VITALITY_POINTS / 100 * percent);
        player.setVitality(player.getVitality() + points);
      }
      getEffects(activeChar, target, false);
    }

    if (isSSPossible()) activeChar.unChargeShots(isMagic());

    super.useSkill(activeChar, targets);
  }