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

    • Migrating a legacy Interlude server to PostgreSQL while adding real observability is basically forcing 2006 MMO engineering to attend a 2026 infrastructure conference at gunpoint. PS: which revision of aCis? PS: 🧻what was broken during this whatever you call it.    AAC Guard beign asked to adapt to this be like: - Creating bugs since early 2018
    • OH MY LORDDDDDDDDDDDDDDDDDDDDD   FINALLY
    • TG Support: https://t.me/buyingproxysup | Channel: https://t.me/buyingproxycom Discord support: #buyingproxy | Server: Join the BuyingProxy Discord Server!  Create your free account here
    • I came out of my cave as I do once every 5 years. By now, I know nobody really cares about L2, but I still find it fun to experiment. Everything you see here will be free and open source. I have no interest in selling anything.   Long story short, I like to revisit Interlude and apply what I've learned to see how far I can push it. Here's Outerlude, a public fork of aCis for the modern age.   Video demo:   Work that has been done:   Redone the netcode from scratch to be async The NPC AI was completely redone based on Finite State Machines Moved to PostgreSQL and using some of its cool features Lots of config that should be hot reloadable has moved to the database OpenTelemetry instrumentation, where it makes sense, and a Grafana dashboard A built-in REST API for server management A built-in MCP Server for LLMs Nidrah AI, an AI Agent to make managing the server easier Real-time server map view Chat auditing and live snooping A new Fake Players Engine with a Node logic system and a new LLM planner for any behavior Just watch the video   If there is interest in this and I'm happy with it, or I get bored (which I always do), I will open-source it. Let me know what you think and if there is some feature you'd like me to implement.
  • 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..