L2JMobius

Helios preRequisiteSkill behavior in Skill Trees

hexash14 · 2 · 5107

Offline hexash14

  • Vassal
  • *
    • Posts: 4
Hello

While I was making a custom skill tree, I tried adding a pre requisite skill to another skill. At the moment it works by checking if the L2PcInstance has the exact skill at the exact level noted there, like this:

Code: [Select]
<preRequisiteSkill id="19125" lvl="2" />
The problem comes when I try, for example, learning a skill that has the skill 19125 as required, but I have that same skill in level 4. One might think that the correct behavior is "having the skill 19125 at level 2 or greater", but actually is "having the skill 19125 at level 2". Then, it cannot be learned.

Checking RequestAcquireSkill class in GameServer.jar/com/l2jmobius/gameserver/network/clientpackets, in the method checkPlayerSkill, I noted that putting a "<" instead of "!=" when checking the skill level would solve the problem.

It is like this:
Code: [Select]
if (player.getSkillLevel(skill.getSkillId()) != skill.getSkillLevel()) {
                              if (skill.getSkillId() == CommonSkill.ONYX_BEAST_TRANSFORMATION.getId()) {
                                    player.sendPacket(SystemMessageId.YOU_MUST_LEARN_THE_ONYX_BEAST_SKILL_BEFORE_YOU_CAN_LEARN_FURTHER_SKILLS);
                                } else {
                                    player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
                                }

                                return false;
                            }

To this:
Code: [Select]
if (player.getSkillLevel(skill.getSkillId()) < skill.getSkillLevel()) {
                                if (skill.getSkillId() == CommonSkill.ONYX_BEAST_TRANSFORMATION.getId()) {
                                    player.sendPacket(SystemMessageId.YOU_MUST_LEARN_THE_ONYX_BEAST_SKILL_BEFORE_YOU_CAN_LEARN_FURTHER_SKILLS);
                                } else {
                                    player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_NECESSARY_MATERIALS_OR_PREREQUISITES_TO_LEARN_THIS_SKILL);
                                }

                                return false;
                            }

Please note that this code doesn't change the retail behavior, as the only skills that use preRequisiteSkill demands skills that are at their highest level. These skills are in abilitySkillTree.xml and transformSkillTree.xml, namely the ability skills and the skills learned through Avant-garde.

Also please note that the code above was decompiled from the .class, and might change a bit. The only important thing is to change the != to <.

Finally, why would I want to make this change? Because I want to make a skill tree with multiple requisites per skill.

Thanks in advance :)


Online Mobius

  • Distinguished King
  • *****
    • Posts: 16153