Jump to content
  • 0

Buffer On Acis


stayros

Question

i have already made a topic but i didnt really got it....

 

the buffer i want to create is with htmls, for example

 

999

999-1

999-2 etc...

 

and inside html buffing is like 

 

<table>
<tr>
<td width=40><button action="bypass -h npc_%objectId%_getbuff 1068 3" width=32 height=32 back="icon.skill1068" fore="icon.skill1068"></td>
<td width=240>
<table>
<tr><td><font color=LEVEL>Might</td></tr>
<tr><td><font color=00FF7F>Increases P. Attack</font></td></tr>
</table>
</td>
</tr>
</table>
 
what code should i apply and where to get this done?
Link to comment
Share on other sites

Recommended Posts

  • 0
+        int buffid = 0;
+        int bufflevel = 1;
 
         if (currentCommand.startsWith("menu"))
         {
                ......
         }
+        else if (currentCommand.equalsIgnoreCase("getbuff"))
+        {
+            if (st.countTokens() == 2)
+            {
+                buffid = Integer.valueOf(st.nextToken());
+                bufflevel = Integer.valueOf(st.nextToken());
+            }
+            else if (st.countTokens() == 1)
+                buffid = Integer.valueOf(st.nextToken());
+            
+            if (buffid != 0 && !player.isDead())
+            {
+                MagicSkillUse msu = new MagicSkillUse(this, player, buffid, bufflevel, 500, 0);
+                SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
+                player.broadcastPacket(msu);
+            }
+            
+            NpcHtmlMessage html = new NpcHtmlMessage(1);
+            html.setFile(getHtmlPath(getNpcId(), 10));
+            html.replace("%objectId%", getObjectId());
+            player.sendPacket(html);
+        }

html.setFile(getHtmlPath(getNpcId(), 10)); stands for 999-10.htm - 10th page.

 

Edit also main page of the buffer with new bypass for that page.

Edited by SweeTs
Link to comment
Share on other sites

  • 0
        int buffid = 0;
        int bufflevel = 1;
 
        if (currentCommand.startsWith("menu"))
        {
               ......
        }
        else if (currentCommand.equalsIgnoreCase("getbuff"))
        {
            if (st.countTokens() == 2)
            {
                buffid = Integer.valueOf(st.nextToken());
                bufflevel = Integer.valueOf(st.nextToken());
            }
            else if (st.countTokens() == 1)
                buffid = Integer.valueOf(st.nextToken());
            
            if (buffid != 0 && !player.isDead())
            {
                MagicSkillUse msu = new MagicSkillUse(this, player, buffid, bufflevel, 500, 0);
                SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
                player.broadcastPacket(msu);
            }
            
            NpcHtmlMessage html = new NpcHtmlMessage(1);
            html.setFile(getHtmlPath(getNpcId(), 10));
            html.replace("%objectId%", getObjectId());
            player.sendPacket(html);
        }

html.setFile(getHtmlPath(getNpcId(), 10)); stands for 999-10.htm - 10th page.

 

Edit also main page of the buffer with new bypass for that page.

 

i place all this code on java/net/sf/l2j/gameserver/model/actor/instance/L2BufferInstance.java under what line?

Link to comment
Share on other sites

  • 0

Ok, 2-3 weeks ago didnt knew anything about making servers, but good people told me about everything i asked. So now i will try to help you.

 

1. Open eclipse

   1.1. Go to aCis_gameserver\java\net\sf\l2j\gameserver\model\actor\instance\L2BufferInstance.java  and open it. 

   1.2. Delete everything and paste this:

                     

 

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 */
package net.sf.l2j.gameserver.model.actor.instance;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
 
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.datatables.BufferTable;
import net.sf.l2j.gameserver.datatables.SkillTable;
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.network.serverpackets.MagicSkillUse;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
 
public class L2BufferInstance extends L2NpcInstance
{
public L2BufferInstance(int objectId, NpcTemplate template)
{
super(objectId, template);
}
 
@Override
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.startsWith("cleanup"))
{
player.stopAllEffectsExceptThoseThatLastThroughDeath();
 
final L2Summon summon = player.getPet();
if (summon != null)
summon.stopAllEffectsExceptThoseThatLastThroughDeath();
 
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(getHtmlPath(getNpcId(), 0));
html.replace("%objectId%", getObjectId());
player.sendPacket(html);
}
else if (currentCommand.startsWith("heal"))
{
player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
player.setCurrentCp(player.getMaxCp());
 
final L2Summon summon = player.getPet();
if (summon != null)
summon.setCurrentHpMp(summon.getMaxHp(), summon.getMaxMp());
 
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(getHtmlPath(getNpcId(), 0));
html.replace("%objectId%", getObjectId());
player.sendPacket(html);
}
else if (currentCommand.startsWith("support"))
{
showGiveBuffsWindow(player, st.nextToken());
}
else if (currentCommand.startsWith("givebuffs"))
{
final String targetType = st.nextToken();
final String schemeName = st.nextToken();
final int cost = Integer.parseInt(st.nextToken());
 
final L2Character target = (targetType.equalsIgnoreCase("pet")) ? player.getPet() : player;
if (target == null)
player.sendMessage("You don't have a pet.");
else if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
{
for (int skillId : BufferTable.getInstance().getScheme(player.getObjectId(), schemeName))
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("skill"))
{
final String groupType = st.nextToken();
final String schemeName = st.nextToken();
 
final int skillId = Integer.parseInt(st.nextToken());
 
final 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(skillId);
else
player.sendMessage("This scheme has reached the maximum amount of buffs.");
}
else if (currentCommand.startsWith("skillunselect"))
skills.remove(Integer.valueOf(skillId));
 
showEditSchemeWindow(player, groupType, schemeName);
}
else if (currentCommand.startsWith("manageschemes"))
{
showManageSchemeWindow(player);
}
else if (currentCommand.startsWith("createscheme"))
{
try
{
final 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;
}
 
final 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<Integer>());
showManageSchemeWindow(player);
}
catch (Exception e)
{
player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
showManageSchemeWindow(player);
}
}
else if (currentCommand.startsWith("deletescheme"))
{
try
{
final String schemeName = st.nextToken();
final 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
{
final String schemeName = st.nextToken();
final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
 
if (schemes != null && schemes.containsKey(schemeName))
schemes.get(schemeName).clear();
}
catch (Exception e)
{
player.sendMessage("This scheme name is invalid.");
}
showManageSchemeWindow(player);
}
else if (currentCommand.startsWith("getbuff"))
{
int buffid = 0;
int bufflevel = 1;
int page = 0;
if (st.countTokens() == 3)
{
buffid = Integer.valueOf(st.nextToken());
bufflevel = Integer.valueOf(st.nextToken());
page = Integer.valueOf(st.nextToken());
}
else if (st.countTokens() == 2)
{
buffid = Integer.valueOf(st.nextToken());
page = Integer.valueOf(st.nextToken());
}
 
if (buffid != 0)
{
MagicSkillUse mgc = new MagicSkillUse(this, player, buffid, bufflevel, 5, 0);
SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
showMessageWindow(player, page);
player.broadcastPacket(mgc);
}
}
 
super.onBypassFeedback(player, command);
}
 
private void showMessageWindow(L2PcInstance player, int page)
{
String filename = "data/html/mods/buffer/" + getNpcId() + ".htm";
 
filename = getHtmlPath(getNpcId(), page);
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile(filename);
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcname%", getName());
player.sendPacket(html);
}
 
@Override
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";
}
 
/**
* Sends an html packet to player with Give Buffs menu info for player and pet, depending on targetType parameter {player, pet}
* @param player : The player to make checks on.
* @param targetType : a String used to define if the player or his pet must be used as target.
*/
private void showGiveBuffsWindow(L2PcInstance player, String targetType)
{
final StringBuilder sb = new StringBuilder();
 
final 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())
{
final int cost = getFee(scheme.getValue());
sb.append("<font color=\"LEVEL\"><a action=\"bypass -h npc_%objectId%_givebuffs " + targetType + " " + scheme.getKey() + " " + cost + "\">" + scheme.getKey() + " (" + 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);
}
 
/**
* Sends an html packet to player with Manage scheme menu info. This allows player to create/delete/clear schemes
* @param player : The player to make checks on.
*/
private void showManageSchemeWindow(L2PcInstance player)
{
final StringBuilder sb = new StringBuilder();
 
final 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>" + scheme.getKey() + " (" + scheme.getValue().size() + " skill(s))</td>");
sb.append("<td width=60><button value=\"Clear\" action=\"bypass -h npc_%objectId%_clearscheme " + 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 " + 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);
}
 
/**
* This sends an html packet to player with Edit Scheme Menu info. This allows player to edit each created scheme (add/delete skills)
* @param player : The player to make checks on.
* @param groupType : The group of skills to select.
* @param schemeName : The scheme to make check.
*/
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);
}
 
/**
* @param player : The player to make checks on.
* @param schemeName : The name to don't link (previously clicked).
* @return a String listing player's schemes. The scheme currently on selection isn't linkable.
*/
private static String getPlayerSchemes(L2PcInstance player, String schemeName)
{
final 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(scheme.getKey()))
tb.append("<tr><td width=200>" + scheme.getKey() + " (<font color=\"LEVEL\">" + 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 " + scheme.getKey() + "\">" + scheme.getKey() + " (" + scheme.getValue().size() + " / " + Config.BUFFER_MAX_SKILLS + " skill(s))</a></td></tr>");
}
 
tb.append("</table>");
 
return tb.toString();
}
 
/**
* @param player : The player to make checks on.
* @param groupType : The group of skills to select.
* @param schemeName : The scheme to make check.
* @return a String representing skills available to selection for a given groupType.
*/
private static String getGroupSkillList(L2PcInstance player, String groupType, String schemeName)
{
final List<Integer> skills = new ArrayList<>();
for (int skillId : BufferTable.getSkillsIdsByType(groupType))
{
if (BufferTable.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId))
continue;
 
skills.add(skillId);
}
 
if (skills.isEmpty())
return "That group doesn't contain any skills.";
 
StringBuilder tb = new StringBuilder();
 
tb.append("<table>");
int count = 0;
for (int skillId : skills)
{
if (BufferTable.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId))
continue;
 
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><tr><td></td></tr>");
count = 0;
}
}
 
if (!tb.toString().endsWith("</tr>"))
tb.append("</tr>");
 
tb.append("</table>");
 
return tb.toString();
}
 
/**
* @param player : The player to make checks on.
* @param groupType : The group of skills to select.
* @param schemeName : The scheme to make check.
* @return a String representing a given scheme's content.
*/
private static String getPlayerSchemeSkillList(L2PcInstance player, String groupType, String schemeName)
{
final 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 (int sk : skills)
{
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><tr><td></td></tr>");
count = 0;
}
}
 
if (!tb.toString().endsWith("<tr>"))
tb.append("<tr>");
 
tb.append("</table>");
 
return tb.toString();
}
 
/**
* @param groupType : The group of skills to select.
* @param schemeName : The scheme to make check.
* @return a string representing all groupTypes availables. The group currently on selection isn't linkable.
*/
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();
}
 
/**
* @param list : A list of skill ids.
* @return a global fee for all skills contained in list.
*/
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 (int sk : list)
fee += Config.BUFFER_BUFFLIST.get(sk).getPrice();
 
return fee;
}
}/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 */
package net.sf.l2j.gameserver.model.actor.instance;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
 
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.datatables.BufferTable;
import net.sf.l2j.gameserver.datatables.SkillTable;
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.network.serverpackets.MagicSkillUse;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
 
public class L2BufferInstance extends L2NpcInstance
{
public L2BufferInstance(int objectId, NpcTemplate template)
{
super(objectId, template);
}
 
@Override
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.startsWith("cleanup"))
{
player.stopAllEffectsExceptThoseThatLastThroughDeath();
 
final L2Summon summon = player.getPet();
if (summon != null)
summon.stopAllEffectsExceptThoseThatLastThroughDeath();
 
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(getHtmlPath(getNpcId(), 0));
html.replace("%objectId%", getObjectId());
player.sendPacket(html);
}
else if (currentCommand.startsWith("heal"))
{
player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
player.setCurrentCp(player.getMaxCp());
 
final L2Summon summon = player.getPet();
if (summon != null)
summon.setCurrentHpMp(summon.getMaxHp(), summon.getMaxMp());
 
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setFile(getHtmlPath(getNpcId(), 0));
html.replace("%objectId%", getObjectId());
player.sendPacket(html);
}
else if (currentCommand.startsWith("support"))
{
showGiveBuffsWindow(player, st.nextToken());
}
else if (currentCommand.startsWith("givebuffs"))
{
final String targetType = st.nextToken();
final String schemeName = st.nextToken();
final int cost = Integer.parseInt(st.nextToken());
 
final L2Character target = (targetType.equalsIgnoreCase("pet")) ? player.getPet() : player;
if (target == null)
player.sendMessage("You don't have a pet.");
else if (cost == 0 || player.reduceAdena("NPC Buffer", cost, this, true))
{
for (int skillId : BufferTable.getInstance().getScheme(player.getObjectId(), schemeName))
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("skill"))
{
final String groupType = st.nextToken();
final String schemeName = st.nextToken();
 
final int skillId = Integer.parseInt(st.nextToken());
 
final 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(skillId);
else
player.sendMessage("This scheme has reached the maximum amount of buffs.");
}
else if (currentCommand.startsWith("skillunselect"))
skills.remove(Integer.valueOf(skillId));
 
showEditSchemeWindow(player, groupType, schemeName);
}
else if (currentCommand.startsWith("manageschemes"))
{
showManageSchemeWindow(player);
}
else if (currentCommand.startsWith("createscheme"))
{
try
{
final 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;
}
 
final 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<Integer>());
showManageSchemeWindow(player);
}
catch (Exception e)
{
player.sendMessage("Scheme's name must contain up to 14 chars. Spaces are trimmed.");
showManageSchemeWindow(player);
}
}
else if (currentCommand.startsWith("deletescheme"))
{
try
{
final String schemeName = st.nextToken();
final 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
{
final String schemeName = st.nextToken();
final Map<String, ArrayList<Integer>> schemes = BufferTable.getInstance().getPlayerSchemes(player.getObjectId());
 
if (schemes != null && schemes.containsKey(schemeName))
schemes.get(schemeName).clear();
}
catch (Exception e)
{
player.sendMessage("This scheme name is invalid.");
}
showManageSchemeWindow(player);
}
else if (currentCommand.startsWith("getbuff"))
{
int buffid = 0;
int bufflevel = 1;
int page = 0;
if (st.countTokens() == 3)
{
buffid = Integer.valueOf(st.nextToken());
bufflevel = Integer.valueOf(st.nextToken());
page = Integer.valueOf(st.nextToken());
}
else if (st.countTokens() == 2)
{
buffid = Integer.valueOf(st.nextToken());
page = Integer.valueOf(st.nextToken());
}
 
if (buffid != 0)
{
MagicSkillUse mgc = new MagicSkillUse(this, player, buffid, bufflevel, 5, 0);
SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
showMessageWindow(player, page);
player.broadcastPacket(mgc);
}
}
 
super.onBypassFeedback(player, command);
}
 
private void showMessageWindow(L2PcInstance player, int page)
{
String filename = "data/html/mods/buffer/" + getNpcId() + ".htm";
 
filename = getHtmlPath(getNpcId(), page);
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile(filename);
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcname%", getName());
player.sendPacket(html);
}
 
@Override
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";
}
 
/**
* Sends an html packet to player with Give Buffs menu info for player and pet, depending on targetType parameter {player, pet}
* @param player : The player to make checks on.
* @param targetType : a String used to define if the player or his pet must be used as target.
*/
private void showGiveBuffsWindow(L2PcInstance player, String targetType)
{
final StringBuilder sb = new StringBuilder();
 
final 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())
{
final int cost = getFee(scheme.getValue());
sb.append("<font color=\"LEVEL\"><a action=\"bypass -h npc_%objectId%_givebuffs " + targetType + " " + scheme.getKey() + " " + cost + "\">" + scheme.getKey() + " (" + 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);
}
 
/**
* Sends an html packet to player with Manage scheme menu info. This allows player to create/delete/clear schemes
* @param player : The player to make checks on.
*/
private void showManageSchemeWindow(L2PcInstance player)
{
final StringBuilder sb = new StringBuilder();
 
final 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>" + scheme.getKey() + " (" + scheme.getValue().size() + " skill(s))</td>");
sb.append("<td width=60><button value=\"Clear\" action=\"bypass -h npc_%objectId%_clearscheme " + 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 " + 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);
}
 
/**
* This sends an html packet to player with Edit Scheme Menu info. This allows player to edit each created scheme (add/delete skills)
* @param player : The player to make checks on.
* @param groupType : The group of skills to select.
* @param schemeName : The scheme to make check.
*/
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);
}
 
/**
* @param player : The player to make checks on.
* @param schemeName : The name to don't link (previously clicked).
* @return a String listing player's schemes. The scheme currently on selection isn't linkable.
*/
private static String getPlayerSchemes(L2PcInstance player, String schemeName)
{
final 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(scheme.getKey()))
tb.append("<tr><td width=200>" + scheme.getKey() + " (<font color=\"LEVEL\">" + 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 " + scheme.getKey() + "\">" + scheme.getKey() + " (" + scheme.getValue().size() + " / " + Config.BUFFER_MAX_SKILLS + " skill(s))</a></td></tr>");
}
 
tb.append("</table>");
 
return tb.toString();
}
 
/**
* @param player : The player to make checks on.
* @param groupType : The group of skills to select.
* @param schemeName : The scheme to make check.
* @return a String representing skills available to selection for a given groupType.
*/
private static String getGroupSkillList(L2PcInstance player, String groupType, String schemeName)
{
final List<Integer> skills = new ArrayList<>();
for (int skillId : BufferTable.getSkillsIdsByType(groupType))
{
if (BufferTable.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId))
continue;
 
skills.add(skillId);
}
 
if (skills.isEmpty())
return "That group doesn't contain any skills.";
 
StringBuilder tb = new StringBuilder();
 
tb.append("<table>");
int count = 0;
for (int skillId : skills)
{
if (BufferTable.getInstance().getSchemeContainsSkill(player.getObjectId(), schemeName, skillId))
continue;
 
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><tr><td></td></tr>");
count = 0;
}
}
 
if (!tb.toString().endsWith("</tr>"))
tb.append("</tr>");
 
tb.append("</table>");
 
return tb.toString();
}
 
/**
* @param player : The player to make checks on.
* @param groupType : The group of skills to select.
* @param schemeName : The scheme to make check.
* @return a String representing a given scheme's content.
*/
private static String getPlayerSchemeSkillList(L2PcInstance player, String groupType, String schemeName)
{
final 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 (int sk : skills)
{
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><tr><td></td></tr>");
count = 0;
}
}
 
if (!tb.toString().endsWith("<tr>"))
tb.append("<tr>");
 
tb.append("</table>");
 
return tb.toString();
}
 
/**
* @param groupType : The group of skills to select.
* @param schemeName : The scheme to make check.
* @return a string representing all groupTypes availables. The group currently on selection isn't linkable.
*/
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();
}
 
/**
* @param list : A list of skill ids.
* @return a global fee for all skills contained in list.
*/
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 (int sk : list)
fee += Config.BUFFER_BUFFLIST.get(sk).getPrice();
 
return fee;
}
}

 

 

    1.4. Save the L2BufferInstance.java

    1.5. Go back to root of ur files,acis_ gameserver (you are still in eclipse) and find Build.xml

    1.6. Right click / Runs as / 1 Ant Build.

 

2. Now close eclipse and open ur workspace. My is in C:/Workspace

3. Find - Build folder and copy l2jserver.java 

                                 C:\workspace\aCis_gameserver\build\l2jserver.java

4. Copy it and paste it  in the folder you installed your server. (the folder from where you run gameserver)

                                 C:\Server\gameserver\libs

              copy and replace.

 

5. Now you can use ur scheme buffer like normal buffer. Next step is to add buttons to buffs.

6. Open you gameserver folder (from where u run the gameserver) and go to HTML/Mods/Buffer. 

 

 There you should see some HTML files (this ones are from acis buffer.)

 

7. Now you need to add your files.

8. Open 50008.html with notepad and add: a link to ur buffer. Write if you dont know how.

Edited by raF
Link to comment
Share on other sites

  • 0

Ehh raF.. Did you c/p default buffer? Since I dont see anything new - the thing he is requesting.

 

 

Anway, I edited my 1st post, added ++. Now you should see what/where to add.

Edited by SweeTs
Link to comment
Share on other sites

  • 0

Its default l2bufferinstance+ Tessa's  lines for new bypass for buffs. Its easier to delete all and copy everything than  delete and add lines.

Edited by raF
Link to comment
Share on other sites

  • 0
+        int buffid = 0;
+        int bufflevel = 1;
 
         if (currentCommand.startsWith("menu"))
         {
                ......
         }
+        else if (currentCommand.equalsIgnoreCase("getbuff"))
+        {
+            if (st.countTokens() == 2)
+            {
+                buffid = Integer.valueOf(st.nextToken());
+                bufflevel = Integer.valueOf(st.nextToken());
+            }
+            else if (st.countTokens() == 1)
+                buffid = Integer.valueOf(st.nextToken());
+            
+            if (buffid != 0 && !player.isDead())
+            {
+                MagicSkillUse msu = new MagicSkillUse(this, player, buffid, bufflevel, 500, 0);
+                SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
+                player.broadcastPacket(msu);
+            }
+            
+            NpcHtmlMessage html = new NpcHtmlMessage(1);
+            html.setFile(getHtmlPath(getNpcId(), 10));
+            html.replace("%objectId%", getObjectId());
+            player.sendPacket(html);
+        }

html.setFile(getHtmlPath(getNpcId(), 10)); stands for 999-10.htm - 10th page.

 

Edit also main page of the buffer with new bypass for that page.

 

what shoud it say? :P

Link to comment
Share on other sites

  • 0

I recommend you to use this this:

Index: java/net/sf/l2j/gameserver/model/actor/instance/L2BufferInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2BufferInstance.java	(revision 1)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2BufferInstance.java	(working copy)
@@ -29,6 +29,7 @@
 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.network.serverpackets.MagicSkillUse;
 import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
 
 public class L2BufferInstance extends L2NpcInstance
@@ -198,6 +199,36 @@
 			}
 			showManageSchemeWindow(player);
 		}
+		else if (currentCommand.startsWith("getbuff"))
+		{
+			int buffid = 0;
+			int bufflevel = 1;
+			int page = 0;
+			if (st.countTokens() == 3)
+			{
+				buffid = Integer.valueOf(st.nextToken());
+				bufflevel = Integer.valueOf(st.nextToken());
+				page = Integer.valueOf(st.nextToken());
+			}
+			else if (st.countTokens() == 2)
+			{
+				buffid = Integer.valueOf(st.nextToken());
+				page = Integer.valueOf(st.nextToken());
+			}
+			
+			if (buffid != 0)
+			{
+				MagicSkillUse mgc = new MagicSkillUse(this, player, buffid, bufflevel, 5, 0);
+				SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, player);
+				player.broadcastPacket(mgc);
+			}
+			
+			NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
+			html.setFile(getHtmlPath(getNpcId(), page));
+			html.replace("%objectId%", String.valueOf(getObjectId()));
+			html.replace("%npcname%", getName());
+			player.sendPacket(html);
+		}
 		
 		super.onBypassFeedback(player, command);
 	}
 

Then in data\html\mods\buffer create a new 50008-10.html file... the "-10" part of the file name is the page number of your buffer, and you can change its number as you wish.

 

The bypass looks like this:

<button action="bypass -h npc_%objectId%_getbuff skillId skillLevel page" width=32 height=32 back="icon.skill1068" fore="icon.skill1068">

You know what the first two values do, the only difference is that the skillLevel is optional and by default is level 1, so if you want to add skill with level 1, you can simply skip skillLevel.

The third value "page" is the page where you will go to, when you take the buff... so in your case the end result should looks like this (if the html's name is 50008-10.html):

<button action="bypass -h npc_%objectId%_getbuff 1068 3 10" width=32 height=32 back="icon.skill1068" fore="icon.skill1068">
Edited by Tessa
Link to comment
Share on other sites

  • 0

Tell me what's the point adding an int to the code and  htm while it does the same thing, lol ?

 

The code is longer of X lines, htm has useless int.. Else, you want to separate buffs/dances/songs page. Then, yes.

Edited by SweeTs
Link to comment
Share on other sites

  • 0

Tell me what's the point adding an int to the code and  htm while it does the same thing, lol ?

 

The code is longer of X lines, htm has useless int.. Else, you want to separate buffs/dances/songs page. Then, yes.

In case he wants to group the buffs.

Link to comment
Share on other sites

  • 0

In case he wants to group the buffs.

Yup, I answered by myself after a while, lol :D

 

Gotta eat something, I'm starving. Scrambled eggs on fire.

Edited by SweeTs
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock