Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.l2jfrozen.gameserver.model.actor.instance;
- import com.l2jfrozen.gameserver.ai.CtrlIntention;
- import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jfrozen.gameserver.model.Inventory;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import com.l2jfrozen.util.database.L2DatabaseFactory;
- import java.util.HashMap;
- import java.util.Map;
- 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
- {
- private final static int ITEM_ID = 57;
- private final static int ITEM_COUNT = 1000000;
- 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.startsWith("active"))
- {
- showActiveWindow(player, 0);
- }
- else if (command.startsWith("passive"))
- {
- showPassiveWindow(player, 0);
- }
- else if (command.startsWith("back"))
- {
- showChatWindow(player, 0);
- }
- else if (command.startsWith("focus"))
- {
- addAugment(player, 14863, 3141, 10);
- }
- else if (command.startsWith("might"))
- {
- addAugment(player, 14960, 3132, 10);
- }
- else if (command.startsWith("healEmpower"))
- {
- addAugment(player, 15125, 3138, 10);
- }
- else if (command.startsWith("magicBarrier"))
- {
- addAugment(player, 15214, 3245, 10);
- }
- else if (command.startsWith("empower"))
- {
- addAugment(player, 15389, 3246, 10);
- }
- else if (command.startsWith("wildMagic"))
- {
- addAugment(player, 15446, 3250, 10);
- }
- }
- @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>Welcome "+ player.getName()+" </font><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><br><br><span color=LEVEL>By Token</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=\"Focus\" action=\"bypass -h npc_%objectId%_focus\" 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 showPassiveWindow(L2PcInstance player, int val)
- {
- TextBuilder tb = new TextBuilder();
- tb.append("<html><title>Augmenter</title><body><center><br>");
- tb.append("<button value=\"Magic barrier\" action=\"bypass -h npc_%objectId%_magicBarrier\" 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);
- }
- 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.");
- statement.close();
- }
- catch (Exception e)
- {
- _log.log(Level.SEVERE, "Could not augment item: "+item.getObjectId()+" ", e);
- }
- finally
- {
- L2DatabaseFactory.close(con);
- }
- }
- }
- INSERT INTO `custom_npc` VALUES ('70016',22124,'Augmenter',1,'Augment shop',1,'NPC.a_guard_MHuman','11.00','27.00','80','male','L2Augmenter',5,'5','5','5.00','5.00','5','5','5','5','5','5','5','5','5','5',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,'0','LAST_HIT')
Advertisement
Add Comment
Please, Sign In to add comment