Jump to content
  • 0

Message On The Screen After Enchant


Question

Posted (edited)

Is there any way to do that using java to enchant an item leaves a message on the screen saying the chanse of success ?

 

like "you have X% chance to enchant your item"

 

im use l2jServer high five

 

Looking I found that should edit the "RequestExTryToPutEnchantTargetItem.java"

But exactly who should edit to make it work ?

package com.l2jserver.gameserver.network.clientpackets;

import java.util.logging.Level;

import com.l2jserver.gameserver.datatables.EnchantItemData;
import com.l2jserver.gameserver.model.EnchantScroll;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExPutEnchantTargetItemResult;

/**
 * @author KenM
 */
public class RequestExTryToPutEnchantTargetItem extends L2GameClientPacket
{
	private static final String _C__D0_4C_REQUESTEXTRYTOPUTENCHANTTARGETITEM = "[C] D0:4C RequestExTryToPutEnchantTargetItem";
	
	private int _objectId = 0;
	
	@Override
	protected void readImpl()
	{
		_objectId = readD();
	}
	
	@Override
	protected void runImpl()
	{
		L2PcInstance activeChar = getClient().getActiveChar();
		
		if ((_objectId == 0) || (activeChar == null))
		{
			return;
		}
		
		if (activeChar.isEnchanting())
		{
			return;
		}
		
		L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
		L2ItemInstance scroll = activeChar.getActiveEnchantItem();
		
		if ((item == null) || (scroll == null))
		{
			return;
		}
		
		EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
		if ((scrollTemplate == null) || !scrollTemplate.isValid(item))
		{
			activeChar.sendPacket(SystemMessageId.DOES_NOT_FIT_SCROLL_CONDITIONS);
			activeChar.setActiveEnchantItem(null);
			activeChar.sendPacket(new ExPutEnchantTargetItemResult(0));
			if (scrollTemplate == null)
			{
				_log.log(Level.WARNING, getClass().getSimpleName() + ": Undefined scroll have been used id: " + scroll.getItemId());
			}
			return;
		}
		activeChar.setIsEnchanting(true);
		activeChar.setActiveEnchantTimestamp(System.currentTimeMillis());
		activeChar.sendPacket(new ExPutEnchantTargetItemResult(_objectId));
	}
	
	@Override
	public String getType()
	{
		return _C__D0_4C_REQUESTEXTRYTOPUTENCHANTTARGETITEM;
	}
}

Edited by Hyo

11 answers to this question

Recommended Posts

  • 0
Posted (edited)

Problem solved

 

I edit my RequestExTryToPutEnchantTargetItem.java

package com.l2jserver.gameserver.network.clientpackets;

import java.util.logging.Level;

import com.l2jserver.gameserver.datatables.EnchantItemData;
import com.l2jserver.gameserver.model.EnchantScroll;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExPutEnchantTargetItemResult;
++ import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;

/**
 * @author KenM
 */

public class RequestExTryToPutEnchantTargetItem extends L2GameClientPacket
{
	private static final String _C__D0_4C_REQUESTEXTRYTOPUTENCHANTTARGETITEM = "[C] D0:4C RequestExTryToPutEnchantTargetItem";

	private int _objectId = 0;

	@Override
	protected void readImpl()
	{
		_objectId = readD();
	}

	@Override
	protected void runImpl()
	{
		L2PcInstance activeChar = getClient().getActiveChar();

		if ((_objectId == 0) || (activeChar == null))
		{
			return;
		}

		if (activeChar.isEnchanting())
		{
			return;
		}

		L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
		L2ItemInstance scroll = activeChar.getActiveEnchantItem();

		if ((item == null) || (scroll == null))
		{
			return;
		}

		EnchantScroll scrollTemplate = EnchantItemData.getInstance().getEnchantScroll(scroll);
		if ((scrollTemplate == null) || !scrollTemplate.isValid(item))
		{
			activeChar.sendPacket(SystemMessageId.DOES_NOT_FIT_SCROLL_CONDITIONS);
			activeChar.setActiveEnchantItem(null);
			activeChar.sendPacket(new ExPutEnchantTargetItemResult(0));
			if (scrollTemplate == null)
			{
				_log.log(Level.WARNING, getClass().getSimpleName() + ": Undefined scroll have been used id: " + scroll.getItemId());
			}
			return;
		}
		activeChar.setIsEnchanting(true);
		++ double chance = scrollTemplate.getChance(item, null);
		++ activeChar.sendPacket(new ExShowScreenMessage("You have " + chance + "% chance of success!", 3000));
		activeChar.setActiveEnchantTimestamp(System.currentTimeMillis());
		activeChar.sendPacket(new ExPutEnchantTargetItemResult(_objectId));
	}

	@Override
	public String getType()
	{
		return _C__D0_4C_REQUESTEXTRYTOPUTENCHANTTARGETITEM;
	}
}

  :happyforever:

Edited by Hyo
  • 0
Posted

I was wrong about the RequestEnchantItem :lol:

You should send the ExShowScreenMessage with the EnchantScrolls handler which you can find in \data\scripts\handlers\itemhandlers

  • 0
Posted

ExShowScreenMessage.java

package com.l2jserver.gameserver.network.serverpackets;

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

import com.l2jserver.gameserver.network.NpcStringId;
import com.l2jserver.gameserver.network.SystemMessageId;

/**
 * @author Kerberos
 */
public class ExShowScreenMessage extends L2GameServerPacket
{
	private final int _type;
	private final int _sysMessageId;
	private final int _unk1;
	private final int _unk2;
	private final int _unk3;
	private final boolean _fade;
	private final int _size;
	private final int _position;
	private boolean _effect;
	private final String _text;
	private final int _time;
	private final int _npcString;
	private List<String> _parameters;
	
	public ExShowScreenMessage(String text, int time)
	{
		_type = 1;
		_sysMessageId = -1;
		_unk1 = 0;
		_unk2 = 0;
		_unk3 = 0;
		_fade = false;
		_position = 0x02;
		_text = text;
		_time = time;
		_size = 0;
		_effect = false;
		_npcString = -1;
	}
	
	public ExShowScreenMessage(NpcStringId npcString, int position, int time) // For npcstring
	{
		_type = 2;
		_sysMessageId = -1;
		_unk1 = 0;
		_unk2 = 0;
		_unk3 = 0;
		_fade = false;
		_position = position;
		_text = null;
		_time = time;
		_size = 0;
		_effect = false;
		_npcString = npcString.getId();
	}
	
	public ExShowScreenMessage(SystemMessageId systemMsg, int position, int time) // For SystemMessage
	{
		_type = 2;
		_sysMessageId = systemMsg.getId();
		_unk1 = 0;
		_unk2 = 0;
		_unk3 = 0;
		_fade = false;
		_position = position;
		_text = null;
		_time = time;
		_size = 0;
		_effect = false;
		_npcString = -1;
	}
	
	public ExShowScreenMessage(int type, int messageId, int position, int unk1, int size, int unk2, int unk3, boolean showEffect, int time, boolean fade, String text, NpcStringId npcString)
	{
		_type = type;
		_sysMessageId = messageId;
		_unk1 = unk1;
		_unk2 = unk2;
		_unk3 = unk3;
		_fade = fade;
		_position = position;
		_text = text;
		_time = time;
		_size = size;
		_effect = showEffect;
		_npcString = npcString.getId();
	}
	
	public ExShowScreenMessage(int type, int messageId, int position, int unk1, int size, int unk2, int unk3, boolean showEffect, int time, boolean fade, String text, NpcStringId npcString, String params)
	{
		_type = type;
		_sysMessageId = messageId;
		_unk1 = unk1;
		_unk2 = unk2;
		_unk3 = unk3;
		_fade = fade;
		_position = position;
		_text = text;
		_time = time;
		_size = size;
		_effect = showEffect;
		_npcString = npcString.getId();
	}
	
	/**
	 * String parameter for argument S1,S2,.. in npcstring-e.dat
	 * @param text
	 */
	public void addStringParameter(String text)
	{
		if (_parameters == null)
		{
			_parameters = new ArrayList<>();
		}
		_parameters.add(text);
	}
	
	@Override
	protected void writeImpl()
	{
		writeC(0xFE);
		writeH(0x39);
		writeD(_type); // 0 - system messages, 1 - your defined text, 2 - npcstring
		writeD(_sysMessageId); // system message id (_type must be 0 otherwise no effect)
		writeD(_position); // message position
		writeD(_unk1); // ?
		writeD(_size); // font size 0 - normal, 1 - small
		writeD(_unk2); // ?
		writeD(_unk3); // ?
		writeD(_effect ? 1 : 0); // upper effect (0 - disabled, 1 enabled) - _position must be 2 (center) otherwise no effect
		writeD(_time); // time
		writeD(_fade ? 1 : 0); // fade effect (0 - disabled, 1 enabled)
		writeD(_npcString); // npcString
		if (_npcString == -1)
		{
			writeS(_text); // your text (_type must be 1, otherwise no effect)
		}
		else
		{
			if (_parameters != null)
			{
				for (String s : _parameters)
				{
					writeS(s);
				}
			}
		}
	}
	
	public ExShowScreenMessage setUpperEffect(boolean value)
	{
		_effect = value;
		return this;
	}
}

Itemhandler

package handlers.itemhandlers;

import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ChooseInventoryItem;

public class EnchantScrolls implements IItemHandler
{
	@Override
	public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
	{
		if (!playable.isPlayer())
		{
			playable.sendPacket(SystemMessageId.ITEM_NOT_FOR_PETS);
			return false;
		}
		
		final L2PcInstance activeChar = playable.getActingPlayer();
		if (activeChar.isCastingNow())
		{
			return false;
		}
		
		if (activeChar.isEnchanting())
		{
			activeChar.sendPacket(SystemMessageId.ENCHANTMENT_ALREADY_IN_PROGRESS);
			return false;
		}
		
		activeChar.setActiveEnchantItem(item);
		activeChar.sendPacket(new ChooseInventoryItem(item.getItemId()));
		return true;
	}
}

  • 0
Posted (edited)

What's the point of those files? Add your code after

activeChar.sendPacket(new ChooseInventoryItem(item.getItemId()));

@ EnchantItem, so you will see the msg after pressing the scroll. It's 0.8 cuz on aCis the value is double ;)

 

75d2zGA.png

Edited by SweeTs
  • 0
Posted

Something like this..

activeChar.sendPacket(new ExShowScreenMessage("You have " + Config.ENCHANT_CHANCE_WEAPON + "% chance of success!", 6000));

Also put a check for the enchant type.. note that if you have different chances for armor and jewels, you should send the chances of the two types, because it doesn't recognize what you want to enchant :)

  • 0
Posted (edited)

i edit my itemhandlers/enchantscroll.java

package handlers.itemhandlers;

import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
+ import com.l2jserver.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ChooseInventoryItem;

public class EnchantScrolls implements IItemHandler
{
	@Override
	public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
	{
		if (!playable.isPlayer())
		{
			playable.sendPacket(SystemMessageId.ITEM_NOT_FOR_PETS);
			return false;
		}
		
		final L2PcInstance activeChar = playable.getActingPlayer();
		if (activeChar.isCastingNow())
		{
			return false;
		}
		
		if (activeChar.isEnchanting())
		{
			activeChar.sendPacket(SystemMessageId.ENCHANTMENT_ALREADY_IN_PROGRESS);
			return false;
		}
		
		activeChar.setActiveEnchantItem(item);
		+ activeChar.sendPacket(new ExShowScreenMessage("You have " + Config.ENCHANT_CHANCE + "% chance of success!", 6000));
		activeChar.sendPacket(new ChooseInventoryItem(item.getItemId()));
		return true;
	}
}

Note: i use the same enchant chance for armors,weaps and jewels.

 

And i take this error in the gameserver console :(

post-133835-0-67961600-1421514814_thumb.jpg

Edited by Hyo
  • 0
Posted (edited)

Import also the Config class..

 

Ok, now are found... but the message leave when i use the scroll.. i want to message leave when i put the item

 

can understand me?

 

My custom enchant config

<enchant id="959" isBlessed="true" targetGrade="s">
		<!-- Custom Progressive enchant system uncomment the lines below to enable. -->
		<step level="1" successRate="100.00" />
		<step level="2" successRate="100.00" />
		<step level="3" successRate="100.00" />
		<step level="4" successRate="80.00" />
		<step level="5" successRate="75.00" />
		<step level="6" successRate="70.00" />
		<step level="7" successRate="65.00" />
		<step level="8" successRate="60.00" />
		<step level="9" successRate="55.00" />
		<step level="10" successRate="50.00" />
		<step level="11" successRate="45.00" />
		<step level="12" successRate="40.00" />
		<step level="13" successRate="35.00" />
		<step level="14" successRate="30.00" />
		<step level="15" successRate="25.00" />
		<step level="16" successRate="20.00" /> 
	</enchant>
Edited by Hyo
Guest
This topic is now closed to further replies.


  • Posts

    • I have a highly customized Hi5 pack based on L2JMobius with a lot of features for performance and modern game design. Disclaimer: I do not run any public server, but I run a "private" server for a group of 10 friends and about 2000 AI bots that required me to do heavy modifications on core systems of the game.  So my opinion will obivously be biased towards L2JMobius.   What I can tell you though without bias is: Most of the features you are asking for are nowadays considered de-facto, don't pay money for them. TvT, offline mode, community boards, premiums, vote rewards are in most packs including the open source ones. So before you pay a thousand plus euro for a pack ask yourself what you are paying that money for, that open source packs don't have.   Also a lot of the "strong points" some old packs were made for are nowadays obsolete. L2JFree derived packs for example used to have a lot of GC optimizations (Trove library) which are not not maintained, but most importantly not needed cause Java has evolved a lot since then and the performance issues these tricks tried to solve back then, are currently solved by Java's JVM itself. So if someone tries to sell you packed / unpacked integers in special hashmap data structures and other such things know that they have really lost their value nowadays.    A lot of people are selling thin air, things that everyone has. "Quality geodata" being one of them. I mean what's "quality geodata" ? Has someone painted them by hand ? Hell there's an online tool for free in github that extracts quality geodata, I think Galagard made it ? In contrast I'll tell you without wanting to boast about it that I use 3D navmesh on my project because 2000 bots could not pathfind large distances on A* on geodata. As far as I know, L2JMobius has it in its subscription version too. So if I could do an acceptable transition to navmesh from geodata in a week alone, I would assume that a decent pack with dedicated developers could do it better and faster. Red flag if someone still tries to sell you geodata in 2026.   Multi-protocol support gives small value and is a high risk.   I would not go for multi-protocol support for a public server cause you are locking yourself to specific providers and the functionality they support. If you need to change (eg pricing issues), you will be locked to a handful of providers. And what are you really gaining from a new client on an old game version ? Better UI ? The engine is still the same, static targeting and menus.    Agentic AI will make old hard features easy to implement, and drop their money value. Pay for AI-proof value. And compared to what most insecure devs claim, its a very powerful tool that allows those who know how to use it to accelerate their development. So a lot of features that took in the past a lot of time and effort to be developed and were a reason to charge money, are becoming a commodity today. So think to: The thing I am paying money for right now, how easy will it be to implement in a year from now ? If for example you are paying money for a game launcher that Claude Code can generate in top 1 hour without issues, I think you are wasting money.    I want to emphasise this a lot. Software engineering is in a transition atm. Most things that were mediocre to implement, launchers, guards, CMS, are nowadays easy. Yet the dev community continues to market them as premium content. They are not, sooner or later, when everyone starts selling them, they will realize that they will have to offer value in more complex features.  Private or public ? Bottom line is that a private pack and 1000 euro wont get you a sucessful server. You're the one that make it or break it. There have been many sucessful servers both in private packs and public packs in the past. It's really on the hands of the beholder, not on the source. A pack that plays good is a good indicator to buy as Trance said, but I would disagree that it's not enough. A server owner is not a player. He's a business man and has to account for longevity, vendor lock-in, expandability, hidden costs,  amortization, price changes and many more. Don't pick a pack based on how it played only.    
    • You don’t even need to look for a ghost project. Just buy the files from a project you’ve personally tested or played. That’s a much better starting point.
    • 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
    • You have to put deep inside your pocket for something like this, for sure 😄
    • Hello everyone, I'm looking for a High Five Java server pack for a long-term project. I'm not looking for free packs. I'm interested in purchasing a professional pack with full source code if it's worth the investment. My priorities are: Stable core Clean and well-structured source code Good geodata and AI Modern Community Board Offline Trade / Offline Craft Premium Account system Vote Reward system Auto Events (TvT, CTF, DM, etc.) HWID protection Auto Farm  Buffer / QoL systems Modern admin tools Good Olympiad & Seven Signs implementation Excellent instance support (Freya, Frintezza, Zaken, Beleth, etc.) A huge bonus would be: Multi-protocol support (High Five + newer clients such as Salvation/Classical clients) Full source code (no closed binaries) Some custom things over Elegia At the moment I'm considering packs like Sunrise and L2-Scripts, but I'd really like to hear opinions from people who have actually worked with them. If you've been running a serious High Five project, I'd appreciate your honest feedback: Which pack are you using? What are its strengths and weaknesses? Would you buy it again? Are there any better alternatives available today? I'm looking for real experience rather than advertisements. Thanks!
  • 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..