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

    • Dear MaxCheaters Community,   It is disappointing to see the project being dismissed before there is a clear understanding of the work, planning, and vision behind it.   Other communities, such as the Russian and Brazilian Lineage II communities, often support their projects and help them grow. I believe the European community would benefit from adopting the same constructive and supportive approach.   We are not asking anyone to believe in promises alone. We will let our work, progress, and results speak for themselves. Actions speak louder than words. Thanks in advance. -MightyProject Founder
    • 🎙️ Mod de Voz Dev — A.L.N ModVozALN • Sistema de Voz por Proximidade para Lineage II Instalador Gráfico para Launchers L2J • v1.9.44 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🚀 O que é O ModVozALN.exe instala automaticamente o sistema completo de voz por proximidade em sua pack L2J, sem necessidade de alterar o código-fonte da revisão. ✅ Recursos ✔️ Não altera arquivos .java (Bridge via Java Agent) ✔️ Não modifica a Engine.dll (cliente utiliza L2VoiceInject.exe) ✔️ Funciona mesmo sem acesso ao source da revisão ✔️ Instalação automatizada em poucos cliques 🎮 Atalhos INSERT → Abre o painel de voz Segure H → Conversa por proximidade ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🖥️ Launchers 🎤 L2VoiceServer.exe Servidor de voz com interface gráfica e monitor de logs. ⚙️ L2GameServer.exe Inicializa o GameServer com o Java Agent automaticamente. ⏳ O GameServer aguarda automaticamente o Voice Server na porta TCP 17667 antes da inicialização. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✨ Principais Recursos 📁 Estrutura organizada 📂 Game 📂 Libs 📂 Voice 📂 System 🔍 Detecção automática de revisões aCis L2jMega L2jMobius L2jFrozen L2Off BrProject Custom ⚙️ Geração automática 📄 gs-voz-launch.cfg 📄 Arquivo .bat ☕ Main Class correta 📦 Bibliotecas adicionadas l2voice-bridge.jar Jedis 🔎 Localização automática do Java Busca o JDK em todos os discos e instalações conhecidas. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ☕ Compatibilidade Java (JDK) Utilize sempre o mesmo JDK exigido pela sua revisão. Revisão JDK BrProject / ext.mods 25 L2jMega / L2JALN 17–21 aCis / RusaCis 11–17 L2jMobius 17–21 L2jFrozen 8–11 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔎 Busca Automática do Java (v1.9.44+) O instalador procura automaticamente o java.exe em: 💿 Todos os discos (C:, D:, E:...) 📁 Program Files / Java Eclipse Adoptium Microsoft JDK Amazon Corretto JAVA_HOME Pastas da própria pack (Game, Libs e raiz) O caminho encontrado é salvo em: Game\gs-voz-launch.cfg ✅ Não é necessário editar o set-java.bat. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚠️ UnsupportedClassVersionError Exemplo 69.0 vs 55.0 ✔️ Solução Instale o JDK compatível com sua revisão. Reinstale utilizando o ModVozALN v1.9.44 ou superior. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🎥 Vídeo de Demonstração 📺 https://www.youtube.com/watch?v=8aJMy08o8so&t=7s ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📥 Download 💻 Projeto https://github.com/ALN2025/ModVozALN 📦 Executável https://github.com/ALN2025/ModVozALN.exe 📄 Consulte também o arquivo VERSION.txt Versão Atual: v1.9.44 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📋 Instalação 1️⃣ Extraia o ModVozALN.zip 2️⃣ Execute ModVozALN.exe 3️⃣ Informe as pastas: 📂 Game 📂 Libs 📂 Voice 📂 System 4️⃣ Clique em Instalar ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ▶️ Ordem de Inicialização Redis ↓ Login Server ↓ L2VoiceServer.exe ↓ L2GameServer.exe ↓ L2VoiceInject.exe ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔥 Firewall (VPS) 🌐 UDP: 17666 🌐 TCP: 17667 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 👨‍💻 Desenvolvido por Dev ⩿ A.L.N/⪀ 🌍 scriptclean.com.br
  • 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..