L2JMobius
Public Development => General Discussion => Topic started by: friendlyfire on February 05, 2019, 03:20:30 PM
-
Hello
Trying to implement custom NPC for Multiskill
package handlers.bypasshandlers;
import java.util.List;
import java.util.logging.Level;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
import com.l2jmobius.gameserver.handler.IBypassHandler;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.L2SkillLearn;
import com.l2jmobius.gameserver.model.base.AcquireSkillType;
import com.l2jmobius.gameserver.network.serverpackets.AcquireSkillList;
import com.l2jmobius.gameserver.network.SystemMessageId;
public class MultiSkill implements IBypassHandler
{
private static final String[] COMMANDS =
{
"MultiSkill"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (Config.ALT_GAME_SKILL_LEARN)
{
try
{
final String classId = command.substring(9).trim();
final AcquireSkillList asl = new AcquireSkillList(AcquireSkillType.CLASS);
int count = 0;
for (L2SkillLearn skillLearn : SkillTreesData.getInstance().getAvailableSkills(activeChar, classId, false, false))
{
if (SkillData.getInstance().getSkill(skillLearn.getSkillId(), skillLearn.getSkillLevel()) != null)
{
count++;
asl.addSkill(skillLearn.getSkillId(), skillLearn.getSkillLevel(), skillLearn.getSkillLevel(), skillLearn.getLevelUpSp(), 0);
}
}
if (count > 0)
{
activeChar.sendPacket(asl);
}
else
{
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
}
}
}
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}
MasterHandler.ajava
import handlers.bypasshandlers.MultiSkill;
MultiSkill.class,
Server throw
[05/02 20:24:15] Loading server scripts...
[05/02 20:24:18] Failed to execute script list!
java.lang.NullPointerException
at com.l2jmobius.gameserver.scripting.java.JavaExecutionContext.executeScripts(JavaExecutionContext.java:173)
at com.l2jmobius.gameserver.scripting.java.JavaExecutionContext.executeScript(JavaExecutionContext.java:250)
at com.l2jmobius.gameserver.scripting.ScriptEngineManager.executeScript(ScriptEngineManager.java:345)
at com.l2jmobius.gameserver.scripting.ScriptEngineManager.executeMasterHandler(ScriptEngineManager.java:237)
at com.l2jmobius.gameserver.GameServer.<init>(GameServer.java:346)
at com.l2jmobius.gameserver.GameServer.main(GameServer.java:490)
-
package handlers.bypasshandlers;
import java.util.List;
import java.util.logging.Level;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
import com.l2jmobius.gameserver.handler.IBypassHandler;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.L2SkillLearn;
import com.l2jmobius.gameserver.model.base.AcquireSkillType;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.network.serverpackets.AcquireSkillList;
import com.l2jmobius.gameserver.network.SystemMessageId;
public class MultiSkill implements IBypassHandler
{
private static final String[] COMMANDS =
{
"MultiSkill"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (Config.ALT_GAME_SKILL_LEARN)
{
try
{
final ClassId classId = ClassId.getClassId(Integer.parseInt(command.substring(9).trim()));
final AcquireSkillList asl = new AcquireSkillList(AcquireSkillType.CLASS);
int count = 0;
for (L2SkillLearn skillLearn : SkillTreesData.getInstance().getAvailableSkills(activeChar, classId, false, false))
{
if (SkillData.getInstance().getSkill(skillLearn.getSkillId(), skillLearn.getSkillLevel()) != null)
{
count++;
asl.addSkill(skillLearn.getSkillId(), skillLearn.getSkillLevel(), skillLearn.getSkillLevel(), skillLearn.getLevelUpSp(), 0);
}
}
if (count > 0)
{
activeChar.sendPacket(asl);
}
else
{
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
}
}
catch (Exception e)
{
}
}
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}
1. ClassId is not string.
2. You use try without catch.
-
Find out about ClassID
Thank you for help Mobius !!!!!!! 8)
When I receive skill window and click on skill nothing happens :(
-
I do not understand what you try to do, but why not use the existing AltGameSkillLearn config?
-
Fixed by adding activeChar.setLearningClass(classId);
Custom Skill Learn NPC (any class)
-
package handlers.bypasshandlers;
import java.util.List;
import java.util.logging.Level;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
import com.l2jmobius.gameserver.handler.IBypassHandler;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.L2SkillLearn;
import com.l2jmobius.gameserver.model.base.AcquireSkillType;
import com.l2jmobius.gameserver.model.base.ClassId;
import com.l2jmobius.gameserver.network.serverpackets.AcquireSkillList;
import com.l2jmobius.gameserver.network.SystemMessageId;
public class MultiSkill implements IBypassHandler
{
private static final String[] COMMANDS =
{
"MultiSkill"
};
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (Config.ALT_GAME_SKILL_LEARN)
{
try
{
final ClassId classId = ClassId.getClassId(Integer.parseInt(command.substring(9).trim()));
final AcquireSkillList asl = new AcquireSkillList(AcquireSkillType.CLASS);
int count = 0;
for (L2SkillLearn skillLearn : SkillTreesData.getInstance().getAvailableSkills(activeChar, classId, false, false))
{
if (SkillData.getInstance().getSkill(skillLearn.getSkillId(), skillLearn.getSkillLevel()) != null)
{
count++;
asl.addSkill(skillLearn.getSkillId(), skillLearn.getSkillLevel(), skillLearn.getSkillLevel(), skillLearn.getLevelUpSp(), 0);
}
}
if (count > 0)
{
activeChar.sendPacket(asl);
}
else
{
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OTHER_SKILLS_TO_LEARN);
}
}
catch (Exception e)
{
}
}
return true;
}
@Override
public String[] getBypassList()
{
return COMMANDS;
}
}
1. ClassId is not string.
2. You use try without catch.
This code is for version 238 essence ?