Пробуй
Скрытый текстpackage com.l2jfrozen.gameserver.model.actor.instance;
import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.ai.CtrlIntention;
import com.l2jfrozen.gameserver.datatables.SkillTable;
import com.l2jfrozen.gameserver.datatables.sql.SkillTreeTable;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.model.Inventory;
import com.l2jfrozen.gameserver.model.L2Skill;
import com.l2jfrozen.gameserver.model.L2SkillLearn;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.l2jfrozen.util.database.L2DatabaseFactory;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import javolution.text.TextBuilder;
import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.network.serverpackets.StatusUpdate;
import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
/**
*
* @author Token
*
*/
public class L2AugmenterInstance extends L2FolkInstance
{
// MINI CONFIGS
private final static int ITEM_ID = 4037; // what you need to learn skill (Donate Coin)
private final static int ITEM_COUNT = 30; // how much Donate Coin you need
private final static int MAX_SKILLS = 1; // max skills character can learn(used if you are putting skills directly to char not on weapon)
private static int[] AUGMENT_SKILLS = {3134,3132,3138,3125,3246,3250}; // IMPORTANT needed if you are putting skills directly to char not on weapon
public L2AugmenterInstance(int objectId, L2NpcTemplate template)
{
super(objectId, template);
}
@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
if (player == null || player.getLastFolkNPC() == null || player.getLastFolkNPC().getObjectId() != this.getObjectId())
{
return;
}
else if (command.equals("active"))
{
showActiveWindow(player, 0);
}
else if (command.equals("passive"))
{
showPassiveWindow(player, 0);
}
else if (command.equals("activeChar"))
{
showActiveCharWindow(player, 0);
}
else if (command.equals("passiveChar"))
{
showPassiveCharWindow(player, 0);
}
else if (command.equals("back"))
{
showChatWindow(player, 0);
}
else if (command.equals("duelMight"))
{
addAugment(player, 14863, 3134, 10);
}
else if (command.equals("might"))
{
addAugment(player, 14960, 3132, 10);
}
else if (command.equals("healEmpower"))
{
addAugment(player, 15125, 3138, 10);
}
else if (command.equals("battleRoar"))
{
addAugment(player, 15214, 3125, 10);
}
else if (command.equals("empower"))
{
addAugment(player, 15389, 3246, 10);
}
else if (command.equals("wildMagic"))
{
addAugment(player, 15446, 3250, 10);
}
else if (command.equals("duelMightChar"))
{
addAugmentChar(player, 14863, 3134, 10);
}
else if (command.equals("mightChar"))
{
addAugmentChar(player, 14960, 3132, 10);
}
else if (command.equals("healEmpowerChar"))
{
addAugmentChar(player, 15125, 3138, 10);
}
else if (command.equals("battleRoarChar"))
{
addAugmentChar(player, 15214, 3125, 10);
}
else if (command.equals("empowerChar"))
{
addAugmentChar(player, 15389, 3246, 10);
}
else if (command.equals("wildMagicChar"))
{
addAugmentChar(player, 15446, 3250, 10);
}
else
return;
}
@Override
public void onAction(L2PcInstance player)
{
if (!this.canTarget(player))
return;
player.setLastFolkNPC(this);
if(player.getTarget() != this)
{
player.setTarget(this);
getAI();
MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
player.sendPacket(my);
StatusUpdate su = new StatusUpdate(getObjectId());
su.addAttribute(StatusUpdate.CUR_HP, (int) getCurrentHp());
su.addAttribute(StatusUpdate.MAX_HP, getMaxHp());
player.sendPacket(su);
player.sendPacket(new ValidateLocation(this));
}
else
{
if(!isAutoAttackable(player))
showChatWindow(player, 0);
else if(!player.isAlikeDead())
player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
player.sendPacket(new ValidateLocation(this));
player.sendPacket(ActionFailed.STATIC_PACKET);
}
}
@Override
public void showChatWindow(L2PcInstance player, int val)
{
TextBuilder tb = new TextBuilder();
tb.append("<html><title>Augmenter</title><body><center><br>");
tb.append("<font color=LEVEL>Привествую "+ player.getName()+" </font><br>");
tb.append("Поставить скил в оружие<br>");
tb.append("<button value=\"Active\" action=\"bypass -h npc_%objectId%_active\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<button value=\"Passive\" action=\"bypass -h npc_%objectId%_passive\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("Поставить скил на чаре<br>");
tb.append("<button value=\"Active\" action=\"bypass -h npc_%objectId%_activeChar\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<button value=\"Passive\" action=\"bypass -h npc_%objectId%_passiveChar\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<br><br><br><span color=LEVEL>lol</span>");
NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
msg.setHtml(tb.toString());
msg.replace("%objectId%", String.valueOf(this.getObjectId()));
player.sendPacket(msg);
}
public void showActiveWindow(L2PcInstance player, int val)
{
TextBuilder tb = new TextBuilder();
tb.append("<html><title>Augmenter</title><body><center><br>");
tb.append("<button value=\"DuelMight\" action=\"bypass -h npc_%objectId%_duelMight\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<button value=\"Heal Emp\" action=\"bypass -h npc_%objectId%_healEmpower\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<button value=\"Might\" action=\"bypass -h npc_%objectId%_might\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<br/><button value=\"Back\" action=\"bypass -h npc_%objectId%_back\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
msg.setHtml(tb.toString());
msg.replace("%objectId%", String.valueOf(this.getObjectId()));
player.sendPacket(msg);
}
public void showActiveCharWindow(L2PcInstance player, int val)
{
TextBuilder tb = new TextBuilder();
tb.append("<html><title>Augmenter Char</title><body><center><br>");
tb.append("<button value=\"DuelMight\" action=\"bypass -h npc_%objectId%_duelMightChar\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<button value=\"Heal Emp\" action=\"bypass -h npc_%objectId%_healEmpowerChar\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<button value=\"Might\" action=\"bypass -h npc_%objectId%_mightChar\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<br/><button value=\"Back\" action=\"bypass -h npc_%objectId%_back\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
msg.setHtml(tb.toString());
msg.replace("%objectId%", String.valueOf(this.getObjectId()));
player.sendPacket(msg);
}
public void showPassiveWindow(L2PcInstance player, int val)
{
TextBuilder tb = new TextBuilder();
tb.append("<html><title>Augmenter</title><body><center><br>");
tb.append("<button value=\"Battle Road\" action=\"bypass -h npc_%objectId%_battleRoar\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<button value=\"Empower\" action=\"bypass -h npc_%objectId%_empower\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<button value=\"Wild magic\" action=\"bypass -h npc_%objectId%_wildMagic\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<br/><button value=\"Back\" action=\"bypass -h npc_%objectId%_back\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
msg.setHtml(tb.toString());
msg.replace("%objectId%", String.valueOf(this.getObjectId()));
player.sendPacket(msg);
}
public void showPassiveCharWindow(L2PcInstance player, int val)
{
TextBuilder tb = new TextBuilder();
tb.append("<html><title>Augmenter Char</title><body><center><br>");
tb.append("<button value=\"Battle Road\" action=\"bypass -h npc_%objectId%_battleRoarChar\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<button value=\"Empower\" action=\"bypass -h npc_%objectId%_empowerChar\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<button value=\"Wild magic\" action=\"bypass -h npc_%objectId%_wildMagicChar\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
tb.append("<br/><button value=\"Back\" action=\"bypass -h npc_%objectId%_back\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">");
NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
msg.setHtml(tb.toString());
msg.replace("%objectId%", String.valueOf(this.getObjectId()));
player.sendPacket(msg);
}
private static void addAugment(L2PcInstance player, int attribute, int skill, int level)
{
L2ItemInstance item = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
if (item == null)
{
player.sendMessage("You have to equip a weapon.");
return;
}
if (player.getInventory().getInventoryItemCount(ITEM_ID, -1) < ITEM_COUNT)
{
player.sendMessage("You dont have enough item.");
return;
}
if (item.isAugmented())
{
player.sendMessage("Remove augment first.");
return;
}
Connection con = null;
try
{
player.destroyItemByItemId("Consume", ITEM_ID, ITEM_COUNT, player, true);
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("REPLACE INTO augmentations VALUES(?,?,?,?)");
statement.setInt(1, item.getObjectId());
statement.setInt(2, attribute*65536+1);
statement.setInt(3, skill);
statement.setInt(4, level);
statement.executeUpdate();
player.sendMessage("Succesfully augmented. You have to relog now.");
player.setIsParalyzed(true);
player.sendMessage("Restart");
statement.close();
}
catch (Exception e)
{
_log.log(Level.SEVERE, "Could not augment item: "+item.getObjectId()+" ", e);
}
finally
{
L2DatabaseFactory.close(con);
}
}
private static void addAugmentChar(L2PcInstance player, int attribute, int auguSkillId, int level)
{
final Set<Integer> values = new HashSet<Integer>();
boolean doHave = false;
int counter = 0;
for(int i : AUGMENT_SKILLS)
values.add(i);
// loop through all skills of player and check how muck augu skills he have
for(L2Skill skills : player.getAllSkills())
{
int skillid = skills.getId();
if(skillid == auguSkillId)
{
doHave = true;
}
if(values.contains(skillid))
{
counter++;
}
}
if(doHave == true)
{
player.sendMessage("You already have this skill");
return;
}
if(counter>=MAX_SKILLS)
{
player.sendMessage("Cant learn anymore skills");
counter = 0;
return;
}
L2Skill skill = null;
try
{
player.destroyItemByItemId("Consume", ITEM_ID, ITEM_COUNT, player, true);
skill = SkillTable.getInstance().getInfo(auguSkillId, level);
}
catch(Exception e)
{
if(Config.ENABLE_ALL_EXCEPTIONS)
e.printStackTrace();
}
if(skill != null)
{
String name = skill.getName();
player.sendMessage("You have got skill " + name + ".");
player.addSkill(skill, true);
player.setIsParalyzed(true);
player.sendMessage("Restart");
///activeChar.sendSkillList();
name = null;
}
else
{
player.sendMessage("Oops error.");
return;
}
skill = null;
player = null;
}
}
При выдаче идет паралич и msg что б сделал рестарт.
Нужно проверить
Возможно нужно будет ити EnterWorld.java что бы снимало паралич