@Override
  protected final void runImpl() {
    final L2PcInstance activeChar = super.getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    // can't use auction fp here
    if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("auction")) {
      activeChar.sendMessage("You are bidding too fast.");
      return;
    }

    if ((_bid < 0) || (_bid > Inventory.MAX_ADENA)) {
      return;
    }

    final ItemAuctionInstance instance =
        ItemAuctionManager.getInstance().getManagerInstance(_instanceId);
    if (instance != null) {
      final ItemAuction auction = instance.getCurrentAuction();
      if (auction != null) {
        auction.registerBid(activeChar, _bid);
      }
    }
  }
  private void useSkill(String skillName, L2Object target, boolean pet) {
    final L2PcInstance activeChar = getActiveChar();
    if (activeChar == null) {
      return;
    }

    final L2Summon summon = activeChar.getPet();
    if (!validateSummon(summon, pet)) {
      return;
    }

    if (!canControl(summon)) {
      return;
    }

    if (summon instanceof L2BabyPetInstance) {
      if (!((L2BabyPetInstance) summon).isInSupportMode()) {
        sendPacket(SystemMessageId.A_PET_ON_AUXILIARY_MODE_CANNOT_USE_SKILLS);
        return;
      }
    }
    final Skill skill = summon.getTemplate().getParameters().getSkillHolder(skillName).getSkill();

    if (skill != null) {
      summon.setTarget(target);
      summon.useMagic(skill, _ctrlPressed, _shiftPressed);

      if (skill.getId() == SWITCH_STANCE_ID) {
        summon.switchMode();
      }
    }
  }
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    activeChar.sendPacket(new UserInfo(activeChar));
    activeChar.sendPacket(new ExBrExtraUserInfo(activeChar));

    Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
    for (L2Object object : objs) {
      if (object.getPoly().isMorphed() && object.getPoly().getPolyType().equals("item")) {
        activeChar.sendPacket(new SpawnItem(object));
      } else {
        if (!object.isVisibleFor(activeChar)) {
          object.sendInfo(activeChar);

          if (object instanceof L2Character) {
            // Update the state of the L2Character object client
            // side by sending Server->Client packet
            // MoveToPawn/CharMoveToLocation and AutoAttackStart to
            // the L2PcInstance
            final L2Character obj = (L2Character) object;
            if (obj.getAI() != null) {
              obj.getAI().describeStateToPlayer(activeChar);
            }
          }
        }
      }
    }
  }
 private final String funcConfirmHtml(
     final L2PcInstance player,
     final L2Npc npc,
     final Castle castle,
     final int func,
     final int level) {
   if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_SET_FUNCTIONS)) {
     final NpcHtmlMessage html;
     final String fstring = (func == Castle.FUNC_TELEPORT) ? "9" : "10";
     if (level == 0) {
       html = getHtmlPacket(player, npc, "castleresetdeco.html");
       html.replace("%AgitDecoSubmit%", Integer.toString(func));
     } else if ((castle.getFunction(func) != null)
         && (castle.getFunction(func).getLvl() == level)) {
       html = getHtmlPacket(player, npc, "castledecoalreadyset.html");
       html.replace("%AgitDecoEffect%", "<fstring p1=\"" + level + "\">" + fstring + "</fstring>");
     } else {
       html = getHtmlPacket(player, npc, "castledeco-0" + func + ".html");
       html.replace(
           "%AgitDecoCost%",
           "<fstring p1=\""
               + getFunctionFee(func, level)
               + "\" p2=\""
               + (getFunctionRatio(func) / 86400000)
               + "\">6</fstring>");
       html.replace("%AgitDecoEffect%", "<fstring p1=\"" + level + "\">" + fstring + "</fstring>");
       html.replace("%AgitDecoSubmit%", func + " " + level);
     }
     player.sendPacket(html);
     return null;
   }
   return "chamberlain-21.html";
 }
 public void doSurrender(L2PcInstance player) {
   if ((player == null) || !player.isInDuel()) {
     return;
   }
   final Duel duel = getDuel(player.getDuelId());
   duel.doSurrender(player);
 }
Exemple #6
0
  /**
   * This function is called whenever a player leaves a party
   *
   * @param player the player quitting.
   */
  public void onRemoveFromParty(L2PcInstance player) {
    // if it isn't a party duel ignore this
    if (!_partyDuel) {
      return;
    }

    // this player is leaving his party during party duel
    // if he's either playerA or playerB cancel the duel and port the players back
    if ((player == _playerA) || (player == _playerB)) {
      for (PlayerCondition cond : _playerConditions.values()) {
        cond.teleportBack();
        cond.getPlayer().setIsInDuel(0);
      }

      _playerA = null;
      _playerB = null;
    } else
    // teleport the player back & delete his PlayerCondition record
    {
      final PlayerCondition cond = _playerConditions.get(player.getObjectId());
      if (cond != null) {
        cond.teleportBack();
        _playerConditions.remove(cond);
      }
      player.setIsInDuel(0);
    }
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    final QuestState st = player.getQuestState(getName());
    String htmltext = getNoQuestMsg(player);
    if (st == null) {
      return htmltext;
    }

    switch (st.getState()) {
      case State.CREATED:
        {
          if (player.getLevel() < MIN_LVL) {
            htmltext = "32054-02.htm";
          } else {
            final QuestState q117 = player.getQuestState("117_OceanOfDistantStar"); // TODO: Update.
            htmltext = (q117 != null) && q117.isCompleted() ? "32054-01.htm" : "32054-04.htm";
          }
          break;
        }
      case State.STARTED:
        {
          htmltext =
              st.hasQuestItems(REMNANTS_OF_OLD_DWARVES_DREAMS) ? "32054-05.html" : "32054-06.html";
          break;
        }
    }
    return htmltext;
  }
 private void showSiegeTimePage(L2PcInstance activeChar) {
   final NpcHtmlMessage adminReply = new NpcHtmlMessage();
   adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/territorywartime.htm");
   adminReply.replace(
       "%time%", TerritoryWarManager.getInstance().getTWStart().getTime().toString());
   activeChar.sendPacket(adminReply);
 }
Exemple #9
0
 @Override
 public String onFirstTalk(L2Npc npc, L2PcInstance player) {
   if (player.isClanLeader() || player.hasClanPrivilege(ClanPrivilege.CL_TROOPS_FAME)) {
     return npc.getId() + ".html";
   }
   return npc.getId() + "-01.html";
 }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    QuestState st = getQuestState(player, false);
    if (st == null) {
      return getNoQuestMsg(player);
    }

    if (Util.isDigit(event)) {
      int i = Integer.valueOf(event);
      final ClassId cid = player.getClassId();
      if ((cid.getRace() == Race.DARK_ELF) && (cid.getId() == CLASSES[i][1])) {
        int suffix;
        final boolean item = st.hasQuestItems(CLASSES[i][6]);
        if (player.getLevel() < 20) {
          suffix = (!item) ? CLASSES[i][2] : CLASSES[i][3];
        } else {
          if (!item) {
            suffix = CLASSES[i][4];
          } else {
            suffix = CLASSES[i][5];
            st.giveItems(SHADOW_WEAPON_COUPON_DGRADE, 15);
            st.takeItems(CLASSES[i][6], -1);
            player.setClassId(CLASSES[i][0]);
            player.setBaseClass(CLASSES[i][0]);
            st.playSound(QuestSound.ITEMSOUND_QUEST_FANFARE_2);
            player.broadcastUserInfo();
            st.exitQuest(false);
          }
        }
        event = npc.getId() + "-" + suffix + ".html";
      }
    }
    return event;
  }
 @Override
 public String onTalk(L2Npc npc, L2PcInstance player) {
   final QuestState st = player.getQuestState(getName());
   String htmltext = getNoQuestMsg(player);
   if (st != null) {
     switch (st.getState()) {
       case State.CREATED:
         {
           htmltext =
               (player.getRace() == Race.DARK_ELF)
                   ? (player.getLevel() >= MIN_LVL) ? "30348-02.htm" : "30348-01.htm"
                   : "30348-00.htm";
           break;
         }
       case State.STARTED:
         {
           if (st.isCond(2) && (st.getQuestItemsCount(DARK_BEZOAR) >= REQUIRED_COUNT)) {
             st.giveItems(LESSER_HEALING_POTION, 5);
             st.addExpAndSp(1000, 0);
             st.exitQuest(false, true);
             htmltext = "30348-05.html";
           } else {
             htmltext = "30348-04.html";
           }
           break;
         }
       case State.COMPLETED:
         {
           htmltext = getAlreadyCompletedMsg(player);
           break;
         }
     }
   }
   return htmltext;
 }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    final QuestState qs = getQuestState(player, true);
    String htmltext = getNoQuestMsg(player);
    if (qs == null) {
      return htmltext;
    }

    if (qs.isCreated()) {
      final QuestState q10288 = player.getQuestState(Q10288_SecretMission.class.getSimpleName());
      if ((player.getLevel() < 82) || (q10288 == null) || !q10288.isCompleted()) {
        htmltext = "32757-00.htm";
      } else {
        htmltext = "32757-01.htm";
      }
    } else if (qs.isStarted()) {
      switch (qs.getCond()) {
        case 1:
          htmltext = "32757-04.html";
          break;
        case 2:
        case 3:
          htmltext = "32757-05.html";
          break;
      }
    } else {
      htmltext = "32757-10.html";
    }
    return htmltext;
  }
  private final synchronized void enterInstance(L2PcInstance player) {
    // check for existing instances for this player
    InstanceWorld world = InstanceManager.getInstance().getPlayerWorld(player);
    if (world != null) {
      if (world.templateId != INSTANCE_ID) {
        player.sendPacket(SystemMessageId.ALREADY_ENTERED_ANOTHER_INSTANCE_CANT_ENTER);
        return;
      }
      Instance inst = InstanceManager.getInstance().getInstance(world.instanceId);
      if (inst != null) {
        teleportPlayer(player, TELEPORT, world.instanceId);
      }
      return;
    }
    // New instance
    final int instanceId =
        InstanceManager.getInstance().createDynamicInstance("PailakaSongOfIceAndFire.xml");

    world = new InstanceWorld();
    world.instanceId = instanceId;
    world.templateId = INSTANCE_ID;
    InstanceManager.getInstance().addWorld(world);

    world.allowed.add(player.getObjectId());
    teleportPlayer(player, TELEPORT, instanceId);
  }
Exemple #14
0
 @Override
 public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
   String htmltext = null;
   switch (event) {
     case "32557-01.html":
       {
         htmltext = event;
         break;
       }
     case "licence":
       {
         final L2Clan clan = player.getClan();
         if ((clan == null) || !player.isClanLeader() || (clan.getLevel() < MIN_CLAN_LV)) {
           htmltext = "32557-02.html";
         } else if (hasAtLeastOneQuestItem(player, LICENCE)) {
           htmltext = "32557-04.html";
         } else if (AirShipManager.getInstance().hasAirShipLicense(clan.getId())) {
           player.sendPacket(SystemMessageId.THE_AIRSHIP_SUMMON_LICENSE_ALREADY_ACQUIRED);
         } else if (getQuestItemsCount(player, STONE) >= STONE_COUNT) {
           takeItems(player, STONE, STONE_COUNT);
           giveItems(player, LICENCE, 1);
         } else {
           htmltext = "32557-03.html";
         }
         break;
       }
   }
   return htmltext;
 }
  private void showFortSelectPage(L2PcInstance activeChar) {
    int i = 0;
    final NpcHtmlMessage adminReply = new NpcHtmlMessage();
    adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/forts.htm");

    final List<Fort> forts = FortManager.getInstance().getForts();
    final StringBuilder cList = new StringBuilder(forts.size() * 100);

    for (Fort fort : forts) {
      if (fort != null) {
        // L2JTW uses fort.getCName() instead of fort.getName()
        StringUtil.append(
            cList,
            "<td fixwidth=90><a action=\"bypass -h admin_fortsiege ",
            String.valueOf(fort.getResidenceId()),
            "\">",
            fort.getName(),
            " id: ",
            String.valueOf(fort.getResidenceId()),
            "</a></td>");
        i++;
      }
      // L2JTW: if (i > 0)
      if (i > 2) {
        cList.append("</tr><tr>");
        i = 0;
      }
    }

    adminReply.replace("%forts%", cList.toString());
    activeChar.sendPacket(adminReply);
  }
Exemple #16
0
  public synchronized void doDie(boolean win) {
    if (_fishAiTask != null) {
      _fishAiTask.cancel(false);
      _fishAiTask = null;
    }

    if (_fisher == null) {
      return;
    }

    if (win) {
      final L2FishingMonster fishingMonster =
          FishingMonstersData.getInstance().getFishingMonster(_fisher.getLevel());
      if (fishingMonster != null) {
        if (Rnd.get(100) <= fishingMonster.getProbability()) {
          _fisher.sendPacket(SystemMessageId.YOU_VE_CAUGHT_GOLDEEN);
          final L2Npc monster =
              AbstractScript.addSpawn(fishingMonster.getFishingMonsterId(), _fisher);
          monster.setTarget(_fisher);
        } else {
          _fisher.sendPacket(SystemMessageId.YOU_CAUGHT_SOMETHING);
          _fisher.addItem("Fishing", _fishId, 1, null, true);
          FishingChampionshipManager.getInstance().newFish(_fisher, _lureId);
        }
      }
    }

    _fisher.endFishing(win, true);
    _fisher = null;
  }
  @Override
  protected void runImpl() {
    if (Config.DEBUG) {
      _log.log(Level.FINE, "Info for clan " + _clanId + " requested");
    }

    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    final L2Clan clan = ClanTable.getInstance().getClan(_clanId);
    if (clan == null) {
      if (Config.DEBUG) {
        _log.warning(
            getType()
                + ": Clan data for clanId "
                + _clanId
                + " is missing for player "
                + activeChar);
      }
      return; // we have no clan data ?!? should not happen
    }

    activeChar.sendPacket(new PledgeInfo(clan));
  }
Exemple #18
0
  public L2Fishing(
      L2PcInstance Fisher, L2Fish fish, boolean isNoob, boolean isUpperGrade, int lureId) {
    _fisher = Fisher;
    _fishMaxHp = fish.getFishHp();
    _fishCurHp = _fishMaxHp;
    _regenHp = fish.getHpRegen();
    _fishId = fish.getItemId();
    _time = fish.getCombatDuration();
    _isUpperGrade = isUpperGrade;
    _lureId = lureId;
    final int lureType;
    if (isUpperGrade) {
      _deceptiveMode = ((Rnd.get(100) >= 90) ? 1 : 0);
      lureType = 2;
    } else {
      _deceptiveMode = 0;
      lureType = (isNoob ? 0 : 1);
    }
    _mode = ((Rnd.get(100) >= 80) ? 1 : 0);

    _fisher.broadcastPacket(
        new ExFishingStartCombat(_fisher, _time, _fishMaxHp, _mode, lureType, _deceptiveMode));
    _fisher.sendPacket(new PlaySound(1, "SF_S_01", 0, 0, 0, 0, 0));
    // Succeeded in getting a bite
    // _fisher.sendPacket(SystemMessageId.YOU_VE_GOT_A_BITE);

    if ((_fishAiTask == null) && _fisher.isFishing()) {
      _fishAiTask = ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(this, 1000, 1000);
    }

    // TODO: New fishing system?
    doDie(true);
  }
  @Override
  public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) {
    final List<L2PcInstance> randomList = new ArrayList<>();
    final QuestState st = killer.getQuestState(getName());
    if ((st != null) && st.isStarted()) {
      randomList.add(killer);
      randomList.add(killer);
    }

    final int monsterChance = MONSTER_DROP_CHANCES.get(npc.getId());
    if (killer.isInParty()) {
      for (L2PcInstance member : killer.getParty().getMembers()) {
        final QuestState qs = member.getQuestState(getName());
        if ((qs != null) && qs.isStarted()) {
          randomList.add(member);
        }
      }
    }

    if (!randomList.isEmpty()) {
      final L2PcInstance player = randomList.get(getRandom(randomList.size()));
      if ((getRandom(1000) < monsterChance) && Util.checkIfInRange(1500, npc, player, true)) {
        giveItems(player, REMNANTS_OF_OLD_DWARVES_DREAMS, 1);
        playSound(player, QuestSound.ITEMSOUND_QUEST_ITEMGET);
      }
    }
    return super.onKill(npc, killer, isSummon);
  }
Exemple #20
0
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    if (command.equals("admin_tvt_add")) {
      L2Object target = activeChar.getTarget();

      if (!(target instanceof L2PcInstance)) {
        activeChar.sendMessage("You should select a player!");
        return true;
      }

      add(activeChar, (L2PcInstance) target);
    } else if (command.equals("admin_tvt_remove")) {
      L2Object target = activeChar.getTarget();

      if (!(target instanceof L2PcInstance)) {
        activeChar.sendMessage("You should select a player!");
        return true;
      }

      remove(activeChar, (L2PcInstance) target);
    } else if (command.equals("admin_tvt_advance")) {
      TvTManager.getInstance().skipDelay();
    }

    return true;
  }
  @Override
  public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon) {
    QuestState st = getQuestState(killer, false);
    if (st == null) {
      return null;
    }

    final int npcId = npc.getId();
    if (killer.getParty() != null) {
      final List<QuestState> PartyMembers = new ArrayList<>();
      for (L2PcInstance member : killer.getParty().getMembers()) {
        st = getQuestState(member, false);
        if ((st != null) && st.isStarted() && !st.hasQuestItems(TISSUE_WA)) {
          PartyMembers.add(st);
        }
      }

      if (!PartyMembers.isEmpty()) {
        rewardItem(npcId, PartyMembers.get(getRandom(PartyMembers.size())));
      }
    } else if (st.isStarted() && !st.hasQuestItems(TISSUE_WA)) {
      rewardItem(npcId, st);
    }
    return null;
  }
  @Override
  protected final void writeImpl() {
    writeC(0xde);
    writeD(_seller.getObjectId());
    writeD((int) _seller.getAdena());
    writeD(_isDwarven ? 0x00 : 0x01);

    if (_recipes == null) {
      writeD(0);
    } else {
      writeD(_recipes.length); // number of items in recipe book

      for (int i = 0; i < _recipes.length; i++) {
        L2RecipeList temp = _recipes[i];
        writeD(temp.getId());
        writeD(i + 1);
      }
    }

    if (_seller.getCreateList() == null) {
      writeD(0);
    } else {
      L2ManufactureList list = _seller.getCreateList();
      writeD(list.size());

      for (L2ManufactureItem item : list.getList()) {
        writeD(item.getRecipeId());
        writeD(0x00);
        writeQ(item.getCost());
      }
    }
  }
  /**
   * Broadcasts a packet to the team opposing the given player.
   *
   * @param player
   * @param packet
   */
  public void broadcastToOppositTeam(L2PcInstance player, L2GameServerPacket packet) {
    if ((player == null) || !player.isInDuel()) {
      return;
    }
    final Duel duel = getDuel(player.getDuelId());
    if (duel == null) {
      return;
    }
    if ((duel.getPlayerA() == null) || (duel.getPlayerB() == null)) {
      return;
    }

    if (duel.getPlayerA() == player) {
      duel.broadcastToTeam2(packet);
    } else if (duel.getPlayerB() == player) {
      duel.broadcastToTeam1(packet);
    } else if (duel.isPartyDuel()) {
      if ((duel.getPlayerA().getParty() != null)
          && duel.getPlayerA().getParty().getMembers().contains(player)) {
        duel.broadcastToTeam2(packet);
      } else if ((duel.getPlayerB().getParty() != null)
          && duel.getPlayerB().getParty().getMembers().contains(player)) {
        duel.broadcastToTeam1(packet);
      }
    }
  }
  @Override
  public String onSkillSee(
      L2Npc npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet) {
    if (caster == null) {
      return null;
    }
    if (!(npc instanceof L2Attackable)) {
      return null;
    }

    L2Attackable attackable = (L2Attackable) npc;

    int skillAggroPoints = skill.getAggroPoints();

    if (caster.getPet() != null) {
      if (targets.length == 1 && contains(targets, caster.getPet())) skillAggroPoints = 0;
    }

    if (skillAggroPoints > 0) {
      if (attackable.hasAI() && (attackable.getAI().getIntention() == AI_INTENTION_ATTACK)) {
        L2Object npcTarget = attackable.getTarget();
        for (L2Object skillTarget : targets) {
          if (npcTarget == skillTarget || npc == skillTarget) {
            L2Character originalCaster = isPet ? caster.getPet() : caster;
            attackable.addDamageHate(
                originalCaster, 0, (skillAggroPoints * 150) / (attackable.getLevel() + 7));
          }
        }
      }
    }

    return null;
  }
  public void setReenterTime(InstanceWorld world) {
    if (world instanceof DPFWorld) {
      // Reenter time should be cleared every Wed and Sat at 6:30 AM, so we set next suitable
      Calendar reenter;
      Calendar now = Calendar.getInstance();
      Calendar reenterPointWed = (Calendar) now.clone();
      reenterPointWed.set(Calendar.AM_PM, Calendar.AM);
      reenterPointWed.set(Calendar.MINUTE, RESET_MIN);
      reenterPointWed.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
      reenterPointWed.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
      Calendar reenterPointSat = (Calendar) reenterPointWed.clone();
      reenterPointSat.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);

      if (now.after(reenterPointSat)) {
        reenterPointWed.add(Calendar.WEEK_OF_MONTH, 1);
        reenter = (Calendar) reenterPointWed.clone();
      } else {
        reenter = (Calendar) reenterPointSat.clone();
      }

      SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.INSTANT_ZONE_S1_RESTRICTED);
      sm.addInstanceName(world.getTemplateId());
      // set instance reenter time for all allowed players
      for (int objectId : world.getAllowed()) {
        L2PcInstance player = L2World.getInstance().getPlayer(objectId);
        if ((player != null) && player.isOnline()) {
          InstanceManager.getInstance()
              .setInstanceTime(objectId, world.getTemplateId(), reenter.getTimeInMillis());
          player.sendPacket(sm);
        }
      }
    }
  }
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    if (!target.isNpc()) {
      return false;
    }

    final L2Npc npc = (L2Npc) target;
    final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
    {
      if (npc.getCastle().getOwnerId() > 0) {
        html.setFile(activeChar.getHtmlPrefix(), "data/html/territorystatus.htm");
        L2Clan clan = ClanTable.getInstance().getClan(npc.getCastle().getOwnerId());
        html.replace("%clanname%", clan.getName());
        html.replace("%clanleadername%", clan.getLeaderName());
      } else {
        html.setFile(activeChar.getHtmlPrefix(), "data/html/territorynoclan.htm");
      }
    }
    html.replace("%castlename%", npc.getCastle().getName());
    html.replace("%taxpercent%", "" + npc.getCastle().getTaxPercent());
    html.replace("%objectId%", String.valueOf(npc.getObjectId()));
    {
      if (npc.getCastle().getResidenceId() > 6) {
        html.replace("%territory%", "The Kingdom of Elmore");
      } else {
        html.replace("%territory%", "The Kingdom of Aden");
      }
    }
    activeChar.sendPacket(html);
    return true;
  }
  /**
   * Use the sit action.
   *
   * @param activeChar the player trying to sit
   * @param target the target to sit, throne, bench or chair
   * @return {@code true} if the player can sit, {@code false} otherwise
   */
  protected boolean useSit(L2PcInstance activeChar, L2Object target) {
    if (activeChar.getMountType() != MountType.NONE) {
      return false;
    }

    if (!activeChar.isSitting()
        && (target instanceof L2StaticObjectInstance)
        && (((L2StaticObjectInstance) target).getType() == 1)
        && activeChar.isInsideRadius(
            target, L2StaticObjectInstance.INTERACTION_DISTANCE, false, false)) {
      final ChairSit cs = new ChairSit(activeChar, target.getId());
      sendPacket(cs);
      activeChar.sitDown();
      activeChar.broadcastPacket(cs);
      return true;
    }

    if (activeChar.isFakeDeath()) {
      activeChar.stopEffects(L2EffectType.FAKE_DEATH);
    } else if (activeChar.isSitting()) {
      activeChar.standUp();
    } else {
      activeChar.sitDown();
    }
    return true;
  }
Exemple #28
0
  @Override
  public void onStart(BuffInfo info) {
    if ((info.getEffector() == null)
        || (info.getEffected() == null)
        || !info.getEffector().isPlayer()
        || !info.getEffected().isAttackable()) {
      return;
    }

    final L2PcInstance player = info.getEffector().getActingPlayer();
    final L2Attackable monster = (L2Attackable) info.getEffected();
    if (!monster.checkSpoilOwner(player, false)) {
      return;
    }

    if (!player
        .getInventory()
        .checkInventorySlotsAndWeight(monster.getSpoilLootItems(), false, false)) {
      return;
    }

    final Collection<ItemHolder> items = monster.takeSweep();
    if (items != null) {
      for (ItemHolder item : items) {
        if (player.isInParty()) {
          player.getParty().distributeItem(player, item, true, monster);
        } else {
          player.addItem("Sweeper", item, info.getEffected(), true);
        }
      }
    }
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    final QuestState st = player.getQuestState(getName());
    if (st == null) {
      return htmltext;
    }

    if (npc.getId() == MOUEN) {
      switch (st.getState()) {
        case State.CREATED:
          htmltext = (player.getLevel() >= 82) ? "30196-01.htm" : "30196-00.htm";
          break;
        case State.STARTED:
          if (st.isCond(1)) {
            htmltext = "30196-04.htm";
          }
          break;
        case State.COMPLETED:
          htmltext = "30196-05.htm";
          break;
      }
    } else if (npc.getId() == JOHNNY) {
      if (st.isCond(1)) {
        htmltext = "32744-01.htm";
      } else if (st.isCompleted()) {
        htmltext = "32744-04.htm";
      }
    }
    return htmltext;
  }
 @Override
 public String onKill(L2Npc npc, L2PcInstance player, boolean isSummon) {
   final QuestState st;
   if ((npc.getId() == FALLEN_ANGEL)) {
     st = player.getQuestState(getName());
     if (st.isCond(5)) {
       st.giveItems(FALLEN_ANGEL_BLOOD, 1);
       st.setCond(6, true);
       isAngelSpawned = false;
     }
   } else {
     final L2PcInstance member = getRandomPartyMember(player, 4);
     if (member != null) {
       st = member.getQuestState(getName());
       if (getRandom(1000) < MOBS.get(npc.getId())) {
         st.giveItems(PROPHECY_FRAGMENT, 1);
         if (st.getQuestItemsCount(PROPHECY_FRAGMENT) >= FRAGMENT_COUNT) {
           st.takeItems(PROPHECY_FRAGMENT, -1);
           st.setCond(5, true);
         } else {
           st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
         }
       }
     }
   }
   return super.onKill(npc, player, isSummon);
 }