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

    • You should buy it then I’ll make a discount  
    • Hi everyone,   In 2014, I completely stepped away from developing L2 servers and doing L2J-related work. Since then, I’ve only opened this server about once a year and helped a few servers and individuals for free. I haven’t taken on any paid L2J work since then.   LINEAGE2.GOLD is a project that has reached about Season 6. The first season launched at the end of 2020 and was a fully rebuilt Gold-style server on the Classic client (protocol 110). It featured many custom systems and enhancements. After several seasons, I decided to abandon the Mobius-based project and move to Lucera, as my goal was to get as close as possible to Interlude PTS behavior while still staying on the L2J platform.   The current project was once again completely rebuilt, this time on the Essence client (protocol 306), and is based on Lucera. Because of that, acquiring a license from Deazer is required.   My Lucera extender includes, but is not limited to: Formulas.java Basic anti-bot detection, which proved quite effective, we caught most Adrenaline users using relatively simple server-side logic, logged them, and took staff action. Simple admin account lookup commands based on IP, HWID, and similar identifiers. In-game Captcha via https://lineage2.gold/code, protected by Cloudflare, including admin commands for blacklisting based on aggression levels and whitelisting. Additional admin tools such as Auto-Play status checks, Enchanted Hero Weapon live sync, force add/remove clans from castle sieges, item listeners for live item monitoring, and more. A fully rewritten Auto-Play system with support for ExAutoPlaySetting, while still using the Auto-Play UI wheel, featuring: Debuff Efficiency Party Leader Assist Respectful Hunting Healer AI Target Mode Range Mode Summoner buff support Dwarf mechanics Reworked EffectDispelEffects to restore buffs after Cancellation. Raid Bomb item support. Reworked CronZoneSwitcher. Prime Time Raid Respawn Service. Community Board features such as Top rankings and RB/Epic status. Custom systems for Noblesse, Subclasses, support-class rewards, and much more.   Depending on the deal, the project can include: The lineage2.gold domain The website built on the Laravel PHP framework The server’s Discord Client Interface source Server files and extender source The server database (excluding private data such as emails and passwords)   I’m primarily looking for a serious team to continue the project, as it would be a shame to see this work abandoned. This is not cheap. You can DM me with offers. If you’re wondering why I’m doing this: I’ve felt a clear lack of appreciation from the L2 community, and I’m not interested in doing charity work for people who don’t deserve it. I’m simply not someone who tolerates BS. Server Info: https://lineage2.gold/info Server for test: https://lineage2.gold/download Over 110 videos YouTube playlist: https://www.youtube.com/watch?v=HO7BZaxUv2U&list=PLD9WZ0Nj-zstZaYeWxAxTKbX7ia2M_DUu&index=113
  • 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..

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