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

    • 黑色星期五 — 为您的流量提供高级福利 仅在11月28日,我们的特别促销码可为您提供13%的商店折扣。 促销码: BLACKFRIDAY (13% 折扣) 您可以通过我们的网站或 Telegram 机器人在商店购物! 有效链接: 数字商品商店(网站): 前往 商店 Telegram 机器人: 前往 – 通过 Telegram Messenger 方便访问商店。 其他服务: 虚拟号码服务: 前往 用于购买 Telegram Stars 的机器人: 前往 – 快速且优惠地在 Telegram 中购买 Stars。 SMM 面板: 前往 – 推广您的社交媒体账户。 我们向您呈现当前的 促销和特惠活动 列表,用于购买我们服务的产品和服务: 1. 您可以在首次购买时使用促销码:SOCNET(15% 折扣) 2. 获取 $1 商店余额或 10–20% 折扣 — 只需在我们网站注册后发送您的用户名,格式如下:“SEND ME BONUS, MY USERNAME IS...” — 您需要在我们的论坛帖子中写下这句话! 3. SMM 面板首次试用可获得 $1:只需在我们的网站(支持)提交主题为“Get Trial Bonus”的工单。 4. 我们的 Telegram 频道和 Stars 购买机器人每周都会举办 Telegram Stars 抽奖活动! 新闻: ➡ Telegram 频道: https://t.me/accsforyou_shop ➡ WhatsApp 频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord 服务器: https://discord.gg/y9AStFFsrh 联系方式与支持: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ 邮箱: solomonbog@socnet.store
    • BLACK FRIDAY — PREMIUM BENEFITS FOR YOUR TRAFFIC Only on November 28 our special promo code gives you a 13% discount in the store. PROMO CODE: BLACKFRIDAY (13% Discount) Shop in our store on the website or via the Telegram bot! Active links: Digital goods store (Website): Go Store Telegram bot: Go – convenient access to the store via Telegram messenger. Other services: Virtual numbers service: Go Telegram bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We want to present you the current list of promotions and special offers for purchasing our service's products and services: 1. You can use a promo code for your first purchase: SOCNET (15% discount) 2. Get $1 to your store balance or a 10–20% discount — just send your username after registering on our website using the following template: "SEND ME BONUS, MY USERNAME IS..." — you need to write this in our forum thread! 3. Get $1 for the first trial start of the SMM Panel: just open a ticket with the subject "Get Trial Bonus" on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our bot for purchasing stars! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Usually, I work alone on my projects, but sometimes the work is much more than I've expected. Could you provide a price list? It would be good if we knew your price before contacting you. 
    • BLACK FRIDAY — PREMIUM BENEFITS FOR YOUR TRAFFIC Only on November 28 our special promo code gives you a 13% discount in the store. PROMO CODE: BLACKFRIDAY (13% Discount) Shop in our store on the website or via the Telegram bot! Active links: Digital goods store (Website): Go Store Telegram bot: Go – convenient access to the store via Telegram messenger. Other services: Virtual numbers service: Go Telegram bot for purchasing Telegram Stars: Go – fast and profitable purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We want to present you the current list of promotions and special offers for purchasing our service's products and services: 1. You can use a promo code for your first purchase: SOCNET (15% discount) 2. Get $1 to your store balance or a 10–20% discount — just send your username after registering on our website using the following template: "SEND ME BONUS, MY USERNAME IS..." — you need to write this in our forum thread! 3. Get $1 for the first trial start of the SMM Panel: just open a ticket with the subject "Get Trial Bonus" on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our bot for purchasing stars! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts and Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • wtf are you talking about
  • 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