예제 #1
0
  /** Method reduceLevel. */
  public void reduceLevel() {
    Player player = getPlayer();

    if (player == null) {
      return;
    }

    for (Effect e : player.getEffectList().getAllEffects()) {
      if (e.getSkill().getId() == _skillId) {
        _level = e.getSkill().getLevel();
        e.exit();
      } else {
        return;
      }
    }

    _level--;

    if (getLevel(player) > 0) {
      player.broadcastPacket(new MagicSkillUse(player, player, _skillId, getLevel(player), 0, 0));
      player.sendPacket(
          new SystemMessage(SystemMessage.THE_LEVEL_S1_SHILENS_BREATH_WILL_BE_ASSESSED)
              .addNumber(getLevel(player)));
    } else {
      player.sendPacket(new SystemMessage(SystemMessage.THE_SHILENS_BREATH_HAS_BEEN_LIFTED));
    }

    player.updateStats();
  }
예제 #2
0
  public Object setStateAndNotSave(int state) {
    Player player = getPlayer();
    if (player == null) {
      return null;
    }

    _state = state;

    if (getQuest().isVisible(player) && isStarted()) {
      player.sendPacket(new ExShowQuestMark(getQuest().getQuestIntId()));
    }

    player.sendPacket(new QuestList(player));
    return state;
  }
예제 #3
0
  /**
   * Method restore.
   *
   * @param player Player
   */
  void restore(Player player) {
    if (player.getEffectList().getEffectsBySkillId(_skillId) != null) {
      for (Effect e : player.getEffectList().getAllEffects()) {
        if (e.getSkill().getId() == _skillId) {
          _level = e.getSkill().getLevel();
          e.exit();
        }
      }
    }

    if (!Config.ALLOW_DEATH_PENALTY_C5) {
      return;
    }

    if (getLevel(player) > 0) {
      Skill skill = SkillTable.getInstance().getInfo(_skillId, _level);

      if (skill == null) {
        return;
      }

      skill.getEffects(player, player, false, false);
      player.sendPacket(
          new SystemMessage(SystemMessage.THE_LEVEL_S1_SHILENS_BREATH_WILL_BE_ASSESSED)
              .addNumber(getLevel(player)));
    }

    player.updateStats();
  }
예제 #4
0
  public void giveItems(int itemId, long count, Element element, int power) {
    Player player = getPlayer();
    if (player == null) {
      return;
    }

    if (count <= 0) {
      count = 1;
    }

    // Get template of item
    ItemTemplate template = ItemHolder.getInstance().getTemplate(itemId);
    if (template == null) {
      return;
    }

    for (int i = 0; i < count; i++) {
      ItemInstance item = ItemFunctions.createItem(itemId);

      if (element != Element.NONE) {
        item.setAttributeElement(element, power);
      }

      // Add items to player's inventory
      player.getInventory().addItem(item);
    }

    player.sendPacket(SystemMessage2.obtainItems(template.getItemId(), count, 0));
    player.sendChanges();
  }
예제 #5
0
  /**
   * Method removeParty.
   *
   * @param party Party
   */
  public void removeParty(Party party) {
    _commandChannelParties.remove(party);
    refreshLevel();
    party.setCommandChannel(null);
    party.broadCast(ExMPCCClose.STATIC);
    Reflection reflection = getReflection();

    if (reflection != null) {
      for (Player player : party.getPartyMembers()) {
        player.teleToLocation(reflection.getReturnLoc(), 0);
      }
    }

    if (_commandChannelParties.size() < 2) {
      disbandChannel();
    } else {
      for (Player $member : party) {
        $member.sendPacket(new ExMPCCPartyInfoUpdate(party, 0));

        if (_matchingRoom != null) {
          _matchingRoom.broadcastPlayerUpdate($member);
        }
      }
    }
  }
예제 #6
0
 public void despawn() {
   if (!isEntitySpawned()) return;
   this.entitySpawned = false;
   ServerDestroyEntitiesPacket destroyEntitiesPacket =
       new ServerDestroyEntitiesPacket(this.entityID);
   this.entityID = Entity.getNextID();
   for (Player pl : MCThunder.getPlayers()) pl.sendPacket(destroyEntitiesPacket);
 }
예제 #7
0
  /**
   * Method broadcastToChannelPartyLeaders.
   *
   * @param gsp L2GameServerPacket
   */
  public void broadcastToChannelPartyLeaders(L2GameServerPacket gsp) {
    for (Party party : _commandChannelParties) {
      Player leader = party.getPartyLeader();

      if (leader != null) {
        leader.sendPacket(gsp);
      }
    }
  }
예제 #8
0
 public void spawn(Location l) {
   if (isEntitySpawned()) return;
   this.entitySpawned = true;
   this.location = l;
   long chunk = getChunk();
   for (Player p : MCThunder.getPlayers())
     if (p.getWorld().equals(getWorld()) && p.isColumnLoaded(chunk))
       for (Packet packet : getPackets()) p.sendPacket(packet);
 }
예제 #9
0
 public void showTutorialHTML(String html, int type) {
   Player player = getPlayer();
   if (player == null) {
     return;
   }
   String text = html;
   if (type == 1) {
     text = HtmCache.getInstance().getNotNull("quests/_255_Tutorial/" + html, player);
   }
   player.sendPacket(new TutorialShowHtml(text, type));
 }
예제 #10
0
  /**
   * Method checkAuthority.
   *
   * @param creator Player
   * @return boolean
   */
  public static boolean checkAuthority(Player creator) {
    if ((creator.getClan() == null)
        || !creator.isInParty()
        || !creator.getParty().isLeader(creator)
        || (creator.getPledgeClass() < Player.RANK_BARON)) {
      creator.sendPacket(
          new SystemMessage(SystemMessage.YOU_DO_NOT_HAVE_AUTHORITY_TO_USE_THE_COMMAND_CHANNEL));
      return false;
    }

    boolean haveSkill = creator.getSkillLevel(CLAN_IMPERIUM_ID) > 0;
    boolean haveItem = creator.getInventory().getItemByItemId(STRATEGY_GUIDE_ID) != null;

    if (!haveSkill && !haveItem) {
      creator.sendPacket(
          new SystemMessage(SystemMessage.YOU_DO_NOT_HAVE_AUTHORITY_TO_USE_THE_COMMAND_CHANNEL));
      return false;
    }

    return true;
  }
예제 #11
0
 public void setName(String newName) {
   if (this.name == null) return;
   String nick = MessageFormat.formatMessage(this.name = newName).getFullText().trim();
   if (nick.length() < 17) {
     super.setCustomName(nick);
     this.metadata.setMetadata(2, nick);
     this.botProfile = new GameProfile(this.uuid, nick);
     this.botProfile.getProperties().put("textures", this.skin);
     updateMetadata();
   }
   MCThunder.getEntryListHandler().refresh(this);
   if (nick.length() < 17) {
     ServerDestroyEntitiesPacket destroyEntitiesPacket =
         new ServerDestroyEntitiesPacket(getEntityID());
     this.entityID = getNextID();
     long chunk = getChunk();
     for (Player pl : MCThunder.getPlayers()) {
       pl.sendPacket(destroyEntitiesPacket);
       if (pl.getWorld().equals(getWorld()) && pl.isColumnLoaded(chunk))
         for (Packet packet : getPackets()) pl.sendPacket(packet);
     }
   }
 }
예제 #12
0
  /**
   * Method addParty.
   *
   * @param party Party
   */
  public void addParty(Party party) {
    broadCast(new ExMPCCPartyInfoUpdate(party, 1));
    _commandChannelParties.add(party);
    refreshLevel();
    party.setCommandChannel(this);

    for (Player $member : party) {
      $member.sendPacket(ExMPCCOpen.STATIC);

      if (_matchingRoom != null) {
        _matchingRoom.broadcastPlayerUpdate($member);
      }
    }
  }
예제 #13
0
 protected void setSkin(Property p) {
   if (p == null || !p.getName().equalsIgnoreCase("textures")) return;
   this.skin = p;
   if (this.capeURL
       != null) // This does not work because signature is not valid after it is changed
   try { // TODO: Try to come up with a way to get this to work, that does not require the private
         // mc auth key
       byte[] bytes = Base64.decode(this.skin.getValue().getBytes("UTF-8"));
       String value = new String(bytes);
       int s = value.indexOf("CAPE");
       value =
           value.substring(0, (s == -1 ? value.length() : s) - 2)
               + ",\"CAPE\":{\"url\":\""
               + this.capeURL
               + "\"}}}";
       this.skin =
           new Property(
               "textures",
               new String(Base64.encode(value.getBytes("UTF-8"))),
               this.skin.getSignature());
     } catch (Exception e) {
       e.printStackTrace();
     }
   this.botProfile.getProperties().put("textures", this.skin);
   MCThunder.getEntryListHandler().refresh(this);
   if (isEntitySpawned()) {
     ServerDestroyEntitiesPacket destroyEntitiesPacket =
         new ServerDestroyEntitiesPacket(this.entityID);
     this.entityID = Entity.getNextID();
     long chunk = getChunk();
     for (Player pl : MCThunder.getPlayers()) {
       pl.sendPacket(destroyEntitiesPacket);
       if (pl.getWorld().equals(getWorld()) && pl.isColumnLoaded(chunk))
         for (Packet packet : getPackets()) pl.sendPacket(packet);
     }
   }
 }
예제 #14
0
  public String setCond(int newCond, boolean store) {
    if (newCond == getCond()) {
      return String.valueOf(newCond);
    }

    int oldCond = getInt(VAR_COND);
    _cond = newCond;

    if ((oldCond & 0x80000000) != 0) {
      // уже используется второй формат
      if (newCond > 2) // Если этап меньше 3 то возвращаемся к первому варианту.
      {
        oldCond &= 0x80000001 | ((1 << newCond) - 1);
        newCond = oldCond | (1 << (newCond - 1));
      }
    } else {
      // Второй вариант теперь используется всегда если этап больше 2
      if (newCond > 2) {
        newCond = 0x80000001 | (1 << (newCond - 1)) | ((1 << oldCond) - 1);
      }
    }

    final String sVal = String.valueOf(newCond);
    final String result = set(VAR_COND, sVal, false);
    if (store) {
      Quest.updateQuestVarInDb(this, VAR_COND, sVal);
    }

    final Player player = getPlayer();
    if (player != null) {
      player.sendPacket(new QuestList(player));
      if ((newCond != 0) && getQuest().isVisible(player) && isStarted()) {
        player.sendPacket(new ExShowQuestMark(getQuest().getQuestIntId()));
      }
    }
    return result;
  }
예제 #15
0
  /**
   * Method castEffect.
   *
   * @param player Player
   */
  void castEffect(Player player) {
    if (getLevel(player) > 0) {
      Skill skill = SkillTable.getInstance().getInfo(_skillId, getLevel(player));

      if (skill == null) {
        return;
      }

      skill.getEffects(player, player, false, false);
      player.sendPacket(
          new SystemMessage(SystemMessage.THE_LEVEL_S1_SHILENS_BREATH_WILL_BE_ASSESSED)
              .addNumber(getLevel(player)));
      player.updateStats();
    }
  }
예제 #16
0
  /**
   * Destroy element used by quest when quest is exited
   *
   * @param repeatable
   * @return QuestState
   */
  public QuestState exitCurrentQuest(boolean repeatable) {
    Player player = getPlayer();
    if (player == null) {
      return this;
    }

    removePlayerOnKillListener();
    // Clean drops
    for (int itemId : _quest.getItems()) {
      // Get [item from] / [presence of the item in] the inventory of the player
      ItemInstance item = player.getInventory().getItemByItemId(itemId);
      if ((item == null) || (itemId == 57)) {
        continue;
      }
      long count = item.getCount();
      // If player has the item in inventory, destroy it (if not gold)
      player.getInventory().destroyItemByItemId(itemId, count);
      player.getWarehouse().destroyItemByItemId(itemId, count); // TODO [G1ta0] analyze this
    }

    // If quest is repeatable, delete quest from list of quest of the player and from database
    // (quest CAN be created again => repeatable)
    if (repeatable) {
      player.removeQuestState(_quest.getName());
      Quest.deleteQuestInDb(this);
      _vars.clear();
    } else { // Otherwise, delete variables for quest and update database (quest CANNOT be created
             // again => not repeatable)
      for (String var : _vars.keySet()) {
        if (var != null) {
          unset(var);
        }
      }
      setState(Quest.COMPLETED);
      Quest.updateQuestInDb(this); // FIXME: оно вроде не нужно?
    }
    if (isCompleted()) {
      // WorldStatisticsManager.getInstance().updateStat(player, CategoryType.QUESTS_COMPLETED,0,
      // 1);
    }
    player.sendPacket(new QuestList(player));
    return this;
  }
예제 #17
0
  /**
   * Удаляет указанные предметы из инвентаря игрока, и обновляет инвентарь
   *
   * @param itemId : id удаляемого предмета
   * @param count : число удаляемых предметов<br>
   *     Если count передать -1, то будут удалены все указанные предметы.
   * @return Количество удаленных предметов
   */
  public long takeItems(int itemId, long count) {
    Player player = getPlayer();
    if (player == null) {
      return 0;
    }

    // Get object item from player's inventory list
    ItemInstance item = player.getInventory().getItemByItemId(itemId);
    if (item == null) {
      return 0;
    }
    // Tests on count value in order not to have negative value
    if ((count < 0) || (count > item.getCount())) {
      count = item.getCount();
    }

    // Destroy the quantity of items wanted
    player.getInventory().destroyItemByItemId(itemId, count);
    // Send message of destruction to client
    player.sendPacket(SystemMessage2.removeItems(itemId, count));

    return count;
  }
예제 #18
0
 /**
  * Send a packet in order to play sound at client terminal
  *
  * @param sound
  */
 public void playSound(String sound) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new PlaySound(sound));
   }
 }
예제 #19
0
 public void playTutorialVoice(String voice) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new PlaySound(PlaySound.Type.VOICE, voice, 0, 0, player.getLoc()));
   }
 }
예제 #20
0
 public void onTutorialClientEvent(int number) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new TutorialEnableClientEvent(number));
   }
 }
예제 #21
0
 public void showQuestionMark(int number) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new TutorialShowQuestionMark(number));
   }
 }
예제 #22
0
 public void showTutorialHTML(String html) {
   Player player = getPlayer();
   if (player == null) return;
   String text = HtmCache.getInstance().getNotNull("quests/_255_Tutorial/" + html, player);
   player.sendPacket(new TutorialShowHtml(TutorialShowHtml.TYPE_HTML, text));
 }
예제 #23
0
 public void showTutorialClientHTML(String html) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new TutorialShowHtml(html, TutorialShowHtml.TYPE_WINDOW));
   }
 }