Jump to content

[SHARE] Java NPC Buffer


Recommended Posts

        • First of all, I apologize if this has been posted previously, I couldnt find another thread after several searchs.
           
          Ok, this is my own npc buffer I coded long time ago. I was downloaded more than 2k times in l2j forums so I guess it is interesting :P
           
          It has several adds to any other common buffer. Whole information and feedback can be found here:
http://l2jserver.com/old-forum/thread.php?threadid=28853&page=1
 
This is a quotation of my own words:
 
Despite in lastest core revs, a core buffer has been committed as a mod I wanna share my own core buffer which works quite different from vanilla's. I have not tested vanilla's actually, but I think this add some interesting feature (based on irc comments).
 
 
Feature
 
  • Each player defines a personal buff scheme (aka pbs), that stores a list of skills. Then, when a player is about to receive his buffs, he will only have to press a button and all buffs' effects will be casted to him.
     
    This avoids wasting time choosing new buffs each time player dead. Obviously this increases performance to due to a considerable reduction at request bypass packets and their effects.
     
  • Admins can (and actually should) sort skills in different groups so that handling with pbs become easier. Adding skills is a very easy task, just an update sentence to database. This provide real-time modifications on available skills
     
  • Players will NOT loose their pbs on crashes, client restart, client exit or even server shutdown/restart. All pbs are stored in database.
     
  • Players can save more than one pbs (since rev3)
     
  • PBS are defined in real time in the same npc by each player using a framed interface that makes this really easy
     
  • Effects are given calling method getEffects(args), so there is no MP consumption or any kind of restriction as a consequence of using useMagic(args).
     
  • Effects can be casted to your pet too (since rev2)
     
  • Admin command to reload skills (since rev3)

 

Programming info

 

  • Code has been writen to achive these three objectives:
    1. Prevent database accesses
    2. Prevent packet's broadcasting
    3. Do not bleed vanilla code

    That is because in case this is committed, it would be as a mod and not bleeding code too much makes easier further improvements/updates for the system and for the rest of the code. Obviously preventing database access and packet's broadcasting are done so that general performance is not decreased.

     

    [*]There are three new class (files):

    1. BufferSkillsTable: a class to store info about available skills. Reads info from database (only at server startup) and stores skills' data sorted by groups
    2. CharSchemesTable: this class handles player <-> memory <-> database interactions. Loads pbs when player enters world and save pbs into database when at server shutdown.
    3. L2BufferInstance: finally this class handles player bypassrequestings: getting buffs, editting pbs, clearing pbs.

     

    [*]About external code: Config.java, EnterWorld.java, GameServer.java, Shutdown.java are the only ones editted files.

     

    [*]Due to "do not bleed vanilla code" and to provide a functional interface to interact bewteen pbs, some tasks are working in an "different" way, I hope general performance is not decreased.

     

    [*]There are some javadoc comments to help code understanding

 

Datapack side info

  • SQL. There are two new tables:
    1. mods_buffer_skills: this table stores info about available skills for npc buffer in four fields: id (skill id, primary key), level (skill level), skill_group (group of the skill) and adena (cost in adenas). Please notice that no null field is allowed
    2. mods_buffer_schemes: this table stores character's pbs. It contains three filds: ownerId (char object id), id (skill id) and level (skill level) and it works like character_skills or merchant_buylist

    [*]SQL. New NPC in npctable. Spawns are your work :P

     

    [*]HTML. Only two new files for giving support to core at .../data/html/custom/buffer/ (maybe I can remove this and hardcode it...)

 

Admin's step by step guide xD

  • First of all install core patch and get it compiled
  • Secondly execute datapack patch so new tables and new NPC are saved into your database.
  • Finally is time to introduce info to mods_buffer_skills and set which skills are available for players, set groups, etc. I  provide a default package with some skills but you'd better do by yourself. There are some restrictions and advices:
    1. Do not use "default" as a type
    2. Do not leave any field as null
    3. Do not overload one group with too many skills. This would decrease performance (the more skills are in a group, the larger is the iteration over it).

    [*]Now save info and restart your server (admin command to reload this table is not done yet)

    [*]Log in and spawn a new L2BufferInstance, default: "//spawn House" or "//spawn 90000"

    [*]Test and edit your pbs :)

 

"To Do" feature list

  • Make this configurable Done in rev. 2
  • Creating some admins command to handle adding and removing skills from available skill list so that can be modified or even build in real time with a friendly interface (similar to merchant_buylist) Partially done in rev. 3
  • Adding some system messages to inform users. Done in rev. 3
  • Adding some info to log
  • Support for adena reduction, for now ther isn't any kind of fee or cost :DDone in rev. 3
  • Some esthetical changes for general interface Done in rev. 2
  • Add default stuff so lazy admins don't have to work :P Done in rev 2.

 

I have tested this in local, not in a live server so I have no info about performance. (However my high rates server has been working with a very similar system (based on this) for more than 4 moths and we have not found any problem. When I have some free time I will add missing feature from TODO list, specially if you like this.

 

Please, feel free of reportting back any kind of impressions, bugs, etc. I need feedback to improve this.

 

Version history

  • Rev 1. Initial work
  • Rev 2.
    1. Fixing some "typpo" bugs.
    2. Added new feature: now you will be able to buff your pet
    3. System is now configurable at l2jmods
    4. Fixing some esthetical issues
      [/list=a]
    5. Rev 3.

      1. Multiple scheme system fully implemented
      2. Some changes in general menu
      3. Some changes in edit scheme interface
      4. Max schemes per player configurable
      5. Max skills per scheme configurable
      6. Saving schemes to DB configurable
      7. Support for handling adena fee: by SQL or at config
      8. Admin command to reload NPC BufferSkillsTable
      9. Initial support for change skills available per group using admin commands (shift click npc and you'll see)
      10. Partial rewrite of L2BufferInstance.java to highly improve performance (do not set full collections anymor or duplicate into a local variable to handle)
      11. Commenting out L2BufferInstance.java class so that ca be easily understood
      12. Moving dp html to data/html/mods/buffer
      13. Changes in SQL datatables
        [/list=a]

     

    To upgrade to rev 3, be carefull due to new html paths and changes in SQL tables (I strongly recommend full rebuild)

     

    Yeah... many things can be improved, I did it before I joint dev team (I had free time to develop stuff like this ;D) . I promised community a new release but I didnt have a chance to work on it yet :P possibly on next L2J release I will try to improve it and put it on a item too.

     

    Hope you like it  ;D

     

    Download link: http://www.megaupload.com/?d=F8WW2PA5

     

    PS: Moving it to l2jfree/l2emu/l2j**** or any revision should be really easy

     

     

Link to comment
Share on other sites

thats why the old l2j forum is still impressive :D

 

yeh +1 xD

 

nice share mate. thnx

 

but just a question... you are DrHouse From L2JForums?

Link to comment
Share on other sites

yeh +1 xD

 

nice share mate. thnx

 

but just a question... you are DrHouse From L2JForums?

 

yes he is L2J invades Maxcheaters :D

Link to comment
Share on other sites

House would you mind attaching some Screenies to it ?

Haven't actually tested it nor read its source, but based on your Features List and our Member's feedback seems to be a great buffer.

Link to comment
Share on other sites

House would you mind attaching some Screenies to it ?

Haven't actually tested it nor read its source, but based on your Features List and our Member's feedback seems to be a great buffer.

 

you naapie dont tell me you dont know the scheme buffer :P

Link to comment
Share on other sites

you naapie dont tell me you dont know the scheme buffer :P

Not this one I guess, I use one that savor made. Love him, he always shares everything (Except for my work from our SVN :o).

Link to comment
Share on other sites

Main screen

http://img23.imageshack.us/i/shot00001bfw.jpg/

 

First of all you have to create an scheme in "manage my schemes" (I created a new one called MaxCheaters)

http://img23.imageshack.us/i/shot00002yvo.jpg/

 

Now go to "edit my schemes". An NpcHtmlMessage similar to this one will appear, with the groups the admin had defined. Click on the scheme you want to edit (MaxCheaters)

http://img166.imageshack.us/i/shot00003d.jpg/

 

Click on any group

http://img23.imageshack.us/i/shot00004ihm.jpg/

 

Start adding skills from any group by clicking on them. You'll notice a new list in the end with the skills you have already choosen

http://img166.imageshack.us/i/shot00005n.jpg/

http://img404.imageshack.us/i/shot00006t.jpg/

http://img404.imageshack.us/i/shot00007l.jpg/

 

Finally go back to main screen and select either buff to you or your pet. Then choose the scheme and you'll have all the buffs for you or your pet

http://img401.imageshack.us/i/shot00008x.jpg/

 

PS: Weird... guys you made me work :P

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.



×
×
  • Create New...