Fixed skill learn after class change.

Thanks Sdw for the pointers.
This commit is contained in:
MobiusDev
2016-12-22 14:43:54 +00:00
parent 67fe2b56b6
commit 42d3a8cf68
18 changed files with 41 additions and 176 deletions

View File

@@ -144,7 +144,6 @@ public final class Config
public static boolean LIFE_CRYSTAL_NEEDED;
public static boolean ES_SP_BOOK_NEEDED;
public static boolean DIVINE_SP_BOOK_NEEDED;
public static boolean ALT_GAME_SKILL_LEARN;
public static boolean ALT_GAME_SUBCLASS_WITHOUT_QUESTS;
public static boolean ALLOW_TRANSFORM_WITHOUT_QUEST;
public static int FEE_DELETE_TRANSFER_SKILLS;
@@ -1330,7 +1329,6 @@ public final class Config
LIFE_CRYSTAL_NEEDED = Character.getBoolean("LifeCrystalNeeded", true);
ES_SP_BOOK_NEEDED = Character.getBoolean("EnchantSkillSpBookNeeded", true);
DIVINE_SP_BOOK_NEEDED = Character.getBoolean("DivineInspirationSpBookNeeded", true);
ALT_GAME_SKILL_LEARN = Character.getBoolean("AltGameSkillLearn", false);
ALT_GAME_SUBCLASS_WITHOUT_QUESTS = Character.getBoolean("AltSubClassWithoutQuests", false);
RESTORE_SERVITOR_ON_RECONNECT = Character.getBoolean("RestoreServitorOnReconnect", true);
RESTORE_PET_ON_RECONNECT = Character.getBoolean("RestorePetOnReconnect", true);

View File

@@ -1171,7 +1171,7 @@ public final class SkillTreesData implements IGameXmlReader
switch (skillType)
{
case CLASS:
sl = getClassSkill(id, lvl, player.getLearningClass());
sl = getClassSkill(id, lvl, player.getClassId());
break;
case TRANSFORM:
sl = getTransformSkill(id, lvl);

View File

@@ -21,10 +21,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.model.base.SocialClass;
import com.l2jmobius.gameserver.model.holders.ItemHolder;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
@@ -276,38 +274,6 @@ public final class L2SkillLearn
return _pointsRequired;
}
/**
* Used for AltGameSkillLearn mod.<br>
* If the alternative skill learn system is enabled and the player is learning a skill from a different class apply a fee.<br>
* If the player is learning a skill from other class type (mage learning warrior skills or vice versa) the fee is higher.
* @param playerClass the player class Id.
* @param learningClass the skill learning player class Id.
* @return the amount of SP required to acquire this skill, by calculating the cost for the alternative skill learn system.
*/
public int getCalculatedLevelUpSp(ClassId playerClass, ClassId learningClass)
{
if ((playerClass == null) || (learningClass == null))
{
return _levelUpSp;
}
int levelUpSp = _levelUpSp;
// If the alternative skill learn system is enabled and the player is learning a skill from a different class apply a fee.
if (Config.ALT_GAME_SKILL_LEARN && (playerClass != learningClass))
{
// If the player is learning a skill from other class type (mage learning warrior skills or vice versa) the fee is higher.
if (playerClass.isMage() != learningClass.isMage())
{
levelUpSp *= 3;
}
else
{
levelUpSp *= 2;
}
}
return levelUpSp;
}
@Override
public String toString()
{

View File

@@ -134,8 +134,6 @@ public class L2NpcInstance extends L2Npc
// Normal skills, No LearnedByFS, no AutoGet skills.
final List<L2SkillLearn> skills = SkillTreesData.getInstance().getAvailableSkills(player, classId, false, false);
player.setLearningClass(classId);
if (skills.isEmpty())
{
final Map<Long, L2SkillLearn> skillTree = SkillTreesData.getInstance().getCompleteClassSkillTree(classId);

View File

@@ -2384,27 +2384,6 @@ public final class L2PcInstance extends L2Playable
}
}
/**
* Used for AltGameSkillLearn to set a custom skill learning class Id.
*/
private ClassId _learningClass = getClassId();
/**
* @return the custom skill learning class Id.
*/
public ClassId getLearningClass()
{
return _learningClass;
}
/**
* @param learningClass the custom skill learning class Id to set.
*/
public void setLearningClass(ClassId learningClass)
{
_learningClass = learningClass;
}
/**
* @return the Experience of the L2PcInstance.
*/
@@ -9636,8 +9615,6 @@ public final class L2PcInstance extends L2Playable
}
_classIndex = classIndex;
setLearningClass(getClassId());
if (isInParty())
{
getParty().recalculatePartyLevel();

View File

@@ -575,7 +575,7 @@ public final class RequestAcquireSkill implements IClientIncomingPacket
}
// First it checks that the skill require SP and the player has enough SP to learn it.
final int levelUpSp = skillLearn.getCalculatedLevelUpSp(player.getClassId(), player.getLearningClass());
final int levelUpSp = skillLearn.getLevelUpSp();
if ((levelUpSp > 0) && (levelUpSp > player.getSp()))
{
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_SP_TO_LEARN_THIS_SKILL);

View File

@@ -118,8 +118,7 @@ public final class RequestAcquireSkillInfo implements IClientIncomingPacket
}
case CLASS:
{
final int customSp = s.getCalculatedLevelUpSp(activeChar.getClassId(), activeChar.getLearningClass());
client.sendPacket(new ExAcquireSkillInfo(activeChar, s, customSp));
client.sendPacket(new ExAcquireSkillInfo(activeChar, s));
break;
}
case PLEDGE:

View File

@@ -45,14 +45,13 @@ public class ExAcquireSkillInfo implements IClientOutgoingPacket
* Sets a custom amount of SP.
* @param player
* @param skillLearn the skill learn.
* @param sp the custom SP amount.
*/
public ExAcquireSkillInfo(L2PcInstance player, L2SkillLearn skillLearn, int sp)
public ExAcquireSkillInfo(L2PcInstance player, L2SkillLearn skillLearn)
{
_id = skillLearn.getSkillId();
_level = skillLearn.getSkillLevel();
_dualClassLevel = skillLearn.getDualClassLevel();
_spCost = sp;
_spCost = skillLearn.getLevelUpSp();
_minLevel = skillLearn.getGetLevel();
_itemReq = skillLearn.getRequiredItems();
_skillRem = skillLearn.getRemoveSkills().stream().map(player::getKnownSkill).filter(Objects::nonNull).collect(Collectors.toList());