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

    • Long story short, I love survivor-like games, so I made a standalone game in the style of Vampire Survivors. It's called Survivors of Lineage (because ofc it is). I think it's very fun even though I kinda suck at it, so give it a go and tell me what you think.   Video   Play online (mobile works too): https://sol.fermata.gg/ Download the desktop version (Windows & Mac): https://updates.fermata.gg/ It includes: 26 heroes, from Lineage 2 classes to raid bosses you can play as: Baium, Antharas, Valakas, Zaken, Queen Ant, Scarlet van Halisha and more. Each has its own signature skill, trait, and evolution. 42 weapons built on L2 skills (Hydro Blast, Aura Bolt, Might of Heaven, Sword Symphony, Wild Hog Cannon...), each with an empowered cast and an evolution. 8 maps, from the Coliseum and Cruma Tower to the Tower of Insolence, Antharas' Lair, Valakas' Lair and the Imperial Tomb, each with its zone's monsters and four raid bosses. Easy, Medium and Hard on every map, and an endless mode once you've won. The Armory: spend your Adena on permanent power-ups, unlock heroes, weapons and maps through feats, and dress your hero in armor and weapon looks that climb the grades. Leaderboards for every map, difficulty and hero, plus daily and weekly runs where everyone plays the same seed. Options to tone it down when the screen gets busy: fewer skill effects, damage numbers on crits only (or off), no screen flashes. It should take about 15-20 hours to max out the main power-ups and about 150 hours to finish everything (based on my simulations; I could be way off). Controller support is coming. It's completely free, with no ads and nothing to buy. Feedback is very welcome, especially on balance. No affiliation with Lineage 2 or NCSoft; I made it to keep myself busy while my agents do stuff, and I wanted to share it.  
    • Progressive Voting System for Lineage II       After spending some time developing and testing this system on my own server, I have decided to release it and share it with the community. It is specifically designed for Lineage II servers that want to encourage daily voting on server ranking websites in a clean, secure, and visually appealing way.     What Does This System Do?   Unlike traditional voting systems where users can see all voting buttons and click on any of them, this system uses a progressive unlocking sequence:   The player logs in using their in-game account. Only the [b]first voting site[/b] is initially available. After voting on the current site, the system polls for updates in real time and [b]automatically unlocks the next one[/b] without reloading the page. Once all voting sites in the list have been completed, the [b]claim reward[/b] button becomes available, allowing the player to receive the reward directly in their character's inventory.     Main Features     Lineage II-Style Interface: Completely redesigned UI featuring a gold, brown, and dark color palette inspired by the game's classic interface. Automatic Multilingual Support: Native support for English, Spanish, Portuguese, and Russian. The system detects the browser language automatically, and users can switch languages using the flag selector. Anti-Fraud System: Configurable reward limits per IP address (for example, a maximum of 7 rewards every 12 hours). Only actual rewards are counted, not voting clicks. Configurable Timers: Set the number of seconds users must wait between voting sites to prevent abuse. Global Monthly Counter: Displays the total number of votes received by the server during the current month, with a configurable automatic reset. Secure Item Delivery: Configure direct delivery through the database (Direct) or through GM commands via Telnet. Strong Security: CSRF protection, secure sessions, restricted subdirectories using .htaccess, external configuration through config.properties, and no external dependencies (Composer is not required).     How to Install   Installation is straightforward and designed to be accessible to anyone with basic technical knowledge:   Upload the files to your web hosting. Configure your database connection details in config.properties. Import install.sql into your database (this creates the l2votesystem_* tables). Configure a Cron Job to run every minute. That's it!   Requirements:   PHP 8.1+, MySQL, Apache (with mod_rewrite).     Screenshots                 Download and Source Code   The project is open source and available on GitLab, allowing everyone to review the code, use the system, or contribute improvements.   https://gitlab.com/L2JDevs/L2VoteSystem   If you find this project useful, please consider giving the repository a Star. It helps others discover the project and supports its continued development.[/i]   Feedback and Support   I have tried to keep the code as clean and maintainable as possible, but there is always room for new features, such as proper GTOP100 callbacks, a ranking system, Discord integration, and more.   If you have any suggestions, encounter a bug, or would like to contribute, feel free to reply to this thread or open an issue on GitLab.   I hope this system proves useful for your Lineage II servers!
    • Opening Closed BETA for discord members today!  Join us! https://discord.gg/bfnXPuEuD
  • 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..