Jump to content

Recommended Posts

Posted (edited)

Hello guys. Last night i found some time to spend in Lineage coding. After a while i decided that i would like to share something with you but i didn't know what, so i figured that there is not a .combinetalismans command shared. I know it is not something special, or hard to do, but since it hasn't been shared before, why not? :) It is coded for L2J HighFive but it can easily be adapted for any pack.

 

I will give full guide on how to install it, in order to avoid future posts like "i have this error" or "how do i fix that?" and bla bla.

 

It is very easy to install it. You need to make small changes to core and add a new .java file to your datapack. Read the steps below:

 

1. Head to com.l2jserver.gameserver.model.items.instance.L2ItemInstance and add the following lines anywhere to your code (just not in any other method).

 

 

/**
  * Method used by .combinetalismans.
  * @param value
  */
public void setMana(int value)
{
  _mana = value;
}

 

 

2. Create  CombineTalismans.java file to game\data\scripts\handlers\voicedcommandhandlers and add the following code in it.

 

 

/*
* Copyright © 2004-2017 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package handlers.voicedcommandhandlers;

import java.util.ArrayList;
import java.util.List;

import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.serverpackets.ItemList;

/**
* @author Solomun
* @see www.MaxCheaters.com
*/
public class CombineTalismans implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
{
  "combinetalismans"
};

@Override
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String args)
{
  List<int[]> _sameIds = new ArrayList<>();
 
  for (L2ItemInstance item : activeChar.getInventory().getItems())
  {
   // Getting talisman
   if ((item.getMana() > 0) && item.getName().contains("Talisman"))
   {
    addTalisman(_sameIds, item.getId());
   }
  }
  int newCount = 0;
  for (int[] idCount : _sameIds)
  {
   // Item Count > 1
   if (idCount[1] > 1)
   {
    int lifeTime = 0;
    List<L2ItemInstance> existingTalismans = activeChar.getInventory().getItemsByItemId(idCount[0]);
    for (L2ItemInstance existingTalisman : existingTalismans)
    {
     // Take remaining mana of this talisman.
     lifeTime += existingTalisman.getMana();
     // Destroy all talismans from this ID.
     activeChar.getInventory().destroyItem("Combine Talismans", existingTalisman, activeChar, null);
    }
   
    L2ItemInstance newTalisman = activeChar.addItem("Combine talismans", idCount[0], 1, null, false);
    // Add the total mana to the new talisman.
    newTalisman.setMana(lifeTime);
    // store in DB
    newTalisman.updateDatabase();
   
    newCount++;
   }
  }
 
  if (newCount > 0)
  {
   activeChar.sendMessage("You have combined " + newCount + " talismans.");
   activeChar.sendPacket(new ItemList(activeChar, false));
  }
  else
  {
   activeChar.sendMessage("You don't have Talismans to combine!");
  }
  return true;
}

private static void addTalisman(List<int[]> sameIds, int itemId)
{
  for (int i = 0; i < sameIds.size(); i++)
  {
   if (sameIds.get(i)[0] == itemId)
   {
    sameIds.get(i)[1] = sameIds.get(i)[1] + 1;
    return;
   }
  }
  sameIds.add(new int[]
  {
   itemId,
   1
  });
}

@Override
public String[] getVoicedCommandList()
{
  return VOICED_COMMANDS;
}

}

 

 

3.(Final Step) Add the following(yellow) lines to game\data\scripts\handlers\MasterHandler.java

 

 

import handlers.voicedcommandhandlers.StatsVCmd;
import handlers.voicedcommandhandlers.CombineTalismans;
import handlers.voicedcommandhandlers.Wedding;

.

.

.

(Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null),
   CombineTalismans.class,

 

 

 

If you have any problems involving this to your pack, send me a private message and i will answer it as fast as i can in order to help you.

Edited by Solomun
Posted

Topic updated. I forget to involve the import in MasterHandler.java.

 

import handlers.voicedcommandhandlers.StatsVCmd;
+import handlers.voicedcommandhandlers.CombineTalismans;
import handlers.voicedcommandhandlers.Wedding;

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

    • Where's the proof? I can tell you're a scammer.
    • Where was I called a scammer? Is there any proof, etc.? There are a lot of reviews about our store online, etc. https://zhyk.org/forum/showthread.php?t=1108673
    • U was reported as scammer in your previos topic why u create new topic?
    • 🔍 Inventory 1.0 is a next-generation inventory system that stands out with its special minimal clothing system. Carefully designed and prepared according to the highest standards of your server, it not only enhances your gaming experience but also contributes to your server's infrastructure. ⚙️ Supported: QB-CORE Features: ✅ Instant Delivery: All products you purchase will be instantly assigned to your account as soon as your payment is completed. ✅ Clothing System: With the special animated clothing configurations in your inventory, you will be able to change outfits with ease. Experience a unique roleplaying experience with high-quality animations and customizable clothing options. ✅ Minimalist Inventory System: This inventory system, with its visuals, animations, and mechanics, offers maximum efficiency without overwhelming your screen and limiting your roleplaying experience. It’s designed to be user-friendly while enhancing your roleplaying experience. ✅ Continuous Updates: The content in the inventory is regularly updated with innovative features added. New animations, additional clothing options, and cutting-edge features ensure a fresh and dynamic experience. ✅ Easy Setup and Compatibility: Compatible with QB-CORE, this system is easy to install and optimized for quick integration into your server. It works seamlessly with a simple drag-and-drop method. ✅ Performance Optimization: The system is optimized to avoid low FPS and performance drops. All features of the inventory run smoothly without affecting your server’s performance. ✅ Multilingual Support: With support for different languages, you can cater to an international player base and build a larger community on your server. ✅ Flexible Customization Options: You can fully customize the inventory according to your needs and server rules. Choose between different outfits and animations to create a unique gaming experience. ✅ Comprehensive Help and Support: With 24/7 support, you can quickly resolve any issues you encounter. Our technical support and user guides are always here to assist you. Shop Now! Take your game to the next level with Inventory 1.0  and enjoy its unique features. Get ready to make a real difference in your roleplaying experience!   --------------------------TEBEX: https://matza.tebex.io/package/7174862 --------------------------
  • Topics

×
×
  • Create New...

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