Addition of AutoLearnSkillsWithoutItems configuration.

This commit is contained in:
MobiusDevelopment
2021-11-05 08:22:05 +00:00
parent 851a4cbd88
commit 460d69f89c
153 changed files with 860 additions and 349 deletions

View File

@@ -179,6 +179,7 @@ public class Config
public static boolean ENABLE_MODIFY_SKILL_REUSE;
public static Map<Integer, Integer> SKILL_REUSE_LIST;
public static boolean AUTO_LEARN_SKILLS;
public static boolean AUTO_LEARN_SKILLS_WITHOUT_ITEMS;
public static boolean AUTO_LEARN_FS_SKILLS;
public static boolean AUTO_LEARN_FP_SKILLS;
public static boolean AUTO_LOOT_HERBS;
@@ -1777,6 +1778,7 @@ public class Config
}
}
AUTO_LEARN_SKILLS = Character.getBoolean("AutoLearnSkills", false);
AUTO_LEARN_SKILLS_WITHOUT_ITEMS = Character.getBoolean("AutoLearnSkillsWithoutItems", false);
AUTO_LEARN_FS_SKILLS = Character.getBoolean("AutoLearnForgottenScrollSkills", false);
AUTO_LEARN_FP_SKILLS = Character.getBoolean("AutoLearnForgottenPowerSkills", false);
AUTO_LOOT_HERBS = Character.getBoolean("AutoLootHerbs", false);

View File

@@ -731,7 +731,17 @@ public class SkillTreeData implements IXmlReader
return result;
}
public Collection<Skill> getAllAvailableSkills(PlayerInstance player, ClassId classId, boolean includeByFs, boolean includeByFp, boolean includeAutoGet)
/**
* Used by auto learn configuration.
* @param player
* @param classId
* @param includeByFs if {@code true} forgotten scroll skills present in the skill tree will be added
* @param includeByFp if {@code true} forgotten power skills present in the skill tree will be added
* @param includeAutoGet if {@code true} auto-get skills present in the skill tree will be added
* @param includeRequiredItems if {@code true} skills that have required items will be added
* @return a list of auto learnable skills for the player.
*/
public Collection<Skill> getAllAvailableSkills(PlayerInstance player, ClassId classId, boolean includeByFs, boolean includeByFp, boolean includeAutoGet, boolean includeRequiredItems)
{
// Get available skills
final PlayerSkillHolder holder = new PlayerSkillHolder(player);
@@ -751,8 +761,13 @@ public class SkillTreeData implements IXmlReader
break;
}
for (SkillLearn skillLearn : learnable)
SEARCH: for (SkillLearn skillLearn : learnable)
{
if (!includeRequiredItems && !skillLearn.getRequiredItems().isEmpty())
{
continue SEARCH;
}
final Skill skill = SkillData.getInstance().getSkill(skillLearn.getSkillId(), skillLearn.getSkillLevel());
// Cleanup skills that has to be removed
for (int skillId : skillLearn.getRemoveSkills())

View File

@@ -2527,7 +2527,7 @@ public class PlayerInstance extends Playable
// Give all normal skills if activated Auto-Learn is activated, included AutoGet skills.
if (Config.AUTO_LEARN_SKILLS)
{
giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, Config.AUTO_LEARN_FP_SKILLS, true);
giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, Config.AUTO_LEARN_FP_SKILLS, true, Config.AUTO_LEARN_SKILLS_WITHOUT_ITEMS);
}
else
{
@@ -2587,16 +2587,17 @@ public class PlayerInstance extends Playable
/**
* Give all available skills to the player.
* @param includedByFs if {@code true} forgotten scroll skills present in the skill tree will be added
* @param includedByFp if {@code true} forgotten power skills present in the skill tree will be added
* @param includeByFs if {@code true} forgotten scroll skills present in the skill tree will be added
* @param includeByFp if {@code true} forgotten power skills present in the skill tree will be added
* @param includeAutoGet if {@code true} auto-get skills present in the skill tree will be added
* @param includeRequiredItems if {@code true} skills that have required items will be added
* @return the amount of new skills earned
*/
public int giveAvailableSkills(boolean includedByFs, boolean includedByFp, boolean includeAutoGet)
public int giveAvailableSkills(boolean includeByFs, boolean includeByFp, boolean includeAutoGet, boolean includeRequiredItems)
{
int skillCounter = 0;
// Get available skills
final Collection<Skill> skills = SkillTreeData.getInstance().getAllAvailableSkills(this, getTemplate().getClassId(), includedByFs, includedByFp, includeAutoGet);
final Collection<Skill> skills = SkillTreeData.getInstance().getAllAvailableSkills(this, getTemplate().getClassId(), includeByFs, includeByFp, includeAutoGet, includeRequiredItems);
final List<Skill> skillsForStore = new ArrayList<>();
for (Skill skill : skills)
{

View File

@@ -287,7 +287,7 @@ public class CharacterCreate implements IClientIncomingPacket
newChar.getStat().setLevel((byte) Config.BALTHUS_KNIGHTS_LEVEL);
if (Config.BALTHUS_KNIGHTS_REWARD_SKILLS)
{
newChar.giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, Config.AUTO_LEARN_FP_SKILLS, true);
newChar.giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, Config.AUTO_LEARN_FP_SKILLS, true, Config.AUTO_LEARN_SKILLS_WITHOUT_ITEMS);
}
}

View File

@@ -114,7 +114,7 @@ public class ExRequestClassChange implements IClientIncomingPacket
if (Config.AUTO_LEARN_SKILLS)
{
player.giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, Config.AUTO_LEARN_FP_SKILLS, true);
player.giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, Config.AUTO_LEARN_FP_SKILLS, true, Config.AUTO_LEARN_SKILLS_WITHOUT_ITEMS);
}
player.store(false); // Save player cause if server crashes before this char is saved, he will lose class.