LIONN

Siege Register Npc

May 6th, 2012
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.30 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2jFrozen_GameServer
  3. Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2SiegeRegisterInstance.java
  4. ===================================================================
  5. --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2SiegeRegisterInstance.java (revision 0)
  6. +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2SiegeRegisterInstance.java (working copy)
  7. @@ -0,0 +1,145 @@
  8. +/* This program is free software; you can redistribute it and/or modify
  9. + * it under the terms of the GNU General Public License as published by
  10. + * the Free Software Foundation; either version 2, or (at your option)
  11. + * any later version.
  12. + *
  13. + * This program is distributed in the hope that it will be useful,
  14. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. + * GNU General Public License for more details.
  17. + *
  18. + * You should have received a copy of the GNU General Public License
  19. + * along with this program; if not, write to the Free Software
  20. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  21. + * 02111-1307, USA.
  22. + *
  23. + * http://www.gnu.org/copyleft/gpl.html
  24. + */
  25. +package com.l2jfrozen.gameserver.model.actor.instance;
  26. +
  27. +import javolution.text.TextBuilder;
  28. +
  29. +import com.l2jfrozen.Config;
  30. +import com.l2jfrozen.gameserver.ai.CtrlIntention;
  31. +import com.l2jfrozen.gameserver.managers.CastleManager;
  32. +import com.l2jfrozen.gameserver.model.entity.siege.Castle;
  33. +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  34. +import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
  35. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  36. +import com.l2jfrozen.gameserver.network.serverpackets.SiegeInfo;
  37. +import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
  38. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  39. +
  40. +public class L2SiegeRegisterInstance extends L2FolkInstance
  41. +{
  42. +   /**
  43. +    * @param objectId
  44. +    * @param template
  45. +    */
  46. +   public L2SiegeRegisterInstance(int objectId, L2NpcTemplate template)
  47. +   {
  48. +       super(objectId, template);
  49. +   }
  50. +  
  51. +   @Override
  52. +   public void onAction(L2PcInstance player)
  53. +   {
  54. +       if (!canTarget(player))
  55. +           return;
  56. +      
  57. +       player.setLastFolkNPC(this);
  58. +      
  59. +       // Check if the L2PcInstance already target the L2NpcInstance
  60. +       if (this != player.getTarget())
  61. +       {
  62. +           // Set the target of the L2PcInstance player
  63. +           player.setTarget(this);
  64. +          
  65. +           // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
  66. +           MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
  67. +           player.sendPacket(my);
  68. +           my = null;
  69. +          
  70. +           // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
  71. +           player.sendPacket(new ValidateLocation(this));
  72. +       }
  73. +       else
  74. +       {
  75. +           // Calculate the distance between the L2PcInstance and the L2NpcInstance
  76. +           if (!canInteract(player))
  77. +           {
  78. +               // Notify the L2PcInstance AI with AI_INTENTION_INTERACT
  79. +               player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  80. +           }
  81. +           else
  82. +           {
  83. +               showHtmlWindow(player);
  84. +           }
  85. +       }
  86. +       // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  87. +       player.sendPacket(ActionFailed.STATIC_PACKET);
  88. +   }
  89. +  
  90. +   @Override
  91. +   public void onBypassFeedback(L2PcInstance player, String command)
  92. +   {
  93. +       if (command.startsWith("gludio_castle"))
  94. +           showSiegeInfoWindow(player, 1);
  95. +       else if (command.startsWith("dion_castle"))
  96. +           showSiegeInfoWindow(player, 2);
  97. +       else if (command.startsWith("giran_castle"))
  98. +           showSiegeInfoWindow(player, 3);
  99. +       else if (command.startsWith("oren_castle"))
  100. +           showSiegeInfoWindow(player, 4);
  101. +       else if (command.startsWith("aden_castle"))
  102. +           showSiegeInfoWindow(player, 5);
  103. +       else if (command.startsWith("innadril_castle"))
  104. +           showSiegeInfoWindow(player, 6);
  105. +       else if (command.startsWith("goddard_castle"))
  106. +           showSiegeInfoWindow(player, 7);
  107. +       else if (command.startsWith("rune_castle"))
  108. +           showSiegeInfoWindow(player, 8);
  109. +       else if (command.startsWith("schuttgart_castle"))
  110. +           showSiegeInfoWindow(player, 9);
  111. +       else
  112. +           super.onBypassFeedback(player, command);
  113. +   }
  114. +  
  115. +   public void showHtmlWindow(L2PcInstance activeChar)
  116. +   {
  117. +       NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  118. +       TextBuilder replyMSG = new TextBuilder("");
  119. +      
  120. +       replyMSG.append("<html><title>Siege Register Npc</title><body><center>");
  121. +       replyMSG.append("<img src=L2UI_CH3.herotower_deco width=256 height=32><br>");
  122. +       replyMSG.append("<font color=LEVEL>NPC Register Siege</font><br>");
  123. +       replyMSG.append("<img src=L2UI.SquareGray width=300 height=1><br><br>");
  124. +       replyMSG.append("<a action=\"bypass -h npc_" + getObjectId() + "_giran_castle\">Giran Castle</a><br>");
  125. +       replyMSG.append("<a action=\"bypass -h npc_" + getObjectId() + "_aden_castle\">Aden Castle</a><br>");
  126. +       replyMSG.append("<a action=\"bypass -h npc_" + getObjectId() + "_rune_castle\">Rune Castle</a><br>");
  127. +       replyMSG.append("<a action=\"bypass -h npc_" + getObjectId() + "_goddard_castle\">Goddard Castle</a><br>");
  128. +       replyMSG.append("<a action=\"bypass -h npc_" + getObjectId() + "_dion_castle\">Dion Castle</a><br>");
  129. +       replyMSG.append("<a action=\"bypass -h npc_" + getObjectId() + "_schuttgart_castle\">Schuttgart Castle</a><br>");
  130. +       replyMSG.append("<a action=\"bypass -h npc_" + getObjectId() + "_innadril_castle\">Innadril Castle</a><br>");
  131. +       replyMSG.append("<a action=\"bypass -h npc_" + getObjectId() + "_oren_castle\">Oren Castle</a><br>");
  132. +       replyMSG.append("<a action=\"bypass -h npc_" + getObjectId() + "_gludio_castle\">Gludio Castle</a><br><br>");
  133. +       replyMSG.append("<img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br>");
  134. +       replyMSG.append("<img src=l2ui.bbs_lineage2 height=16 width=80>");
  135. +       replyMSG.append("<font color=808080>" + Config.ALT_Server_Name + "</font>");
  136. +       replyMSG.append("</center></body></html>");
  137. +       nhm.setHtml(replyMSG.toString());
  138. +       activeChar.sendPacket(nhm);
  139. +       return;
  140. +   }
  141. +  
  142. +   /**
  143. +    * @param player
  144. +    * @param castleId
  145. +    */
  146. +   public void showSiegeInfoWindow(L2PcInstance player, int castleId)
  147. +   {
  148. +       Castle c = CastleManager.getInstance().getCastleById(castleId);
  149. +       if (c != null)
  150. +           player.sendPacket(new SiegeInfo(c));
  151. +   }
  152. +}
Advertisement
Add Comment
Please, Sign In to add comment