package net.sf.l2j.gameserver.scripting.scripts.custom;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.sf.l2j.commons.random.Rnd;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.data.xml.NpcData;
import net.sf.l2j.gameserver.model.actor.Attackable;
import net.sf.l2j.gameserver.model.actor.Creature;
import net.sf.l2j.gameserver.model.actor.Npc;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.holder.IntIntHolder;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.scripting.Quest;
import net.sf.l2j.gameserver.scripting.QuestState;
/**
* @author Tayran.JavaDev
* @version 4
*/
public class Feanor extends Quest
{
private static final String qn = "Feanor";
public Feanor()
{
super(-1, "custom");
if (Config.ALLOW_GLOBAL_DROP)
{
for (NpcTemplate npcTemplate : NpcData.getInstance().getAllNpcs())
{
if (npcTemplate.getType().equalsIgnoreCase("Monster"))
super.addKillId(npcTemplate.getIdTemplate());
}
System.out.println("[Feanor Activated] All Monster have been added with Global Drop Items");
}
else
{
System.out.println("[Drop Global Disabled] No Monster was changed");
}
}
private static void dropItem(final Npc npc, final Player player, final Map<Integer, List<Integer>> droplist)
{
Integer key;
Integer chance;
Integer min;
Integer max;
Integer itemMin;
Integer itemMax;
Integer count;
Integer rnd;
for (Entry<Integer, List<Integer>> entry : droplist.entrySet())
{
key = entry.getKey();
List<Integer> valueList = entry.getValue();
chance = valueList.get(0);
min = valueList.get(1);
max = valueList.get(2);
if (npc.getStatus().getLevel() > 9 && Config.ALLOW_GLOBAL_DROP_RANDOM)
{
itemMin = npc.getStatus().getLevel() * min / 5;
itemMax = npc.getStatus().getLevel() * max / 6;
}
else
{
itemMin = min;
itemMax = max;
}
count = Rnd.get(itemMin, itemMax);
rnd = Rnd.get(100);
if (rnd < chance)
{
IntIntHolder item = new IntIntHolder(key, count);
dropItem(npc, player, item);
continue;
}
}
}
/**
* Drop item.
* @author Tayran.JavaDev
* @param mob
* @param lastAttacker The player who made ultimate damage.
* @param item instance IntIntHolder.
* @return the dropped item instance.
*/
public static ItemInstance dropItem(Npc npc, Player player, IntIntHolder item)
{
if (Config.AUTO_LOOT)
dropItem(npc, player, item);/** player.addItem("Loot", item, null, true); */
else
return dropItem(npc, player, item);
return null;
}
public String onKill(Npc npc, Player killer)
{
final Player player = killer.getActingPlayer();
int levelMobMin = 0;
for (int i = 1; i < 81; i++)
{
levelMobMin = killer.getStatus().getLevel() - 8;
if (i > 10)
{
if (killer.getStatus().getLevel() == i && npc.getStatus().getLevel() < levelMobMin)
return "";
}
}
dropItem(npc, killer, Config.GLOBAL_DROP_ITEMS);
return super.onKill(npc, killer);
}
}
Index: config/players.properties
===================================================================
--- config/players.properties (revision 5)
+++ config/players.properties (working copy)
@@ -320,4 +320,18 @@
DressMeLegs = Imperial,6374
DressMeBoots = Draconic,6381;Imperial,6376;Arcana,6385
DressMeGloves = Draconic,6380;Imperial,6375;Arcana,6384
DressMeWeapons = Draconic_Bow,7577;Shining_Bow,6594;Arcana_Mace,6608
+
+#=============================================================
+# Global Drop
+#=============================================================
+# Configuração de Drop Global
+# Liga / Desliga Drop Global
+AllowGlobalDrop = True
+# Ativa Drop random que aumenta de acordo com level do MOB.
+AllowRandomQuantityDrop = True
+# Itemid,chance,min,max;Itemid,chance,min,max
+GlobalDropItems = 6392,100,1,2;6393,50,1,3;
+# Itemid,chance,min,max;Itemid,chance,min,max
+# Essa configuração é para mobs do tipo Champion
+ChampionGlobalDropItems = 6391,100,1,2;
\ No newline at end of file
Index: java/net/sf/l2j/Config.java
===================================================================
--- java/net/sf/l2j/Config.java (revision 5)
+++ java/net/sf/l2j/Config.java (working copy)
@@ -690,6 +690,11 @@
public static int CLIENT_PACKET_QUEUE_MAX_OVERFLOWS_PER_MIN = 1; // default 1
public static int CLIENT_PACKET_QUEUE_MAX_UNDERFLOWS_PER_MIN = 1; // default 1
public static int CLIENT_PACKET_QUEUE_MAX_UNKNOWN_PER_MIN = 5; // default 5
+
+ public static Map<Integer, List<Integer>> GLOBAL_DROP_ITEMS = new HashMap<>();
+ public static boolean ALLOW_GLOBAL_DROP_RANDOM;
+ public static boolean ALLOW_GLOBAL_DROP;
// --------------------------------------------------
@@ -1133,7 +1138,31 @@
*/
private static final void loadPlayers()
{
final ExProperties players = initProperties(PLAYERS_FILE);
+ String globalTemp = players.getProperty("GlobalDropItems", "");
+ String[] globalTemp2 = globalTemp.split(";");
+ for (String s : globalTemp2)
+ {
+ List<Integer> list = new ArrayList<>();
+ String[] t = s.split(",");
+ list.add(Integer.parseInt(t[1]));
+ list.add(Integer.parseInt(t[2]));
+ list.add(Integer.parseInt(t[3]));
+ GLOBAL_DROP_ITEMS.put(Integer.parseInt(t[0]), list);
+ }
+ ALLOW_GLOBAL_DROP_RANDOM = players.getProperty("AllowRandomQuantityDrop", true);
+ ALLOW_GLOBAL_DROP = players.getProperty("AllowGlobalDrop", true);
STARTING_ADENA = players.getProperty("StartingAdena", 100);
EFFECT_CANCELING = players.getProperty("CancelLesserEffect", true);
HP_REGEN_MULTIPLIER = players.getProperty("HpRegenMultiplier",
Так может поделитесь с нами решением?)Вопрос решен. Всем спасибо
Так может поделитесь с нами решением?)