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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Posts

    • Website: https://l2aurum.com/  Discord: https://discord.gg/l2aurum   Hello Everyone,  finally, the moment has arrived: I'm launching my own server, L2Aurum!   L2Aurum x300 Closed Beta Test - Start: 17.02.2025  [20:00 GMT+2] Grand Opening 21.02.2025 [20:00 GMT+2]     Experience Rates: x300 Skill Points Rates: x300 Adena Drop: x300 Premium Accounts: x2 Drop Rates: x1 Spoil Rates: x1 Quest Rates: x1 Only one account per player, no dualboxing allowed. Everything is earned through gameplay, no pay-to-win mechanics. No server wipes—your progress is permanent. Fair play is a priority, with no room for corruption. All players are treated equally, no special favors.     Buffs slots: 26+4, all buffs in NPC and Scheme System. Custom Armors: Aurum Apella Armor Custom Weapons: Aurum Weapon Custom Accessories: +300 P.Def & M.Def Tattoos: Mage & Fighter & Custom Shirts Custom Jewels: New Grand Bosses Auto Farm is FREE for everyone. Status Noblesse: Barakiel. Player Spawn Protection: 10 seconds. Geodata e Panthodes: ENABLED. All Commands are visible in .menu. System 2 Bishop Per Party: ENABLED. Boss Protect - Anti-Zerg: ENABLED.     Siege Duration: 2 hours (120 minutes). Siege Period: Every 7 days. Castle Reward: 100E Per Castle. Available Castles: Rune Aden Giran Giran Siege: Every Friday 20:00 GMT +2. Aden Siege: Every Saturday 20:00 GMT +2. Rune Siege: Every Sunday 20:00 GMT +2. Main Clan: 40 Members max. Royal Clan: 12 Members max. Knight Clan: 7 Members max. Alliance: You can have only 1.     Epic Boss Valakas: Monday 22:30 (GMT+2) Zaken: Tuesday | Thursday 22:30 (GMT+2) Queen Ant: Monday | Wednesday 22:30 (GMT+2) Baium: Friday 22:30 (GMT+2) Antharas: Saturday 22:30 (GMT+2) Orfen: Tuesday | Thursday | Saturday 18:30 (GMT+2) Core: Monday | Wednesday | Friday | Sunday 18:30 (GMT+2)   Raid Boss  Flame Of Splendor Barakiel Last Hit: Every Day Respawn 3-4 hours Ember: Every Day Respawn 3-4 hours Lilith: Every Day Respawn 3-4 hours Anakim: Every Day Respawn 3-4 hours Queen Shyeed: Every Day Respawn 3-4 hours Golkonda: Every Day Respawn 3-4 hours Shuriel: Every Day Respawn 3-4 hours Varka's Hero Shadith: Every Day Respawn 3-4 hours Ketra's Hero Hekaton: Every Day Respawn 3-4 hours Varka's Mos: Every Day Respawn 3-4 hours Chief Horus: Every Day Respawn 3-4 hours Ketra's Tayer: Every Day Respawn 3-4 hours Chief Brakki: Every Day Respawn 3-4 hours Sailren: Every Day Respawn 02:00   🥳🥳🥳🥳 I would like to chat personally with all of you over on our Discord and discuss any suggestions or feedback you might have.      Website: https://l2aurum.com/  Discord: https://discord.gg/l2aurum
    • DISCORD : https://discord.com/users/325653525793210378 utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/uthciha-services https://campsite.bio/utchihaamkt
    • DISCORD : https://discord.com/users/325653525793210378 utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/uthciha-services https://campsite.bio/utchihaamkt
    • DISCORD : https://discord.com/users/325653525793210378 utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/uthciha-services https://campsite.bio/utchihaamkt
    • DISCORD : https://discord.com/users/325653525793210378 utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/uthciha-services https://campsite.bio/utchihaamkt
  • Topics

×
×
  • Create New...