Guest User

coyote

a guest
Jan 8th, 2010
1,917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 56.28 KB | None | 0 0
  1. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  2. ===================================================================
  3. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 49)
  4. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  5. @@ -126,6 +126,7 @@
  6.  import net.sf.l2j.gameserver.model.base.Race;
  7.  import net.sf.l2j.gameserver.model.base.SubClass;
  8.  import net.sf.l2j.gameserver.model.entity.Castle;
  9. +import net.sf.l2j.gameserver.model.entity.DM;
  10.  import net.sf.l2j.gameserver.model.entity.Duel;
  11.  import net.sf.l2j.gameserver.model.entity.L2Event;
  12.  import net.sf.l2j.gameserver.model.entity.Siege;
  13. @@ -348,6 +349,12 @@
  14.  
  15.     /** The number of player killed during a PvP (the player killed was PvP Flagged) */
  16.     private int _pvpKills;
  17. +  
  18. +   /** The hexadecimal Color of players name (white is 0xFFFFFF) */
  19. +   private int _nameColor;
  20. +  
  21. +   /** The hexadecimal Color of players title (white is 0xFFFFFF) */
  22. +   private int _titleColor;
  23.  
  24.     /** The PK counter of the L2PcInstance (= Number of non PvP Flagged player killed) */
  25.     private int _pkKills;
  26. @@ -587,6 +594,12 @@
  27.     public LinkedList<String> kills = new LinkedList<String>();
  28.     public boolean eventSitForced = false;
  29.     public boolean atEvent = false;
  30. +  
  31. +   /** DM Engine parameters */
  32. +   public int _originalNameColorDM,
  33. +   _countDMkills,
  34. +   _originalKarmaDM;
  35. +   public boolean _inEventDM = false;
  36.  
  37.     /** new loto ticket **/
  38.     private int _loto[] = new int[5];
  39. @@ -874,6 +887,8 @@
  40.  
  41.         _accountName  = accountName;
  42.         _appearance   = app;
  43. +       _nameColor    = 0xFFFFFF;
  44. +        _titleColor   = 0xFFFF77;
  45.  
  46.         // Create an AI
  47.         _ai = new L2PlayerAI(new L2PcInstance.AIAccessor());
  48. @@ -2379,6 +2394,8 @@
  49.         {
  50.             sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up ...");
  51.         }
  52. +       else if (DM._sitForced && _inEventDM)
  53. +           sendMessage("Only the Event Starter can allow you to stand up!");
  54.         else if (_waitTypeSitting && !isInStoreMode() && !isAlikeDead())
  55.         {
  56.             if (_relax)
  57. @@ -3376,6 +3393,11 @@
  58.             player.sendPacket(new ActionFailed());
  59.             return;
  60.         }
  61. +       if (_inEventDM && DM._started && !Config.DM_ALLOW_INTERFERENCE)
  62. +       {
  63. +           player.sendPacket(new ActionFailed());
  64. +           return;
  65. +       }
  66.  
  67.         // Check if the L2PcInstance is confused
  68.         if (player.isOutOfControl())
  69. @@ -3407,7 +3429,7 @@
  70.             else
  71.             {
  72.                 // Check if this L2PcInstance is autoAttackable
  73. -               if (isAutoAttackable(player))
  74. +               if (isAutoAttackable(player)|| (player._inEventDM && DM._started))
  75.                 {
  76.                     // Player with lvl < 21 can't attack a cursed weapon holder
  77.                     // And a cursed weapon holder  can't attack players with lvl < 21
  78. @@ -4257,6 +4279,25 @@
  79.         if (killer != null)
  80.         {
  81.             L2PcInstance pk = null;
  82. +          
  83. +           if ((killer instanceof L2PcInstance && ((L2PcInstance)killer)._inEventDM) && _inEventDM)
  84. +           {
  85. +               if (DM._teleport || DM._started)
  86. +               {
  87. +                   ((L2PcInstance)killer)._countDMkills++;
  88. +                  
  89. +                   sendMessage("You will be revived and teleported to spot in 20 seconds!");
  90. +                   ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  91. +                   {
  92. +                       public void run()
  93. +                       {
  94. +                           teleToLocation(DM._playerX, DM._playerY, DM._playerZ, false);
  95. +                           doRevive();
  96. +                       }
  97. +                   }, 20000);
  98. +               }
  99. +           }
  100. +          
  101.             if (killer instanceof L2PcInstance)
  102.                 pk = (L2PcInstance) killer;
  103.  
  104. @@ -4346,7 +4387,7 @@
  105.  
  106.     private void onDieDropItem(L2Character killer)
  107.     {
  108. -       if (atEvent || killer == null)
  109. +       if (atEvent || (DM._started && _inEventDM) || (killer == null))
  110.              return;
  111.  
  112.         if (getKarma()<=0
  113. @@ -4462,6 +4503,8 @@
  114.     {
  115.         if (target == null) return;
  116.         if (!(target instanceof L2PlayableInstance)) return;
  117. +      
  118. +       if (_inEventDM) return;
  119.  
  120.         L2PcInstance targetPlayer = null;
  121.         if (target instanceof L2PcInstance)
  122. @@ -4516,6 +4559,8 @@
  123.              }
  124.  
  125.              // 'No war' or 'One way war' -> 'Normal PK'
  126. +            if (!_inEventDM)
  127. +            {
  128.             if (targetPlayer.getKarma() > 0)                                        // Target player has karma
  129.             {
  130.                 if ( Config.KARMA_AWARD_PK_KILL )
  131. @@ -4527,6 +4572,7 @@
  132.             {
  133.                  increasePkKillsAndKarma(targetPlayer.getLevel());
  134.             }
  135. +            }
  136.         }
  137.     }
  138.  
  139. @@ -4536,6 +4582,10 @@
  140.       */
  141.      public void increasePvpKills()
  142.      {
  143. +        if (DM._started && _inEventDM)
  144. +        {
  145. +            return;
  146. +        }
  147.          // Add karma to attacker and increase its PK counter
  148.          setPvpKills(getPvpKills() + 1);
  149.          
  150. @@ -4570,6 +4620,8 @@
  151.       */
  152.      public void increasePkKillsAndKarma(int targLVL)
  153.      {
  154. +    if ((DM._started && _inEventDM))
  155. +       return;
  156.          int baseKarma           = Config.KARMA_MIN_KARMA;
  157.          int newKarma            = baseKarma;
  158.          int karmaLimit          = Config.KARMA_MAX_KARMA;
  159. @@ -4662,6 +4714,8 @@
  160.  
  161.     public void updatePvPStatus()
  162.     {
  163. +       if ((DM._started && _inEventDM))
  164. +           return;
  165.         if (isInsideZone(ZONE_PVP)) return;
  166.         setPvpFlagLasts(System.currentTimeMillis() + Config.PVP_NORMAL_TIME);
  167.  
  168. @@ -4738,7 +4792,7 @@
  169.  
  170.         // Calculate the Experience loss
  171.         long lostExp = 0;
  172. -       if (!atEvent)
  173. +       if ((!atEvent && !_inEventDM))
  174.             if (lvl < Experience.MAX_LEVEL)
  175.                 lostExp = Math.round((getStat().getExpForLevel(lvl+1) - getStat().getExpForLevel(lvl)) * percentLost /100);
  176.             else
  177. @@ -7343,12 +7397,11 @@
  178.             }
  179.  
  180.             // Check if a Forced ATTACK is in progress on non-attackable target
  181. -           if (!target.isAutoAttackable(this) && !forceUse &&
  182. -                   sklTargetType != SkillTargetType.TARGET_AURA &&
  183. -                   sklTargetType != SkillTargetType.TARGET_CLAN &&
  184. -                   sklTargetType != SkillTargetType.TARGET_ALLY &&
  185. -                   sklTargetType != SkillTargetType.TARGET_PARTY &&
  186. -                   sklTargetType != SkillTargetType.TARGET_SELF)
  187. +               if (!target.isAutoAttackable(this) && !forceUse  
  188. +               && !(_inEventDM && DM._started)  
  189. +               && (sklTargetType != SkillTargetType.TARGET_AURA) && (sklTargetType != SkillTargetType.TARGET_CLAN)  
  190. +               && (sklTargetType != SkillTargetType.TARGET_ALLY) && (sklTargetType != SkillTargetType.TARGET_PARTY)  
  191. +               && (sklTargetType != SkillTargetType.TARGET_SELF))
  192.             {
  193.                 // Send a Server->Client packet ActionFailed to the L2PcInstance
  194.                 sendPacket(new ActionFailed());
  195. @@ -7530,6 +7583,8 @@
  196.      */
  197.     public boolean checkPvpSkill(L2Object target, L2Skill skill)
  198.     {
  199. +       if ((_inEventDM && DM._started))
  200. +           return true;
  201.         // check for PC->PC Pvp status
  202.         if (
  203.                 target != null &&                                                       // target not null and
  204. @@ -8407,6 +8462,36 @@
  205.     {
  206.         return _team;
  207.     }
  208. +  
  209. +   public int getNameColor()
  210. +   {
  211. +       return _nameColor;
  212. +   }
  213. +  
  214. +   public void setNameColor(int nameColor)
  215. +   {
  216. +       _nameColor = nameColor;
  217. +   }
  218. +  
  219. +   public int getTitleColor()
  220. +   {
  221. +       return _titleColor;
  222. +   }
  223. +  
  224. +   public void setTitleColor(int titleColor)
  225. +   {
  226. +       _titleColor = titleColor;
  227. +   }
  228. +  
  229. +   public void setTitleColor(int red, int green, int blue)
  230. +   {
  231. +       _titleColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
  232. +   }
  233. +  
  234. +   public void setNameColor(int red, int green, int blue)
  235. +   {
  236. +       _nameColor = (red & 0xFF) + ((green & 0xFF) << 8) + ((blue & 0xFF) << 16);
  237. +   }
  238.  
  239.     public void setWantsPeace(int wantsPeace)
  240.     {
  241. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java
  242. ===================================================================
  243. --- java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java  (revision 47)
  244. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2NpcInstance.java  (working copy)
  245. @@ -61,6 +61,7 @@
  246.  import net.sf.l2j.gameserver.model.actor.stat.NpcStat;
  247.  import net.sf.l2j.gameserver.model.actor.status.NpcStatus;
  248.  import net.sf.l2j.gameserver.model.entity.Castle;
  249. +import net.sf.l2j.gameserver.model.entity.DM;
  250.  import net.sf.l2j.gameserver.model.entity.L2Event;
  251.  import net.sf.l2j.gameserver.model.quest.Quest;
  252.  import net.sf.l2j.gameserver.model.quest.QuestState;
  253. @@ -123,6 +124,7 @@
  254.      private int _castleIndex = -2;
  255.  
  256.      public boolean isEventMob = false;
  257. +    public boolean _isEventMobDM = false;
  258.      private boolean _isInTown = false;
  259.  
  260.      private int _isSpoiledBy = 0;
  261. @@ -655,7 +657,14 @@
  262.                      broadcastPacket(sa);
  263.  
  264.                      // Open a chat window on client with the text of the L2NpcInstance
  265. -                    if(isEventMob){ L2Event.showEventHtml(player, String.valueOf(getObjectId())); }
  266. +                    if(isEventMob)
  267. +                    {
  268. +                       L2Event.showEventHtml(player, String.valueOf(getObjectId()));
  269. +                    }
  270. +                    else if (_isEventMobDM)
  271. +                    {
  272. +                       DM.showEventHtml(player, String.valueOf(this.getObjectId()));
  273. +                    }
  274.                      else
  275.                      {
  276.                          Quest[] qlst = getTemplate().getEventQuests(Quest.QuestEventType.NPC_FIRST_TALK);
  277. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminDMEngine.java
  278. ===================================================================
  279. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminDMEngine.java  (revision 0)
  280. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminDMEngine.java  (revision 0)
  281. @@ -0,0 +1,234 @@
  282. +/*
  283. + * This program is free software; you can redistribute it and/or modify
  284. + * it under the terms of the GNU General Public License as published by
  285. + * the Free Software Foundation; either version 2, or (at your option)
  286. + * any later version.
  287. + *
  288. + * This program is distributed in the hope that it will be useful,
  289. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  290. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  291. + * GNU General Public License for more details.
  292. + *
  293. + * You should have received a copy of the GNU General Public License
  294. + * along with this program; if not, write to the Free Software
  295. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  296. + * 02111-1307, USA.
  297. + *
  298. + * [URL]http://www.gnu.org/copyleft/gpl.html[/URL]
  299. + */
  300. +
  301. +/**
  302. + *
  303. + * @author: FBIagent
  304. + *
  305. + */
  306. +
  307. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  308. +
  309. +import javolution.text.TextBuilder;
  310. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  311. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  312. +import net.sf.l2j.gameserver.model.entity.DM;
  313. +import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
  314. +
  315. +public class AdminDMEngine implements IAdminCommandHandler {
  316. +
  317. + private static String[] _adminCommands = {"admin_dmevent", "admin_dmevent_name", "admin_dmevent_desc", "admin_dmevent_join_loc",
  318. +                                           "admin_dmevent_minlvl", "admin_dmevent_maxlvl", "admin_dmevent_npc", "admin_dmevent_npc_pos",
  319. +                                           "admin_dmevent_reward", "admin_dmevent_reward_amount", "admin_dmevent_spawnpos", "admin_dmevent_color",
  320. +                                           "admin_dmevent_join", "admin_dmevent_teleport", "admin_dmevent_start", "admin_dmevent_abort", "admin_dmevent_finish",
  321. +                                           "admin_dmevent_sit", "admin_dmevent_dump", "admin_dmevent_save", "admin_dmevent_load"};
  322. +
  323. + private static final int REQUIRED_LEVEL = 100;
  324. +
  325. +    public boolean useAdminCommand(String command, L2PcInstance activeChar)
  326. +    {
  327. +        if (!(checkLevel(activeChar.getAccessLevel()) && activeChar.isGM())) return false;
  328. +        
  329. +        if (command.equals("admin_dmevent"))
  330. +            showMainPage(activeChar);
  331. +        else if (command.startsWith("admin_dmevent_name "))
  332. +        {
  333. +            DM._eventName = command.substring(19);
  334. +            showMainPage(activeChar);
  335. +        }
  336. +        else if (command.startsWith("admin_dmevent_desc "))
  337. +        {
  338. +            DM._eventDesc = command.substring(19);
  339. +            showMainPage(activeChar);
  340. +        }
  341. +        else if (command.startsWith("admin_dmevent_minlvl "))
  342. +        {
  343. +            if (!DM.checkMinLevel(Integer.valueOf(command.substring(21))))
  344. +                return false;
  345. +            DM._minlvl = Integer.valueOf(command.substring(21));
  346. +            showMainPage(activeChar);
  347. +        }
  348. +        else if (command.startsWith("admin_dmevent_maxlvl "))
  349. +        {
  350. +            if (!DM.checkMaxLevel(Integer.valueOf(command.substring(21))))
  351. +                return false;
  352. +            DM._maxlvl = Integer.valueOf(command.substring(21));
  353. +            showMainPage(activeChar);
  354. +        }
  355. +        else if (command.startsWith("admin_dmevent_join_loc "))
  356. +        {
  357. +            DM._joiningLocationName = command.substring(23);
  358. +            showMainPage(activeChar);
  359. +        }
  360. +        else if (command.startsWith("admin_dmevent_npc "))
  361. +        {
  362. +            DM._npcId = Integer.valueOf(command.substring(18));
  363. +            showMainPage(activeChar);
  364. +        }
  365. +        else if (command.equals("admin_dmevent_npc_pos"))
  366. +        {
  367. +            DM.setNpcPos(activeChar);
  368. +            showMainPage(activeChar);
  369. +        }
  370. +        else if (command.startsWith("admin_dmevent_reward "))
  371. +        {
  372. +            DM._rewardId = Integer.valueOf(command.substring(21));
  373. +            showMainPage(activeChar);
  374. +        }
  375. +        else if (command.startsWith("admin_dmevent_reward_amount "))
  376. +        {
  377. +            DM._rewardAmount = Integer.valueOf(command.substring(28));
  378. +            showMainPage(activeChar);
  379. +        }
  380. +        else if (command.equals("admin_dmevent_spawnpos"))
  381. +        {
  382. +            DM.setPlayersPos(activeChar);
  383. +            showMainPage(activeChar);
  384. +        }
  385. +        else if (command.startsWith("admin_dmevent_color "))
  386. +        {
  387. +            DM._playerColors = Integer.decode("0x" + command.substring(20));
  388. +            showMainPage(activeChar);
  389. +        }
  390. +        else if(command.equals("admin_dmevent_join"))
  391. +        {
  392. +            DM.startJoin(activeChar);
  393. +            showMainPage(activeChar);
  394. +        }
  395. +        else if (command.equals("admin_dmevent_teleport"))
  396. +        {
  397. +            DM.teleportStart();
  398. +            showMainPage(activeChar);
  399. +        }
  400. +        else if(command.equals("admin_dmevent_start"))
  401. +        {
  402. +            DM.startEvent(activeChar);
  403. +            showMainPage(activeChar);
  404. +        }
  405. +        else if(command.equals("admin_dmevent_abort"))
  406. +        {
  407. +            activeChar.sendMessage("Aborting event");
  408. +            DM.abortEvent();
  409. +            showMainPage(activeChar);
  410. +        }
  411. +        else if(command.equals("admin_dmevent_finish"))
  412. +        {
  413. +            DM.finishEvent(activeChar);
  414. +            showMainPage(activeChar);
  415. +        }
  416. +        else if (command.equals("admin_dmevent_sit"))
  417. +        {
  418. +            DM.sit();
  419. +            showMainPage(activeChar);
  420. +        }
  421. +        else if (command.equals("admin_dmevent_load"))
  422. +        {
  423. +            DM.loadData();
  424. +            showMainPage(activeChar);
  425. +        }
  426. +        else if (command.equals("admin_dmevent_save"))
  427. +        {
  428. +            DM.saveData();
  429. +            showMainPage(activeChar);
  430. +        }
  431. +        else if (command.equals("admin_dmevent_dump"))
  432. +            DM.dumpData();
  433. +
  434. +        return true;
  435. +    }
  436. +
  437. +    public String[] getAdminCommandList()
  438. +    {
  439. +        return _adminCommands;
  440. +    }
  441. +
  442. +    private boolean checkLevel(int level)
  443. +    {
  444. +        return (level >= REQUIRED_LEVEL);
  445. +    }
  446. +
  447. +    public void showMainPage(L2PcInstance activeChar)
  448. +    {
  449. +        NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  450. +        TextBuilder replyMSG = new TextBuilder("<html><body>");
  451. +        
  452. +        replyMSG.append("<center><font color=\"LEVEL\">[dm Engine]</font></center><br><br><br>");
  453. +        replyMSG.append("<table><tr><td><edit var=\"input1\" width=\"125\"></td><td><edit var=\"input2\" width=\"125\"></td></tr></table>");
  454. +        replyMSG.append("<table border=\"0\"><tr>");
  455. +        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>");
  456. +        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>");
  457. +        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>");
  458. +        replyMSG.append("</tr></table><br><table><tr>");
  459. +        replyMSG.append("</tr></table><br><table><tr>");
  460. +        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>");
  461. +        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>");
  462. +        replyMSG.append("</tr></table><br><table><tr>");
  463. +        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>");
  464. +        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>");
  465. +        replyMSG.append("</tr></table><br><table><tr>");
  466. +        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>");
  467. +        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>");
  468. +        replyMSG.append("</tr></table><br><table><tr>");
  469. +        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>");
  470. +        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>");
  471. +        replyMSG.append("</tr></table><table><br><br><tr>");
  472. +        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>");
  473. +        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>");
  474. +        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>");
  475. +        replyMSG.append("</tr></table><table><tr>");
  476. +        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>");
  477. +        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>");
  478. +        replyMSG.append("</tr></table><br><table><tr>");
  479. +        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>");
  480. +        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>");
  481. +        replyMSG.append("</tr></table><br><br><table><tr>");
  482. +        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>");
  483. +        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>");
  484. +        replyMSG.append("</tr></table><br><br>");
  485. +        replyMSG.append("Current event...<br1>");
  486. +        replyMSG.append("    ... name:&nbsp;<font color=\"00FF00\">" + DM._eventName + "</font><br1>");
  487. +        replyMSG.append("    ... description:&nbsp;<font color=\"00FF00\">" + DM._eventDesc + "</font><br1>");
  488. +        replyMSG.append("    ... joining location name:&nbsp;<font color=\"00FF00\">" + DM._joiningLocationName + "</font><br1>");
  489. +        replyMSG.append("    ... joining NPC ID:&nbsp;<font color=\"00FF00\">" + DM._npcId + " on pos " + DM._npcX + "," + DM._npcY + "," + DM._npcZ + "</font><br1>");
  490. +        replyMSG.append("    ... reward ID:&nbsp;<font color=\"00FF00\">" + DM._rewardId + "</font><br1>");
  491. +        replyMSG.append("    ... reward Amount:&nbsp;<font color=\"00FF00\">" + DM._rewardAmount + "</font><br><br>");
  492. +        replyMSG.append("    ... Min lvl:&nbsp;<font color=\"00FF00\">" + DM._minlvl + "</font><br>");
  493. +        replyMSG.append("    ... Max lvl:&nbsp;<font color=\"00FF00\">" + DM._maxlvl + "</font><br><br>");
  494. +        replyMSG.append("    ... Death Match Color:&nbsp;<font color=\"00FF00\">" + DM._playerColors + "</font><br>");
  495. +        replyMSG.append("    ... Death Match Spawn Pos:&nbsp;<font color=\"00FF00\">" + DM._playerX + "," + DM._playerY + "," + DM._playerZ + "</font><br><br>");
  496. +        replyMSG.append("Current players:<br1>");
  497. +        
  498. +        if (!DM._started)
  499. +        {
  500. +            replyMSG.append("<br1>");
  501. +            replyMSG.append(DM._players.size() + " players participating.");
  502. +            replyMSG.append("<br><br>");
  503. +        }
  504. +        else if (DM._started)
  505. +        {
  506. +            replyMSG.append("<br1>");
  507. +            replyMSG.append(DM._players.size() + " players in fighting event.");
  508. +            replyMSG.append("<br><br>");
  509. +        }
  510. +        
  511. +        replyMSG.append("</body></html>");
  512. +        adminReply.setHtml(replyMSG.toString());
  513. +        activeChar.sendPacket(adminReply);
  514. +    }
  515. +}
  516. Index: java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java
  517. ===================================================================
  518. --- java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java (revision 47)
  519. +++ java/net/sf/l2j/gameserver/clientpackets/RequestBypassToServer.java (working copy)
  520. @@ -31,6 +31,7 @@
  521.  import net.sf.l2j.gameserver.model.L2World;
  522.  import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
  523.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  524. +import net.sf.l2j.gameserver.model.entity.DM;
  525.  import net.sf.l2j.gameserver.model.entity.L2Event;
  526.  import net.sf.l2j.gameserver.serverpackets.ActionFailed;
  527.  import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
  528. @@ -103,8 +104,25 @@
  529.                 try
  530.                 {
  531.                     L2Object object = L2World.getInstance().findObject(Integer.parseInt(id));
  532. -
  533. -                   if (_command.substring(endOfId+1).startsWith("event_participate")) L2Event.inscribePlayer(activeChar);
  534. +                   if (_command.substring(endOfId+1).startsWith("dmevent_player_join"))
  535. +                   {
  536. +                       if (DM._joining)
  537. +                           DM.addPlayer(activeChar);
  538. +                       else
  539. +                           activeChar.sendMessage("The event is already started. You can not join now!");
  540. +                   }
  541. +                  
  542. +                   if (_command.substring(endOfId+1).startsWith("dmevent_player_leave"))
  543. +                   {
  544. +                       if (DM._joining)
  545. +                           DM.removePlayer(activeChar);
  546. +                       else
  547. +                       activeChar.sendMessage("The event is already started. You can not leave now!");
  548. +                   }
  549. +                   if (_command.substring(endOfId+1).startsWith("event_participate"))
  550. +                   {
  551. +                       L2Event.inscribePlayer(activeChar);
  552. +                   }
  553.                     else if (object != null && object instanceof L2NpcInstance && endOfId > 0 && activeChar.isInsideRadius(object, L2NpcInstance.INTERACTION_DISTANCE, false, false))
  554.                     {
  555.                         ((L2NpcInstance)object).onBypassFeedback(activeChar, _command.substring(endOfId+1));
  556. Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  557. ===================================================================
  558. --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 47)
  559. +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
  560. @@ -26,6 +26,7 @@
  561.  
  562.  import javolution.util.FastMap;
  563.  import net.sf.l2j.Config;
  564. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminDMEngine;
  565.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  566.  
  567.  /**
  568. @@ -57,6 +58,7 @@
  569.     private AdminCommandHandler()
  570.     {
  571.         _datatable = new FastMap<String, IAdminCommandHandler>();
  572. +       registerAdminCommandHandler(new AdminDMEngine());
  573.     }
  574.  
  575.     public void registerAdminCommandHandler(IAdminCommandHandler handler)
  576. Index: java/config/l2jmods.properties
  577. ===================================================================
  578. --- java/config/l2jmods.properties  (revision 50)
  579. +++ java/config/l2jmods.properties  (working copy)
  580. @@ -282,4 +282,21 @@
  581.  # Disabled = -1 (if you want to read adena from SQL)
  582.  # Default value: -1
  583.  NPCBufferStaticCostPerBuff = -1
  584. -  
  585. \ No newline at end of file
  586. +
  587. +#-------------------------------------------------------------
  588. +#              Death Match Event Engine                      -
  589. +#-------------------------------------------------------------
  590. +# Players that haven't participated in DM can target the players of the event (?)
  591. +DMAllowInterference=false
  592. +
  593. +# By setting the following value to true/false, you enable/disable the use of potions in the event.
  594. +DMAllowPotions=false
  595. +
  596. +# Allow/Disallow the participants to have summonings.
  597. +DMAllowSummon=false
  598. +
  599. +# When event starts, the participants lose/keep their effects. (debuffing, etc.)
  600. +DMOnStartRemoveAllEffects=true
  601. +
  602. +# Allow to unsummon the participants' pets, when event starts.
  603. +DMOnStartUnsummonPet=true
  604. Index: java/net/sf/l2j/gameserver/model/entity/DM.java
  605. ===================================================================
  606. --- java/net/sf/l2j/gameserver/model/entity/DM.java (revision 0)
  607. +++ java/net/sf/l2j/gameserver/model/entity/DM.java (revision 0)
  608. @@ -0,0 +1,719 @@
  609. +/*
  610. + * This program is free software; you can redistribute it and/or modify
  611. + * it under the terms of the GNU General Public License as published by
  612. + * the Free Software Foundation; either version 2, or (at your option)
  613. + * any later version.
  614. + *
  615. + * This program is distributed in the hope that it will be useful,
  616. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  617. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  618. + * GNU General Public License for more details.
  619. + *
  620. + * You should have received a copy of the GNU General Public License
  621. + * along with this program; if not, write to the Free Software
  622. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  623. + * 02111-1307, USA.
  624. + *
  625. + * http://www.gnu.org/copyleft/gpl.html
  626. + */
  627. +
  628. +/**
  629. + *
  630. + * @author FBIagent
  631. + *
  632. + */
  633. +
  634. +package net.sf.l2j.gameserver.model.entity;
  635. +
  636. +import java.sql.PreparedStatement;
  637. +import java.sql.ResultSet;
  638. +import java.util.Vector;
  639. +
  640. +import javolution.text.TextBuilder;
  641. +import net.sf.l2j.Config;
  642. +import net.sf.l2j.L2DatabaseFactory;
  643. +import net.sf.l2j.gameserver.Announcements;
  644. +import net.sf.l2j.gameserver.datatables.NpcTable;
  645. +import net.sf.l2j.gameserver.datatables.SpawnTable;
  646. +import net.sf.l2j.gameserver.ThreadPoolManager;
  647. +import net.sf.l2j.gameserver.model.L2Effect;
  648. +import net.sf.l2j.gameserver.model.L2Party;
  649. +import net.sf.l2j.gameserver.model.L2Spawn;
  650. +import net.sf.l2j.gameserver.model.L2Summon;
  651. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  652. +import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
  653. +import net.sf.l2j.gameserver.serverpackets.ActionFailed;
  654. +import net.sf.l2j.gameserver.serverpackets.MagicSkillUser;
  655. +import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
  656. +import net.sf.l2j.gameserver.serverpackets.StatusUpdate;
  657. +import net.sf.l2j.gameserver.templates.L2NpcTemplate;
  658. +
  659. +import org.apache.commons.logging.Log;
  660. +import org.apache.commons.logging.LogFactory;
  661. +
  662. +public class DM
  663. +{  
  664. +   private final static Log _log = LogFactory.getLog(DM.class.getName());
  665. +   public static String _eventName = new String(),
  666. +       _eventDesc = new String(),
  667. +       _joiningLocationName = new String();
  668. +    public static Vector<String> _savePlayers = new Vector<String>();
  669. +    public static Vector<L2PcInstance> _players = new Vector<L2PcInstance>();                                      
  670. +    public static boolean _joining = false,
  671. +       _teleport = false,
  672. +       _started = false,
  673. +       _sitForced = false;
  674. +    public static L2Spawn _npcSpawn;
  675. +    public static L2PcInstance _topPlayer;
  676. +    public static int _npcId = 0,
  677. +                      _npcX = 0,
  678. +                      _npcY = 0,
  679. +                      _npcZ = 0,
  680. +                      _rewardId = 0,
  681. +                      _rewardAmount = 0,
  682. +                      _topKills = 0,
  683. +                      _minlvl = 0,
  684. +                      _maxlvl = 0,
  685. +                      _playerColors = 0,
  686. +                      _playerX = 0,
  687. +                      _playerY = 0,
  688. +                      _playerZ = 0;
  689. +
  690. +    public static void setNpcPos(L2PcInstance activeChar)
  691. +    {
  692. +        _npcX = activeChar.getX();
  693. +        _npcY = activeChar.getY();
  694. +        _npcZ = activeChar.getZ();
  695. +    }
  696. +    
  697. +    public static boolean checkMaxLevel(int maxlvl)
  698. +    {
  699. +        if (_minlvl >= maxlvl)
  700. +            return false;
  701. +        
  702. +        return true;
  703. +    }
  704. +    
  705. +    public static boolean checkMinLevel(int minlvl)
  706. +    {
  707. +        if (_maxlvl <= minlvl)
  708. +            return false;
  709. +        
  710. +        return true;
  711. +    }
  712. +    
  713. +    public static void setPlayersPos(L2PcInstance activeChar)
  714. +    {
  715. +        _playerX = activeChar.getX();
  716. +        _playerY = activeChar.getY();
  717. +        _playerZ = activeChar.getZ();
  718. +    }
  719. +    
  720. +    public static boolean checkPlayerOk()
  721. +    {
  722. +        if (_started || _teleport || _joining)
  723. +            return false;
  724. +        
  725. +        return true;
  726. +    }
  727. +    
  728. +    public static void startJoin(L2PcInstance activeChar)
  729. +    {
  730. +        if (!startJoinOk())
  731. +        {
  732. +           if (_log.isDebugEnabled())_log.debug("DM Engine[startJoin(" + activeChar.getName() + ")]: startJoinOk() = false");
  733. +            return;
  734. +        }
  735. +        
  736. +        _joining = true;
  737. +        spawnEventNpc(activeChar);
  738. +        Announcements.getInstance().announceToAll(_eventName + "(DM): Joinable in " + _joiningLocationName + "!");
  739. +    }
  740. +    
  741. +    private static boolean startJoinOk()
  742. +    {
  743. +        if (_started || _teleport || _joining || _eventName.equals("") ||
  744. +            _joiningLocationName.equals("") || _eventDesc.equals("") || _npcId == 0 ||
  745. +            _npcX == 0 || _npcY == 0 || _npcZ == 0 || _rewardId == 0 || _rewardAmount == 0 ||
  746. +            _playerX == 0 || _playerY == 0 || _playerZ == 0)
  747. +            return false;
  748. +        
  749. +        return true;
  750. +    }
  751. +    
  752. +    private static void spawnEventNpc(L2PcInstance activeChar)
  753. +    {
  754. +        L2NpcTemplate tmpl = NpcTable.getInstance().getTemplate(_npcId);
  755. +
  756. +        try
  757. +        {
  758. +            _npcSpawn = new L2Spawn(tmpl);
  759. +
  760. +            _npcSpawn.setLocx(_npcX);
  761. +            _npcSpawn.setLocy(_npcY);
  762. +            _npcSpawn.setLocz(_npcZ);
  763. +            _npcSpawn.setAmount(1);
  764. +            _npcSpawn.setHeading(activeChar.getHeading());
  765. +            _npcSpawn.setRespawnDelay(1);
  766. +
  767. +            SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
  768. +
  769. +            _npcSpawn.init();
  770. +            _npcSpawn.getLastSpawn().getStatus().setCurrentHp(999999999);
  771. +            _npcSpawn.getLastSpawn().setTitle(_eventName);
  772. +            _npcSpawn.getLastSpawn()._isEventMobDM = true;
  773. +            _npcSpawn.getLastSpawn().isAggressive();
  774. +            _npcSpawn.getLastSpawn().decayMe();
  775. +            _npcSpawn.getLastSpawn().spawnMe(_npcSpawn.getLastSpawn().getX(), _npcSpawn.getLastSpawn().getY(), _npcSpawn.getLastSpawn().getZ());
  776. +
  777. +            _npcSpawn.getLastSpawn().broadcastPacket(new MagicSkillUser(_npcSpawn.getLastSpawn(), _npcSpawn.getLastSpawn(), 1034, 1, 1, 1));
  778. +        }
  779. +        catch (Exception e)
  780. +        {
  781. +           if (_log.isDebugEnabled())_log.debug("DM Engine[spawnEventNpc(" + activeChar.getName() + ")]: exception: " + e.getMessage());
  782. +        }
  783. +    }
  784. +    
  785. +    public static void teleportStart()
  786. +    {
  787. +        if (!_joining || _started || _teleport)
  788. +            return;
  789. +        
  790. +        _joining = false;
  791. +        Announcements.getInstance().announceToAll(_eventName + "(DM): Teleport to team spot in 20 seconds!");
  792. +
  793. +        setUserData();
  794. +        ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  795. +        {
  796. +           public void run()
  797. +           {
  798. +               DM.sit();
  799. +              
  800. +               for (L2PcInstance player : DM._players)
  801. +               {
  802. +                   if (player !=  null)
  803. +                   {
  804. +                       if (Config.DM_ON_START_UNSUMMON_PET)
  805. +                       {
  806. +                           //Remove Summon's buffs
  807. +                           if (player.getPet() != null)
  808. +                           {
  809. +                               L2Summon summon = player.getPet();
  810. +                               for (L2Effect e : summon.getAllEffects())
  811. +                               e.exit();
  812. +                              
  813. +                               if (summon instanceof L2PetInstance)
  814. +                               summon.unSummon(player);
  815. +                           }
  816. +                       }
  817. +                      
  818. +                       if (Config.DM_ON_START_REMOVE_ALL_EFFECTS)
  819. +                       {
  820. +                           for (L2Effect e : player.getAllEffects())
  821. +                           {
  822. +                               if (e != null) e.exit();
  823. +                           }
  824. +                       }
  825. +                      
  826. +                       // Remove player from his party
  827. +                       if (player.getParty() != null)
  828. +                       {
  829. +                           L2Party party = player.getParty();
  830. +                           party.removePartyMember(player);
  831. +                       }
  832. +                       player.teleToLocation(_playerX, _playerY, _playerZ);
  833. +                   }
  834. +               }
  835. +           }
  836. +        }, 20000);
  837. +        _teleport = true;
  838. +    }
  839. +    
  840. +    public static void startEvent(L2PcInstance activeChar)
  841. +    {
  842. +        if (!startEventOk())
  843. +        {
  844. +           if (_log.isDebugEnabled())_log.debug("DM Engine[startEvent(" + activeChar.getName() + ")]: startEventOk() = false");
  845. +            return;
  846. +        }
  847. +        
  848. +        _teleport = false;
  849. +        sit();
  850. +        Announcements.getInstance().announceToAll(_eventName + "(DM): Started. Go to kill your enemies!");
  851. +        _started = true;
  852. +    }
  853. +    
  854. +    private static boolean startEventOk()
  855. +    {
  856. +        if (_joining || !_teleport || _started)
  857. +            return false;
  858. +        
  859. +        return true;
  860. +    }
  861. +    
  862. +    public static void setUserData()
  863. +    {
  864. +        for (L2PcInstance player : _players)
  865. +        {
  866. +           player._originalNameColorDM = player.getAppearance().getNameColor();
  867. +           player._originalKarmaDM = player.getKarma();
  868. +           player._inEventDM = true;
  869. +           player._countDMkills = 0;
  870. +           player.getAppearance().setNameColor(_playerColors);
  871. +            player.setKarma(0);
  872. +            player.broadcastUserInfo();
  873. +        }
  874. +    }
  875. +    
  876. +    public static void removeUserData()
  877. +   {
  878. +       for (L2PcInstance player : _players)
  879. +       {
  880. +           player.getAppearance().setNameColor(player._originalNameColorDM);
  881. +           player.setKarma(player._originalKarmaDM);
  882. +           player._inEventDM = false;
  883. +           player._countDMkills = 0;
  884. +           player.broadcastUserInfo();
  885. +       }
  886. +   }
  887. +    
  888. +    public static void finishEvent(L2PcInstance activeChar)
  889. +    {
  890. +        if (!finishEventOk())
  891. +        {
  892. +            if (_log.isDebugEnabled())_log.debug("DM Engine[finishEvent(" + activeChar.getName() + ")]: finishEventOk() = false");
  893. +            return;
  894. +        }
  895. +
  896. +        _started = false;
  897. +        unspawnEventNpc();
  898. +        processTopPlayer();
  899. +
  900. +        if (_topKills == 0)
  901. +            Announcements.getInstance().announceToAll(_eventName + "(DM): No players win the match(nobody killed).");
  902. +        else
  903. +        {
  904. +            Announcements.getInstance().announceToAll(_eventName + "(DM): " + _topPlayer.getName() + " wins the match! " + _topKills + " kills.");
  905. +            rewardPlayer(activeChar);
  906. +        }
  907. +        
  908. +        teleportFinish();
  909. +    }
  910. +    
  911. +    private static boolean finishEventOk()
  912. +    {
  913. +        if (!_started)
  914. +            return false;
  915. +        
  916. +        return true;
  917. +    }
  918. +    
  919. +    public static void processTopPlayer()
  920. +    {
  921. +        for (L2PcInstance player : _players)
  922. +        {
  923. +           if (player._countDMkills > _topKills)
  924. +            {
  925. +                _topPlayer = player;
  926. +                _topKills = player._countDMkills;
  927. +            }
  928. +        }
  929. +    }
  930. +    
  931. +    public static void rewardPlayer(L2PcInstance activeChar)
  932. +    {
  933. +       if (_topPlayer != null)
  934. +       {
  935. +           _topPlayer.addItem("DM Event: " + _eventName, _rewardId, _rewardAmount, _topPlayer, true);
  936. +          
  937. +           StatusUpdate su = new StatusUpdate(_topPlayer.getObjectId());
  938. +           su.addAttribute(StatusUpdate.CUR_LOAD, _topPlayer.getCurrentLoad());
  939. +           _topPlayer.sendPacket(su);
  940. +          
  941. +           NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  942. +           TextBuilder replyMSG = new TextBuilder("");
  943. +          
  944. +           replyMSG.append("<html><body>You won the event. Look in your inventory for the reward.</body></html>");
  945. +          
  946. +           nhm.setHtml(replyMSG.toString());
  947. +           _topPlayer.sendPacket(nhm);
  948. +          
  949. +           // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  950. +           _topPlayer.sendPacket(new ActionFailed());
  951. +        }
  952. +    }
  953. +    
  954. +    public static void abortEvent()
  955. +    {
  956. +        if (!_joining && !_teleport && !_started)
  957. +            return;
  958. +        
  959. +        _joining = false;
  960. +        _teleport = false;
  961. +        _started = false;
  962. +        unspawnEventNpc();
  963. +        Announcements.getInstance().announceToAll(_eventName + "(DM): Match aborted!");
  964. +        teleportFinish();
  965. +    }
  966. +    
  967. +    public static void sit()
  968. +    {
  969. +        if (_sitForced)
  970. +            _sitForced = false;
  971. +        else
  972. +            _sitForced = true;
  973. +        
  974. +        for (L2PcInstance player : _players)
  975. +        {
  976. +            if (player != null)
  977. +            {
  978. +                if (_sitForced)
  979. +                {
  980. +                    player.stopMove(null, false);
  981. +                    player.abortAttack();
  982. +                    player.abortCast();
  983. +                    
  984. +                    if (!player.isSitting())
  985. +                        player.sitDown();
  986. +                }
  987. +                else
  988. +                {
  989. +                    if (player.isSitting())
  990. +                        player.standUp();
  991. +                }
  992. +            }
  993. +        }
  994. +    }
  995. +    
  996. +    public static void dumpData()
  997. +    {
  998. +        System.out.println("");
  999. +        System.out.println("");
  1000. +        
  1001. +        if (!_joining && !_teleport && !_started)
  1002. +        {
  1003. +            System.out.println("<<---------------------------------->>");
  1004. +            System.out.println(">> DM Engine infos dump (INACTIVE) <<");
  1005. +            System.out.println("<<--^----^^-----^----^^------^^----->>");
  1006. +        }
  1007. +        else if (_joining && !_teleport && !_started)
  1008. +        {
  1009. +            System.out.println("<<--------------------------------->>");
  1010. +            System.out.println(">> DM Engine infos dump (JOINING) <<");
  1011. +            System.out.println("<<--^----^^-----^----^^------^----->>");
  1012. +        }
  1013. +        else if (!_joining && _teleport && !_started)
  1014. +        {
  1015. +            System.out.println("<<---------------------------------->>");
  1016. +            System.out.println(">> DM Engine infos dump (TELEPORT) <<");
  1017. +            System.out.println("<<--^----^^-----^----^^------^^----->>");
  1018. +        }
  1019. +        else if (!_joining && !_teleport && _started)
  1020. +        {
  1021. +            System.out.println("<<--------------------------------->>");
  1022. +            System.out.println(">> DM Engine infos dump (STARTED) <<");
  1023. +            System.out.println("<<--^----^^-----^----^^------^----->>");
  1024. +        }
  1025. +
  1026. +        System.out.println("Name: " + _eventName);
  1027. +        System.out.println("Desc: " + _eventDesc);
  1028. +        System.out.println("Join location: " + _joiningLocationName);
  1029. +        System.out.println("Min lvl: " + _minlvl);
  1030. +        System.out.println("Max lvl: " + _maxlvl);
  1031. +        
  1032. +        System.out.println("");
  1033. +        System.out.println("##################################");
  1034. +        System.out.println("# _players(Vector<L2PcInstance>) #");
  1035. +        System.out.println("##################################");
  1036. +        
  1037. +        System.out.println("Total Players : " + _players.size());
  1038. +        
  1039. +        for (L2PcInstance player : _players)
  1040. +        {
  1041. +            if (player != null)
  1042. +                System.out.println("Name: " + player.getName()+ " kills :" + player._countDMkills);
  1043. +        }
  1044. +        
  1045. +        System.out.println("");
  1046. +        System.out.println("################################");
  1047. +        System.out.println("# _savePlayers(Vector<String>) #");
  1048. +        System.out.println("################################");
  1049. +        
  1050. +        for (String player : _savePlayers)
  1051. +            System.out.println("Name: " + player );
  1052. +        
  1053. +        System.out.println("");
  1054. +        System.out.println("");
  1055. +    }
  1056. +    
  1057. +    public static void loadData()
  1058. +    {
  1059. +        _eventName = new String();
  1060. +        _eventDesc = new String();
  1061. +        _joiningLocationName = new String();
  1062. +        _savePlayers = new Vector<String>();
  1063. +        _players = new Vector<L2PcInstance>();
  1064. +        _topPlayer = null;
  1065. +        _npcSpawn = null;
  1066. +        _joining = false;
  1067. +        _teleport = false;
  1068. +        _started = false;
  1069. +        _sitForced = false;
  1070. +        _npcId = 0;
  1071. +       _npcX = 0;
  1072. +       _npcY = 0;
  1073. +       _npcZ = 0;
  1074. +       _rewardId = 0;
  1075. +       _rewardAmount = 0;
  1076. +       _topKills = 0;
  1077. +       _minlvl = 0;
  1078. +       _maxlvl = 0;
  1079. +       _playerColors = 0;
  1080. +       _playerX = 0;
  1081. +       _playerY = 0;
  1082. +       _playerZ = 0;
  1083. +        
  1084. +        java.sql.Connection con = null;
  1085. +        try
  1086. +        {
  1087. +            PreparedStatement statement;
  1088. +            ResultSet rs;
  1089. +
  1090. +            con = L2DatabaseFactory.getInstance().getConnection();
  1091. +
  1092. +            statement = con.prepareStatement("Select * from dm");
  1093. +            rs = statement.executeQuery();
  1094. +            
  1095. +            while (rs.next())
  1096. +            {        
  1097. +                _eventName = rs.getString("eventName");
  1098. +                _eventDesc = rs.getString("eventDesc");
  1099. +                _joiningLocationName = rs.getString("joiningLocation");
  1100. +                _minlvl = rs.getInt("minlvl");
  1101. +                _maxlvl = rs.getInt("maxlvl");
  1102. +                _npcId = rs.getInt("npcId");
  1103. +                _npcX = rs.getInt("npcX");
  1104. +                _npcY = rs.getInt("npcY");
  1105. +                _npcZ = rs.getInt("npcZ");
  1106. +                _rewardId = rs.getInt("rewardId");
  1107. +                _rewardAmount = rs.getInt("rewardAmount");
  1108. +                _playerColors = rs.getInt("color");
  1109. +                _playerX = rs.getInt("playerX");
  1110. +                _playerY = rs.getInt("playerY");
  1111. +                _playerZ = rs.getInt("playerZ");
  1112. +            
  1113. +            }                    
  1114. +            statement.close();            
  1115. +                  
  1116. +        }        
  1117. +        catch (Exception e)
  1118. +        {
  1119. +            if (_log.isDebugEnabled())_log.debug("Exception: DM.loadData(): " + e.getMessage());
  1120. +        }
  1121. +        finally {try { con.close(); } catch (Exception e) {}}
  1122. +    }
  1123. +    
  1124. +    public static void saveData()
  1125. +    {
  1126. +        java.sql.Connection con = null;
  1127. +        try
  1128. +        {
  1129. +            con = L2DatabaseFactory.getInstance().getConnection();
  1130. +            PreparedStatement statement;
  1131. +            
  1132. +            statement = con.prepareStatement("Delete from dm");
  1133. +            statement.execute();
  1134. +            statement.close();
  1135. +
  1136. +            statement = con.prepareStatement("INSERT INTO dm (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, rewardId, rewardAmount, color, playerX, playerY, player Z ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");  
  1137. +            statement.setString(1, _eventName);
  1138. +            statement.setString(2, _eventDesc);
  1139. +            statement.setString(3, _joiningLocationName);
  1140. +            statement.setInt(4, _minlvl);
  1141. +            statement.setInt(5, _maxlvl);
  1142. +            statement.setInt(6, _npcId);
  1143. +            statement.setInt(7, _npcX);
  1144. +            statement.setInt(8, _npcY);
  1145. +            statement.setInt(9, _npcZ);
  1146. +            statement.setInt(10, _rewardId);
  1147. +            statement.setInt(11, _rewardAmount);
  1148. +            statement.setInt(12, _playerColors);
  1149. +            statement.setInt(13, _playerX);
  1150. +            statement.setInt(14, _playerY);
  1151. +            statement.setInt(15, _playerZ);
  1152. +            statement.execute();
  1153. +            statement.close();            
  1154. +        }
  1155. +        catch (Exception e)
  1156. +        {
  1157. +            if (_log.isDebugEnabled())_log.debug("Exception: DM.saveData(): " + e.getMessage());
  1158. +        }        
  1159. +        finally {try { con.close(); } catch (Exception e) {}}
  1160. +    }
  1161. +
  1162. +    public static void showEventHtml(L2PcInstance eventPlayer, String objectId)
  1163. +    {
  1164. +        try
  1165. +        {
  1166. +            NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  1167. +
  1168. +            TextBuilder replyMSG = new TextBuilder("<html><body>");
  1169. +            replyMSG.append("DM Match<br><br><br>");
  1170. +            replyMSG.append("Current event...<br1>");
  1171. +            replyMSG.append("    ... name:&nbsp;<font color=\"00FF00\">" + _eventName + "</font><br1>");
  1172. +            replyMSG.append("    ... description:&nbsp;<font color=\"00FF00\">" + _eventDesc + "</font><br><br>");
  1173. +
  1174. +            if (!_started && !_joining)
  1175. +                replyMSG.append("<center>Wait till the admin/gm start the participation.</center>");
  1176. +            else if (!_started && _joining && eventPlayer.getLevel()>=_minlvl && eventPlayer.getLevel()<=_maxlvl)
  1177. +            {
  1178. +                if (_players.contains(eventPlayer))
  1179. +                {
  1180. +                    replyMSG.append("You participated already!<br><br>");
  1181. +
  1182. +                    replyMSG.append("<table border=\"0\"><tr>");
  1183. +                    replyMSG.append("<td width=\"200\">Wait till event start or</td>");
  1184. +                    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>");
  1185. +                    replyMSG.append("<td width=\"100\">your participation!</td>");
  1186. +                    replyMSG.append("</tr></table>");
  1187. +                }
  1188. +                else
  1189. +                {
  1190. +                    replyMSG.append("You want to participate in the event?<br><br>");
  1191. +                    replyMSG.append("<td width=\"200\">Admin set min lvl : <font color=\"00FF00\">" + _minlvl + "</font></td><br>");
  1192. +                    replyMSG.append("<td width=\"200\">Admin set max lvl : <font color=\"00FF00\">" + _maxlvl + "</font></td><br><br>");
  1193. +                    
  1194. +                    replyMSG.append("<button value=\"Join\" action=\"bypass -h npc_" + objectId + "_dmevent_player_join\" width=50 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
  1195. +                    
  1196. +                }
  1197. +            }
  1198. +            else if (_started && !_joining)
  1199. +                replyMSG.append("<center>DM match is in progress.</center>");
  1200. +            else if (eventPlayer.getLevel()<_minlvl || eventPlayer.getLevel()>_maxlvl )
  1201. +            {
  1202. +                replyMSG.append("Your lvl : <font color=\"00FF00\">" + eventPlayer.getLevel() +"</font><br>");
  1203. +                replyMSG.append("Admin set min lvl : <font color=\"00FF00\">" + _minlvl + "</font><br>");
  1204. +                replyMSG.append("Admin set max lvl : <font color=\"00FF00\">" + _maxlvl + "</font><br><br>");
  1205. +                replyMSG.append("<font color=\"FFFF00\">You can't participate to this event.</font><br>");
  1206. +            }
  1207. +            
  1208. +            replyMSG.append("</body></html>");
  1209. +            adminReply.setHtml(replyMSG.toString());
  1210. +            eventPlayer.sendPacket(adminReply);
  1211. +            
  1212. +         // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  1213. +         eventPlayer.sendPacket(new ActionFailed());
  1214. +        }
  1215. +        catch (Exception e)
  1216. +        {
  1217. +            if (_log.isDebugEnabled())_log.debug("DM Engine[showEventHtlm(" + eventPlayer.getName() + ", " + objectId + ")]: exception" + e.getMessage());
  1218. +        }
  1219. +    }
  1220. +
  1221. +    public static void addPlayer(L2PcInstance player)
  1222. +    {
  1223. +        if (!addPlayerOk(player))
  1224. +            return;
  1225. +        _players.add(player);
  1226. +        player._originalNameColorDM = player.getAppearance().getNameColor();
  1227. +        player._originalKarmaDM = player.getKarma();
  1228. +        player._inEventDM = true;
  1229. +        player._countDMkills = 0;
  1230. +       _savePlayers.add(player.getName());
  1231. +    }
  1232. +    
  1233. +    public static boolean addPlayerOk(L2PcInstance eventPlayer)
  1234. +    {
  1235. +       if (eventPlayer._inEventDM)
  1236. +       {
  1237. +           eventPlayer.sendMessage("You have already participated in the event!");  
  1238. +           return false;
  1239. +       }
  1240. +        return true;
  1241. +    }
  1242. +
  1243. +    public static synchronized void addDisconnectedPlayer(L2PcInstance player)
  1244. +    {
  1245. +       if (!_players.contains(player) && _savePlayers.contains(player.getName()))
  1246. +       {
  1247. +           if (Config.DM_ON_START_REMOVE_ALL_EFFECTS)
  1248. +           {
  1249. +               for (L2Effect e : player.getAllEffects())
  1250. +               {
  1251. +                   if (e != null)
  1252. +                   e.exit();
  1253. +               }
  1254. +           }
  1255. +          
  1256. +            _players.add(player);
  1257. +            player._originalNameColorDM = player.getAppearance().getNameColor();
  1258. +            player._originalKarmaDM = player.getKarma();
  1259. +            player._inEventDM = true;
  1260. +
  1261. +            if (_teleport || _started)
  1262. +            {
  1263. +                player.setNameColor(_playerColors);
  1264. +                player.setKarma(0);
  1265. +                player.broadcastUserInfo();
  1266. +                player.teleToLocation(_playerX, _playerY , _playerZ);
  1267. +            }
  1268. +        }
  1269. +    }
  1270. +    
  1271. +    public static void removePlayer(L2PcInstance player)
  1272. +    {
  1273. +        if (player != null)
  1274. +        {
  1275. +            _players.remove(player);
  1276. +        }
  1277. +    }
  1278. +    
  1279. +    public static void cleanDM()
  1280. +    {
  1281. +        for (L2PcInstance player : _players)
  1282. +        {
  1283. +            removePlayer(player);            
  1284. +        }
  1285. +
  1286. +        _savePlayers = new Vector<String>();
  1287. +       _topPlayer = null;
  1288. +       _npcSpawn = null;
  1289. +       _joining = false;
  1290. +       _teleport = false;
  1291. +       _started = false;
  1292. +       _sitForced = false;
  1293. +        _topKills = 0;
  1294. +        _players = new Vector<L2PcInstance>();
  1295. +        
  1296. +    }
  1297. +    
  1298. +    public static void unspawnEventNpc()
  1299. +    {
  1300. +        if (_npcSpawn == null)
  1301. +            return;
  1302. +
  1303. +        _npcSpawn.getLastSpawn().deleteMe();
  1304. +        _npcSpawn.stopRespawn();
  1305. +        SpawnTable.getInstance().deleteSpawn(_npcSpawn, true);
  1306. +    }
  1307. +    
  1308. +    public static void teleportFinish()
  1309. +    {
  1310. +        Announcements.getInstance().announceToAll(_eventName + "(DM): Teleport back to participation NPC in 20 seconds!");
  1311. +
  1312. +        removeUserData();
  1313. +        ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  1314. +        {
  1315. +           public void run()
  1316. +           {
  1317. +               for (L2PcInstance player : _players)
  1318. +               {
  1319. +                   if (player !=  null)
  1320. +                   player.teleToLocation(_npcX, _npcY, _npcZ);
  1321. +               }  
  1322. +               cleanDM();
  1323. +           }
  1324. +        }, 20000);
  1325. +    }    
  1326. +    
  1327. +}
  1328. Index: java/net/sf/l2j/Config.java
  1329. ===================================================================
  1330. --- java/net/sf/l2j/Config.java (revision 50)
  1331. +++ java/net/sf/l2j/Config.java (working copy)
  1332. @@ -932,6 +932,11 @@
  1333.     public static int       NPCBUFFER_MAX_SKILLS;
  1334.     public static boolean   NPCBUFFER_STORE_SCHEMES;
  1335.     public static int       NPCBUFFER_STATIC_BUFF_COST;
  1336. +   public static boolean   DM_ALLOW_INTERFERENCE;
  1337. +   public static boolean   DM_ALLOW_POTIONS;
  1338. +   public static boolean   DM_ALLOW_SUMMON;
  1339. +   public static boolean   DM_ON_START_REMOVE_ALL_EFFECTS;
  1340. +   public static boolean   DM_ON_START_UNSUMMON_PET;
  1341.      /** Customs - End              */
  1342.  
  1343.      // Packet information
  1344. @@ -1961,7 +1966,12 @@
  1345.                 NPCBUFFER_MAX_SKILLS                    = Integer.parseInt(L2JModSettings.getProperty("NPCBufferMaxSkllsperScheme", "24"));
  1346.                 NPCBUFFER_STORE_SCHEMES                 = Boolean.valueOf(L2JModSettings.getProperty("NPCBufferStoreSchemes", "True"));
  1347.                 NPCBUFFER_STATIC_BUFF_COST              = Integer.parseInt(L2JModSettings.getProperty("NPCBufferStaticCostPerBuff", "-1"));
  1348. -              
  1349. +               DM_ALLOW_INTERFERENCE                   = Boolean.parseBoolean(L2JModSettings.getProperty("DMAllowInterference", "false"));
  1350. +               DM_ALLOW_POTIONS                        = Boolean.parseBoolean(L2JModSettings.getProperty("DMAllowPotions", "false"));
  1351. +               DM_ALLOW_SUMMON                         = Boolean.parseBoolean(L2JModSettings.getProperty("DMAllowSummon", "false"));
  1352. +               DM_ON_START_REMOVE_ALL_EFFECTS          = Boolean.parseBoolean(L2JModSettings.getProperty("DMOnStartRemoveAllEffects", "true"));
  1353. +               DM_ON_START_UNSUMMON_PET                = Boolean.parseBoolean(L2JModSettings.getProperty("DMOnStartUnsummonPet", "true"));
  1354. +              
  1355.                  if (TVT_EVENT_PARTICIPATION_NPC_ID == 0)
  1356.                  {
  1357.                      TVT_EVENT_ENABLED = false;
  1358. #P sql
  1359. Index: dm.sql
  1360. ===================================================================
  1361. --- dm.sql  (revision 0)
  1362. +++ dm.sql  (revision 0)
  1363. @@ -0,0 +1,22 @@
  1364. +-- --------------------------------
  1365. +-- Table structure for table `dm`
  1366. +--
  1367. +
  1368. +DROP TABLE IF EXISTS `dm`;
  1369. +CREATE TABLE `dm` (
  1370. +  `eventName` varchar(255) NOT NULL default '',
  1371. +  `eventDesc` varchar(255) NOT NULL default '',
  1372. +  `joiningLocation` varchar(255) NOT NULL default '',
  1373. +  `minlvl` int(4) NOT NULL default '0',
  1374. +  `maxlvl` int(4) NOT NULL default '0',
  1375. +  `npcId` int(8) NOT NULL default '0',
  1376. +  `npcX` int(11) NOT NULL default '0',
  1377. +  `npcY` int(11) NOT NULL default '0',
  1378. +  `npcZ` int(11) NOT NULL default '0',
  1379. +  `rewardId` int(11) NOT NULL default '0',
  1380. +  `rewardAmount` int(11) NOT NULL default '0',
  1381. +  `color` int(11) NOT NULL default '0',
  1382. +  `playerX` int(11) NOT NULL default '0',
  1383. +  `playerY` int(11) NOT NULL default '0',
  1384. +  `playerZ` int(11) NOT NULL default '0'  
  1385. +) DEFAULT CHARSET=utf8;
  1386. \ No newline at end of file
  1387. #P tools
  1388. Index: database_installer.bat
  1389. ===================================================================
  1390. --- database_installer.bat  (revision 50)
  1391. +++ database_installer.bat  (working copy)
  1392. @@ -551,6 +551,7 @@
  1393.  class_list.sql
  1394.  cursed_weapons.sql
  1395.  dimensional_rift.sql
  1396. +dm.sql
  1397.  droplist.sql
  1398.  enchant_skill_trees.sql
  1399.  etcitem.sql
  1400. Index: full_install.sql
  1401. ===================================================================
  1402. --- full_install.sql    (revision 50)
  1403. +++ full_install.sql    (working copy)
  1404. @@ -34,6 +34,7 @@
  1405.  DROP TABLE IF EXISTS clanhall_functions;
  1406.  DROP TABLE IF EXISTS class_list;
  1407.  DROP TABLE IF EXISTS cursed_weapons;
  1408. +DROP TABLE IF EXISTS dm;
  1409.  DROP TABLE IF EXISTS droplist;
  1410.  DROP TABLE IF EXISTS games;
  1411.  DROP TABLE IF EXISTS enchant_skill_trees;
  1412. Index: database_installer.sh
  1413. ===================================================================
  1414. --- database_installer.sh   (revision 50)
  1415. +++ database_installer.sh   (working copy)
  1416. @@ -291,6 +291,7 @@
  1417.  $MYG < ../sql/class_list.sql &> /dev/null
  1418.  $MYG < ../sql/cursed_weapons.sql &> /dev/null
  1419.  $MYG < ../sql/dimensional_rift.sql &> /dev/null
  1420. +$MYG < ../sql/dm.sql &> /dev/null
  1421.  $MYG < ../sql/droplist.sql &> /dev/null
  1422.  $MYG < ../sql/enchant_skill_trees.sql &> /dev/null
  1423.  $MYG < ../sql/etcitem.sql &> /dev/null
Advertisement
Add Comment
Please, Sign In to add comment