Auto Learn Skills

Статус
В этой теме нельзя размещать новые ответы.

katowice

Знаменитый
Участник
Сообщения
103
Розыгрыши
0
Решения
1
Репутация
14
Реакции
28
Баллы
1 298
Хроники
  1. Interlude
Исходники
Присутствуют
Сборка
aCis r 401
Нужна помощь не со всем мне понятно куда добавить кусок кода чтоб скиллы после 3 профы не изучались
Java:
        // Check if 3rd class skills are auto-learned
            if (!Config.AUTO_LEARN_3RD_SKILLS && getStatus().getLevel() >= 76 && getClassId().getLevel() == 3)
            {
                continue;
            }
 
Решение
Есть беда, после взятие 3 профы удаляются пассивные скиллы(не все)

Кусок кода
Java:
    /**
     * Method used by admin commands, Config.AUTO_LEARN_SKILLS or class master.<br>
     * Reward the {@link Player} with all available skills, being autoGet or general skills.
     */
    public void rewardSkills()
    {
        // Check if 3rd class skills are auto-learned
        if (!Config.AUTO_LEARN_3RD_SKILLS && (getClassId().getLevel() == 3))
        {
            return;
        }
  
        // We reward all skills to the players, but don't store autoGet skills on the database.
        for (final GeneralSkillNode skill : getAllAvailableSkills())
            addSkill(skill.getSkill()...
Load your project in IntelliJ, since it indexes your entire project, making it easier to search everywhere.
Then, you can either go to EDIT->FIND->FIND IN FILES, or press Ctrl+Shift+F and type in AutoLearnSkills.

1664528046224.png


In my case, there are 3 hits - 2 in player.properties (which is a txt file in the configs) and 1 in Config.java.

1664528079583.png

Now, your code has a config that is not present on my source, namely Auto_learn_3rd_skills. This means, that you have to create this manually in the Config.java and also take it out in the player.properties near the line with AutoLearnSkills = True/False. I won't be explaining how to do that for obvious reasons.

Then, you go back to IntelliJ and do a second search for Auto_Learn_Skills. You will have several hits, but you open the first in the Config.java.

There, you can CTRL+CLICK on the AUTO_LEARN_SKILLS, and it will show you all the functions that use it, like so:

1664527818860.png
As we can notice, two of these are in Player.java. Here, we have two options:
1 - add to these two function our check for whether the 3rd class config is set to TRUE or FALSE and whatever else you might need to add as a check.
2 - (the first one is superior/better in my opinion) Both of the uses in the Player.java use a function called RewardSkills(). As such, we can just add your code within that particular function and be done with it.
 
Может кому и пригодиться
Ищем Player.java (model/actor) открываем его
Находим
Java:
public void rewardSkills()
Добавляем в него
Java:
        // Check if 3rd class skills are auto-learned
        if (!Config.AUTO_LEARN_3RD_SKILLS && (getClassId().getLevel() == 3))
        {
            return;
        }
 
Есть беда, после взятие 3 профы удаляются пассивные скиллы(не все)

Кусок кода
Java:
    /**
     * Method used by admin commands, Config.AUTO_LEARN_SKILLS or class master.<br>
     * Reward the {@link Player} with all available skills, being autoGet or general skills.
     */
    public void rewardSkills()
    {
        // Check if 3rd class skills are auto-learned
        if (!Config.AUTO_LEARN_3RD_SKILLS && (getClassId().getLevel() == 3))
        {
            return;
        }
   
        // We reward all skills to the players, but don't store autoGet skills on the database.
        for (final GeneralSkillNode skill : getAllAvailableSkills())
            addSkill(skill.getSkill(), skill.getCost() != 0);
       
        // Remove the Lucky skill if level superior to 10.
        if (getStatus().getLevel() >= 10 && hasSkill(L2Skill.SKILL_LUCKY))
            removeSkill(L2Skill.SKILL_LUCKY, false);
       
        // Remove invalid skills.
        removeInvalidSkills();
       
        sendSkillList();
       
    }
 
Есть беда, после взятие 3 профы удаляются пассивные скиллы(не все)

Кусок кода
Java:
    /**
     * Method used by admin commands, Config.AUTO_LEARN_SKILLS or class master.<br>
     * Reward the {@link Player} with all available skills, being autoGet or general skills.
     */
    public void rewardSkills()
    {
        // Check if 3rd class skills are auto-learned
        if (!Config.AUTO_LEARN_3RD_SKILLS && (getClassId().getLevel() == 3))
        {
            return;
        }
  
        // We reward all skills to the players, but don't store autoGet skills on the database.
        for (final GeneralSkillNode skill : getAllAvailableSkills())
            addSkill(skill.getSkill(), skill.getCost() != 0);
      
        // Remove the Lucky skill if level superior to 10.
        if (getStatus().getLevel() >= 10 && hasSkill(L2Skill.SKILL_LUCKY))
            removeSkill(L2Skill.SKILL_LUCKY, false);
      
        // Remove invalid skills.
        removeInvalidSkills();
      
        sendSkillList();
      
    }
Java:
    public void rewardSkills()
    {
        boolean auto = Config.AUTO_LEARN_3RD_SKILLS || (getClassId().getLevel() < 3);
        // We reward all skills to the players, but don't store autoGet skills on the database.
        for (final GeneralSkillNode skill : auto ? getAllAvailableSkills() : getAvailableAutoGetSkills())
            addSkill(skill.getSkill(), (auto && skill.getCost() != 0));
        
        // Remove the Lucky skill if level superior to 10.
        if (getStatus().getLevel() >= 10 && hasSkill(L2Skill.SKILL_LUCKY))
            removeSkill(L2Skill.SKILL_LUCKY, false);
        
        // Remove invalid skills.
        removeInvalidSkills();
        
        sendSkillList();
    }
 
Решение
Java:
    public void rewardSkills()
    {
        boolean auto = Config.AUTO_LEARN_3RD_SKILLS || (getClassId().getLevel() < 3);
        // We reward all skills to the players, but don't store autoGet skills on the database.
        for (final GeneralSkillNode skill : auto ? getAllAvailableSkills() : getAvailableAutoGetSkills())
            addSkill(skill.getSkill(), (auto && skill.getCost() != 0));
      
        // Remove the Lucky skill if level superior to 10.
        if (getStatus().getLevel() >= 10 && hasSkill(L2Skill.SKILL_LUCKY))
            removeSkill(L2Skill.SKILL_LUCKY, false);
      
        // Remove invalid skills.
        removeInvalidSkills();
      
        sendSkillList();
    }
Thanks вроде работает
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху Снизу