Jump to content
  • 0

Shadow Items Modifying.


raF

Question

Hello cheaters. I want to make shadow items expiring even if player is offline or doesnt wear them. 

 

1. Make counter start when player obtain the item, not when equip it.

 

2. Remove all checks that can stop the task.

    Tryskell:  If you speak of aCis, try dropping all ShadowItemTaskManager.getInstance().remove( method calls, and ShadowItemTaskManager onUnequip( content. Basically said,                      what you want is one time you put the item, the counter continue no matter what.

 

3. Keep counting when player is offline (db storage).

Edited by raF
Link to comment
Share on other sites

Recommended Posts

  • 0

If you speak of aCis, try dropping all ShadowItemTaskManager.getInstance().remove( method calls, and ShadowItemTaskManager onUnequip( content. Basically said, what you want is one time you put the item, the counter continue no matter what.

 

If the player instance isn't maintained by the map on player disconnection, you have to code on ShadowItemTaskManager a sql query to care about item even if player is offline.

Edited by Tryskell
Link to comment
Share on other sites

  • 0

     In the ShadowItemTaskManager.java  there are 2 tasks:  onEquip & onUnequip. I already edited the 2nd one and I fixed : 2. Remove all checks that can stop the task.

 

     Now I have to change "onEquip" task to "onLogin" task.  Looking for help.

Link to comment
Share on other sites

  • 0

Oh, I didn't understand you wanted the shadow weapon timer to be fired at item acquisition.

 

From implements Runnable, OnEquipListener you drop OnEquipListener and both overidden methods (you don't need them at all).

 

Then I guess you have to put content from onEquip (method you just dropped) into item acquisition method (addItem from L2PcInstance I guess).

 

There is nothing like "login" task to create. Basically you want counter starts on item acquisition (additem method) and never be stopped (drop of all possibility to remove Map entry). The only thing you have to care about after is how the content of run() is running, if it needs offline check, if it can works even if the player is offline, etc.

 

If I didn't understand, repeat your needs in detail.

Edited by Tryskell
Link to comment
Share on other sites

  • 0

Here is what Ive done:

public class ShadowItemTaskManager implements Runnable
{
	private static final int DELAY = 1; // 1 second
	
	private final Map<ItemInstance, L2PcInstance> _shadowItems = new ConcurrentHashMap<>();
	
	public static final ShadowItemTaskManager getInstance()
	{
		return SingletonHolder._instance;
	}
	
	protected ShadowItemTaskManager()
	{
		// Run task each second.
		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this, 1000, 1000);
	}
	
	public final void addItem(int slot, ItemInstance item, L2Playable playable)
	{
		// Must be a shadow item.
		if (!item.isShadowItem())
			return;
		
		// Must be a player.
		if (!(playable instanceof L2PcInstance))
			return;
		
		_shadowItems.put(item, (L2PcInstance) playable);
	}

And the full code:

 

 

 

/*
 * This program 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.
 * 
 * This program 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 net.sf.l2j.gameserver.taskmanager;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.model.actor.L2Playable;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;

/**
 * Updates the timer and removes the {@link ItemInstance} as a shadow item.
 * @author Hasha
 */
public class ShadowItemTaskManager implements Runnable
{
	private static final int DELAY = 1; // 1 second
	
	private final Map<ItemInstance, L2PcInstance> _shadowItems = new ConcurrentHashMap<>();
	
	public static final ShadowItemTaskManager getInstance()
	{
		return SingletonHolder._instance;
	}
	
	protected ShadowItemTaskManager()
	{
		// Run task each second.
		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this, 1000, 1000);
	}
	
	public final void addItem(int slot, ItemInstance item, L2Playable playable)
	{
		// Must be a shadow item.
		if (!item.isShadowItem())
			return;
		
		// Must be a player.
		if (!(playable instanceof L2PcInstance))
			return;
		
		_shadowItems.put(item, (L2PcInstance) playable);
	}
	
	public final void remove(L2PcInstance player)
	{
		// List is empty, skip.
		if (_shadowItems.isEmpty())
			return;
		
		// For all items.
		for (Iterator<Entry<ItemInstance, L2PcInstance>> iterator = _shadowItems.entrySet().iterator(); iterator.hasNext();)
		{
			// Item is from player, remove from the list.
			if (iterator.next().getValue() == player)
				iterator.remove();
		}
	}
	
	@Override
	public final void run()
	{
		// List is empty, skip.
		if (_shadowItems.isEmpty())
			return;
		
		// For all items.
		for (Entry<ItemInstance, L2PcInstance> entry : _shadowItems.entrySet())
		{
			// Get item and player.
			final ItemInstance item = entry.getKey();
			final L2PcInstance player = entry.getValue();
			
			// Decrease item mana.
			int mana = item.decreaseMana(DELAY);
			
			// If not enough mana, destroy the item and inform the player.
			if (mana == -1)
			{
				// Remove item first.
				player.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
				InventoryUpdate iu = new InventoryUpdate();
				iu.addModifiedItem(item);
				player.sendPacket(iu);
				
				// Destroy shadow item, remove from list.
				player.destroyItem("ShadowItem", item, player, false);
				player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_0).addItemName(item.getItemId()));
				_shadowItems.remove(item);
				
				continue;
			}
			
			// Enough mana, show messages.
			if (mana == 60 - DELAY)
				player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_1).addItemName(item.getItemId()));
			else if (mana == 300 - DELAY)
				player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_5).addItemName(item.getItemId()));
			else if (mana == 600 - DELAY)
				player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1S_REMAINING_MANA_IS_NOW_10).addItemName(item.getItemId()));
			
			// Update inventory every minute.
			if (mana % 60 == 60 - DELAY)
			{
				InventoryUpdate iu = new InventoryUpdate();
				iu.addModifiedItem(item);
				player.sendPacket(iu);
			}
		}
	}
	
	private static class SingletonHolder
	{
		protected static final ShadowItemTaskManager _instance = new ShadowItemTaskManager();
	}
}

 

 

  • Like 1
Link to comment
Share on other sites

  • 0

Seriously i got no answer for your question. Started just to test if i can open at least an empty server,then liked it and continued adding features in the frozen package, too lazy to change now i guess :)

Link to comment
Share on other sites

  • 0
On 20/2/2018 at 1:58 AM, ThelwHelpRePaidia said:

@igregz why would you use frozen? 

what question is this? guess he just needs it for his server 

  • Haha 2
Link to comment
Share on other sites

  • 0

 

On 20/2/2018 at 1:58 AM, ThelwHelpRePaidia said:

@igregz why would you use frozen? 

 

With what kind of experience you support this statement? As far i saw you posted 50 questions in 2 days. As if aCis is better. You can take pure L2J interlude

from 2005 and make a better server than L2Scripts if you are patient and willing to fix.

 

30 minutes ago, igregz said:

Seriously i got no answer for your question. Started just to test if i can open at least an empty server,then liked it and continued adding features in the frozen package, too lazy to change now i guess :)

If you mean local then ok but if empty refer to online then dont bother. We don't need more servers from owners who play Lineage 2 10-12 years and because they got bored they decided to be GM's. No offense but L2 community ruined by this + shared packs. If you want to learn then okay but having no idea whats goin on then don't bother. 

Link to comment
Share on other sites

  • 0
2 minutes ago, Evie Frye said:

We don't need more servers from owners who play Lineage 2 10-12 years and because they got bored they decided to be GM's.

If they played that much they could've probably create at least a good gameplay,or have some good ideas for their servers,yet most servers are totally trash.Most of 'em lack of experience even as players,and don't even know about 1st  class change q of their char.

 

41 minutes ago, igregz said:

Seriously i got no answer for your question. Started just to test if i can open at least an empty server,then liked it and continued adding features in the frozen package, too lazy to change now i guess :)

don't worry bro if you work properly and patiently you can make a decent pack ,keep up.

  • Like 2
Link to comment
Share on other sites

  • 0
Just now, camenomat0 said:

If they played that much they could've probably create at least a good gameplay,or have some good ideas for their servers,yet most servers are totally trash.Most of 'em lack of experience even as players,and don't even know about 1st  class change q of their char.

 

Most of people who asked me for help and clients were people who said "We got bored to play and we have enough experience to make a server now." 

As if Lineage 2 server is school and once u graduate you make one.

Link to comment
Share on other sites

  • 0
1 minute ago, Evie Frye said:

 

Most of people who asked me for help and clients were people who said "We got bored to play and we have enough experience to make a server now." 

As if Lineage 2 server is school and once u graduate you make one.

They got bored to get pwned in an old game,so they decide to make one to pk newbies with their op gm edited chars.It's not lucky fact that only few servers are made proffesionaly while most of them are pure fail. I still remember that server i played once while the admin registered his admin char to olympiad,hahaha couldn't even use second window properly.

  • Upvote 1
Link to comment
Share on other sites

  • 0
5 minutes ago, camenomat0 said:

If they played that much they could've probably create at least a good gameplay,or have some good ideas for their servers,yet most servers are totally trash.Most of 'em lack of experience even as players,and don't even know about 1st  class change q of their char.

 

 why u need experience of playing? since for xxxx years there still not 100% soft w/o bugs, even newdays servers are more bugged than  old times servers... those ppl just destroying more  and more l2 with opening servers for 10-20 ppl max 

Link to comment
Share on other sites

  • 0
3 minutes ago, AchYlek said:

 why u need experience of playing? since for xxxx years there still not 100% soft w/o bugs, even newdays servers are more bugged than  old times servers... those ppl just destroying more  and more l2 with opening servers for 10-20 ppl max 

Experience on playing will help you creatng a retail gameplay environment,and having knowledge on how skills or such stuff works will make job easier and of course with better results. How can you expect someone who never played to fix skills and balance the server's economy and overall gameplay? at least there should be such a Gm,with knowledge on game, quests,skills, and such stuff to support all players correctly and build the server right.

Also totally agree  on what u say on files,thats because they use shared files without even wasting a minute to test or fix.

Edited by camenomat0
  • Upvote 1
Link to comment
Share on other sites

  • 0
4 minutes ago, camenomat0 said:

At least there should be such a Gm,with knowledge on game, quests,skills, and such stuff to support all players correctly and build the server right.

At least there should be an admin with Java knowledge to support its own server and fix critical issue if happen - mostly their own crappy custom. Sadly, we lack this one nowadays. 

 

Get shared pack, make it live, let it roll, close. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...