Package l2p.gameserver.model.base

Examples of l2p.gameserver.model.base.L2EnchantSkillLearn


    if(activeChar.getLevel() < 76 || activeChar.getClassId().getLevel() < 4)
    {
      activeChar.sendMessage("You must have 3rd class change quest completed.");
      return;
    }
    L2EnchantSkillLearn sl = SkillTreeTable.getSkillEnchant(_skillId, _skillLvl);
    if(sl == null)
    {
      return;
    }
    short slevel = activeChar.getSkillLevel(_skillId);
    if(slevel == -1)
    {
      return;
    }
    int enchantLevel = SkillTreeTable.convertEnchantLevel(sl.getBaseLevel(), _skillLvl, sl.getMaxLevel());
    // already knows the skill with this level
    if(slevel >= enchantLevel)
    {
      return;
    }
    // Можем ли мы перейти с текущего уровня скилла на данную заточку
    if(slevel == sl.getBaseLevel() ? _skillLvl % 100 != 1 : slevel != enchantLevel - 1)
    {
      activeChar.sendMessage("Incorrect enchant level.");
      return;
    }
    L2Skill skill = SkillTable.getInstance().getInfo(_skillId, enchantLevel);
    if(skill == null)
    {
      activeChar.sendMessage("Internal error: not found skill level");
      return;
    }
    int[] cost = sl.getCost();
    int requiredSp = cost[1] * SkillTreeTable.NORMAL_ENCHANT_COST_MULTIPLIER * sl.getCostMult();
    int requiredAdena = cost[0] * SkillTreeTable.NORMAL_ENCHANT_COST_MULTIPLIER * sl.getCostMult();
    int rate = sl.getRate(activeChar);
    if(activeChar.getSp() < requiredSp)
    {
      sendPacket(Msg.SP_REQUIRED_FOR_SKILL_ENCHANT_IS_INSUFFICIENT);
      return;
    }
    if(activeChar.getAdena() < requiredAdena)
    {
      sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
      return;
    }
    if(_skillLvl % 100 == 1) // only first lvl requires book (101, 201, 301 ...)
    {
      if(Functions.getItemCount(activeChar, SkillTreeTable.NORMAL_ENCHANT_BOOK) == 0)
      {
        activeChar.sendPacket(Msg.ITEMS_REQUIRED_FOR_SKILL_ENCHANT_ARE_INSUFFICIENT);
        return;
      }
      Functions.removeItem(activeChar, SkillTreeTable.NORMAL_ENCHANT_BOOK, 1);
    }
    if(Rnd.chance(rate))
    {
      activeChar.addExpAndSp(0, -1 * requiredSp, false, false);
      Functions.removeItem(activeChar, 57, requiredAdena);
      activeChar.sendPacket(new SystemMessage(SystemMessage.SP_HAS_DECREASED_BY_S1).addNumber(requiredSp), new SystemMessage(SystemMessage.SUCCEEDED_IN_ENCHANTING_SKILL_S1).addSkillName(_skillId, _skillLvl), new SkillList(activeChar), new ExEnchantSkillResult(1));
      Log.add(activeChar.getName() + "|Successfully enchanted|" + _skillId + "|to+" + _skillLvl + "|" + rate, "enchant_skills");
    }
    else
    {
      skill = SkillTable.getInstance().getInfo(_skillId, sl.getBaseLevel());
      activeChar.sendPacket(new SystemMessage(SystemMessage.FAILED_IN_ENCHANTING_SKILL_S1).addSkillName(_skillId, _skillLvl), new ExEnchantSkillResult(0));
      Log.add(activeChar.getName() + "|Failed to enchant|" + _skillId + "|to+" + _skillLvl + "|" + rate, "enchant_skills");
    }
    activeChar.addSkill(skill, true);
    updateSkillShortcuts(activeChar);
View Full Code Here


        }
        String ename = enchant.getAttributes().getNamedItem("name").getNodeValue();
        for(int r = 1; r <= eLevels; r++)
        {
          short level = (short) (lastLvl + eLevels * count + r);
          L2EnchantSkillLearn e = new L2EnchantSkillLearn(skillId, 100 * (count + 1) + r, skillName, "+" + r + " " + ename, (r == 1 ? lastLvl : 100 * (count + 1) + r - 1), lastLvl, eLevels);
          GArray<L2EnchantSkillLearn> t = EnchantTable._enchant.get(skillId);
          if(t == null)
          {
            t = new GArray<L2EnchantSkillLearn>();
          }
          t.add(e);
          EnchantTable._enchant.put(skillId, t);
          displayLevels.put(level, (short) ((count + 1) * 100 + r));
        }
        count++;
        Node first = enchant.getFirstChild();
        Node curr = null;
        for(curr = first; curr != null; curr = curr.getNextSibling())
        {
          if("table".equalsIgnoreCase(curr.getNodeName()))
          {
            NamedNodeMap a = curr.getAttributes();
            String name = a.getNamedItem("name").getNodeValue();
            Object[] table = parseTable(curr);
            table = fillTableToSize(table, eLevels);
            Object[] fulltable = etables.get(name);
            if(fulltable == null)
            {
              fulltable = new Object[lastLvl + eLevels * 8 + 1];
            }
            System.arraycopy(table, 0, fulltable, lastLvl + (count - 1) * eLevels, eLevels);
            etables.put(name, fulltable);
          }
        }
      }
      lastLvl += eLevels * count;
      currentSkill.id = skillId;
      currentSkill.name = skillName;
      currentSkill.sets = new StatsSet[lastLvl];
      for(int i = 0; i < lastLvl; i++)
      {
        currentSkill.sets[i] = new StatsSet();
        currentSkill.sets[i].set("skill_id", currentSkill.id);
        currentSkill.sets[i].set("level", i + 1);
        currentSkill.sets[i].set("name", currentSkill.name);
      }
      if(currentSkill.sets.length != lastLvl)
      {
        throw new RuntimeException("Skill id=" + skillId + " number of levels missmatch, " + lastLvl + " levels expected");
      }
      Node first = n.getFirstChild();
      for(n = first; n != null; n = n.getNextSibling())
      {
        if("table".equalsIgnoreCase(n.getNodeName()))
        {
          parseTable(n);
        }
      }
      // обрабатываем таблицы сливая их с энчантами
      for(String tn : tables.keySet())
      {
        Object[] et = etables.get(tn);
        if(et != null)
        {
          Object[] t = tables.get(tn);
          Object max = t[t.length - 1];
          System.arraycopy(t, 0, et, 0, t.length);
          for(int j = 0; j < et.length; j++)
          {
            if(et[j] == null)
            {
              et[j] = max;
            }
          }
          tables.put(tn, et);
        }
      }
      for(int i = 1; i <= lastLvl; i++)
      {
        for(n = first; n != null; n = n.getNextSibling())
        {
          if("set".equalsIgnoreCase(n.getNodeName()))
          {
            parseBeanSet(n, currentSkill.sets[i - 1], i);
          }
        }
      }
      makeSkills();
      for(int i = 0; i < lastLvl; i++)
      {
        currentSkill.currentLevel = i;
        L2Skill current = currentSkill.currentSkills.get(i);
        if(displayLevels.get(current.getLevel()) != null)
        {
          current.setDisplayLevel(displayLevels.get(current.getLevel()).shortValue());
        }
        current.setEnchantLevelCount(eLevels);
        //System.out.println(current.getLevel() + ":" + displayLevels.get(current.getLevel()));
        for(n = first; n != null; n = n.getNextSibling())
        {
          if("cond".equalsIgnoreCase(n.getNodeName()))
          {
            Condition condition = parseCondition(n.getFirstChild());
            if(condition != null)
            {
              Node msg = n.getAttributes().getNamedItem("msg");
              if(msg != null)
              {
                condition.setMessage(msg.getNodeValue());
              }
              current.attach(condition);
            }
          }
          if("for".equalsIgnoreCase(n.getNodeName()))
          {
            parseTemplate(n, current);
          }
        }
      }
      currentSkill.skills.addAll(currentSkill.currentSkills);
    }
    catch(Exception e)
    {
      _log.severe("Error loading skill " + skillId);
      e.printStackTrace();
    }
  }
View Full Code Here

    // skill already enchanted?
    if(_level > 100)
    {
      canDecrease = 1;
      // get detail for next level
      L2EnchantSkillLearn esd = SkillTreeTable.getSkillEnchant(_id, _level + 1);
      // if it exists add it
      if(esd != null)
      {
        addEnchantSkillDetail(esd.getLevel());
        _canAdd = 1;
      }
      for(L2EnchantSkillLearn el : SkillTreeTable.getEnchantsForChange(_id, _level))
      {
        addEnchantSkillDetail(el.getLevel());
      }
    }
    else
    // not already enchanted
    {
      for(L2EnchantSkillLearn esd : SkillTreeTable.getFirstEnchantsForSkill(_id))
      {
        addEnchantSkillDetail(esd.getLevel());
        _canAdd = 1;
      }
    }
  }
View Full Code Here

    short oldSkillLevel = activeChar.getSkillDisplayLevel(_skillId);
    if(oldSkillLevel == -1)
    {
      return;
    }
    L2EnchantSkillLearn sl = SkillTreeTable.getSkillEnchant(_skillId, oldSkillLevel);
    if(sl == null)
    {
      return;
    }
    L2Skill newSkill;
    if(_skillLvl % 100 == 0)
    {
      _skillLvl = sl.getBaseLevel();
      newSkill = SkillTable.getInstance().getInfo(_skillId, _skillLvl);
    }
    else
    {
      newSkill = SkillTable.getInstance().getInfo(_skillId, SkillTreeTable.convertEnchantLevel(sl.getBaseLevel(), _skillLvl, sl.getMaxLevel()));
    }
    if(newSkill == null)
    {
      return;
    }
    if(Functions.getItemCount(activeChar, SkillTreeTable.UNTRAIN_ENCHANT_BOOK) == 0)
    {
      activeChar.sendPacket(Msg.ITEMS_REQUIRED_FOR_SKILL_ENCHANT_ARE_INSUFFICIENT);
      return;
    }
    Functions.removeItem(activeChar, SkillTreeTable.UNTRAIN_ENCHANT_BOOK, 1);
    activeChar.addExpAndSp(0, sl.getCost()[1] * sl.getCostMult(), false, false);
    activeChar.addSkill(newSkill, true);
    if(_skillLvl > 100)
    {
      SystemMessage sm = new SystemMessage(SystemMessage.Untrain_of_enchant_skill_was_successful_Current_level_of_enchant_skill_S1_has_been_decreased_by_1);
      sm.addSkillName(_skillId, _skillLvl);
View Full Code Here

    {
      return;
    }
    if(_skillLvl > 100)
    {
      L2EnchantSkillLearn sl = SkillTreeTable.getSkillEnchant(_skillId, _skillLvl);
      if(sl == null)
      {
        activeChar.sendMessage("Not found enchant info for this skill");
        return;
      }
      L2Skill skill = SkillTable.getInstance().getInfo(_skillId, SkillTreeTable.convertEnchantLevel(sl.getBaseLevel(), _skillLvl, sl.getMaxLevel()));
      if(skill == null || skill.getId() != _skillId)
      {
        activeChar.sendMessage("This skill doesn't yet have enchant info in Datapack");
        return;
      }
View Full Code Here

    if(activeChar.getLevel() < 76 || activeChar.getClassId().getLevel() < 4)
    {
      activeChar.sendMessage("You must have 3rd class change quest completed.");
      return;
    }
    L2EnchantSkillLearn sl = SkillTreeTable.getSkillEnchant(_skillId, _skillLvl);
    if(sl == null)
    {
      return;
    }
    short slevel = activeChar.getSkillLevel(_skillId);
    if(slevel == -1)
    {
      return;
    }
    if(slevel < sl.getBaseLevel())
    {
      return;
    }
    int[] cost = sl.getCost();
    int requiredSp = cost[1] * sl.getCostMult() / SkillTreeTable.SAFE_ENCHANT_COST_MULTIPLIER;
    int requiredAdena = cost[0] * sl.getCostMult() / SkillTreeTable.SAFE_ENCHANT_COST_MULTIPLIER;
    if(activeChar.getSp() < requiredSp)
    {
      sendPacket(Msg.SP_REQUIRED_FOR_SKILL_ENCHANT_IS_INSUFFICIENT);
      return;
    }
    if(activeChar.getAdena() < requiredAdena)
    {
      sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
      return;
    }
    if(Functions.getItemCount(activeChar, SkillTreeTable.CHANGE_ENCHANT_BOOK) == 0)
    {
      activeChar.sendPacket(Msg.ITEMS_REQUIRED_FOR_SKILL_ENCHANT_ARE_INSUFFICIENT);
      return;
    }
    Functions.removeItem(activeChar, SkillTreeTable.CHANGE_ENCHANT_BOOK, 1);
    Functions.removeItem(activeChar, 57, requiredAdena);
    activeChar.addExpAndSp(0, -1 * requiredSp, false, false);
    int levelPenalty = Rnd.get(Math.min(4, _skillLvl % 100));
    _skillLvl -= levelPenalty;
    if(_skillLvl % 100 == 0)
    {
      _skillLvl = sl.getBaseLevel();
    }
    L2Skill skill = SkillTable.getInstance().getInfo(_skillId, SkillTreeTable.convertEnchantLevel(sl.getBaseLevel(), _skillLvl, sl.getMaxLevel()));
    if(skill != null)
    {
      activeChar.addSkill(skill, true);
    }
    if(levelPenalty == 0)
View Full Code Here

    if(activeChar.getLevel() < 76 || activeChar.getClassId().getLevel() < 4)
    {
      activeChar.sendMessage("You must have 3rd class change quest completed.");
      return;
    }
    L2EnchantSkillLearn sl = SkillTreeTable.getSkillEnchant(_skillId, _skillLvl);
    if(sl == null)
    {
      return;
    }
    short slevel = activeChar.getSkillLevel(_skillId);
    if(slevel == -1)
    {
      return;
    }
    int enchantLevel = SkillTreeTable.convertEnchantLevel(sl.getBaseLevel(), _skillLvl, sl.getMaxLevel());
    // already knows the skill with this level
    if(slevel >= enchantLevel)
    {
      return;
    }
    // Можем ли мы перейти с текущего уровня скилла на данную заточку
    if(slevel == sl.getBaseLevel() ? _skillLvl % 100 != 1 : slevel != enchantLevel - 1)
    {
      activeChar.sendMessage("Incorrect enchant level.");
      return;
    }
    L2Skill skill = SkillTable.getInstance().getInfo(_skillId, enchantLevel);
    if(skill == null)
    {
      return;
    }
    int[] cost = sl.getCost();
    int requiredSp = cost[1] * SkillTreeTable.SAFE_ENCHANT_COST_MULTIPLIER * sl.getCostMult();
    int requiredAdena = cost[0] * SkillTreeTable.SAFE_ENCHANT_COST_MULTIPLIER * sl.getCostMult();
    int rate = sl.getRate(activeChar);
    if(activeChar.getSp() < requiredSp)
    {
      sendPacket(Msg.SP_REQUIRED_FOR_SKILL_ENCHANT_IS_INSUFFICIENT);
      return;
    }
View Full Code Here

    }
    int bookId = 0;
    int sp = 0;
    int adenaCount = 0;
    float spMult = SkillTreeTable.NORMAL_ENCHANT_COST_MULTIPLIER;
    L2EnchantSkillLearn esd;
    switch(_type)
    {
      case TYPE_NORMAL_ENCHANT:
        if(_skillLvl % 100 == 1)
        {
          bookId = SkillTreeTable.NORMAL_ENCHANT_BOOK;
        }
        esd = SkillTreeTable.getSkillEnchant(_skillId, _skillLvl);
        break;
      case TYPE_SAFE_ENCHANT:
        bookId = SkillTreeTable.SAFE_ENCHANT_BOOK;
        esd = SkillTreeTable.getSkillEnchant(_skillId, _skillLvl);
        spMult = SkillTreeTable.SAFE_ENCHANT_COST_MULTIPLIER;
        break;
      case TYPE_UNTRAIN_ENCHANT:
        bookId = SkillTreeTable.UNTRAIN_ENCHANT_BOOK;
        esd = SkillTreeTable.getSkillEnchant(_skillId, _skillLvl + 1);
        break;
      case TYPE_CHANGE_ENCHANT:
        bookId = SkillTreeTable.CHANGE_ENCHANT_BOOK;
        esd = SkillTreeTable.getEnchantsForChange(_skillId, _skillLvl).get(0);
        spMult = 1f / SkillTreeTable.SAFE_ENCHANT_COST_MULTIPLIER;
        break;
      default:
        _log.severe("Unknown skill enchant type: " + _type);
        return;
    }
    if(esd == null)
    {
      return;
    }
    spMult *= esd.getCostMult();
    int[] cost = esd.getCost();
    sp = (int) (cost[1] * spMult);
    if(_type != TYPE_UNTRAIN_ENCHANT)
    {
      adenaCount = (int) (cost[0] * spMult);
    }
    // send skill enchantment detail
    activeChar.sendPacket(new ExEnchantSkillInfoDetail(_skillId, _skillLvl, sp, esd.getRate(activeChar), bookId, adenaCount));
  }
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.base.L2EnchantSkillLearn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.