Addition of AutoLearnSkillsWithoutItems configuration.
This commit is contained in:
@@ -73,6 +73,10 @@ SkillReuseList =
|
||||
# Default: False
|
||||
AutoLearnSkills = False
|
||||
|
||||
# Auto learn skills that need items to be learned.
|
||||
# Default: False
|
||||
AutoLearnSkillsWithoutItems = False
|
||||
|
||||
# If it's true skills from forgotten scrolls will be delivered upon level up and login, require AutoLearnSkills.
|
||||
# Default: False
|
||||
AutoLearnForgottenScrollSkills = False
|
||||
|
@@ -368,7 +368,7 @@ public class ClassMaster extends AbstractNpcAI implements IXmlReader
|
||||
}
|
||||
if (Config.AUTO_LEARN_SKILLS)
|
||||
{
|
||||
player.giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, true);
|
||||
player.giveAvailableSkills(Config.AUTO_LEARN_FS_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 and the money payed for class change.
|
||||
player.broadcastUserInfo();
|
||||
@@ -385,7 +385,7 @@ public class ClassMaster extends AbstractNpcAI implements IXmlReader
|
||||
}
|
||||
case "learnskills":
|
||||
{
|
||||
player.giveAvailableSkills(true, true);
|
||||
player.giveAvailableSkills(true, true, true);
|
||||
break;
|
||||
}
|
||||
case "clanlevelup":
|
||||
@@ -762,7 +762,7 @@ public class ClassMaster extends AbstractNpcAI implements IXmlReader
|
||||
}
|
||||
if (Config.AUTO_LEARN_SKILLS)
|
||||
{
|
||||
player.giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, true);
|
||||
player.giveAvailableSkills(Config.AUTO_LEARN_FS_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 and the money payed for class change.
|
||||
player.broadcastUserInfo();
|
||||
|
@@ -156,11 +156,11 @@ public class AdminSkill implements IAdminCommandHandler
|
||||
}
|
||||
else if (command.equals("admin_give_all_skills"))
|
||||
{
|
||||
adminGiveAllSkills(activeChar, false);
|
||||
adminGiveAllSkills(activeChar, false, false);
|
||||
}
|
||||
else if (command.equals("admin_give_all_skills_fs"))
|
||||
{
|
||||
adminGiveAllSkills(activeChar, true);
|
||||
adminGiveAllSkills(activeChar, true, true);
|
||||
}
|
||||
else if (command.equals("admin_give_clan_skills"))
|
||||
{
|
||||
@@ -277,9 +277,10 @@ public class AdminSkill implements IAdminCommandHandler
|
||||
/**
|
||||
* This function will give all the skills that the target can learn at his/her level
|
||||
* @param activeChar the player
|
||||
* @param includedByFs if {@code true} Forgotten Scroll skills will be delivered.
|
||||
* @param includeByFs if {@code true} Forgotten Scroll skills will be delivered.
|
||||
* @param includeRequiredItems if {@code true} skills that have required items will be added
|
||||
*/
|
||||
private void adminGiveAllSkills(PlayerInstance activeChar, boolean includedByFs)
|
||||
private void adminGiveAllSkills(PlayerInstance activeChar, boolean includeByFs, boolean includeRequiredItems)
|
||||
{
|
||||
final WorldObject target = activeChar.getTarget();
|
||||
if ((target == null) || !target.isPlayer())
|
||||
@@ -289,7 +290,7 @@ public class AdminSkill implements IAdminCommandHandler
|
||||
}
|
||||
final PlayerInstance player = target.getActingPlayer();
|
||||
// Notify player and admin
|
||||
BuilderUtil.sendSysMessage(activeChar, "You gave " + player.giveAvailableSkills(includedByFs, true) + " skills to " + player.getName());
|
||||
BuilderUtil.sendSysMessage(activeChar, "You gave " + player.giveAvailableSkills(includeByFs, true, includeRequiredItems) + " skills to " + player.getName());
|
||||
player.sendSkillList();
|
||||
player.sendPacket(new AcquireSkillList(player));
|
||||
}
|
||||
|
@@ -174,6 +174,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_LOOT_HERBS;
|
||||
public static byte BUFFS_MAX_AMOUNT;
|
||||
@@ -1710,6 +1711,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_LOOT_HERBS = Character.getBoolean("AutoLootHerbs", false);
|
||||
BUFFS_MAX_AMOUNT = Character.getByte("MaxBuffAmount", (byte) 20);
|
||||
|
@@ -727,7 +727,16 @@ public class SkillTreeData implements IXmlReader
|
||||
return result;
|
||||
}
|
||||
|
||||
public Collection<Skill> getAllAvailableSkills(PlayerInstance player, ClassId classId, boolean includeByFs, 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 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 includeAutoGet, boolean includeRequiredItems)
|
||||
{
|
||||
// Get available skills
|
||||
final PlayerSkillHolder holder = new PlayerSkillHolder(player);
|
||||
@@ -747,8 +756,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())
|
||||
|
@@ -2488,7 +2488,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, true);
|
||||
giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, true, Config.AUTO_LEARN_SKILLS_WITHOUT_ITEMS);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2548,15 +2548,16 @@ 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 includeByFs if {@code true} forgotten scroll 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 includeAutoGet)
|
||||
public int giveAvailableSkills(boolean includeByFs, boolean includeAutoGet, boolean includeRequiredItems)
|
||||
{
|
||||
int skillCounter = 0;
|
||||
// Get available skills
|
||||
final Collection<Skill> skills = SkillTreeData.getInstance().getAllAvailableSkills(this, getTemplate().getClassId(), includedByFs, includeAutoGet);
|
||||
final Collection<Skill> skills = SkillTreeData.getInstance().getAllAvailableSkills(this, getTemplate().getClassId(), includeByFs, includeAutoGet, includeRequiredItems);
|
||||
final List<Skill> skillsForStore = new ArrayList<>();
|
||||
for (Skill skill : skills)
|
||||
{
|
||||
|
@@ -120,7 +120,7 @@ public class ExRequestClassChange implements IClientIncomingPacket
|
||||
|
||||
if (Config.AUTO_LEARN_SKILLS)
|
||||
{
|
||||
player.giveAvailableSkills(Config.AUTO_LEARN_FS_SKILLS, true);
|
||||
player.giveAvailableSkills(Config.AUTO_LEARN_FS_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.
|
||||
|
Reference in New Issue
Block a user