@Override
 protected final void writeImpl() {
   writeS(_charName);
   writeQ(_charAdena);
   writeH(_items.length);
   for (ItemInstance temp : _items) {
     writeItemInfo(temp);
     writeD(temp.getObjectId());
   }
 }
  @Override
  public void onEquip(int slot, ItemInstance item, Playable actor) {
    if (!item.isEquipable()) {
      return;
    }
    if (!item.isAugmented()) {
      return;
    }

    Player player = actor.getPlayer();

    // При несоотвествии грейда аугмент не применяется
    if (player.getExpertisePenalty(item) > 0) {
      return;
    }

    int stats[] = new int[2];
    stats[0] = 0x0000FFFF & item.getAugmentationId();
    stats[1] = item.getAugmentationId() >> 16;

    boolean sendList = false;
    boolean sendReuseList = false;
    for (int i : stats) {
      OptionDataTemplate template = OptionDataHolder.getInstance().getTemplate(i);
      if (template == null) {
        continue;
      }

      player.addStatFuncs(template.getStatFuncs(template));

      for (Skill skill : template.getSkills()) {
        sendList = true;
        player.addSkill(skill);
        if (player.isSkillDisabled(skill)) {
          sendReuseList = true;
        }
      }

      player.addTriggers(template);
    }

    if (sendList) {
      player.sendSkillList();
    }

    if (sendReuseList) {
      player.sendPacket(new SkillCoolTime(player));
    }

    player.updateStats();
  }
  @Override
  public void onUnequip(int slot, ItemInstance item, Playable actor) {
    if (!item.isEquipable()) {
      return;
    }
    if (!item.isAugmented()) {
      return;
    }

    Player player = actor.getPlayer();

    int stats[] = new int[2];
    stats[0] = 0x0000FFFF & item.getAugmentationId();
    stats[1] = item.getAugmentationId() >> 16;

    boolean sendList = false;
    for (int i : stats) {
      OptionDataTemplate template = OptionDataHolder.getInstance().getTemplate(i);
      if (template == null) {
        continue;
      }

      player.removeStatsOwner(template);

      for (Skill skill : template.getSkills()) {
        sendList = true;
        player.removeSkill(skill);
      }

      player.removeTriggers(template);
    }

    if (sendList) {
      player.sendSkillList();
    }

    player.updateStats();
  }
Beispiel #4
0
  @Override
  public boolean useItem(Playable playable, ItemInstance item, boolean ctrl) {
    if (playable == null || !playable.isPlayer()) {
      return false;
    }
    Player player = (Player) playable;

    int itemId = item.getItemId();

    if (!player.getInventory().destroyItem(item, 1)) {
      player.sendActionFailed();
      return false;
    }

    switch (itemId) {
      case 5235:
        player.setFace(0);
        break;
      case 5236:
        player.setFace(1);
        break;
      case 5237:
        player.setFace(2);
        break;
      case 5238:
        player.setHairColor(0);
        break;
      case 5239:
        player.setHairColor(1);
        break;
      case 5240:
        player.setHairColor(2);
        break;
      case 5241:
        player.setHairColor(3);
        break;
      case 5242:
        player.setHairStyle(0);
        break;
      case 5243:
        player.setHairStyle(1);
        break;
      case 5244:
        player.setHairStyle(2);
        break;
      case 5245:
        player.setHairStyle(3);
        break;
      case 5246:
        player.setHairStyle(4);
        break;
      case 5247:
        player.setHairStyle(5);
        break;
      case 5248:
        player.setHairStyle(6);
        break;
    }

    player.broadcastPacket(new MagicSkillUse(player, player, 2003, 1, 1, 0));
    player.broadcastCharInfo();
    return true;
  }