String targettype = st.nextToken();
String scheme_key = st.nextToken();
int cost = Integer.parseInt(st.nextToken());
if (cost == 0 || cost <= player.getInventory().getAdena())
{
L2Character target = player;
if (targettype.equalsIgnoreCase("pet"))
target = player.getPet();
if (target != null)
{
for (L2Skill sk : CharSchemesTable.getInstance().getScheme(player.getObjectId(), scheme_key))
if(buffer!=null)
{
buffer.setBusy(true);
buffer.setCurrentMp(buffer.getMaxMp());
buffer.setTarget(target);
//buffer.doCast(skill);
sk.getEffects(buffer, target,false,false,false);
buffer.setBusy(false);
} else
sk.getEffects(target, target,false,false,false);
//sk.getEffects(buffer, target);
player.reduceAdena("NPC Buffer", cost, null, true);
}else
{
player.sendMessage("Incorrect Target");
// go to main menu
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(PARENT_DIR + "menu.htm");
sendHtmlMessage(player, html);
}
}
else
{
player.sendMessage("Not enough adena");
showGiveBuffsWindow(player, targettype);
}
}
// handles edit schemes {skillselect, skillunselect}
else if (currentCommand.startsWith("editscheme"))
{
String skill_group = st.nextToken();
String scheme_key = null;
try
{
scheme_key = st.nextToken();
}
catch (Exception e)
{
if(Config.ENABLE_ALL_EXCEPTIONS)
e.printStackTrace();
}
showEditSchemeWindow(player, skill_group, scheme_key);
}
else if (currentCommand.startsWith("skill"))
{
String skill_group = st.nextToken();
String scheme_key = st.nextToken();
int skill_id = Integer.parseInt(st.nextToken());
int level = BufferSkillsTable.getInstance().getSkillLevelById(skill_id);
if (currentCommand.startsWith("skillselect") && !scheme_key.equalsIgnoreCase("unselected"))
{
if(CharSchemesTable.getInstance() != null
&& CharSchemesTable.getInstance().getScheme(player.getObjectId(), scheme_key)!=null
&& CharSchemesTable.getInstance().getScheme(player.getObjectId(), scheme_key).size() < 24)
CharSchemesTable.getInstance().getScheme(player.getObjectId(), scheme_key).add(SkillTable.getInstance().getInfo(skill_id, level));
else
player.sendMessage("This scheme has reached maximun amount of buffs");
}
else if (currentCommand.startsWith("skillunselect") && CharSchemesTable.getInstance() != null
&& CharSchemesTable.getInstance().getScheme(player.getObjectId(), scheme_key)!=null)
CharSchemesTable.getInstance().getScheme(player.getObjectId(), scheme_key).remove(SkillTable.getInstance().getInfo(skill_id, level));
showEditSchemeWindow(player, skill_group, scheme_key);
}
// manage schemes {create, delete, clear}
else if (currentCommand.startsWith("manageschemes"))
showManageSchemeWindow(player);
else if (currentCommand.startsWith("createscheme"))
{
if(!st.hasMoreTokens()){
player.sendMessage("Error: Specify Schema Name!");
showManageSchemeWindow(player);
return;
}
String name = st.nextToken();
if (name.length() > 14)
{
player.sendMessage("Error: Scheme's name must contain up to 14 chars without any spaces");
showManageSchemeWindow(player);
}
else if (CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()) != null && CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()).size() == 24)
{
player.sendMessage("Error: Maximun schemes amount reached, please delete one before creating a new one");
showManageSchemeWindow(player);
}
else if (CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()) != null && CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()).containsKey(name))
{
player.sendMessage("Error: duplicate entry. Please use another name");
showManageSchemeWindow(player);
}
else
{
if (CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()) == null)
CharSchemesTable.getInstance().getSchemesTable().put(player.getObjectId(), new FastMap<String, FastList<L2Skill>>(24 + 1));
CharSchemesTable.getInstance().setScheme(player.getObjectId(), name.trim(), new FastList<L2Skill>(24 + 1));
showManageSchemeWindow(player);
}
}
// handles deletion
else if (currentCommand.startsWith("deletescheme"))
{
if(!st.hasMoreTokens()){
player.sendMessage("Error: Specify Schema Name!");
showManageSchemeWindow(player);
return;
}
String name = st.nextToken();
if (CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()) != null && CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()).containsKey(name))
{
CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()).remove(name);
showManageSchemeWindow(player);
}
}
// handles cleanning
else if (currentCommand.startsWith("clearscheme"))
{
if(!st.hasMoreTokens()){
player.sendMessage("Error: Specify Schema Name!");
showManageSchemeWindow(player);
return;
}
String name = st.nextToken();
if (CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()) != null && CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()).containsKey(name))
{
CharSchemesTable.getInstance().getAllSchemes(player.getObjectId()).get(name).clear();
showManageSchemeWindow(player);
}
}
//predefined buffs
else if (currentCommand.startsWith("fighterbuff") || currentCommand.startsWith("magebuff"))
{
ArrayList<L2Skill> skills_to_buff = new ArrayList<L2Skill>();
if(currentCommand.startsWith("magebuff")){
for(int skillId:PowerPakConfig.MAGE_SKILL_LIST.keySet()){
L2Skill skill = SkillTable.getInstance().getInfo(skillId, PowerPakConfig.MAGE_SKILL_LIST.get(skillId));
if(skill!=null)
{
skills_to_buff.add(skill);
}
}
}else{
for(int skillId:PowerPakConfig.FIGHTER_SKILL_LIST.keySet()){
L2Skill skill = SkillTable.getInstance().getInfo(skillId, PowerPakConfig.FIGHTER_SKILL_LIST.get(skillId));
if(skill!=null)
{
skills_to_buff.add(skill);
}
}
}
String targettype = "";
if(st.hasMoreTokens())
targettype = st.nextToken();
int cost = 0;
if(PowerPakConfig.BUFFER_PRICE>0)
cost = PowerPakConfig.BUFFER_PRICE*skills_to_buff.size();
if (cost == 0 || cost <= player.getInventory().getAdena())
{
L2Character target = player;
if (targettype.equalsIgnoreCase("pet"))
target = player.getPet();
if (target != null)
{