Jump to content
adm kalunga

[aCis] NPC BUFFER - INTERLUDE

Recommended Posts

 

Área errada, movido para área correta.

Há algo errado aqui...

Este npc tem a parte dos efeitos e isso devia ser implementado com código java. Entretanto, no download disponível não há nada em relação a Java.

Procede?!


"And I now wait to shake the hand of fate

Like the dusk awaiting dawn"

Share this post


Link to post
Share on other sites

Otímo npc aqui vai o code java para quem tiver affim!

 

 

 

package net.sf.l2j.gameserver.model.actor.instance;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.ai.L2CharacterAI;
import net.sf.l2j.gameserver.datatables.BufferTable;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.gameserver.model.actor.L2Summon;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.holder.BuffSkillHolder;
import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
import net.sf.l2j.util.Rnd;

public class L2BufferInstance
  extends L2NpcInstance
{
  private static final int VOTE_COIN = 9517;
  
  public L2BufferInstance(int objectId, NpcTemplate template)
  {
    super(objectId, template);
  }
  
  public void onAction(L2PcInstance player)
  {
    if (this != player.getTarget())
    {
      player.setTarget(this);
      player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
      player.sendPacket(new ValidateLocation(this));
    }
    else if (isInsideRadius(player, 150, false, false))
    {
      SocialAction sa = new SocialAction(this, Rnd.get(8));
      broadcastPacket(sa);
      player.setCurrentFolkNPC(this);
      showSubBufferWindow(player);
      player.sendPacket(ActionFailed.STATIC_PACKET);
    }
    else
    {
      player.getAI().setIntention(CtrlIntention.INTERACT, this);
      player.sendPacket(ActionFailed.STATIC_PACKET);
    }
  }
  
  public void onBypassFeedback(L2PcInstance player, String command)
  {
    StringTokenizer st = new StringTokenizer(command, " ");
    String currentCommand = st.nextToken();
    if (currentCommand.startsWith("menu"))
    {
      NpcHtmlMessage html = new NpcHtmlMessage(1);
      html.setFile(getHtmlPath(getNpcId(), 0));
      html.replace("%objectId%", getObjectId());
      player.sendPacket(html);
    }
    else if (currentCommand.equalsIgnoreCase("getbuff"))
    {
      int buffid = 0;
      int bufflevel = 1;
      String nextWindow = null;
      if (st.countTokens() == 3)
      {
        buffid = Integer.valueOf(st.nextToken()).intValue();
        bufflevel = Integer.valueOf(st.nextToken()).intValue();
        nextWindow = st.nextToken();
      }
      else if (st.countTokens() == 1)
      {
        buffid = Integer.valueOf(st.nextToken()).intValue();
      }
      if (buffid != 0)
      {
        player.broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 5, 0));
        
        player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, bufflevel));
        SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
        showSubBufferWindow(player);
        showChatWindow(player, nextWindow);
      }
    }
    else if (currentCommand.equalsIgnoreCase("heroic_vote"))
    {
      if (player.getInventory().getInventoryItemCount(9517, 0) >= 1)
      {
        player.destroyItemByItemId("Consume", 9517, 1, player, true);
        player.broadcastPacket(new MagicSkillUse(this, player, 1374, 1, 5, 0));
        
        player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(1374, 1));
        SkillTable.getInstance().getInfo(1374, 1).getEffects(this, player);
      }
      else
      {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        html.setFile("data/html/mods/buffer/Vote-Coin.htm");
        
        player.sendPacket(html);
      }
    }
    else if (currentCommand.equalsIgnoreCase("fbuff"))
    {
      player.stopAllEffects();
      SkillTable.getInstance().getInfo(1204, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1068, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1040, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1035, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1036, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1045, 6).getEffects(player, player);
      SkillTable.getInstance().getInfo(1086, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1077, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1240, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1242, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1062, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(264, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(267, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(268, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(269, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(304, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(364, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(349, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(271, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(272, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(274, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(275, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(310, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(1363, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(1389, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(4699, 13).getEffects(player, player);
      SkillTable.getInstance().getInfo(4703, 13).getEffects(player, player);
      player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
      player.setCurrentCp(player.getMaxCp());
      player.sendMessage("You get a Fighter-buff complect.");
      showSubBufferWindow(player);
      player.broadcastUserInfo();
    }
    else if (currentCommand.equalsIgnoreCase("mbuff"))
    {
      player.stopAllEffects();
      SkillTable.getInstance().getInfo(1204, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1040, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1035, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1045, 6).getEffects(player, player);
      SkillTable.getInstance().getInfo(1048, 6).getEffects(player, player);
      SkillTable.getInstance().getInfo(1036, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1062, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1078, 6).getEffects(player, player);
      SkillTable.getInstance().getInfo(1303, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1059, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1085, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(264, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(267, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(268, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(304, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(364, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(349, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(273, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(276, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(365, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(1413, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(4703, 13).getEffects(player, player);
      player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
      player.setCurrentCp(player.getMaxCp());
      player.sendMessage("You get a Mage-buff complect.");
      showSubBufferWindow(player);
      player.broadcastUserInfo();
    }
    else if (currentCommand.startsWith("cleanup"))
    {
      player.broadcastPacket(new MagicSkillUse(this, player, 1056, 12, 100, 0));
      player.stopAllEffectsExceptThoseThatLastThroughDeath();
      
      L2Summon summon = player.getPet();
      if (summon != null) {
        summon.stopAllEffectsExceptThoseThatLastThroughDeath();
      }
      NpcHtmlMessage html = new NpcHtmlMessage(1);
      html.setFile(getHtmlPath(getNpcId(), 6));
      html.replace("%objectId%", getObjectId());
      player.sendPacket(html);
    }
    else if (currentCommand.startsWith("heal"))
    {
      player.broadcastPacket(new MagicSkillUse(this, player, 1218, 33, 100, 0));
      
      player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
      player.setCurrentCp(player.getMaxCp());
      
      L2Summon summon = player.getPet();
      if (summon != null) {
        summon.setCurrentHpMp(summon.getMaxHp(), summon.getMaxMp());
      }
      NpcHtmlMessage html = new NpcHtmlMessage(1);
      html.setFile(getHtmlPath(getNpcId(), 6));
      html.replace("%objectId%", getObjectId());
      player.sendPacket(html);
    }
    else if (currentCommand.startsWith("support"))
    {
      showGiveBuffsWindow(player, st.nextToken());
    }
    else if (currentCommand.startsWith("givebuffs"))
    {
      String targetType = st.nextToken();
      String schemeName = st.nextToken();
      int cost = Integer.parseInt(st.nextToken());
      
      L2Character target = targetType.equalsIgnoreCase("pet") ? player.getPet() : player;
      Iterator i$;
      if (target == null) {
        player.sendMessage("You don't have a pet.");
      } else if ((cost == 0) || (player.reduceAdena("NPC Buffer", cost, this, true))) {
        for (i$ = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName).iterator(); i$.hasNext();)
        {
          int skillId = ((Integer)i$.next()).intValue();
          SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId)).getEffects(this, target);
        }
      }
      showGiveBuffsWindow(player, targetType);
    }
    else if (currentCommand.startsWith("editschemes"))
    {
      showEditSchemeWindow(player, st.nextToken(), st.nextToken());
    }
    else if (currentCommand.startsWith("editmyschemes"))
    {
      MyListWindow(player, st.nextToken(), st.nextToken());
    }
    else if (currentCommand.startsWith("skill"))
    {
      String groupType = st.nextToken();
      String schemeName = st.nextToken();
      
      int skillId = Integer.parseInt(st.nextToken());
      
      List<Integer> skills = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName);
      if ((currentCommand.startsWith("skillselect")) && (!schemeName.equalsIgnoreCase("none")))
      {
        if (skills.size() < Config.BUFFER_MAX_SKILLS) {
          skills.add(Integer.valueOf(skillId));
        } else {
          player.sendMessage("This scheme has reached the maximum amount of buffs.");
        }
      }
      else if (currentCommand.startsWith("skillunselect"))
      {
        skills.remove(Integer.valueOf(skillId));
        MyListWindow(player, groupType, schemeName);
        return;
      }
      showEditSchemeWindow(player, groupType, schemeName);
    }
    else if (currentCommand.startsWith("subbuffer"))
    {
      showSubBufferWindow(player);
    }
    else if (currentCommand.startsWith("manageschemes"))
    {
      showManageSchemeWindow(player);
    }
    else
    {
      if (currentCommand.startsWith("createscheme")) {
        try
        {
          String schemeName = st.nextToken();
          if (schemeName.length() > 14)
          {
            player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
            showManageSchemeWindow(player);
            return;
          }
          Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
          if (schemes != null)
          {
            if (schemes.size() == Config.BUFFER_MAX_SCHEMES)
            {
              player.sendMessage("Maximum schemes amount is already reached.");
              showManageSchemeWindow(player);
              return;
            }
            if (schemes.containsKey(schemeName))
            {
              player.sendMessage("The scheme name already exists.");
              showManageSchemeWindow(player);
              return;
            }
          }
          BufferTable.getInstance().setScheme(player.getObjectId(), schemeName.trim(), new ArrayList());
          showManageSchemeWindow(player);
        }
        catch (Exception e)
        {
          player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
          showManageSchemeWindow(player);
        }
      }
      if (currentCommand.startsWith("deletescheme"))
      {
        try
        {
          String schemeName = st.nextToken();
          Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
          if ((schemes != null) && (schemes.containsKey(schemeName))) {
            schemes.remove(schemeName);
          }
        }
        catch (Exception e)
        {
          player.sendMessage("This scheme name is invalid.");
        }
        showManageSchemeWindow(player);
      }
      else if (currentCommand.startsWith("clearscheme"))
      {
        try
        {
          String schemeName = st.nextToken();
          Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
          if ((schemes != null) && (schemes.containsKey(schemeName))) {
            ((ArrayList)schemes.get(schemeName)).clear();
          }
        }
        catch (Exception e)
        {
          player.sendMessage("This scheme name is invalid.");
        }
        showManageSchemeWindow(player);
      }
    }
    super.onBypassFeedback(player, command);
  }
  
  public String getHtmlPath(int npcId, int val)
  {
    String filename = "";
    if (val == 0) {
      filename = "" + npcId;
    } else {
      filename = npcId + "-" + val;
    }
    return "data/html/mods/buffer/" + filename + ".htm";
  }
  
  private void showGiveBuffsWindow(L2PcInstance player, String targetType)
  {
    StringBuilder sb = new StringBuilder();
    
    Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
    if ((schemes == null) || (schemes.isEmpty())) {
      sb.append("<font color=\"LEVEL\">You haven't defined any scheme, please go to 'Manage my schemes' and create at least one valid scheme.</font>");
    } else {
      for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
      {
        int cost = getFee((ArrayList)scheme.getValue());
        sb.append("<font color=\"LEVEL\"><a action=\"bypass -h npc_%objectId%_givebuffs " + targetType + " " + (String)scheme.getKey() + " " + cost + "\">" + (String)scheme.getKey() + " (" + ((ArrayList)scheme.getValue()).size() + " skill(s))</a>" + (cost > 0 ? " - Adena cost: " + cost : "") + "</font><br1>");
      }
    }
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    html.setFile(getHtmlPath(getNpcId(), 1));
    html.replace("%schemes%", sb.toString());
    html.replace("%targettype%", targetType.equalsIgnoreCase("pet") ? " <a action=\"bypass -h npc_%objectId%_support player\">yourself</a> | your pet" : "yourself | <a action=\"bypass -h npc_%objectId%_support pet\">your pet</a>");
    html.replace("%objectId%", getObjectId());
    player.sendPacket(html);
  }
  
  private void showManageSchemeWindow(L2PcInstance player)
  {
    StringBuilder sb = new StringBuilder();
    
    Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
    if ((schemes == null) || (schemes.isEmpty()))
    {
      sb.append("<font color=\"LEVEL\">You haven't created any scheme.</font>");
    }
    else
    {
      sb.append("<table>");
      for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
      {
        sb.append("<tr><td width=140>" + (String)scheme.getKey() + " (" + ((ArrayList)scheme.getValue()).size() + " skill(s))</td>");
        sb.append("<td width=60><button value=\"Clear\" action=\"bypass -h npc_%objectId%_clearscheme " + (String)scheme.getKey() + "\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
        sb.append("<td width=60><button value=\"Drop\" action=\"bypass -h npc_%objectId%_deletescheme " + (String)scheme.getKey() + "\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
      }
      sb.append("</table>");
    }
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    html.setFile(getHtmlPath(getNpcId(), 2));
    html.replace("%schemes%", sb.toString());
    html.replace("%max_schemes%", Config.BUFFER_MAX_SCHEMES);
    html.replace("%objectId%", getObjectId());
    player.sendPacket(html);
  }
  
  private void showEditSchemeWindow(L2PcInstance player, String groupType, String schemeName)
  {
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    if (schemeName.equalsIgnoreCase("none"))
    {
      html.setFile(getHtmlPath(getNpcId(), 3));
    }
    else
    {
      if (groupType.equalsIgnoreCase("none"))
      {
        html.setFile(getHtmlPath(getNpcId(), 4));
      }
      else
      {
        html.setFile(getHtmlPath(getNpcId(), 5));
        html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName));
      }
      html.replace("%schemename%", schemeName);
      html.replace("%myschemeframe%", getPlayerSchemeSkillList(player, groupType, schemeName));
      html.replace("%typesframe%", getTypesFrame(groupType, schemeName));
    }
    html.replace("%schemes%", getPlayerSchemes(player, schemeName));
    html.replace("%objectId%", getObjectId());
    player.sendPacket(html);
  }
  
  private void MyListWindow(L2PcInstance player, String groupType, String schemeName)
  {
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    if (schemeName.equalsIgnoreCase("none"))
    {
      html.setFile(getHtmlPath(getNpcId(), 19));
    }
    else
    {
      if (groupType.equalsIgnoreCase("none"))
      {
        html.setFile(getHtmlPath(getNpcId(), 20));
      }
      else
      {
        html.setFile(getHtmlPath(getNpcId(), 21));
        html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName));
      }
      html.replace("%schemename%", schemeName);
      html.replace("%myschemeframe%", getPlayerSchemeSkillList(player, groupType, schemeName));
      html.replace("%typesframe%", getTypesFrame(groupType, schemeName));
    }
    html.replace("%schemes%", getPlayerMySchemes(player, schemeName));
    html.replace("%objectId%", String.valueOf(getObjectId()));
    player.sendPacket(html);
  }
  
  private void showSubBufferWindow(L2PcInstance player)
  {
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    
    html.setFile(getHtmlPath(getNpcId(), 6));
    html.replace("%objectId%", getObjectId());
    player.sendPacket(html);
  }
  
  private static String getPlayerSchemes(L2PcInstance player, String schemeName)
  {
    Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
    if ((schemes == null) || (schemes.isEmpty())) {
      return "Please create at least one scheme.";
    }
    StringBuilder tb = new StringBuilder();
    tb.append("<table>");
    for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet()) {
      if (schemeName.equalsIgnoreCase((String)scheme.getKey())) {
        tb.append("<tr><td width=200>" + (String)scheme.getKey() + " (<font color=\"LEVEL\">" + ((ArrayList)scheme.getValue()).size() + "</font> / " + Config.BUFFER_MAX_SKILLS + " skill(s))</td></tr>");
      } else {
        tb.append("<tr><td width=200><a action=\"bypass -h npc_%objectId%_editschemes none " + (String)scheme.getKey() + "\">" + (String)scheme.getKey() + " (" + ((ArrayList)scheme.getValue()).size() + " / " + Config.BUFFER_MAX_SKILLS + " skill(s))</a></td></tr>");
      }
    }
    tb.append("</table>");
    
    return tb.toString();
  }
  
  private static String getPlayerMySchemes(L2PcInstance player, String schemeName)
  {
    Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
    if ((schemes == null) || (schemes.isEmpty())) {
      return "Please create at least one scheme.";
    }
    StringBuilder tb = new StringBuilder();
    tb.append("<table>");
    for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet()) {
      if (schemeName.equalsIgnoreCase((String)scheme.getKey())) {
        tb.append("<tr><td width=200>" + (String)scheme.getKey() + " (<font color=\"LEVEL\">" + ((ArrayList)scheme.getValue()).size() + "</font> / " + Config.BUFFER_MAX_SKILLS + " skill(s))</td></tr>");
      } else {
        tb.append("<tr><td width=200><a action=\"bypass -h npc_%objectId%_editmyschemes none " + (String)scheme.getKey() + "\">" + (String)scheme.getKey() + " (" + ((ArrayList)scheme.getValue()).size() + " / " + Config.BUFFER_MAX_SKILLS + " skill(s))</a></td></tr>");
      }
    }
    tb.append("</table>");
    
    return tb.toString();
  }
  
  private static String getGroupSkillList(L2PcInstance player, String groupType, String schemeName)
  {
    List<Integer> skills = new ArrayList();
    for (Iterator i$ = BufferTable.getSkillsIdsByType(groupType).iterator(); i$.hasNext();)
    {
      int skillId = ((Integer)i$.next()).intValue();
      if (!BufferTable.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId)) {
        skills.add(Integer.valueOf(skillId));
      }
    }
    if (skills.isEmpty()) {
      return "That group doesn't contain any skills.";
    }
    StringBuilder tb = new StringBuilder();
    
    tb.append("<table>");
    int count = 0;
    for (Iterator i$ = skills.iterator(); i$.hasNext();)
    {
      int skillId = ((Integer)i$.next()).intValue();
      if (!BufferTable.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId))
      {
        if (count == 0) {
          tb.append("<tr>");
        }
        if (skillId < 100) {
          tb.append("<td><img src=\"icon.skill00" + skillId + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
        } else if (skillId < 1000) {
          tb.append("<td><img src=\"icon.skill0" + skillId + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
        } else {
          tb.append("<td><img src=\"icon.skill" + skillId + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
        }
        count++;
        if (count == 2)
        {
          tb.append("</tr>");
          count = 0;
        }
      }
    }
    if (!tb.toString().endsWith("</tr>")) {
      tb.append("</tr>");
    }
    tb.append("</table>");
    
    return tb.toString();
  }
  
  private static String getPlayerSchemeSkillList(L2PcInstance player, String groupType, String schemeName)
  {
    List<Integer> skills = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName);
    if (skills.isEmpty()) {
      return "That scheme is empty.";
    }
    StringBuilder tb = new StringBuilder();
    tb.append("<table>");
    int count = 0;
    for (Iterator i$ = skills.iterator(); i$.hasNext();)
    {
      int sk = ((Integer)i$.next()).intValue();
      if (count == 0) {
        tb.append("<tr>");
      }
      if (sk < 100) {
        tb.append("<td><img src=\"icon.skill00" + sk + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
      } else if (sk < 1000) {
        tb.append("<td><img src=\"icon.skill0" + sk + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
      } else {
        tb.append("<td><img src=\"icon.skill" + sk + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
      }
      count++;
      if (count == 2)
      {
        tb.append("</tr>");
        count = 0;
      }
    }
    if (!tb.toString().endsWith("<tr>")) {
      tb.append("<tr>");
    }
    tb.append("</table>");
    
    return tb.toString();
  }
  
  private static String getTypesFrame(String groupType, String schemeName)
  {
    StringBuilder tb = new StringBuilder();
    tb.append("<table>");
    
    int count = 0;
    for (String s : BufferTable.getSkillTypes())
    {
      if (count == 0) {
        tb.append("<tr>");
      }
      if (groupType.equalsIgnoreCase(s)) {
        tb.append("<td width=65>" + s + "</td>");
      } else {
        tb.append("<td width=65><a action=\"bypass -h npc_%objectId%_editschemes " + s + " " + schemeName + "\">" + s + "</a></td>");
      }
      count++;
      if (count == 4)
      {
        tb.append("</tr>");
        count = 0;
      }
    }
    if (!tb.toString().endsWith("</tr>")) {
      tb.append("</tr>");
    }
    tb.append("</table>");
    
    return tb.toString();
  }
  
  private static int getFee(ArrayList<Integer> list)
  {
    if (Config.BUFFER_STATIC_BUFF_COST >= 0) {
      return list.size() * Config.BUFFER_STATIC_BUFF_COST;
    }
    int fee = 0;
    for (Iterator i$ = list.iterator(); i$.hasNext();)
    {
      int sk = ((Integer)i$.next()).intValue();
      fee += ((BuffSkillHolder)Config.BUFFER_BUFFLIST.get(Integer.valueOf(sk))).getPrice();
    }
    return fee;
  }
}

 

 

Share this post


Link to post
Share on other sites

Esse NPC é para aCis, que já tem o L2BufferInstance.

 

Otímo npc aqui vai o code java para quem tiver affim!

 

 

 

package net.sf.l2j.gameserver.model.actor.instance;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.ai.L2CharacterAI;
import net.sf.l2j.gameserver.datatables.BufferTable;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.gameserver.model.actor.L2Summon;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.holder.BuffSkillHolder;
import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
import net.sf.l2j.util.Rnd;

public class L2BufferInstance
  extends L2NpcInstance
{
  private static final int VOTE_COIN = 9517;
  
  public L2BufferInstance(int objectId, NpcTemplate template)
  {
    super(objectId, template);
  }
  
  public void onAction(L2PcInstance player)
  {
    if (this != player.getTarget())
    {
      player.setTarget(this);
      player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
      player.sendPacket(new ValidateLocation(this));
    }
    else if (isInsideRadius(player, 150, false, false))
    {
      SocialAction sa = new SocialAction(this, Rnd.get(8));
      broadcastPacket(sa);
      player.setCurrentFolkNPC(this);
      showSubBufferWindow(player);
      player.sendPacket(ActionFailed.STATIC_PACKET);
    }
    else
    {
      player.getAI().setIntention(CtrlIntention.INTERACT, this);
      player.sendPacket(ActionFailed.STATIC_PACKET);
    }
  }
  
  public void onBypassFeedback(L2PcInstance player, String command)
  {
    StringTokenizer st = new StringTokenizer(command, " ");
    String currentCommand = st.nextToken();
    if (currentCommand.startsWith("menu"))
    {
      NpcHtmlMessage html = new NpcHtmlMessage(1);
      html.setFile(getHtmlPath(getNpcId(), 0));
      html.replace("%objectId%", getObjectId());
      player.sendPacket(html);
    }
    else if (currentCommand.equalsIgnoreCase("getbuff"))
    {
      int buffid = 0;
      int bufflevel = 1;
      String nextWindow = null;
      if (st.countTokens() == 3)
      {
        buffid = Integer.valueOf(st.nextToken()).intValue();
        bufflevel = Integer.valueOf(st.nextToken()).intValue();
        nextWindow = st.nextToken();
      }
      else if (st.countTokens() == 1)
      {
        buffid = Integer.valueOf(st.nextToken()).intValue();
      }
      if (buffid != 0)
      {
        player.broadcastPacket(new MagicSkillUse(this, player, buffid, bufflevel, 5, 0));
        
        player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(buffid, bufflevel));
        SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
        showSubBufferWindow(player);
        showChatWindow(player, nextWindow);
      }
    }
    else if (currentCommand.equalsIgnoreCase("heroic_vote"))
    {
      if (player.getInventory().getInventoryItemCount(9517, 0) >= 1)
      {
        player.destroyItemByItemId("Consume", 9517, 1, player, true);
        player.broadcastPacket(new MagicSkillUse(this, player, 1374, 1, 5, 0));
        
        player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT).addSkillName(1374, 1));
        SkillTable.getInstance().getInfo(1374, 1).getEffects(this, player);
      }
      else
      {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        html.setFile("data/html/mods/buffer/Vote-Coin.htm");
        
        player.sendPacket(html);
      }
    }
    else if (currentCommand.equalsIgnoreCase("fbuff"))
    {
      player.stopAllEffects();
      SkillTable.getInstance().getInfo(1204, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1068, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1040, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1035, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1036, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1045, 6).getEffects(player, player);
      SkillTable.getInstance().getInfo(1086, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1077, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1240, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1242, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1062, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(264, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(267, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(268, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(269, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(304, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(364, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(349, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(271, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(272, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(274, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(275, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(310, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(1363, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(1389, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(4699, 13).getEffects(player, player);
      SkillTable.getInstance().getInfo(4703, 13).getEffects(player, player);
      player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
      player.setCurrentCp(player.getMaxCp());
      player.sendMessage("You get a Fighter-buff complect.");
      showSubBufferWindow(player);
      player.broadcastUserInfo();
    }
    else if (currentCommand.equalsIgnoreCase("mbuff"))
    {
      player.stopAllEffects();
      SkillTable.getInstance().getInfo(1204, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1040, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1035, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1045, 6).getEffects(player, player);
      SkillTable.getInstance().getInfo(1048, 6).getEffects(player, player);
      SkillTable.getInstance().getInfo(1036, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1062, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1078, 6).getEffects(player, player);
      SkillTable.getInstance().getInfo(1303, 2).getEffects(player, player);
      SkillTable.getInstance().getInfo(1059, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(1085, 3).getEffects(player, player);
      SkillTable.getInstance().getInfo(264, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(267, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(268, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(304, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(364, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(349, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(273, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(276, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(365, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(1413, 1).getEffects(player, player);
      SkillTable.getInstance().getInfo(4703, 13).getEffects(player, player);
      player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
      player.setCurrentCp(player.getMaxCp());
      player.sendMessage("You get a Mage-buff complect.");
      showSubBufferWindow(player);
      player.broadcastUserInfo();
    }
    else if (currentCommand.startsWith("cleanup"))
    {
      player.broadcastPacket(new MagicSkillUse(this, player, 1056, 12, 100, 0));
      player.stopAllEffectsExceptThoseThatLastThroughDeath();
      
      L2Summon summon = player.getPet();
      if (summon != null) {
        summon.stopAllEffectsExceptThoseThatLastThroughDeath();
      }
      NpcHtmlMessage html = new NpcHtmlMessage(1);
      html.setFile(getHtmlPath(getNpcId(), 6));
      html.replace("%objectId%", getObjectId());
      player.sendPacket(html);
    }
    else if (currentCommand.startsWith("heal"))
    {
      player.broadcastPacket(new MagicSkillUse(this, player, 1218, 33, 100, 0));
      
      player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
      player.setCurrentCp(player.getMaxCp());
      
      L2Summon summon = player.getPet();
      if (summon != null) {
        summon.setCurrentHpMp(summon.getMaxHp(), summon.getMaxMp());
      }
      NpcHtmlMessage html = new NpcHtmlMessage(1);
      html.setFile(getHtmlPath(getNpcId(), 6));
      html.replace("%objectId%", getObjectId());
      player.sendPacket(html);
    }
    else if (currentCommand.startsWith("support"))
    {
      showGiveBuffsWindow(player, st.nextToken());
    }
    else if (currentCommand.startsWith("givebuffs"))
    {
      String targetType = st.nextToken();
      String schemeName = st.nextToken();
      int cost = Integer.parseInt(st.nextToken());
      
      L2Character target = targetType.equalsIgnoreCase("pet") ? player.getPet() : player;
      Iterator i$;
      if (target == null) {
        player.sendMessage("You don't have a pet.");
      } else if ((cost == 0) || (player.reduceAdena("NPC Buffer", cost, this, true))) {
        for (i$ = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName).iterator(); i$.hasNext();)
        {
          int skillId = ((Integer)i$.next()).intValue();
          SkillTable.getInstance().getInfo(skillId, SkillTable.getInstance().getMaxLevel(skillId)).getEffects(this, target);
        }
      }
      showGiveBuffsWindow(player, targetType);
    }
    else if (currentCommand.startsWith("editschemes"))
    {
      showEditSchemeWindow(player, st.nextToken(), st.nextToken());
    }
    else if (currentCommand.startsWith("editmyschemes"))
    {
      MyListWindow(player, st.nextToken(), st.nextToken());
    }
    else if (currentCommand.startsWith("skill"))
    {
      String groupType = st.nextToken();
      String schemeName = st.nextToken();
      
      int skillId = Integer.parseInt(st.nextToken());
      
      List<Integer> skills = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName);
      if ((currentCommand.startsWith("skillselect")) && (!schemeName.equalsIgnoreCase("none")))
      {
        if (skills.size() < Config.BUFFER_MAX_SKILLS) {
          skills.add(Integer.valueOf(skillId));
        } else {
          player.sendMessage("This scheme has reached the maximum amount of buffs.");
        }
      }
      else if (currentCommand.startsWith("skillunselect"))
      {
        skills.remove(Integer.valueOf(skillId));
        MyListWindow(player, groupType, schemeName);
        return;
      }
      showEditSchemeWindow(player, groupType, schemeName);
    }
    else if (currentCommand.startsWith("subbuffer"))
    {
      showSubBufferWindow(player);
    }
    else if (currentCommand.startsWith("manageschemes"))
    {
      showManageSchemeWindow(player);
    }
    else
    {
      if (currentCommand.startsWith("createscheme")) {
        try
        {
          String schemeName = st.nextToken();
          if (schemeName.length() > 14)
          {
            player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
            showManageSchemeWindow(player);
            return;
          }
          Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
          if (schemes != null)
          {
            if (schemes.size() == Config.BUFFER_MAX_SCHEMES)
            {
              player.sendMessage("Maximum schemes amount is already reached.");
              showManageSchemeWindow(player);
              return;
            }
            if (schemes.containsKey(schemeName))
            {
              player.sendMessage("The scheme name already exists.");
              showManageSchemeWindow(player);
              return;
            }
          }
          BufferTable.getInstance().setScheme(player.getObjectId(), schemeName.trim(), new ArrayList());
          showManageSchemeWindow(player);
        }
        catch (Exception e)
        {
          player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
          showManageSchemeWindow(player);
        }
      }
      if (currentCommand.startsWith("deletescheme"))
      {
        try
        {
          String schemeName = st.nextToken();
          Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
          if ((schemes != null) && (schemes.containsKey(schemeName))) {
            schemes.remove(schemeName);
          }
        }
        catch (Exception e)
        {
          player.sendMessage("This scheme name is invalid.");
        }
        showManageSchemeWindow(player);
      }
      else if (currentCommand.startsWith("clearscheme"))
      {
        try
        {
          String schemeName = st.nextToken();
          Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
          if ((schemes != null) && (schemes.containsKey(schemeName))) {
            ((ArrayList)schemes.get(schemeName)).clear();
          }
        }
        catch (Exception e)
        {
          player.sendMessage("This scheme name is invalid.");
        }
        showManageSchemeWindow(player);
      }
    }
    super.onBypassFeedback(player, command);
  }
  
  public String getHtmlPath(int npcId, int val)
  {
    String filename = "";
    if (val == 0) {
      filename = "" + npcId;
    } else {
      filename = npcId + "-" + val;
    }
    return "data/html/mods/buffer/" + filename + ".htm";
  }
  
  private void showGiveBuffsWindow(L2PcInstance player, String targetType)
  {
    StringBuilder sb = new StringBuilder();
    
    Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
    if ((schemes == null) || (schemes.isEmpty())) {
      sb.append("<font color=\"LEVEL\">You haven't defined any scheme, please go to 'Manage my schemes' and create at least one valid scheme.</font>");
    } else {
      for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
      {
        int cost = getFee((ArrayList)scheme.getValue());
        sb.append("<font color=\"LEVEL\"><a action=\"bypass -h npc_%objectId%_givebuffs " + targetType + " " + (String)scheme.getKey() + " " + cost + "\">" + (String)scheme.getKey() + " (" + ((ArrayList)scheme.getValue()).size() + " skill(s))</a>" + (cost > 0 ? " - Adena cost: " + cost : "") + "</font><br1>");
      }
    }
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    html.setFile(getHtmlPath(getNpcId(), 1));
    html.replace("%schemes%", sb.toString());
    html.replace("%targettype%", targetType.equalsIgnoreCase("pet") ? " <a action=\"bypass -h npc_%objectId%_support player\">yourself</a> | your pet" : "yourself | <a action=\"bypass -h npc_%objectId%_support pet\">your pet</a>");
    html.replace("%objectId%", getObjectId());
    player.sendPacket(html);
  }
  
  private void showManageSchemeWindow(L2PcInstance player)
  {
    StringBuilder sb = new StringBuilder();
    
    Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
    if ((schemes == null) || (schemes.isEmpty()))
    {
      sb.append("<font color=\"LEVEL\">You haven't created any scheme.</font>");
    }
    else
    {
      sb.append("<table>");
      for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet())
      {
        sb.append("<tr><td width=140>" + (String)scheme.getKey() + " (" + ((ArrayList)scheme.getValue()).size() + " skill(s))</td>");
        sb.append("<td width=60><button value=\"Clear\" action=\"bypass -h npc_%objectId%_clearscheme " + (String)scheme.getKey() + "\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
        sb.append("<td width=60><button value=\"Drop\" action=\"bypass -h npc_%objectId%_deletescheme " + (String)scheme.getKey() + "\" width=55 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
      }
      sb.append("</table>");
    }
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    html.setFile(getHtmlPath(getNpcId(), 2));
    html.replace("%schemes%", sb.toString());
    html.replace("%max_schemes%", Config.BUFFER_MAX_SCHEMES);
    html.replace("%objectId%", getObjectId());
    player.sendPacket(html);
  }
  
  private void showEditSchemeWindow(L2PcInstance player, String groupType, String schemeName)
  {
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    if (schemeName.equalsIgnoreCase("none"))
    {
      html.setFile(getHtmlPath(getNpcId(), 3));
    }
    else
    {
      if (groupType.equalsIgnoreCase("none"))
      {
        html.setFile(getHtmlPath(getNpcId(), 4));
      }
      else
      {
        html.setFile(getHtmlPath(getNpcId(), 5));
        html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName));
      }
      html.replace("%schemename%", schemeName);
      html.replace("%myschemeframe%", getPlayerSchemeSkillList(player, groupType, schemeName));
      html.replace("%typesframe%", getTypesFrame(groupType, schemeName));
    }
    html.replace("%schemes%", getPlayerSchemes(player, schemeName));
    html.replace("%objectId%", getObjectId());
    player.sendPacket(html);
  }
  
  private void MyListWindow(L2PcInstance player, String groupType, String schemeName)
  {
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    if (schemeName.equalsIgnoreCase("none"))
    {
      html.setFile(getHtmlPath(getNpcId(), 19));
    }
    else
    {
      if (groupType.equalsIgnoreCase("none"))
      {
        html.setFile(getHtmlPath(getNpcId(), 20));
      }
      else
      {
        html.setFile(getHtmlPath(getNpcId(), 21));
        html.replace("%skilllistframe%", getGroupSkillList(player, groupType, schemeName));
      }
      html.replace("%schemename%", schemeName);
      html.replace("%myschemeframe%", getPlayerSchemeSkillList(player, groupType, schemeName));
      html.replace("%typesframe%", getTypesFrame(groupType, schemeName));
    }
    html.replace("%schemes%", getPlayerMySchemes(player, schemeName));
    html.replace("%objectId%", String.valueOf(getObjectId()));
    player.sendPacket(html);
  }
  
  private void showSubBufferWindow(L2PcInstance player)
  {
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    
    html.setFile(getHtmlPath(getNpcId(), 6));
    html.replace("%objectId%", getObjectId());
    player.sendPacket(html);
  }
  
  private static String getPlayerSchemes(L2PcInstance player, String schemeName)
  {
    Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
    if ((schemes == null) || (schemes.isEmpty())) {
      return "Please create at least one scheme.";
    }
    StringBuilder tb = new StringBuilder();
    tb.append("<table>");
    for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet()) {
      if (schemeName.equalsIgnoreCase((String)scheme.getKey())) {
        tb.append("<tr><td width=200>" + (String)scheme.getKey() + " (<font color=\"LEVEL\">" + ((ArrayList)scheme.getValue()).size() + "</font> / " + Config.BUFFER_MAX_SKILLS + " skill(s))</td></tr>");
      } else {
        tb.append("<tr><td width=200><a action=\"bypass -h npc_%objectId%_editschemes none " + (String)scheme.getKey() + "\">" + (String)scheme.getKey() + " (" + ((ArrayList)scheme.getValue()).size() + " / " + Config.BUFFER_MAX_SKILLS + " skill(s))</a></td></tr>");
      }
    }
    tb.append("</table>");
    
    return tb.toString();
  }
  
  private static String getPlayerMySchemes(L2PcInstance player, String schemeName)
  {
    Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
    if ((schemes == null) || (schemes.isEmpty())) {
      return "Please create at least one scheme.";
    }
    StringBuilder tb = new StringBuilder();
    tb.append("<table>");
    for (Map.Entry<String, ArrayList<Integer>> scheme : schemes.entrySet()) {
      if (schemeName.equalsIgnoreCase((String)scheme.getKey())) {
        tb.append("<tr><td width=200>" + (String)scheme.getKey() + " (<font color=\"LEVEL\">" + ((ArrayList)scheme.getValue()).size() + "</font> / " + Config.BUFFER_MAX_SKILLS + " skill(s))</td></tr>");
      } else {
        tb.append("<tr><td width=200><a action=\"bypass -h npc_%objectId%_editmyschemes none " + (String)scheme.getKey() + "\">" + (String)scheme.getKey() + " (" + ((ArrayList)scheme.getValue()).size() + " / " + Config.BUFFER_MAX_SKILLS + " skill(s))</a></td></tr>");
      }
    }
    tb.append("</table>");
    
    return tb.toString();
  }
  
  private static String getGroupSkillList(L2PcInstance player, String groupType, String schemeName)
  {
    List<Integer> skills = new ArrayList();
    for (Iterator i$ = BufferTable.getSkillsIdsByType(groupType).iterator(); i$.hasNext();)
    {
      int skillId = ((Integer)i$.next()).intValue();
      if (!BufferTable.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId)) {
        skills.add(Integer.valueOf(skillId));
      }
    }
    if (skills.isEmpty()) {
      return "That group doesn't contain any skills.";
    }
    StringBuilder tb = new StringBuilder();
    
    tb.append("<table>");
    int count = 0;
    for (Iterator i$ = skills.iterator(); i$.hasNext();)
    {
      int skillId = ((Integer)i$.next()).intValue();
      if (!BufferTable.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId))
      {
        if (count == 0) {
          tb.append("<tr>");
        }
        if (skillId < 100) {
          tb.append("<td><img src=\"icon.skill00" + skillId + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
        } else if (skillId < 1000) {
          tb.append("<td><img src=\"icon.skill0" + skillId + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
        } else {
          tb.append("<td><img src=\"icon.skill" + skillId + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillselect " + groupType + " " + schemeName + " " + skillId + "\">" + SkillTable.getInstance().getInfo(skillId, 1).getName() + "</a></font></td>");
        }
        count++;
        if (count == 2)
        {
          tb.append("</tr>");
          count = 0;
        }
      }
    }
    if (!tb.toString().endsWith("</tr>")) {
      tb.append("</tr>");
    }
    tb.append("</table>");
    
    return tb.toString();
  }
  
  private static String getPlayerSchemeSkillList(L2PcInstance player, String groupType, String schemeName)
  {
    List<Integer> skills = BufferTable.getInstance().getScheme(player.getObjectId(), schemeName);
    if (skills.isEmpty()) {
      return "That scheme is empty.";
    }
    StringBuilder tb = new StringBuilder();
    tb.append("<table>");
    int count = 0;
    for (Iterator i$ = skills.iterator(); i$.hasNext();)
    {
      int sk = ((Integer)i$.next()).intValue();
      if (count == 0) {
        tb.append("<tr>");
      }
      if (sk < 100) {
        tb.append("<td><img src=\"icon.skill00" + sk + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
      } else if (sk < 1000) {
        tb.append("<td><img src=\"icon.skill0" + sk + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
      } else {
        tb.append("<td><img src=\"icon.skill" + sk + "\" width=32 height=13></td><td width=180><font color=\"6e6e6a\"><a action=\"bypass -h npc_%objectId%_skillunselect " + groupType + " " + schemeName + " " + sk + "\">" + SkillTable.getInstance().getInfo(sk, 1).getName() + "</a></font></td>");
      }
      count++;
      if (count == 2)
      {
        tb.append("</tr>");
        count = 0;
      }
    }
    if (!tb.toString().endsWith("<tr>")) {
      tb.append("<tr>");
    }
    tb.append("</table>");
    
    return tb.toString();
  }
  
  private static String getTypesFrame(String groupType, String schemeName)
  {
    StringBuilder tb = new StringBuilder();
    tb.append("<table>");
    
    int count = 0;
    for (String s : BufferTable.getSkillTypes())
    {
      if (count == 0) {
        tb.append("<tr>");
      }
      if (groupType.equalsIgnoreCase(s)) {
        tb.append("<td width=65>" + s + "</td>");
      } else {
        tb.append("<td width=65><a action=\"bypass -h npc_%objectId%_editschemes " + s + " " + schemeName + "\">" + s + "</a></td>");
      }
      count++;
      if (count == 4)
      {
        tb.append("</tr>");
        count = 0;
      }
    }
    if (!tb.toString().endsWith("</tr>")) {
      tb.append("</tr>");
    }
    tb.append("</table>");
    
    return tb.toString();
  }
  
  private static int getFee(ArrayList<Integer> list)
  {
    if (Config.BUFFER_STATIC_BUFF_COST >= 0) {
      return list.size() * Config.BUFFER_STATIC_BUFF_COST;
    }
    int fee = 0;
    for (Iterator i$ = list.iterator(); i$.hasNext();)
    {
      int sk = ((Integer)i$.next()).intValue();
      fee += ((BuffSkillHolder)Config.BUFFER_BUFFLIST.get(Integer.valueOf(sk))).getPrice();
    }
    return fee;
  }
}

 

 

 

minha rev é acis e tem o L2BufferInstance Eu vou ter que adc esse mod ai? não ne ?

 

aaah e outra coisa, tem um bloco de notas com o nome npc buffer data base, diz que é pra copiar e colar eu copio e colo la no navicat na jdb e nada se eu executar da erro e não sei pra que tabela ele vai .

Edited by isaquepe

Share this post


Link to post
Share on other sites

 

 

minha rev é acis e tem o L2BufferInstance Eu vou ter que adc esse mod ai? não ne ?

 

aaah e outra coisa, tem um bloco de notas com o nome npc buffer data base, diz que é pra copiar e colar eu copio e colo la no navicat na jdb e nada se eu executar da erro e não sei pra que tabela ele vai .

 

É so você colocar está e remover a que tem na sua rev

  • Like 1

Share this post


Link to post
Share on other sites

Tem um bloco de notas com o nome "Copie e cole no database" é pra eu colar aonde porque eu ja adc tudo e so ta faltando isso .

tbm to com esse problema ja resolveu?


Não Temas , Se Você Tem Um Sonho Corra Atras , Nunca Desista =D

Share this post


Link to post
Share on other sites

alguem conseguiu usar esse npc buffer ? aqui eu clico e ele nao meda buff algum


Conhecimento Em HTML , Multisell , SQL , DataBase e Scripts.

Share this post


Link to post
Share on other sites




     



×
×
  • Create New...