コード例 #1
0
  @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();
  }
コード例 #2
0
  @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();
  }