Jump to content
  • 0

Drop Item Enchanted aCis


l2jkain
 Share

Question

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;
+    }
     

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

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

  • Thanks 1
Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0
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.

Link to comment
Share on other sites

  • 0
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.

Link to comment
Share on other sites

  • 0
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.

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

  • 0
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);
            }
        }
        

Link to comment
Share on other sites

  • 0

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);
		}
	}
}

 

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

  • 0
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...

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



  • Posts

    • Hello, if you order, always order with refill so you are 100% sure, the followers,likes stay.   We now accept PayPal sometimes, open ticket and ask, our support team will tell you if we accept it or not.
    • AM Acumen +3 DB Clean Drac Armor set  DC robe set AS Clean TT SET +3 1.5B Adena in stock  discord : AliTarash#5255 or dm here 
    • private int _ispro; private long _isproTime; public void increasePvpKills(L2Character target) {     if (target instanceof L2PcInstance && AntiFeedManager.getInstance().check(this, target))     {         if (_isproTime < System.currentTimeMillis())             _ispro = 0;           _ispro++;         _isproTime = System.currentTimeMillis() + 60000L;   There is no need for any task or anything..
    • Hi, i make 4 new custom zone where can set zonename, but have problem bcs  still working only last zonename for all new zones...   373    0    26    16    30000.00000000    -30000.00000000    a,TvT Event\0    -1    -1    -1    -1    -1    -1    0.00000000    a, 374    0    16    16    30000.00000000    -30000.00000000    a,TvT Event\0    -1    -1    -1    -1    -1    -1    0.00000000    a, 375    0    21    11    30000.00000000    -30000.00000000    a,TvT Event\0    -1    -1    -1    -1    -1    -1    0.00000000    a, 376    0    17    16    30000.00000000    -30000.00000000    a,PvP Zone\0    -1    -1    -1    -1    -1    -1    0.00000000    a,   Some1 understand it how its working ? i need set new nbr, zone_color_id and other geodata coords + 1 map for zone... If all working good ofc i pay for it 😉 pm on discord: ! KejbL#0290 thx.
    • LF BP MAIN  PM US AT DISCORD APO#2611 OR OUR FACEBOOK PAGE !
  • 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