Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 49)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -126,6 +126,7 @@
- import net.sf.l2j.gameserver.model.base.Race;
- import net.sf.l2j.gameserver.model.base.SubClass;
- import net.sf.l2j.gameserver.model.entity.Castle;
- +import net.sf.l2j.gameserver.model.entity.DM;
- import net.sf.l2j.gameserver.model.entity.Duel;
- import net.sf.l2j.gameserver.model.entity.L2Event;
- import net.sf.l2j.gameserver.model.entity.Siege;
- @@ -348,6 +349,12 @@
- /** The number of player killed during a PvP (the player killed was PvP Flagged) */
- private int _pvpKills;
- +
- + /** The hexadecimal Color of players name (white is 0xFFFFFF) */
- + private int _nameColor;
- +
- + /** The hexadecimal Color of players title (white is 0xFFFFFF) */
- + private int _titleColor;
- /** The PK counter of the L2PcInstance (= Number of non PvP Flagged player killed) */
- private int _pkKills;
- @@ -587,6 +594,12 @@
- public LinkedList<String> kills = new LinkedList<String>();
- public boolean eventSitForced = false;
- public boolean atEvent = false;
- +
- + /** DM Engine parameters */
- + public int _originalNameColorDM,
- + _countDMkills,
- + _originalKarmaDM;
- + public boolean _inEventDM = false;
- /** new loto ticket **/
- private int _loto[] = new int[5];
- @@ -874,6 +887,8 @@
- _accountName = accountName;
- _appearance = app;
- + _nameColor = 0xFFFFFF;
- + _titleColor = 0xFFFF77;
- // Create an AI
- _ai = new L2PlayerAI(new L2PcInstance.AIAccessor());
- @@ -2379,6 +2394,8 @@
- {
- sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up ...");
- }
- + else if (DM._sitForced && _inEventDM)
- + sendMessage("Only the Event Starter can allow you to stand up!");
- else if (_waitTypeSitting && !isInStoreMode() && !isAlikeDead())
- {
- if (_relax)
- @@ -3376,6 +3393,11 @@
- player.sendPacket(new ActionFailed());
- return;
- }
- + if (_inEventDM && DM._started && !Config.DM_ALLOW_INTERFERENCE)
- + {
- + player.sendPacket(new ActionFailed());
- + return;
- + }
- // Check if the L2PcInstance is confused
- if (player.isOutOfControl())
- @@ -3407,7 +3429,7 @@
- else
- {
- // Check if this L2PcInstance is autoAttackable
- - if (isAutoAttackable(player))
- + if (isAutoAttackable(player)|| (player._inEventDM && DM._started))
- {
- // Player with lvl < 21 can't attack a cursed weapon holder
- // And a cursed weapon holder can't attack players with lvl < 21
- @@ -4257,6 +4279,25 @@
- if (killer != null)
- {
- L2PcInstance pk = null;
- +
- + if ((killer instanceof L2PcInstance && ((L2PcInstance)killer)._inEventDM) && _inEventDM)
- + {
- + if (DM._teleport || DM._started)
- + {
- + ((L2PcInstance)killer)._countDMkills++;
- +
- + sendMessage("You will be revived and teleported to spot in 20 seconds!");
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- + public void run()
- + {
- + teleToLocation(DM._playerX, DM._playerY, DM._playerZ, false);
- + doRevive();
- + }
- + }, 20000);
- + }
- + }
- +
- if (killer instanceof L2PcInstance)
- pk = (L2PcInstance) killer;
- @@ -4346,7 +4387,7 @@
- private void onDieDropItem(L2Character killer)
- {
- - if (atEvent || killer == null)
- + if (atEvent || (DM._started && _inEventDM) || (killer == null))
- return;
- if (getKarma()<=0
- @@ -4462,6 +4503,8 @@
- {
- if (target == null) return;
- if (!(target instanceof L2PlayableInstance)) return;
- +
- + if (_inEventDM) return;
- L2PcInstance targetPlayer = null;
- if (target instanceof L2PcInstance)
- @@ -4516,6 +4559,8 @@
- }
- // 'No war' or 'One way war' -> 'Normal PK'
- + if (!_inEventDM)
- + {
- if (targetPlayer.getKarma() > 0) // Target player has karma
- {
- if ( Config.KARMA_AWARD_PK_KILL )
- @@ -4527,6 +4572,7 @@
- {
- increasePkKillsAndKarma(targetPlayer.getLevel());
- }
- + }
- }
- }
- @@ -4536,6 +4582,10 @@
- */
- public void increasePvpKills()
- {
- + if (DM._started && _inEventDM)
- + {
- + return;
- + }
- // Add karma to attacker and increase its PK counter
- setPvpKills(getPvpKills() + 1);
- @@ -4570,6 +4620,8 @@
- */
- public void increasePkKillsAndKarma(int targLVL)
- {
- + if ((DM._started && _inEventDM))
- + return;
- int baseKarma = Config.KARMA_MIN_KARMA;
- int newKarma = baseKarma;
- int karmaLimit = Config.KARMA_MAX_KARMA;
- @@ -4662,6 +4714,8 @@
- public void updatePvPStatus()
- {
- + if ((DM._started && _inEventDM))
- + return;
- if (isInsideZone(ZONE_PVP)) return;
- setPvpFlagLasts(System.currentTimeMillis() + Config.PVP_NORMAL_TIME);
- @@ -4738,7 +4792,7 @@
- // Calculate the Experience loss
- long lostExp = 0;
- - if (!atEvent)
- + if ((!atEvent && !_inEventDM))
- if (lvl < Experience.MAX_LEVEL)
- lostExp = Math.round((getStat().getExpForLevel(lvl+1) - getStat().getExpForLevel(lvl)) * percentLost /100);
- else
- @@ -7343,12 +7397,11 @@
- }
- // Check if a Forced ATTACK is in progress on non-attackable target
- - if (!target.isAutoAttackable(this) && !forceUse &&
- - sklTargetType != SkillTargetType.TARGET_AURA &&
- - sklTargetType != SkillTargetType.TARGET_CLAN &&
- - sklTargetType != SkillTargetType.TARGET_ALLY &&
- - sklTargetType != SkillTargetType.TARGET_PARTY &&
- - sklTargetType != SkillTargetType.TARGET_SELF)
- + if (!target.isAutoAttackable(this) && !forceUse
- + && !(_inEventDM && DM._started)
- + && (sklTargetType != SkillTargetType.TARGET_AURA) && (sklTargetType != SkillTargetType.TARGET_CLAN)
- + && (sklTargetType != SkillTargetType.TARGET_ALLY) && (sklTargetType != SkillTargetType.TARGET_PARTY)
- + && (sklTargetType != SkillTargetType.TARGET_SELF))
- {
- // Send a Server->Client packet ActionFailed to the L2PcInstance
- sendPacket(new ActionFailed());
- @@ -7530,6 +7583,8 @@
- */
- public boolean checkPvpSkill(L2Object target, L2Skill skill)
- {
- + if ((_inEventDM && DM._started))
- + return true;
- // check for PC->PC Pvp status
- if (
- target != null && // target not null and
- @@ -8407,6 +8462,36 @@
- {
- return _team;
- }
- +
- + public int getNameColor()
- + {
- + return _nameColor;
- + }
- +
- + public void setNameColor(int nameColor)
- + {
- + _nameColor = nameColor;
- + }
- +
- + public int getTitleColor()
- + {
- + return _titleColor;
- + }
- +
- + public void setTitleColor(int titleColor)
- + {
- + _titleColor = titleColor;
- + }
- +
- + public void setTitleColor(int red, int green, int blue)
- + {
- + _titleColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
- + }
- +
- + public void setNameColor(int red, int green, int blue)
- + {
- + _nameColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
- + }
- public void setWantsPeace(int wantsPeace)
- {
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java (revision 47)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java (working copy)
- @@ -61,6 +61,7 @@
- import net.sf.l2j.gameserver.model.actor.stat.NpcStat;
- import net.sf.l2j.gameserver.model.actor.status.NpcStatus;
- import net.sf.l2j.gameserver.model.entity.Castle;
- +import net.sf.l2j.gameserver.model.entity.DM;
- import net.sf.l2j.gameserver.model.entity.L2Event;
- import net.sf.l2j.gameserver.model.quest.Quest;
- import net.sf.l2j.gameserver.model.quest.QuestState;
- @@ -123,6 +124,7 @@
- private int _castleIndex = -2;
- public boolean isEventMob = false;
- + public boolean _isEventMobDM = false;
- private boolean _isInTown = false;
- private int _isSpoiledBy = 0;
- @@ -655,7 +657,14 @@
- broadcastPacket(sa);
- // Open a chat window on client with the text of the L2NpcInstance
- - if(isEventMob){ L2Event.showEventHtml(player, String.valueOf(getObjectId())); }
- + if(isEventMob)
- + {
- + L2Event.showEventHtml(player, String.valueOf(getObjectId()));
- + }
- + else if (_isEventMobDM)
- + {
- + DM.showEventHtml(player, String.valueOf(this.getObjectId()));
- + }
- else
- {
- Quest[] qlst = getTemplate().getEventQuests(Quest.QuestEventType.NPC_FIRST_TALK);
- Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminDMEngine.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminDMEngine.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminDMEngine.java (revision 0)
- @@ -0,0 +1,234 @@
- +/*
- + * 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 2, 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, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * [URL]http://www.gnu.org/copyleft/gpl.html[/URL]
- + */
- +
- +/**
- + *
- + * @author: FBIagent
- + *
- + */
- +
- +package net.sf.l2j.gameserver.handler.admincommandhandlers;
- +
- +import javolution.text.TextBuilder;
- +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.DM;
- +import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
- +
- +public class AdminDMEngine implements IAdminCommandHandler {
- +
- + private static String[] _adminCommands = {"admin_dmevent", "admin_dmevent_name", "admin_dmevent_desc", "admin_dmevent_join_loc",
- + "admin_dmevent_minlvl", "admin_dmevent_maxlvl", "admin_dmevent_npc", "admin_dmevent_npc_pos",
- + "admin_dmevent_reward", "admin_dmevent_reward_amount", "admin_dmevent_spawnpos", "admin_dmevent_color",
- + "admin_dmevent_join", "admin_dmevent_teleport", "admin_dmevent_start", "admin_dmevent_abort", "admin_dmevent_finish",
- + "admin_dmevent_sit", "admin_dmevent_dump", "admin_dmevent_save", "admin_dmevent_load"};
- +
- + private static final int REQUIRED_LEVEL = 100;
- +
- + public boolean useAdminCommand(String command, L2PcInstance activeChar)
- + {
- + if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM())) return false;
- +
- + if (command.equals("admin_dmevent"))
- + showMainPage(activeChar);
- + else if (command.startsWith("admin_dmevent_name "))
- + {
- + DM._eventName = command.substring(19);
- + showMainPage(activeChar);
- + }
- + else if (command.startsWith("admin_dmevent_desc "))
- + {
- + DM._eventDesc = command.substring(19);
- + showMainPage(activeChar);
- + }
- + else if (command.startsWith("admin_dmevent_minlvl "))
- + {
- + if (!DM.checkMinLevel(Integer.valueOf(command.substring(21))))
- + return false;
- + DM._minlvl = Integer.valueOf(command.substring(21));
- + showMainPage(activeChar);
- + }
- + else if (command.startsWith("admin_dmevent_maxlvl "))
- + {
- + if (!DM.checkMaxLevel(Integer.valueOf(command.substring(21))))
- + return false;
- + DM._maxlvl = Integer.valueOf(command.substring(21));
- + showMainPage(activeChar);
- + }
- + else if (command.startsWith("admin_dmevent_join_loc "))
- + {
- + DM._joiningLocationName = command.substring(23);
- + showMainPage(activeChar);
- + }
- + else if (command.startsWith("admin_dmevent_npc "))
- + {
- + DM._npcId = Integer.valueOf(command.substring(18));
- + showMainPage(activeChar);
- + }
- + else if (command.equals("admin_dmevent_npc_pos"))
- + {
- + DM.setNpcPos(activeChar);
- + showMainPage(activeChar);
- + }
- + else if (command.startsWith("admin_dmevent_reward "))
- + {
- + DM._rewardId = Integer.valueOf(command.substring(21));
- + showMainPage(activeChar);
- + }
- + else if (command.startsWith("admin_dmevent_reward_amount "))
- + {
- + DM._rewardAmount = Integer.valueOf(command.substring(28));
- + showMainPage(activeChar);
- + }
- + else if (command.equals("admin_dmevent_spawnpos"))
- + {
- + DM.setPlayersPos(activeChar);
- + showMainPage(activeChar);
- + }
- + else if (command.startsWith("admin_dmevent_color "))
- + {
- + DM._playerColors = Integer.decode("0x" + command.substring(20));
- + showMainPage(activeChar);
- + }
- + else if(command.equals("admin_dmevent_join"))
- + {
- + DM.startJoin(activeChar);
- + showMainPage(activeChar);
- + }
- + else if (command.equals("admin_dmevent_teleport"))
- + {
- + DM.teleportStart();
- + showMainPage(activeChar);
- + }
- + else if(command.equals("admin_dmevent_start"))
- + {
- + DM.startEvent(activeChar);
- + showMainPage(activeChar);
- + }
- + else if(command.equals("admin_dmevent_abort"))
- + {
- + activeChar.sendMessage("Aborting event");
- + DM.abortEvent();
- + showMainPage(activeChar);
- + }
- + else if(command.equals("admin_dmevent_finish"))
- + {
- + DM.finishEvent(activeChar);
- + showMainPage(activeChar);
- + }
- + else if (command.equals("admin_dmevent_sit"))
- + {
- + DM.sit();
- + showMainPage(activeChar);
- + }
- + else if (command.equals("admin_dmevent_load"))
- + {
- + DM.loadData();
- + showMainPage(activeChar);
- + }
- + else if (command.equals("admin_dmevent_save"))
- + {
- + DM.saveData();
- + showMainPage(activeChar);
- + }
- + else if (command.equals("admin_dmevent_dump"))
- + DM.dumpData();
- +
- + return true;
- + }
- +
- + public String[] getAdminCommandList()
- + {
- + return _adminCommands;
- + }
- +
- + private boolean checkLevel(int level)
- + {
- + return (level >= REQUIRED_LEVEL);
- + }
- +
- + public void showMainPage(L2PcInstance activeChar)
- + {
- + NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
- + TextBuilder replyMSG = new TextBuilder("<html><body>");
- +
- + replyMSG.append("<center><font color=\"LEVEL\">[dm Engine]</font></center><br><br><br>");
- + replyMSG.append("<table><tr><td><edit var=\"input1\" width=\"125\"></td><td><edit var=\"input2\" width=\"125\"></td></tr></table>");
- + replyMSG.append("<table border=\"0\"><tr>");
- + replyMSG.append("<td width=\"100\"><button value=\"Name\" action=\"bypass -h admin_dmevent_name $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"Description\" action=\"bypass -h admin_dmevent_desc $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"Join Location\" action=\"bypass -h admin_dmevent_join_loc $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("</tr></table><br><table><tr>");
- + replyMSG.append("</tr></table><br><table><tr>");
- + replyMSG.append("<td width=\"100\"><button value=\"Max lvl\" action=\"bypass -h admin_dmevent_maxlvl $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"Min lvl\" action=\"bypass -h admin_dmevent_minlvl $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("</tr></table><br><table><tr>");
- + replyMSG.append("<td width=\"100\"><button value=\"NPC\" action=\"bypass -h admin_dmevent_npc $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"NPC Pos\" action=\"bypass -h admin_dmevent_npc_pos\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("</tr></table><br><table><tr>");
- + replyMSG.append("<td width=\"100\"><button value=\"Reward\" action=\"bypass -h admin_dmevent_reward $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"Reward Amount\" action=\"bypass -h admin_dmevent_reward_amount $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("</tr></table><br><table><tr>");
- + replyMSG.append("<td width=\"100\"><button value=\"DM Color\" action=\"bypass -h admin_dmevent_color $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"DM SpawnPos\" action=\"bypass -h admin_dmevent_spawnpos\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("</tr></table><table><br><br><tr>");
- + replyMSG.append("<td width=\"100\"><button value=\"Join\" action=\"bypass -h admin_dmevent_join\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"Teleport\" action=\"bypass -h admin_dmevent_teleport\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"Start\" action=\"bypass -h admin_dmevent_start\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("</tr></table><table><tr>");
- + replyMSG.append("<td width=\"100\"><button value=\"Abort\" action=\"bypass -h admin_dmevent_abort\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"Finish\" action=\"bypass -h admin_dmevent_finish\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("</tr></table><br><table><tr>");
- + replyMSG.append("<td width=\"100\"><button value=\"Sit Force\" action=\"bypass -h admin_dmevent_sit\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"Dump\" action=\"bypass -h admin_dmevent_dump\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("</tr></table><br><br><table><tr>");
- + replyMSG.append("<td width=\"100\"><button value=\"Save\" action=\"bypass -h admin_dmevent_save\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("<td width=\"100\"><button value=\"Load\" action=\"bypass -h admin_dmevent_load\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
- + replyMSG.append("</tr></table><br><br>");
- + replyMSG.append("Current event...<br1>");
- + replyMSG.append(" ... name: <font color=\"00FF00\">" + DM._eventName + "</font><br1>");
- + replyMSG.append(" ... description: <font color=\"00FF00\">" + DM._eventDesc + "</font><br1>");
- + replyMSG.append(" ... joining location name: <font color=\"00FF00\">" + DM._joiningLocationName + "</font><br1>");
- + replyMSG.append(" ... joining NPC ID: <font color=\"00FF00\">" + DM._npcId + " on pos " + DM._npcX + "," + DM._npcY + "," + DM._npcZ + "</font><br1>");
- + replyMSG.append(" ... reward ID: <font color=\"00FF00\">" + DM._rewardId + "</font><br1>");
- + replyMSG.append(" ... reward Amount: <font color=\"00FF00\">" + DM._rewardAmount + "</font><br><br>");
- + replyMSG.append(" ... Min lvl: <font color=\"00FF00\">" + DM._minlvl + "</font><br>");
- + replyMSG.append(" ... Max lvl: <font color=\"00FF00\">" + DM._maxlvl + "</font><br><br>");
- + replyMSG.append(" ... Death Match Color: <font color=\"00FF00\">" + DM._playerColors + "</font><br>");
- + replyMSG.append(" ... Death Match Spawn Pos: <font color=\"00FF00\">" + DM._playerX + "," + DM._playerY + "," + DM._playerZ + "</font><br><br>");
- + replyMSG.append("Current players:<br1>");
- +
- + if (!DM._started)
- + {
- + replyMSG.append("<br1>");
- + replyMSG.append(DM._players.size() + " players participating.");
- + replyMSG.append("<br><br>");
- + }
- + else if (DM._started)
- + {
- + replyMSG.append("<br1>");
- + replyMSG.append(DM._players.size() + " players in fighting event.");
- + replyMSG.append("<br><br>");
- + }
- +
- + replyMSG.append("</body></html>");
- + adminReply.setHtml(replyMSG.toString());
- + activeChar.sendPacket(adminReply);
- + }
- +}
- Index: java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java (revision 47)
- +++ java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java (working copy)
- @@ -31,6 +31,7 @@
- import net.sf.l2j.gameserver.model.L2World;
- import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.entity.DM;
- import net.sf.l2j.gameserver.model.entity.L2Event;
- import net.sf.l2j.gameserver.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
- @@ -103,8 +104,25 @@
- try
- {
- L2Object object = L2World.getInstance().findObject(Integer.parseInt(id));
- -
- - if (_command.substring(endOfId+1).startsWith("event_participate")) L2Event.inscribePlayer(activeChar);
- + if (_command.substring(endOfId+1).startsWith("dmevent_player_join"))
- + {
- + if (DM._joining)
- + DM.addPlayer(activeChar);
- + else
- + activeChar.sendMessage("The event is already started. You can not join now!");
- + }
- +
- + if (_command.substring(endOfId+1).startsWith("dmevent_player_leave"))
- + {
- + if (DM._joining)
- + DM.removePlayer(activeChar);
- + else
- + activeChar.sendMessage("The event is already started. You can not leave now!");
- + }
- + if (_command.substring(endOfId+1).startsWith("event_participate"))
- + {
- + L2Event.inscribePlayer(activeChar);
- + }
- else if (object != null && object instanceof L2NpcInstance && endOfId > 0 && activeChar.isInsideRadius(object, L2NpcInstance.INTERACTION_DISTANCE, false, false))
- {
- ((L2NpcInstance)object).onBypassFeedback(activeChar, _command.substring(endOfId+1));
- Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 47)
- +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
- @@ -26,6 +26,7 @@
- import javolution.util.FastMap;
- import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminDMEngine;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- /**
- @@ -57,6 +58,7 @@
- private AdminCommandHandler()
- {
- _datatable = new FastMap<String, IAdminCommandHandler>();
- + registerAdminCommandHandler(new AdminDMEngine());
- }
- public void registerAdminCommandHandler(IAdminCommandHandler handler)
- Index: java/config/l2jmods.properties
- ===================================================================
- --- java/config/l2jmods.properties (revision 50)
- +++ java/config/l2jmods.properties (working copy)
- @@ -282,4 +282,21 @@
- # Disabled = -1 (if you want to read adena from SQL)
- # Default value: -1
- NPCBufferStaticCostPerBuff = -1
- -
- \ No newline at end of file
- +
- +#-------------------------------------------------------------
- +# Death Match Event Engine -
- +#-------------------------------------------------------------
- +# Players that haven't participated in DM can target the players of the event (?)
- +DMAllowInterference=false
- +
- +# By setting the following value to true/false, you enable/disable the use of potions in the event.
- +DMAllowPotions=false
- +
- +# Allow/Disallow the participants to have summonings.
- +DMAllowSummon=false
- +
- +# When event starts, the participants lose/keep their effects. (debuffing, etc.)
- +DMOnStartRemoveAllEffects=true
- +
- +# Allow to unsummon the participants' pets, when event starts.
- +DMOnStartUnsummonPet=true
- Index: java/net/sf/l2j/gameserver/model/entity/DM.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/DM.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/DM.java (revision 0)
- @@ -0,0 +1,719 @@
- +/*
- + * 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 2, 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, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * http://www.gnu.org/copyleft/gpl.html
- + */
- +
- +/**
- + *
- + * @author FBIagent
- + *
- + */
- +
- +package net.sf.l2j.gameserver.model.entity;
- +
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.Vector;
- +
- +import javolution.text.TextBuilder;
- +import net.sf.l2j.Config;
- +import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.gameserver.Announcements;
- +import net.sf.l2j.gameserver.datatables.NpcTable;
- +import net.sf.l2j.gameserver.datatables.SpawnTable;
- +import net.sf.l2j.gameserver.ThreadPoolManager;
- +import net.sf.l2j.gameserver.model.L2Effect;
- +import net.sf.l2j.gameserver.model.L2Party;
- +import net.sf.l2j.gameserver.model.L2Spawn;
- +import net.sf.l2j.gameserver.model.L2Summon;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
- +import net.sf.l2j.gameserver.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.serverpackets.MagicSkillUser;
- +import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.serverpackets.StatusUpdate;
- +import net.sf.l2j.gameserver.templates.L2NpcTemplate;
- +
- +import org.apache.commons.logging.Log;
- +import org.apache.commons.logging.LogFactory;
- +
- +public class DM
- +{
- + private final static Log _log = LogFactory.getLog(DM.class.getName());
- + public static String _eventName = new String(),
- + _eventDesc = new String(),
- + _joiningLocationName = new String();
- + public static Vector<String> _savePlayers = new Vector<String>();
- + public static Vector<L2PcInstance> _players = new Vector<L2PcInstance>();
- + public static boolean _joining = false,
- + _teleport = false,
- + _started = false,
- + _sitForced = false;
- + public static L2Spawn _npcSpawn;
- + public static L2PcInstance _topPlayer;
- + public static int _npcId = 0,
- + _npcX = 0,
- + _npcY = 0,
- + _npcZ = 0,
- + _rewardId = 0,
- + _rewardAmount = 0,
- + _topKills = 0,
- + _minlvl = 0,
- + _maxlvl = 0,
- + _playerColors = 0,
- + _playerX = 0,
- + _playerY = 0,
- + _playerZ = 0;
- +
- + public static void setNpcPos(L2PcInstance activeChar)
- + {
- + _npcX = activeChar.getX();
- + _npcY = activeChar.getY();
- + _npcZ = activeChar.getZ();
- + }
- +
- + public static boolean checkMaxLevel(int maxlvl)
- + {
- + if (_minlvl >= maxlvl)
- + return false;
- +
- + return true;
- + }
- +
- + public static boolean checkMinLevel(int minlvl)
- + {
- + if (_maxlvl <= minlvl)
- + return false;
- +
- + return true;
- + }
- +
- + public static void setPlayersPos(L2PcInstance activeChar)
- + {
- + _playerX = activeChar.getX();
- + _playerY = activeChar.getY();
- + _playerZ = activeChar.getZ();
- + }
- +
- + public static boolean checkPlayerOk()
- + {
- + if (_started || _teleport || _joining)
- + return false;
- +
- + return true;
- + }
- +
- + public static void startJoin(L2PcInstance activeChar)
- + {
- + if (!startJoinOk())
- + {
- + if (_log.isDebugEnabled())_log.debug("DM Engine[startJoin(" + activeChar.getName() + ")]: startJoinOk() = false");
- + return;
- + }
- +
- + _joining = true;
- + spawnEventNpc(activeChar);
- + Announcements.getInstance().announceToAll(_eventName + "(DM): Joinable in " + _joiningLocationName + "!");
- + }
- +
- + private static boolean startJoinOk()
- + {
- + if (_started || _teleport || _joining || _eventName.equals("") ||
- + _joiningLocationName.equals("") || _eventDesc.equals("") || _npcId == 0 ||
- + _npcX == 0 || _npcY == 0 || _npcZ == 0 || _rewardId == 0 || _rewardAmount == 0 ||
- + _playerX == 0 || _playerY == 0 || _playerZ == 0)
- + return false;
- +
- + return true;
- + }
- +
- + private static void spawnEventNpc(L2PcInstance activeChar)
- + {
- + L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_npcId);
- +
- + try
- + {
- + _npcSpawn = new L2Spawn(tmpl);
- +
- + _npcSpawn.setLocx(_npcX);
- + _npcSpawn.setLocy(_npcY);
- + _npcSpawn.setLocz(_npcZ);
- + _npcSpawn.setAmount(1);
- + _npcSpawn.setHeading(activeChar.getHeading());
- + _npcSpawn.setRespawnDelay(1);
- +
- + SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
- +
- + _npcSpawn.init();
- + _npcSpawn.getLastSpawn().getStatus().setCurrentHp(999999999);
- + _npcSpawn.getLastSpawn().setTitle(_eventName);
- + _npcSpawn.getLastSpawn()._isEventMobDM = true;
- + _npcSpawn.getLastSpawn().isAggressive();
- + _npcSpawn.getLastSpawn().decayMe();
- + _npcSpawn.getLastSpawn().spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
- +
- + _npcSpawn.getLastSpawn().broadcastPacket(new MagicSkillUser(_npcSpawn.getLastSpawn(), _npcSpawn.getLastSpawn(), 1034, 1, 1, 1));
- + }
- + catch (Exception e)
- + {
- + if (_log.isDebugEnabled())_log.debug("DM Engine[spawnEventNpc(" + activeChar.getName() + ")]: exception: " + e.getMessage());
- + }
- + }
- +
- + public static void teleportStart()
- + {
- + if (!_joining || _started || _teleport)
- + return;
- +
- + _joining = false;
- + Announcements.getInstance().announceToAll(_eventName + "(DM): Teleport to team spot in 20 seconds!");
- +
- + setUserData();
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- + public void run()
- + {
- + DM.sit();
- +
- + for (L2PcInstance player : DM._players)
- + {
- + if (player != null)
- + {
- + if (Config.DM_ON_START_UNSUMMON_PET)
- + {
- + //Remove Summon's buffs
- + if (player.getPet() != null)
- + {
- + L2Summon summon = player.getPet();
- + for (L2Effect e : summon.getAllEffects())
- + e.exit();
- +
- + if (summon instanceof L2PetInstance)
- + summon.unSummon(player);
- + }
- + }
- +
- + if (Config.DM_ON_START_REMOVE_ALL_EFFECTS)
- + {
- + for (L2Effect e : player.getAllEffects())
- + {
- + if (e != null) e.exit();
- + }
- + }
- +
- + // Remove player from his party
- + if (player.getParty() != null)
- + {
- + L2Party party = player.getParty();
- + party.removePartyMember(player);
- + }
- + player.teleToLocation(_playerX, _playerY, _playerZ);
- + }
- + }
- + }
- + }, 20000);
- + _teleport = true;
- + }
- +
- + public static void startEvent(L2PcInstance activeChar)
- + {
- + if (!startEventOk())
- + {
- + if (_log.isDebugEnabled())_log.debug("DM Engine[startEvent(" + activeChar.getName() + ")]: startEventOk() = false");
- + return;
- + }
- +
- + _teleport = false;
- + sit();
- + Announcements.getInstance().announceToAll(_eventName + "(DM): Started. Go to kill your enemies!");
- + _started = true;
- + }
- +
- + private static boolean startEventOk()
- + {
- + if (_joining || !_teleport || _started)
- + return false;
- +
- + return true;
- + }
- +
- + public static void setUserData()
- + {
- + for (L2PcInstance player : _players)
- + {
- + player._originalNameColorDM = player.getAppearance().getNameColor();
- + player._originalKarmaDM = player.getKarma();
- + player._inEventDM = true;
- + player._countDMkills = 0;
- + player.getAppearance().setNameColor(_playerColors);
- + player.setKarma(0);
- + player.broadcastUserInfo();
- + }
- + }
- +
- + public static void removeUserData()
- + {
- + for (L2PcInstance player : _players)
- + {
- + player.getAppearance().setNameColor(player._originalNameColorDM);
- + player.setKarma(player._originalKarmaDM);
- + player._inEventDM = false;
- + player._countDMkills = 0;
- + player.broadcastUserInfo();
- + }
- + }
- +
- + public static void finishEvent(L2PcInstance activeChar)
- + {
- + if (!finishEventOk())
- + {
- + if (_log.isDebugEnabled())_log.debug("DM Engine[finishEvent(" + activeChar.getName() + ")]: finishEventOk() = false");
- + return;
- + }
- +
- + _started = false;
- + unspawnEventNpc();
- + processTopPlayer();
- +
- + if (_topKills == 0)
- + Announcements.getInstance().announceToAll(_eventName + "(DM): No players win the match(nobody killed).");
- + else
- + {
- + Announcements.getInstance().announceToAll(_eventName + "(DM): " + _topPlayer.getName() + " wins the match! " + _topKills + " kills.");
- + rewardPlayer(activeChar);
- + }
- +
- + teleportFinish();
- + }
- +
- + private static boolean finishEventOk()
- + {
- + if (!_started)
- + return false;
- +
- + return true;
- + }
- +
- + public static void processTopPlayer()
- + {
- + for (L2PcInstance player : _players)
- + {
- + if (player._countDMkills > _topKills)
- + {
- + _topPlayer = player;
- + _topKills = player._countDMkills;
- + }
- + }
- + }
- +
- + public static void rewardPlayer(L2PcInstance activeChar)
- + {
- + if (_topPlayer != null)
- + {
- + _topPlayer.addItem("DM Event: " + _eventName, _rewardId, _rewardAmount, _topPlayer, true);
- +
- + StatusUpdate su = new StatusUpdate(_topPlayer.getObjectId());
- + su.addAttribute(StatusUpdate.CUR_LOAD, _topPlayer.getCurrentLoad());
- + _topPlayer.sendPacket(su);
- +
- + NpcHtmlMessage nhm = new NpcHtmlMessage(5);
- + TextBuilder replyMSG = new TextBuilder("");
- +
- + replyMSG.append("<html><body>You won the event. Look in your inventory for the reward.</body></html>");
- +
- + nhm.setHtml(replyMSG.toString());
- + _topPlayer.sendPacket(nhm);
- +
- + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
- + _topPlayer.sendPacket(new ActionFailed());
- + }
- + }
- +
- + public static void abortEvent()
- + {
- + if (!_joining && !_teleport && !_started)
- + return;
- +
- + _joining = false;
- + _teleport = false;
- + _started = false;
- + unspawnEventNpc();
- + Announcements.getInstance().announceToAll(_eventName + "(DM): Match aborted!");
- + teleportFinish();
- + }
- +
- + public static void sit()
- + {
- + if (_sitForced)
- + _sitForced = false;
- + else
- + _sitForced = true;
- +
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + {
- + if (_sitForced)
- + {
- + player.stopMove(null, false);
- + player.abortAttack();
- + player.abortCast();
- +
- + if (!player.isSitting())
- + player.sitDown();
- + }
- + else
- + {
- + if (player.isSitting())
- + player.standUp();
- + }
- + }
- + }
- + }
- +
- + public static void dumpData()
- + {
- + System.out.println("");
- + System.out.println("");
- +
- + if (!_joining && !_teleport && !_started)
- + {
- + System.out.println("<<---------------------------------->>");
- + System.out.println(">> DM Engine infos dump (INACTIVE) <<");
- + System.out.println("<<--^----^^-----^----^^------^^----->>");
- + }
- + else if (_joining && !_teleport && !_started)
- + {
- + System.out.println("<<--------------------------------->>");
- + System.out.println(">> DM Engine infos dump (JOINING) <<");
- + System.out.println("<<--^----^^-----^----^^------^----->>");
- + }
- + else if (!_joining && _teleport && !_started)
- + {
- + System.out.println("<<---------------------------------->>");
- + System.out.println(">> DM Engine infos dump (TELEPORT) <<");
- + System.out.println("<<--^----^^-----^----^^------^^----->>");
- + }
- + else if (!_joining && !_teleport && _started)
- + {
- + System.out.println("<<--------------------------------->>");
- + System.out.println(">> DM Engine infos dump (STARTED) <<");
- + System.out.println("<<--^----^^-----^----^^------^----->>");
- + }
- +
- + System.out.println("Name: " + _eventName);
- + System.out.println("Desc: " + _eventDesc);
- + System.out.println("Join location: " + _joiningLocationName);
- + System.out.println("Min lvl: " + _minlvl);
- + System.out.println("Max lvl: " + _maxlvl);
- +
- + System.out.println("");
- + System.out.println("##################################");
- + System.out.println("# _players(Vector<L2PcInstance>) #");
- + System.out.println("##################################");
- +
- + System.out.println("Total Players : " + _players.size());
- +
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + System.out.println("Name: " + player.getName()+ " kills :" + player._countDMkills);
- + }
- +
- + System.out.println("");
- + System.out.println("################################");
- + System.out.println("# _savePlayers(Vector<String>) #");
- + System.out.println("################################");
- +
- + for (String player : _savePlayers)
- + System.out.println("Name: " + player );
- +
- + System.out.println("");
- + System.out.println("");
- + }
- +
- + public static void loadData()
- + {
- + _eventName = new String();
- + _eventDesc = new String();
- + _joiningLocationName = new String();
- + _savePlayers = new Vector<String>();
- + _players = new Vector<L2PcInstance>();
- + _topPlayer = null;
- + _npcSpawn = null;
- + _joining = false;
- + _teleport = false;
- + _started = false;
- + _sitForced = false;
- + _npcId = 0;
- + _npcX = 0;
- + _npcY = 0;
- + _npcZ = 0;
- + _rewardId = 0;
- + _rewardAmount = 0;
- + _topKills = 0;
- + _minlvl = 0;
- + _maxlvl = 0;
- + _playerColors = 0;
- + _playerX = 0;
- + _playerY = 0;
- + _playerZ = 0;
- +
- + java.sql.Connection con = null;
- + try
- + {
- + PreparedStatement statement;
- + ResultSet rs;
- +
- + con = L2DatabaseFactory.getInstance().getConnection();
- +
- + statement = con.prepareStatement("Select * from dm");
- + rs = statement.executeQuery();
- +
- + while (rs.next())
- + {
- + _eventName = rs.getString("eventName");
- + _eventDesc = rs.getString("eventDesc");
- + _joiningLocationName = rs.getString("joiningLocation");
- + _minlvl = rs.getInt("minlvl");
- + _maxlvl = rs.getInt("maxlvl");
- + _npcId = rs.getInt("npcId");
- + _npcX = rs.getInt("npcX");
- + _npcY = rs.getInt("npcY");
- + _npcZ = rs.getInt("npcZ");
- + _rewardId = rs.getInt("rewardId");
- + _rewardAmount = rs.getInt("rewardAmount");
- + _playerColors = rs.getInt("color");
- + _playerX = rs.getInt("playerX");
- + _playerY = rs.getInt("playerY");
- + _playerZ = rs.getInt("playerZ");
- +
- + }
- + statement.close();
- +
- + }
- + catch (Exception e)
- + {
- + if (_log.isDebugEnabled())_log.debug("Exception: DM.loadData(): " + e.getMessage());
- + }
- + finally {try { con.close(); } catch (Exception e) {}}
- + }
- +
- + public static void saveData()
- + {
- + java.sql.Connection con = null;
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement statement;
- +
- + statement = con.prepareStatement("Delete from dm");
- + statement.execute();
- + statement.close();
- +
- + statement = con.prepareStatement("INSERT INTO dm (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, rewardId, rewardAmount, color, playerX, playerY, player Z ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
- + statement.setString(1, _eventName);
- + statement.setString(2, _eventDesc);
- + statement.setString(3, _joiningLocationName);
- + statement.setInt(4, _minlvl);
- + statement.setInt(5, _maxlvl);
- + statement.setInt(6, _npcId);
- + statement.setInt(7, _npcX);
- + statement.setInt(8, _npcY);
- + statement.setInt(9, _npcZ);
- + statement.setInt(10, _rewardId);
- + statement.setInt(11, _rewardAmount);
- + statement.setInt(12, _playerColors);
- + statement.setInt(13, _playerX);
- + statement.setInt(14, _playerY);
- + statement.setInt(15, _playerZ);
- + statement.execute();
- + statement.close();
- + }
- + catch (Exception e)
- + {
- + if (_log.isDebugEnabled())_log.debug("Exception: DM.saveData(): " + e.getMessage());
- + }
- + finally {try { con.close(); } catch (Exception e) {}}
- + }
- +
- + public static void showEventHtml(L2PcInstance eventPlayer, String objectId)
- + {
- + try
- + {
- + NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
- +
- + TextBuilder replyMSG = new TextBuilder("<html><body>");
- + replyMSG.append("DM Match<br><br><br>");
- + replyMSG.append("Current event...<br1>");
- + replyMSG.append(" ... name: <font color=\"00FF00\">" + _eventName + "</font><br1>");
- + replyMSG.append(" ... description: <font color=\"00FF00\">" + _eventDesc + "</font><br><br>");
- +
- + if (!_started && !_joining)
- + replyMSG.append("<center>Wait till the admin/gm start the participation.</center>");
- + else if (!_started && _joining && eventPlayer.getLevel()>=_minlvl && eventPlayer.getLevel()<=_maxlvl)
- + {
- + if (_players.contains(eventPlayer))
- + {
- + replyMSG.append("You participated already!<br><br>");
- +
- + replyMSG.append("<table border=\"0\"><tr>");
- + replyMSG.append("<td width=\"200\">Wait till event start or</td>");
- + replyMSG.append("<td width=\"60\"><center><button value=\"remove\" action=\"bypass -h npc_" + objectId + "_dmevent_player_leave\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></td>");
- + replyMSG.append("<td width=\"100\">your participation!</td>");
- + replyMSG.append("</tr></table>");
- + }
- + else
- + {
- + replyMSG.append("You want to participate in the event?<br><br>");
- + replyMSG.append("<td width=\"200\">Admin set min lvl : <font color=\"00FF00\">" + _minlvl + "</font></td><br>");
- + replyMSG.append("<td width=\"200\">Admin set max lvl : <font color=\"00FF00\">" + _maxlvl + "</font></td><br><br>");
- +
- + replyMSG.append("<button value=\"Join\" action=\"bypass -h npc_" + objectId + "_dmevent_player_join\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
- +
- + }
- + }
- + else if (_started && !_joining)
- + replyMSG.append("<center>DM match is in progress.</center>");
- + else if (eventPlayer.getLevel()<_minlvl || eventPlayer.getLevel()>_maxlvl )
- + {
- + replyMSG.append("Your lvl : <font color=\"00FF00\">" + eventPlayer.getLevel() +"</font><br>");
- + replyMSG.append("Admin set min lvl : <font color=\"00FF00\">" + _minlvl + "</font><br>");
- + replyMSG.append("Admin set max lvl : <font color=\"00FF00\">" + _maxlvl + "</font><br><br>");
- + replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>");
- + }
- +
- + replyMSG.append("</body></html>");
- + adminReply.setHtml(replyMSG.toString());
- + eventPlayer.sendPacket(adminReply);
- +
- + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
- + eventPlayer.sendPacket(new ActionFailed());
- + }
- + catch (Exception e)
- + {
- + if (_log.isDebugEnabled())_log.debug("DM Engine[showEventHtlm(" + eventPlayer.getName() + ", " + objectId + ")]: exception" + e.getMessage());
- + }
- + }
- +
- + public static void addPlayer(L2PcInstance player)
- + {
- + if (!addPlayerOk(player))
- + return;
- + _players.add(player);
- + player._originalNameColorDM = player.getAppearance().getNameColor();
- + player._originalKarmaDM = player.getKarma();
- + player._inEventDM = true;
- + player._countDMkills = 0;
- + _savePlayers.add(player.getName());
- + }
- +
- + public static boolean addPlayerOk(L2PcInstance eventPlayer)
- + {
- + if (eventPlayer._inEventDM)
- + {
- + eventPlayer.sendMessage("You have already participated in the event!");
- + return false;
- + }
- + return true;
- + }
- +
- + public static synchronized void addDisconnectedPlayer(L2PcInstance player)
- + {
- + if (!_players.contains(player) && _savePlayers.contains(player.getName()))
- + {
- + if (Config.DM_ON_START_REMOVE_ALL_EFFECTS)
- + {
- + for (L2Effect e : player.getAllEffects())
- + {
- + if (e != null)
- + e.exit();
- + }
- + }
- +
- + _players.add(player);
- + player._originalNameColorDM = player.getAppearance().getNameColor();
- + player._originalKarmaDM = player.getKarma();
- + player._inEventDM = true;
- +
- + if (_teleport || _started)
- + {
- + player.setNameColor(_playerColors);
- + player.setKarma(0);
- + player.broadcastUserInfo();
- + player.teleToLocation(_playerX, _playerY , _playerZ);
- + }
- + }
- + }
- +
- + public static void removePlayer(L2PcInstance player)
- + {
- + if (player != null)
- + {
- + _players.remove(player);
- + }
- + }
- +
- + public static void cleanDM()
- + {
- + for (L2PcInstance player : _players)
- + {
- + removePlayer(player);
- + }
- +
- + _savePlayers = new Vector<String>();
- + _topPlayer = null;
- + _npcSpawn = null;
- + _joining = false;
- + _teleport = false;
- + _started = false;
- + _sitForced = false;
- + _topKills = 0;
- + _players = new Vector<L2PcInstance>();
- +
- + }
- +
- + public static void unspawnEventNpc()
- + {
- + if (_npcSpawn == null)
- + return;
- +
- + _npcSpawn.getLastSpawn().deleteMe();
- + _npcSpawn.stopRespawn();
- + SpawnTable.getInstance().deleteSpawn(_npcSpawn, true);
- + }
- +
- + public static void teleportFinish()
- + {
- + Announcements.getInstance().announceToAll(_eventName + "(DM): Teleport back to participation NPC in 20 seconds!");
- +
- + removeUserData();
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
- + {
- + public void run()
- + {
- + for (L2PcInstance player : _players)
- + {
- + if (player != null)
- + player.teleToLocation(_npcX, _npcY, _npcZ);
- + }
- + cleanDM();
- + }
- + }, 20000);
- + }
- +
- +}
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 50)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ -932,6 +932,11 @@
- public static int NPCBUFFER_MAX_SKILLS;
- public static boolean NPCBUFFER_STORE_SCHEMES;
- public static int NPCBUFFER_STATIC_BUFF_COST;
- + public static boolean DM_ALLOW_INTERFERENCE;
- + public static boolean DM_ALLOW_POTIONS;
- + public static boolean DM_ALLOW_SUMMON;
- + public static boolean DM_ON_START_REMOVE_ALL_EFFECTS;
- + public static boolean DM_ON_START_UNSUMMON_PET;
- /** Customs - End */
- // Packet information
- @@ -1961,7 +1966,12 @@
- NPCBUFFER_MAX_SKILLS = Integer.parseInt(L2JModSettings.getProperty("NPCBufferMaxSkllsperScheme", "24"));
- NPCBUFFER_STORE_SCHEMES = Boolean.valueOf(L2JModSettings.getProperty("NPCBufferStoreSchemes", "True"));
- NPCBUFFER_STATIC_BUFF_COST = Integer.parseInt(L2JModSettings.getProperty("NPCBufferStaticCostPerBuff", "-1"));
- -
- + DM_ALLOW_INTERFERENCE = Boolean.parseBoolean(L2JModSettings.getProperty("DMAllowInterference", "false"));
- + DM_ALLOW_POTIONS = Boolean.parseBoolean(L2JModSettings.getProperty("DMAllowPotions", "false"));
- + DM_ALLOW_SUMMON = Boolean.parseBoolean(L2JModSettings.getProperty("DMAllowSummon", "false"));
- + DM_ON_START_REMOVE_ALL_EFFECTS = Boolean.parseBoolean(L2JModSettings.getProperty("DMOnStartRemoveAllEffects", "true"));
- + DM_ON_START_UNSUMMON_PET = Boolean.parseBoolean(L2JModSettings.getProperty("DMOnStartUnsummonPet", "true"));
- +
- if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
- {
- TVT_EVENT_ENABLED = false;
- #P sql
- Index: dm.sql
- ===================================================================
- --- dm.sql (revision 0)
- +++ dm.sql (revision 0)
- @@ -0,0 +1,22 @@
- +-- --------------------------------
- +-- Table structure for table `dm`
- +--
- +
- +DROP TABLE IF EXISTS `dm`;
- +CREATE TABLE `dm` (
- + `eventName` varchar(255) NOT NULL default '',
- + `eventDesc` varchar(255) NOT NULL default '',
- + `joiningLocation` varchar(255) NOT NULL default '',
- + `minlvl` int(4) NOT NULL default '0',
- + `maxlvl` int(4) NOT NULL default '0',
- + `npcId` int(8) NOT NULL default '0',
- + `npcX` int(11) NOT NULL default '0',
- + `npcY` int(11) NOT NULL default '0',
- + `npcZ` int(11) NOT NULL default '0',
- + `rewardId` int(11) NOT NULL default '0',
- + `rewardAmount` int(11) NOT NULL default '0',
- + `color` int(11) NOT NULL default '0',
- + `playerX` int(11) NOT NULL default '0',
- + `playerY` int(11) NOT NULL default '0',
- + `playerZ` int(11) NOT NULL default '0'
- +) DEFAULT CHARSET=utf8;
- \ No newline at end of file
- #P tools
- Index: database_installer.bat
- ===================================================================
- --- database_installer.bat (revision 50)
- +++ database_installer.bat (working copy)
- @@ -551,6 +551,7 @@
- class_list.sql
- cursed_weapons.sql
- dimensional_rift.sql
- +dm.sql
- droplist.sql
- enchant_skill_trees.sql
- etcitem.sql
- Index: full_install.sql
- ===================================================================
- --- full_install.sql (revision 50)
- +++ full_install.sql (working copy)
- @@ -34,6 +34,7 @@
- DROP TABLE IF EXISTS clanhall_functions;
- DROP TABLE IF EXISTS class_list;
- DROP TABLE IF EXISTS cursed_weapons;
- +DROP TABLE IF EXISTS dm;
- DROP TABLE IF EXISTS droplist;
- DROP TABLE IF EXISTS games;
- DROP TABLE IF EXISTS enchant_skill_trees;
- Index: database_installer.sh
- ===================================================================
- --- database_installer.sh (revision 50)
- +++ database_installer.sh (working copy)
- @@ -291,6 +291,7 @@
- $MYG < ../sql/class_list.sql &> /dev/null
- $MYG < ../sql/cursed_weapons.sql &> /dev/null
- $MYG < ../sql/dimensional_rift.sql &> /dev/null
- +$MYG < ../sql/dm.sql &> /dev/null
- $MYG < ../sql/droplist.sql &> /dev/null
- $MYG < ../sql/enchant_skill_trees.sql &> /dev/null
- $MYG < ../sql/etcitem.sql &> /dev/null
Advertisement
Add Comment
Please, Sign In to add comment