Jump to content

Recommended Posts

Posted

Credits to FBIAgent from l2jserver.com and to me for some changes...

Go to java/net/sf/l2j/gameserver/datatables and make a new file called NpcBufferSkillIdsTable.java

add this code

 

package net.sf.l2j.gameserver.datatables;

 

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.Map;

 

import javolution.util.FastMap;

 

import net.sf.l2j.L2DatabaseFactory;

 

public class NpcBufferSkillIdsTable

{

private static NpcBufferSkillIdsTable _instance = null;

 

private Map<Integer, NpcBufferSkills> _buffers = new FastMap<Integer, NpcBufferSkills>();

 

private NpcBufferSkillIdsTable()

{

Connection con = null;

int skillCount = 0;

 

try

{

con = L2DatabaseFactory.getInstance().getConnection();

 

PreparedStatement statement = con.prepareStatement("SELECT npc_id`,`skill_id`,`skill_level`,`skill_fee_id`,`skill_fee_amount` FROM `npc_buffer_skill_ids` ORDER BY `npc_id` ASC");

ResultSet rset = statement.executeQuery();

 

int lastNpcId = 0;

NpcBufferSkills skills = null;

 

while (rset.next())

{

int npcId = rset.getInt("npc_id");

int skillId = rset.getInt("skill_id");

int skillLevel = rset.getInt("skill_level");

int skillFeeId = rset.getInt("skill_fee_id");

int skillFeeAmount = rset.getInt("skill_fee_amount");

 

if (npcId != lastNpcId)

{

if (lastNpcId != 0)

_buffers.put(lastNpcId, skills);

 

skills = new NpcBufferSkills(npcId);

skills.addSkill(skillId, skillLevel, skillFeeId, skillFeeAmount);

}

else

skills.addSkill(skillId, skillLevel, skillFeeId, skillFeeAmount);

 

lastNpcId = npcId;

skillCount++;

}

 

_buffers.put(lastNpcId, skills);

rset.close();

statement.close();

}

catch (Exception e)

{

System.out.println("NpcBufferSkillIdsTable: Error reading npc_buffer_skill_ids table: " + e);

}

finally

{

try{con.close();}catch(Exception e){}

}

 

System.out.println("NpcBufferSkillIdsTable: Loaded " + _buffers.size() + " buffers and " + skillCount + " skills.");

}

 

public static NpcBufferSkillIdsTable getInstance()

{

if (_instance == null)

_instance = new NpcBufferSkillIdsTable();

return _instance;

}

 

public int[] getSkillInfo(int npcId, int skillId)

{

NpcBufferSkills skills = _buffers.get(npcId);

 

if (skills == null)

return null;

 

return skills.getSkillInfo(skillId);

}

}

 

Go to java/net/sf/l2j/gameserver/datatables and make a new file called NpcBufferSkills.java

 

package net.sf.l2j.gameserver.datatables;

 

import java.util.Map;

 

import javolution.util.FastMap;

 

public class NpcBufferSkills

{

private int _npcId = 0;

private Map<Integer, Integer> _skillLevels = new FastMap<Integer, Integer>();

private Map<Integer, Integer> _skillFeeIds = new FastMap<Integer, Integer>();

private Map<Integer, Integer> _skillFeeAmounts = new FastMap<Integer, Integer>();

 

public NpcBufferSkills(int npcId)

{

_npcId = npcId;

}

 

public void addSkill(int skillId, int skillLevel, int skillFeeId, int skillFeeAmount)

{

_skillLevels.put(skillId, skillLevel);

_skillFeeIds.put(skillId, skillFeeId);

_skillFeeAmounts.put(skillId, skillFeeAmount);

}

 

public int[] getSkillInfo(int skillId)

{

Integer skillLevel = _skillLevels.get(skillId);

Integer skillFeeId = _skillFeeIds.get(skillId);

Integer skillFeeAmount = _skillFeeAmounts.get(skillId);

 

if (skillLevel == null || skillFeeId == null || skillFeeAmount == null)

return null;

 

return new int[] {skillLevel, skillFeeId, skillFeeAmount};

}

 

public int getNpcId()

{

return _npcId;

}

}

 

Go to java/net/sf/l2j/gameserver/model/actor/instance and make a new file called L2NpcBufferInstance.java

 

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

 

import java.util.Vector;

import java.util.concurrent.ScheduledFuture;

 

import net.sf.l2j.gameserver.ThreadPoolManager;

import net.sf.l2j.gameserver.cache.HtmCache;

import net.sf.l2j.gameserver.datatables.NpcBufferSkillIdsTable;

import net.sf.l2j.gameserver.datatables.SkillTable;

import net.sf.l2j.gameserver.model.L2Effect;

import net.sf.l2j.gameserver.model.L2ItemInstance;

import net.sf.l2j.gameserver.model.L2Skill;

import net.sf.l2j.gameserver.serverpackets.ActionFailed;

import net.sf.l2j.gameserver.serverpackets.MagicSkillUser;

import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;

import net.sf.l2j.gameserver.skills.Formulas;

import net.sf.l2j.gameserver.templates.L2NpcTemplate;

import net.sf.l2j.util.Rnd;

 

/**

* L2NpcBufferInstance

*

* @author FBIagent

*/

public class L2NpcBufferInstance extends L2NpcInstance

{

private class BuffTask implements Runnable

{

private Boolean _buffing = false;

private L2NpcBufferInstance _me = null;

private Vector<L2PcInstance> _playerInstances = new Vector<L2PcInstance>();

private Vector<Integer> _skillIds = new Vector<Integer>();

private Vector<Integer> _skillLevels = new Vector<Integer>();

private ScheduledFuture _task = null;

 

public BuffTask(L2NpcBufferInstance me)

{

_me = me;

_task = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this, 100, 100);

}

 

public void addBuff(L2PcInstance playerInstance, int skillId, int skillLevel)

{

synchronized (_playerInstances)

{

/* int count = 0;

 

for (L2PcInstance playerInstance2 : _playerInstances)

{

if (playerInstance2 == playerInstance)

count++;

}

 

if (count > 4)

{

playerInstance.sendMessage("The buffer can't imagine more than 5 buffs per player.");

return;

}*/

 

_playerInstances.add(playerInstance);

_skillIds.add(skillId);

_skillLevels.add(skillLevel);

}

}

 

public void run()

{

boolean abort = false;

 

synchronized (_buffing)

{

abort = _buffing;

_buffing = true;

}

 

if (abort)

return;

 

try

{

Thread.sleep(1);

}

catch (InterruptedException ie)

{}

 

int index = -1;

L2PcInstance playerInstance = null;

int skillId = 0;

int skillLevel = 0;

 

synchronized (_playerInstances)

{

index = _skillIds.size() - 1;

 

if (index != -1)

{

index = Rnd.get(_skillIds.size());

playerInstance = _playerInstances.get(index);

skillId = _skillIds.get(index);

skillLevel = _skillLevels.get(index);

}

}

 

if (index == -1)

return;

 

L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLevel);

 

if (playerInstance != null && skill != null)

{

//if (_me.isInsideRadius(playerInstance.getX(), playerInstance.getY(), skill.getCastRange(), true))

//continue;

 

int skillTime = Formulas.getInstance().calcMAtkSpd(_me, skill, skill.getHitTime());

 

if (skill.isDance())

_me.broadcastPacket(new MagicSkillUser(_me, _me, skillId, skillLevel, skillTime, 0));

else

_me.broadcastPacket(new MagicSkillUser(_me, playerInstance, skillId, skillLevel, skillTime, 0));

 

long continueTime = System.currentTimeMillis() + skillTime;

 

while (continueTime >= System.currentTimeMillis())

{

try

{

Thread.sleep(1);

}

catch (InterruptedException ie)

{}

}

 

L2Effect[] effects = playerInstance.getAllEffects();

 

if (effects != null)

{

for (L2Effect e : effects)

{

if (e != null && skill != null)

{

if (e.getSkill().getId() == skill.getId())

e.exit();

}

}

}

 

skill.getEffects(playerInstance, playerInstance);

}

else

System.out.println("NpcBuffer warning(" + getNpcId() + " at " + getX() + ", " + getY() + ", " + getZ() + "): Skill or Player null!");

 

synchronized (_playerInstances)

{

_playerInstances.remove(index);

_skillIds.remove(index);

_skillLevels.remove(index);

}

 

synchronized (_buffing)

{

_buffing = false;

}

}

 

protected void stopTask()

{

if (_task != null)

{

_task.cancel(true);

_task = null;

}

}

}

 

private BuffTask _buffTaskInstance = null;

 

public L2NpcBufferInstance(int objectId, L2NpcTemplate template)

{

super(objectId, template);

_buffTaskInstance = new BuffTask(this);

}

 

@Override

public void showChatWindow(L2PcInstance playerInstance, int val)

{

if (playerInstance == null)

return;

 

String htmFile = "data/html/mods/NpcBuffer.htm";

String htmContent = HtmCache.getInstance().getHtm(htmFile);

 

if (htmContent != null)

    {

    NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage(getObjectId());

 

npcHtmlMessage.setHtml(htmContent);

    npcHtmlMessage.replace("%objectId%", String.valueOf(getObjectId()));

    playerInstance.sendPacket(npcHtmlMessage);

    }

 

playerInstance.sendPacket(new ActionFailed());

}

 

@Override

public void deleteMe()

{

_buffTaskInstance.stopTask();

_buffTaskInstance = null;

super.deleteMe();

}

 

@Override

    public void onBypassFeedback(L2PcInstance playerInstance, String command)

    {

    if (playerInstance == null)

    return;

 

    int npcId = getNpcId();

 

    if (command.startsWith("npc_buffer_buff"))

        {

    String[] params = command.split(" ");

      int skillId = Integer.parseInt(params[1]);

      int[] skillInfos = NpcBufferSkillIdsTable.getInstance().getSkillInfo(npcId, skillId);

     

      if (skillInfos == null)

      {

      System.out.println("NpcBuffer warning(" + npcId + " at " + getX() + ", " + getY() + ", " + getZ() + "): Player " + playerInstance.getName() + " tried to use skill(" + skillId + ") not assigned to npc buffer!");

      return;

      }

 

    int skillLevel = skillInfos[0];

    int skillFeeId = skillInfos[1];

    int skillFeeAmount = skillInfos[2];

 

    if (skillFeeId != 0) // take some item?

    {

    if (skillFeeAmount == 0)

    {

    System.out.println("NpcBuffer warning(" + npcId + " at " + getX() + ", " + getY() + ", " + getZ() + "): Fee amount of skill(" + skillId + ") fee id(" + skillFeeId + ") is 0!");

    return;

    }

           

    L2ItemInstance itemInstance = playerInstance.getInventory().getItemByItemId(skillFeeId);

 

    if (itemInstance == null || (!itemInstance.isStackable() && playerInstance.getInventory().getInventoryItemCount(skillFeeId, -1) < skillFeeAmount))

    {

    playerInstance.sendMessage("You do not have enought items!");

    return;

    }

 

    if (itemInstance.isStackable())

    {

    if (!playerInstance.destroyItemByItemId("Npc Buffer", skillFeeId, skillFeeAmount, playerInstance.getTarget(), true))

    {

    playerInstance.sendMessage("You do not have enought items!");

    return;

    }

    }

    else

    {

    for (int i=0;i<skillFeeAmount;i++)

    playerInstance.destroyItemByItemId("Npc Buffer", skillFeeId, 1, playerInstance.getTarget(), true);

    }

    }

L2Skill skill;

skill = SkillTable.getInstance().getInfo(skillId, skillLevel);

skill.getEffects(playerInstance, playerInstance);

        }

 

    showChatWindow(playerInstance, 0);

    }

}

 

 

Go to java/net/sf/l2j/gameserver and open file GameServer.java

 

Add the fallowing lines:

 

import net.sf.l2j.gameserver.datatables.NobleSkillTable;

+import net.sf.l2j.gameserver.datatables.NpcBufferSkillIdsTable;

import net.sf.l2j.gameserver.datatables.NpcTable;

 

HeroSkillTable.getInstance();

+ NpcBufferSkillIdsTable.getInstance();

 

        //Call to load caches

 

Run the SQL files into your database, add the NpcBuffer.Htm file into data\html\mods and voila...You got a java buffer with no posible bugs.

 

I personally prefer core buffer much more than python buffers. Python buffer can stuck if something goes wrong with a player doing a quest and you need a restart...with core buffer it wont happen ever :D

 

 

http://rapidshare.com/files/147162181/Core_Buffer.rar.html

 

  • 4 weeks later...
  • 2 months later...
  • 1 month later...
Posted

nothing. core buffer uses java scripts more than a buffer with jscript

 

Made it because my python scripts used to lock up...Nothing python-based worked. So I decided to make a core buffer because this one can't lock up in any way...

Posted

This buffer is totally bugged.If 2 players get buffs from the same buffer,the buffer gets confused and changes html's between players.

Posted

This buffer is totally bugged.If 2 players get buffs from the same buffer,the buffer gets confused and changes html's between players.

 

OMG! Yes this is true.... ;D

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • Added: Server monitoring has been added to the protection dashboard, available for Premium+ plans. Each entry displays: Account — game login. HWID — hardware ID. GSID — the game server the entry belongs to. IP — the player's address. Country — determined by IP, with flag and name. Useful for SEO promotion, do you know where more players come from Status — "Banned" or "OK". Extra windows — how many additional windows are allowed for this HWID beyond the global limit. Last seen — time of last activity.   At the top — a summary: total entries, number banned, time of the last report, and an Online/Offline indicator (based on how fresh the data from the protection is).   Filters and search Search by account, HWID, or IP. Country — select from countries actually present in the data. Game server (GS) — filter by GSID. Period — by last activity date (from / to). Banned only — quick filter for violators. Grouping — collapse data by HWID, IP, or account: one row per key with counts of accounts/HWIDs/IPs and number of entries. Handy for catching multi-accounters (many accounts from one HWID) and suspicious IPs.   Ban / Unban — banning by HWID blocks all accounts on that hardware. The protection will pick up the command within a minute; until applied, a "Pending…" status is shown. Grant windows — set additional windows (+N) for a specific HWID via a convenient selector. Single token per account to link the protection with the dashboard: Generate / Reissue token in one click. Show token — view the current value at any time. The token is stored encrypted. Don't share it with anyone — if compromised, simply reissue it and the old one stops working immediately. In the protection config, you can enable monitoring, insert the token, and change how often data is sent to the protection dashboard.
    • Dear BarbieQ server. https://www.mediafire.com/file/lfimqw9c63xd6l5/L2DAMAGE_MUST_BE_STOPPED_in_L2_Server_support_%26_problems_-_Page_1_of_-_l2topzone.com.pdf/file
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..