-
Posts
-
package custom.events.RandomZoneEvent; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.concurrent.ScheduledFuture; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.l2jmobius.commons.threads.ThreadPool; import org.l2jmobius.commons.time.SchedulingPattern; import org.l2jmobius.commons.time.TimeUtil; import org.l2jmobius.commons.util.IXmlReader; import org.l2jmobius.gameserver.managers.ZoneManager; import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Creature; import org.l2jmobius.gameserver.model.actor.Npc; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.quest.Event; import org.l2jmobius.gameserver.model.zone.ZoneId; import org.l2jmobius.gameserver.model.zone.ZoneType; import org.l2jmobius.gameserver.model.zone.type.RandomZone; import org.l2jmobius.gameserver.util.Broadcast; /** * Random Zone Event - Activates one random PvP zone temporarily. No modifica la clase de la zona: usa flags PvP en runtime. * @author Juan */ public class RandomZoneEvent extends Event { private static final String CONFIG_FILE = "data/scripts/custom/events/RandomZoneEvent/config.xml"; private static int EVENT_DURATION_MINUTES = 15; private static boolean _isActive = false; private ScheduledFuture<?> _eventTask = null; private final List<ZoneType> _availableZones = new ArrayList<>(); private ZoneType _activeZone = null; public RandomZoneEvent() { loadConfig(); loadZones(); registerZoneListeners(); } /** * Registra listeners a TODAS LAS ZONAS random */ private void registerZoneListeners() { for (ZoneType zone : _availableZones) { addEnterZoneId(zone.getId()); addExitZoneId(zone.getId()); LOGGER.info("[RandomZoneEvent] Registered listener for zone: " + zone.getName()); } } private void loadConfig() { new IXmlReader() { @Override public void load() { parseDatapackFile(CONFIG_FILE); } @Override public void parseDocument(Document doc, File file) { forEach(doc, "event", eventNode -> { final StatSet att = new StatSet(parseAttributes(eventNode)); final String name = att.getString("name"); for (Node node = eventNode.getFirstChild(); node != null; node = node.getNextSibling()) { if ("schedule".equals(node.getNodeName())) { final StatSet attributes = new StatSet(parseAttributes(node)); final String pattern = attributes.getString("pattern"); final SchedulingPattern schedulingPattern = new SchedulingPattern(pattern); final StatSet params = new StatSet(); params.set("Name", name); params.set("SchedulingPattern", pattern); final long delay = schedulingPattern.getDelayToNextFromNow(); getTimers().addTimer("Schedule_" + name, params, delay + 5000, null, null); LOGGER.info("[RandomZoneEvent] Event " + name + " scheduled at " + TimeUtil.getDateTimeString(System.currentTimeMillis() + delay)); } } }); } }.load(); } private void loadZones() { for (ZoneType zone : ZoneManager.getInstance().getAllZones(RandomZone.class)) { if ((zone.getName() != null) && zone.getName().toLowerCase().startsWith("random_zone")) { _availableZones.add(zone); LOGGER.info("[RandomZoneEvent] Loaded zone: " + zone.getName() + " (id=" + zone.getId() + ")"); } } LOGGER.info("[RandomZoneEvent] Total random zones loaded: " + _availableZones.size()); } @Override public void onTimerEvent(String event, StatSet params, Npc npc, Player player) { if (event.startsWith("Schedule_")) { eventStart(null); final SchedulingPattern schedulingPattern = new SchedulingPattern(params.getString("SchedulingPattern")); final long delay = schedulingPattern.getDelayToNextFromNow(); getTimers().addTimer(event, params, delay + 5000, null, null); LOGGER.info("[RandomZoneEvent] Rescheduled for " + TimeUtil.getDateTimeString(System.currentTimeMillis() + delay)); } } @Override public boolean eventStart(Player eventMaker) { if (_isActive) { if (eventMaker != null) { eventMaker.sendMessage("RandomZoneEvent already active."); } return false; } if (_availableZones.isEmpty()) { Broadcast.toAllOnlinePlayers("[RandomZoneEvent] No zones configured."); return false; } _isActive = true; Broadcast.toAllOnlinePlayers("⚔️ Random Zone Event has started!"); _eventTask = ThreadPool.schedule(this::activateRandomZone, 5_000); return true; } private void activateRandomZone() { _activeZone = _availableZones.get(new Random().nextInt(_availableZones.size())); _activeZone.setEnabled(true); Broadcast.toAllOnlinePlayers("🔥 Random Zone Event: " + _activeZone.getName() + " is now PvP for " + EVENT_DURATION_MINUTES + " minutes!"); _eventTask = ThreadPool.schedule(this::eventStop, EVENT_DURATION_MINUTES * 60 * 1000L); } @Override public boolean eventStop() { if (!_isActive) { return false; } _isActive = false; if (_eventTask != null) { _eventTask.cancel(true); _eventTask = null; } if (_activeZone != null) { _activeZone.setEnabled(false); Broadcast.toAllOnlinePlayers("🏁 Random Zone Event ended. " + _activeZone.getName() + " is back to normal."); _activeZone = null; } else { Broadcast.toAllOnlinePlayers("🏁 Random Zone Event ended."); } return true; } @Override public void onEnterZone(Creature creature, ZoneType zone) { if (!_isActive || (_activeZone == null)) { return; } if ((zone == _activeZone) && creature.isPlayable()) { creature.setInsideZone(ZoneId.PVP, true); if (creature.isPlayer()) { creature.sendMessage("Esta zona está en modo PvP temporalmente."); } } } @Override public void onExitZone(Creature creature, ZoneType zone) { if (!_isActive || (_activeZone == null)) { return; } if ((zone == _activeZone) && creature.isPlayable()) { creature.setInsideZone(ZoneId.PVP, false); if (creature.isPlayer()) { creature.sendMessage("Abandonaste la zona PvP temporal."); } } } @Override public boolean eventBypass(Player player, String bypass) { return true; } @Override public String onEvent(String event, Npc npc, Player player) { return super.onEvent(event, npc, player); } @Override public String onFirstTalk(Npc npc, Player player) { return null; } public static void main(String[] args) { new RandomZoneEvent(); } } i have this but its not working
-
ZonePvPSpawnBossRadio=0 ZonePvPSpawnBossBarakiel=0 at the Customs.ini in L2Server folder. Im prety sure this is it because i had the same problem with you in cruma 1 floor for example and i couldn't fix it but i fixed it finally by changing these 2 lines
-
Siege Reward Start PM Msg Rework Config root BossDieAnnounce and BossDieSound in the L24Team.properties and Config.java files for global raid boss death notifications and sounds. Adds a new reward_list table to the DB.sql file to track castle rewards. Improves character creation logic for thread safety and validation. Adds extensive state checks to the RequestEnchantItem method to prevent enchantments during inappropriate player states. Fixed auto-attack animation bug (there was no attack animation, only damage animation) Clean Code Other fixes I forgot to list! Java 14 Fixed issue where deleting a character would prevent it from leaving the screen or being removed, or even after a delete CD (it would only exit when re-logging in or creating a new character). Added Premium System from the other C2 project (Needs testing and improvement). Added the "Improved" Community Board (incomplete).
-
Topics

Question
AlexHack
### Eclipse Workspace Patch 1.0#P elfobitchIndex:
/gameserver/model/L2Attackable.java
===================================================================---
/gameserver/model/L2Attackable.java (revision 903)
+++ /gameserver/model/L2Attackable.java (working copy)
@@ -244,12 +244,22 @@
protected int _itemId; protected int _count;
+ private int _enchant = -1;
+ private int _chance = 0;
+ public RewardItem(int itemId, int count)
{
_itemId = itemId;
_count = count; }
+ public RewardItem(int itemId, int count, int enchant, int chance)
+ {
+ this(itemId, count);
+ _enchant = enchant;
+ _chance = chance;
+ }
+ public int getItemId()
{
return _itemId;
@@ -259,6 +269,9 @@
{
return _count;
}
+
+ public int getEnchant()
{ return _enchant; }
+ public int getEnchantChance()
{ return _chance;
}
}
/**@@ -1560,7 +1573,7 @@
}
if(itemCount > 0)
- return new RewardItem(drop.getItemId(), itemCount);
+ return new RewardItem(drop.getItemId(), itemCount, drop.getEnchant(), drop.getEnchantChance());
else if(itemCount == 0 && Config.DEBUG)
{
_log.fine("Roll produced 0 items to drop...");
@@ -1845,7 +1858,7 @@
}
if(itemCount > 0)
-
return new RewardItem(drop.getItemId(), itemCount);
+ return new RewardItem(drop.getItemId(), itemCount, drop.getEnchant(), drop.getEnchantChance());
else if(itemCount == 0 && Config.DEBUG)
{
_log.fine("Roll produced 0 items to drop...");
@@ -2503,6 +2516,16 @@
// Init the dropped L2ItemInstance and add it in the world as a visible object at the position where mob was last
*
*/
ditem = ItemTable.getInstance().createItem("Loot", item.getItemId(), item.getCount(), mainDamageDealer, this); ditem.getDropProtection().protect(mainDamageDealer);
+ if(item.getEnchant() > 0)
+ {
+ if(ditem.getItem().getType1() == L2Item.TYPE1_WEAPON_RING_EARRING_NECKLACE+ || ditem.getItem().getType1() == L2Item.TYPE1_SHIELD_ARMOR)
+ {
+ double chance = Rnd.get(1, 100);
+ if(chance <= item.getEnchantChance())
+ ditem.setEnchantLevel(item.getEnchant());
+ }
+ }
ditem.dropMe(this, newX, newY, newZ);
// Add drop to auto destroy item taskIndex:
/gameserver/datatables/sql/NpcTable.java
===================================================================
--- gameserver/head-src/com/l2jfrozen/gameserver/datatables/sql/NpcTable.java
(revision 903)
+++ gameserver/head-src/com/l2jfrozen/gameserver/datatables/sql/NpcTable.java
(working copy)
@@ -247,7 +247,7
@@ {
statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
{
- "mobId", "itemId", "min", "max", "category", "chance"
+ "mobId", "itemId", "min", "max", "category", "chance", "enchant", "enchantChance" })
+ " FROM custom_droplist ORDER BY mobId, chance DESC");
ResultSet dropData = statement.executeQuery();
@@ -270,6 +270,8 @@
dropDat.setMinDrop(dropData.getInt("min"));
dropDat.setMaxDrop(dropData.getInt("max"));
dropDat.setChance(dropData.getInt("chance"));
+ dropDat.setEnchant(dropData.getInt("enchant"));
+ dropDat.setEnchantChance(dropData.getInt("enchantChance"));
int category = dropData.getInt("category");
@@ -295,7 +297,7 @@
{
statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
{
- "mobId", "itemId", "min", "max", "category", "chance"
+ "mobId", "itemId", "min", "max", "category", "chance", "enchant", "enchantChance" })
+ " FROM droplist ORDER BY mobId, chance DESC");
ResultSet dropData = statement.executeQuery();
L2DropData dropDat = null;
@@ -319,6 +321,8 @@
dropDat.setMinDrop(dropData.getInt("min"));
dropDat.setMaxDrop(dropData.getInt("max"));
dropDat.setChance(dropData.getInt("chance"));
+ dropDat.setEnchant(dropData.getInt("enchant"));
+ dropDat.setEnchantChance(dropData.getInt("enchantChance"));
int category = dropData.getInt("category");
Index: /gameserver/script/faenor/FaenorInterface.java
===================================================================
---/gameserver/script/faenor/FaenorInterface.java
(revision 903)+++
gameserver/head-src/com/l2jfrozen/gameserver/script/faenor/FaenorInterface.java
(working copy)
@@ -82,6 +82,27 @@
addDrop(npc, drop, false);
} + public void addQuestDrop(int npcID, int itemID, int min, int max, int chance, String questID, String[] states,
+ int enchant, int enchantChance)
+ {
+ L2NpcTemplate npc = npcTable.getTemplate(npcID);
+ if (npc == null)
+ {
+ _log.info("FeanorInterface: Npc "+npcID+" is null..");
+ return;
+ }
+ L2DropData drop = new L2DropData();
+ drop.setItemId(itemID);
+ drop.setMinDrop(min);
+ drop.setMaxDrop(max);
+ drop.setEnchant(enchant);
+ drop.setEnchantChance(enchantChance);
+ drop.setChance(chance);
+ drop.setQuestID(questID);
+ drop.addStates(states);
+ addDrop(npc, drop, false);
+ }
+ /** * Adds a new Drop to an NPC
*@@ -106,7 +127,31 @@
* addDrop(npc, drop, sweep);
* }
* +
* + public void addDrop(int npcID, int itemID, int min, int max, boolean sweep, int chance,+ int enchant, int enchantChance) throws NullPointerException
* + {
* + L2NpcTemplate npc = npcTable.getTemplate(npcID);
* + if (npc == null)
* + {
* + if (Config.DEBUG)
* + {
* + _log.warning("Npc doesnt Exist");
* + }
* + throw new NullPointerException();
* + }
* + L2DropData drop = new L2DropData();
* + drop.setItemId(itemID);
* + drop.setMinDrop(min);
* + drop.setMaxDrop(max);
* + drop.setChance(chance);
* + drop.setEnchant(enchant);
* + drop.setEnchantChance(enchantChance);
* +
* + addDrop(npc, drop, sweep);
* + }
* + /** * Adds a new drop to an NPC. If the drop is sweep, it adds it to the NPC's Sweep category If the drop is non-sweep, * it creates a new category for this drop.
* Index: /gameserver/handler/admincommandhandlers/AdminEditNpc.java
* ===================================================================
* --- /gameserver/handler/admincommandhandlers/AdminEditNpc.java
* (revision 903)+++
* /gameserver/handler/admincommandhandlers/AdminEditNpc.java
* (working copy)
* @@ -407,7 +407,7 @@
* e.printStackTrace();
* }
*
* }
* - else if(st.countTokens() == 6)
* + else if(st.countTokens() == 8)
* {
* try
* {
* @@ -417,8 +417,10 @@
* int min = Integer.parseInt(st.nextToken());
* int max = Integer.parseInt(st.nextToken());
* int chance = Integer.parseInt(st.nextToken());
* + int enchant = Integer.parseInt(st.nextToken());
* + int enchantChance = Integer.parseInt(st.nextToken());
* - updateDropData(activeChar, npcId, itemId, min, max, category, chance);
* + updateDropData(activeChar, npcId, itemId, min, max, category, chance, enchant, enchantChance);
* }
* catch(Exception e)
* {@@ -430,7 +432,7 @@
}
else
* {
* - activeChar.sendMessage("Usage: //edit_drop <npc_id> <item_id> <category> [<min> <max> <chance>]");
* + activeChar.sendMessage("Usage: //edit_drop <npc_id> <item_id> <category> [<min> <max> <chance> <enchant> <enchantChance>]");
* } st = null;
* @@ -440,7 +442,7 @@
* if(Config.ENABLE_ALL_EXCEPTIONS)
* e.printStackTrace();
* - activeChar.sendMessage("Usage: //edit_drop <npc_id> <item_id> <category> [<min> <max> <chance>]");
* + activeChar.sendMessage("Usage: //edit_drop <npc_id> <item_id> <category> [<min> <max> <chance> <enchant> <enchantChance>]");
* }
* } else if(command.startsWith("admin_add_drop "))
* @@ -474,7 +476,7 @@
* npcData = null;
* }
* }
* - else if(st.countTokens() == 6)
* + else if(st.countTokens() == 8)
* {
* try
* {
* @@ -484,8 +486,10 @@
* int min = Integer.parseInt(st.nextToken());
* int max = Integer.parseInt(st.nextToken());
* int chance = Integer.parseInt(st.nextToken());
* + int enchant = Integer.parseInt(st.nextToken());
* + int enchantChance = Integer.parseInt(st.nextToken());
* - addDropData(activeChar, npcId, itemId, min, max, category, chance);
* + addDropData(activeChar, npcId, itemId, min, max, category, chance, enchant, enchantChance);
* }
* catch(Exception e)
* {
* @@ -497,7 +501,7 @@
* }
* else
* {
* - activeChar.sendMessage("Usage: //add_drop <npc_id> [<item_id> <category> <min> <max> <chance>]");
* + activeChar.sendMessage("Usage: //add_drop <npc_id> [<item_id> <category> <min> <max> <chance> <enchant> <enchantChance>]");
* } st = null;
* @@ -507,7 +511,7 @@
* if(Config.ENABLE_ALL_EXCEPTIONS)
* e.printStackTrace();
* - activeChar.sendMessage("Usage: //add_drop <npc_id> [<item_id> <category> <min> <max> <chance>]");
* + activeChar.sendMessage("Usage: //add_drop <npc_id> [<item_id> <category> <min> <max> <chance> <enchant> <enchantChance>]");
* }
* }
* else if(command.startsWith("admin_del_drop "))
* @@ -1323,7 +1327,7 @@
* {
* con = L2DatabaseFactory.getInstance().getConnection(false);
* - PreparedStatement statement = con.prepareStatement("SELECT mobId, itemId, min, max, category, chance FROM droplist WHERE mobId=" + npcId + " AND itemId=" + itemId + " AND category=" + category);
* + PreparedStatement statement = con.prepareStatement("SELECT mobId, itemId, min, max, category, chance, enchant, enchantChance FROM droplist WHERE mobId=" + npcId + " AND itemId=" + itemId + " AND category=" + category);
* ResultSet dropData = statement.executeQuery();
*
* NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
* @@ -1340,9 +1344,11 @@
* replyMSG.append("<tr><td>MIN(" + dropData.getInt("min") + ")</td><td><edit var=\"min\" width=80></td></tr>");
* replyMSG.append("<tr><td>MAX(" + dropData.getInt("max") + ")</td><td><edit var=\"max\" width=80></td></tr>");
* replyMSG.append("<tr><td>CHANCE(" + dropData.getInt("chance") + ")</td><td><edit var=\"chance\" width=80></td></tr>");
* + replyMSG.append("<tr><td>ENC-VALUE(" + dropData.getInt("enchant") + ")</td><td><edit var=\"enchant\" width=80></td></tr>");
* + replyMSG.append("<tr><td>ENC-CHANCE(" + dropData.getInt("enchantChance") + ")</td><td><edit var=\"enchantChance\" width=80></td></tr>");
* replyMSG.append("</table>");
* replyMSG.append("<center>");
* - replyMSG.append("<button value=\"Save Modify\" action=\"bypass -h admin_edit_drop " + npcId + " " + itemId + " " + category + " $min $max $chance\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
* + replyMSG.append("<button value=\"Save Modify\" action=\"bypass -h admin_edit_drop " + npcId + " " + itemId + " " + category + " $min $max $chance $enchant $enchantChance\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
* replyMSG.append("<br><button value=\"DropList\" action=\"bypass -h admin_show_droplist " + dropData.getInt("mobId") + "\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
* replyMSG.append("</center>");
* }
* @@ -1383,9 +1389,11 @@
* replyMSG.append("<tr><td>MAX</td><td><edit var=\"max\" width=80></td></tr>");
* replyMSG.append("<tr><td>CATEGORY(sweep=-1)</td><td><edit var=\"category\" width=80></td></tr>");
* replyMSG.append("<tr><td>CHANCE(0-1000000)</td><td><edit var=\"chance\" width=80></td></tr>");
* + replyMSG.append("<tr><td>ENC-VALUE(0-65535)</td><td><edit var=\"enchant\" width=80></td></tr>");
* + replyMSG.append("<tr><td>ENC-CHANCE(0-100)</td><td><edit var=\"enchantChance\" width=80></td></tr>");
* replyMSG.append("</table>");
* replyMSG.append("<center>");
* - replyMSG.append("<button value=\"SAVE\" action=\"bypass -h admin_add_drop " + npcData.npcId + " $itemId $category $min $max $chance\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
* + replyMSG.append("<button value=\"SAVE\" action=\"bypass -h admin_add_drop " + npcData.npcId + " $itemId $category $min $max $chance $enchant $enchantChance\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
* replyMSG.append("<br><button value=\"DropList\" action=\"bypass -h admin_show_droplist " + npcData.npcId + "\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
* replyMSG.append("</center>"); replyMSG.append("</body></html>");
* @@ -1397,7 +1405,7 @@
* replyMSG = null;
* }
* - private void updateDropData(L2PcInstance activeChar, int npcId, int itemId, int min, int max, int category, int chance)
* + private void updateDropData(L2PcInstance activeChar, int npcId, int itemId, int min, int max, int category, int chance, int enchant, int enchantChance)
* {
* Connection con = null;
* @@ -1405,13 +1413,15 @@
*
}
}
}
}
}
i Delete the Patch cause to do not advertise another work !
Mporei kapoios na voi8isi an exei kapoios to swsto
1 answer to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now