Jump to content
  • 0

Question

Posted

Hello I created this system to drop enchanted items but it drops 2 item even putting the amount 1. What can I do to improve the code ?

 

Index: java/net/sf/l2j/gameserver/model/actor/Attackable.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/Attackable.java    (revision 3)
+++ java/net/sf/l2j/gameserver/model/actor/Attackable.java    (working copy)
@@ -1184,6 +1184,28 @@
             }
         }
         
+        // Drop All Monsters Itens enchantados By Dev Williams
+        if ((Config.ENABLE_DROP_ITEM_ENCHANT) && ((this instanceof Monster)))
+        {
+            for (int i = 1; i < 81; i++)
+            {
+                if (i > 10)
+                {
+                    if (player.getLevel() == i && getLevel() < player.getLevel() - 8)
+                        return;
+                }
+            }
+            if (Rnd.get(100) < Config.DROP_ITEM_ENCHANT[3])
+            {
+                IntIntHolder item = new IntIntHolder(Config.DROP_ITEM_ENCHANT[0], Config.DROP_ITEM_ENCHANT[1]);
+                if (Config.AUTO_LOOT)
+                    player.doAutoLoot(this, item);
+                else
+                    dropItem(player, item);
+                    player.getInventory().addEnchantedItem("Reward Enchant: ", Config.DROP_ITEM_ENCHANT[0], Config.DROP_ITEM_ENCHANT[1], Config.DROP_ITEM_ENCHANT[2], player, null);
+            }
+        }
+        
Index: java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java
===================================================================
--- java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java    (revision 2)
+++ java/net/sf/l2j/gameserver/model/itemcontainer/PcInventory.java    (working copy)
@@ -17,9 +17,11 @@
 import net.sf.l2j.gameserver.model.itemcontainer.listeners.ItemPassiveSkillsListener;
 import net.sf.l2j.gameserver.model.tradelist.TradeItem;
 import net.sf.l2j.gameserver.model.tradelist.TradeList;
+import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
 import net.sf.l2j.gameserver.network.serverpackets.ItemList;
 import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
+import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
 import net.sf.l2j.gameserver.taskmanager.ShadowItemTaskManager;
 
 public class PcInventory extends Inventory
@@ -439,6 +441,43 @@
         
         return item;
     }
+
+    public ItemInstance addEnchantedItem(String process, int itemId, int itemCount, int enchantLevel, Player actor, WorldObject reference)
+    {
+        ItemInstance item = super.addItem(process, itemId, itemCount, actor, reference);
+        
+        if (item == null)
+            return null;
+        
+        if (enchantLevel > 0)
+            item.setEnchantLevel(enchantLevel);
+        
+        if (itemId == 57)
+        {
+            SystemMessage smsg = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S1_ADENA);
+            smsg.addItemNumber(itemCount);
+            actor.sendPacket(smsg);
+        }
+        else if (itemCount > 1)
+        {
+            SystemMessage smsg = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
+            smsg.addItemName(itemId);
+            smsg.addItemNumber(itemCount);
+            actor.sendPacket(smsg);
+        }
+        else
+        {
+            SystemMessage smsg = SystemMessage.getSystemMessage(SystemMessageId.ACQUIRED_S1_S2);
+            smsg.addNumber(enchantLevel);
+            smsg.addItemName(itemId);
+            actor.sendPacket(smsg);
+        }
+        StatusUpdate su = new StatusUpdate(actor);
+        su.addAttribute(14, actor.getCurrentLoad());
+        actor.sendPacket(su);
+        
+        return item;
+    }
     

11 answers to this question

Recommended Posts

  • 0
Posted

actor.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ACQUIRED_S1_S2).addNumber(enchantLevel).addItemName(itemId));

  • Thanks 1
  • 0
Posted

sounds logic lol . look again what you did there 

 

+                if (Config.AUTO_LOOT)
+                    player.doAutoLoot(this, item);
+                else
+                    dropItem(player, item);
+                    player.getInventory().addEnchantedItem("Reward Enchant: ", Config.DROP_ITEM_ENCHANT[0], Config.DROP_ITEM_ENCHANT[1], Config.DROP_ITEM_ENCHANT[2], player, null);

 

you are adding an item with enchant value after the default drop. 1+1 = 2 :p

 

also what's the logic of this?

 

+            for (int i = 1; i < 81; i++)
+            {
+                if (i > 10)
+                {
+                    if (player.getLevel() == i && getLevel() < player.getLevel() - 8)
+                        return;
+                }
+            }

you can simple do one check

 

if (Config.ENABLE_DROP_ITEM_ENCHANT && this instanceof Monster && getLevel() < (player.getLevel() - 8))
	return;

 

also, in order to make enchant system for both loot cases you need a big rework. start by reading how the values from the drop xml are working and add one more value there

  • 0
Posted
2 hours ago, melron said:

sounds logic lol . look again what you did there 

 


+                if (Config.AUTO_LOOT)
+                    player.doAutoLoot(this, item);
+                else
+                    dropItem(player, item);
+                    player.getInventory().addEnchantedItem("Reward Enchant: ", Config.DROP_ITEM_ENCHANT[0], Config.DROP_ITEM_ENCHANT[1], Config.DROP_ITEM_ENCHANT[2], player, null);

 

you are adding an item with enchant value after the default drop. 1+1 = 2 :p

 

also what's the logic of this?

 


+            for (int i = 1; i < 81; i++)
+            {
+                if (i > 10)
+                {
+                    if (player.getLevel() == i && getLevel() < player.getLevel() - 8)
+                        return;
+                }
+            }

you can simple do one check

 


if (Config.ENABLE_DROP_ITEM_ENCHANT && this instanceof Monster && getLevel() < (player.getLevel() - 8))
	return;

 

also, in order to make enchant system for both loot cases you need a big rework. start by reading how the values from the drop xml are working and add one more value there

 

this is a verification for player lvl 81 does not win the item killing mobe lvl 1

 

The auto loot was stupid, my kk.

  • 0
Posted
3 minutes ago, l2jkain said:

 

this is a verification for player lvl 81 does not win the item killing mobe lvl 1

 

The auto loot was stupid, my kk.

 

heh actually the check itself will allow rewards from lvl 1 to 10 without checking the player's lvl :D

use the check i gave you. one line check is enough for this thing.

  • 0
Posted
30 minutes ago, melron said:

 

heh, na verdade, o cheque em si permitirá recompensas de lvl 1 a 10 sem verificar o jogador lvl : D

use o cheque que eu te dei. Uma verificação de linha é suficiente para essa coisa.

I did it your way and it did not work. I level 81 I won the mob level 1 award.

  • 0
Posted
5 minutes ago, l2jkain said:

I did it your way and it did not work. I level 81 I won the mob level 1 award.

just cant be. You won enchanted drop? I dont think so... probably you obtained retail drop but not the custom one

  • 0
Posted
5 minutes ago, melron said:

just cant be. You won enchanted drop? I dont think so... probably you obtained retail drop but not the custom one

 

only problem is if I put more than 1 item to dropa only comes 1 enchantado taking it ta 100% functional


        // Drop All Monsters Itens enchantados By Dev Williams
        if ((Config.ENABLE_DROP_ITEM_ENCHANT) && ((this instanceof Monster)))
        {
            for (int i = 1; i < 81; i++)
            {
                if (i > 10)
                {
                    if (player.getLevel() == i && getLevel() < player.getLevel() - 8)
                        return;
                }
            }
            if (Rnd.get(100) < Config.DROP_ITEM_ENCHANT[3])
            {
                if (Config.AUTO_LOOT)
                    player.getInventory().addEnchantedItem("Reward Enchant: ", Config.DROP_ITEM_ENCHANT[0], Config.DROP_ITEM_ENCHANT[1], Config.DROP_ITEM_ENCHANT[2], player, null);
            }
        }
        

  • 0
Posted

remove the for loop dude lol.. its rly useless...

what exactly are you trying to do? you need for example 5 db's + 16?

 

if ((Config.ENABLE_DROP_ITEM_ENCHANT) && ((this instanceof Monster)))
{
	if (Config.ENABLE_DROP_ITEM_ENCHANT && this instanceof Monster && getLevel() < (player.getLevel() - 8))
		return;
	if (Rnd.get(100) < Config.DROP_ITEM_ENCHANT[3])
	{
		if (Config.AUTO_LOOT)
			for (int i = 0; i < Config.DROP_ITEM_ENCHANT[1]; i++)
				player.getInventory().addEnchantedItem("Reward Enchant: ", Config.DROP_ITEM_ENCHANT[0], 1,
							Config.DROP_ITEM_ENCHANT[2], player, null);
		}
	}
}

 

  • 0
Posted
4 minutes ago, melron said:

remover o loop for dude rsrs .. é rly inútil ...

o que exatamente você está tentando fazer? você precisa, por exemplo, de 5 db's + 16?

 


 

 

I just want to leave enchanted items dropping

  • 0
Posted
1 minute ago, l2jkain said:

 

I just want to leave enchanted items dropping

Sorry i cant understand you.. if you want to drop on the floor enchanted items then you are moving wrong...

  • 0
Posted
4 minutes ago, melron said:

Desculpe eu não posso te entender .. se você quiser cair no chão itens encantados, então você está se movendo errado ...

thanks for the help I give up trying to do can close the topic

Guest
This topic is now closed to further replies.


  • Posts

    • Faltan demasiados archivos,  y lógicas en clases claves como L2pcInstance, entre otras. si bien muchas cosas están y el flujo es valorable.  Gracias por tu esfuerzo es bastante... pero realmente no esta completo el código, falta que subas todas las modificaciones en clases colaterales... podrías intentar subir un diff de todo el mod  completo de tu pack y bueno ahí si que cada uno adapte... pero faltan muchas cosas, dudo que haya gente que lo haya echo funcionar con esto... 
    • I know people who have fully bypassed and reversed AAC. One day, they might even release the full source code, but for now, they’re still making money off it. I won’t name anyone, but it’s clear that there aren’t any truly solid anticheats for Lineage2. As I’ve said before, kernel level anticheats are the only real solution. Anything that runs as Internal and injects gets flagged, and your account ends up getting kicked or banned. That’s just how most games handle it nowadays. To TL;DR the whole thing cheating will always exist because there are people out there smart enough to bypass any protection and run private cheats. Public cheats are always detected eventually, so I don’t see any point in buying AAC, especially when they claim it blocks adr, which simply isn’t true.
    • 🌐 Website: https://l2adonis.com 📅 GRAND OPENING: July 18, 2025 – 20:00 (UTC+2) 💬 Discord: https://discord.com/invite/tZBj8JxAwx 🚫 No auto-farm • No auto-macro • No pay-to-win • No custom   Some Basic Info's (More detalied info's on website)  EXP/SP: x25  Adena: x15  Drop: x15  Spoil: x15  Seal Stones: x15  Raid Boss Drop: x10  Epic Boss Drop: x1  Manor: x10  Safe Enchant: +4  Max Enchant: +16  Normal Scroll Chance: 50%  Blessed Scroll Chance: 66% (If enchant fail item remain +4)  Buff Slots (30+4 extra with Divine Inspiration)  Dances/Songs Slots 14  Auto-learn skills  ⚔️ Real PvP • Real Progression • Retail-like experience JOIN NOW and relive the real L2 experience!
    • Discord         :  utchiha_market Telegram        : https://t.me/utchiha_market Auto Buy Store  : https://utchihamkt.mysellauth.com/ Not sure if we’re legit? Check Our server — real reviews, real buyers https://discord.gg/uthciha-servicess  | https://campsite.bio/utchihaamkt
    • Looking for a Developer – Lineage II Interlude (Vanganth Files)   I’m seeking a developer to collaborate on a project based on Vanganth Interlude files.   Important: Applicants with a bad attitude, lack of respect, or unwillingness to work will be immediately rejected. Payment: Hourly rate, not per task. Contact: Please reach out to me via PM.
  • 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