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

    • We remind you that right now you can create a new character and get the benefits of the bonus-start, which will begin on April 19th. These advantages include: — 10 sets of buff scrolls (phys or mage, depending on class), — 10 packs of +50% Drop/Spoil runes (2 hours each), — 10 packs of +50% Exp runes (2 hours each). Moreover, characters between level 21 and 30 will receive upon login: — 6 sets of buff scrolls, — 6 packs of +50% Drop/Spoil runes (2h each), — 6 packs of +50% Exp runes (2h each). Don't miss the chance to start your adventure on Airin!
    • We are certainly not an ambulance, but we will definitely cure you of blacklists and empty pockets. Live freely with SX! Each of you will receive a trial version of SX to familiarize yourself with the product, all you have to do is post in this thread
    • It's also the players' fault, because there have been decent servers implementing some of the things you said plus some other 'innovations', plus many QOL things for newbies (ingame bestiary, with drops searchers, etc). In the end, it's the players who decide to feed into that shit and play the most garbage servers simply because the owners of the servers gave their clan leaders 100 euros, or they insta quit the server because they didn't win the first QA, etc, etc, etc.   In the end, if a server is garbage or great it doesn't really matter if the players don't wanna stay in there.   Players are no better than the devs themselves, in the end it seems there are abusive devs who will milk the shit out of their willingly milkable players, or there are none, goes both ways.
    • In my opinion, L2 is dead because the people who make servers didn’t adapt to today’s reality. People are getting older, life moves faster, there are more responsibilities, and less free time. And I’m not even talking about newcomers—how can you expect someone new to this game to learn by Googling every drop location or quest requirement? These things should’ve been integrated into the game, made accessible with just a few clicks through the interface. Instead, so much time was wasted trying to recreate retail-like features that no one asked for. Everyone hates autofarm, but why? Because admins never found a smart way to implement it. You could have made it available only in specific zones, with reduced drops, working like Adrenaline, or auto-teleporting to farm for a limited time per day—just enough to help people with limited time stay relevant in-game. There should also be zones with better drops, where active farming actually matters. Other features feel pointless—like the Life Stone system. Spamming LS to get a skill? Instead, you could create a system where you level up the skill with low chances per level, something that feels progressive and fair. Crafting should be simpler too. Right-click a recipe, and the required materials should show up right there. As for sieges, why not create daily clan war events at peak hours—one for Europeans, one for Latinos? You could spawn crystals inside or outside castles that give points and trigger PvP. Add a boss during the event that gives even more points, and let the top clan in the ranking take the castle. I could go on forever, but what’s the point? The community died because the people who had the knowledge to improve the game just took the easy way out, copying the same server formula over and over until no one could enjoy playing it anymore.
    • It's not because I'm an admin that he treated me differently. I actually gave him several clients from my side without him even knowing they came from me, and most of them had no issues. I was also waiting 3–4 weeks at times for things I bought from AvE, even when I was in a rush. He still delivered in the end. That said, I'm not defending him blindly. I'm just saying it's unlikely he’d risk scamming someone over 60–100€, especially knowing how quickly word spreads here.
  • Topics

×
×
  • Create New...