Guest User

Boss Respawn

a guest
Aug 16th, 2010
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 10.17 KB | None | 0 0
  1. Index: data/scripts/custom/BossRespawn/home.htm
  2. ===================================================================
  3. --- data/scripts/custom/BossRespawn/home.htm    (revision 0)
  4. +++ data/scripts/custom/BossRespawn/home.htm    (revision 0)
  5. @@ -0,0 +1,16 @@
  6. +<html>
  7. +   <head>
  8. +       <title>
  9. +           L2 Private Server
  10. +       </title>
  11. +   </head>
  12. +   <body>
  13. +   <center>
  14. +       <img src="L2UI_CH3.herotower_deco" width=256 height=32>
  15. +       Server Rules here ...<br>
  16. +       <button value="I Accept" action="bypass -h npc_%objectId%_Quest BossRespawn" width=100 height=21 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
  17. +       <img src="L2UI_CH3.herotower_deco" width=256 height=32>
  18. +       <br>
  19. +   </center>
  20. +   </body>
  21. +</html>
  22. \ No newline at end of file
  23. Index: data/scripts/custom/BossRespawn/raidbosses.htm
  24. ===================================================================
  25. --- data/scripts/custom/BossRespawn/raidbosses.htm  (revision 0)
  26. +++ data/scripts/custom/BossRespawn/raidbosses.htm  (revision 0)
  27. @@ -0,0 +1,30 @@
  28. +<html>
  29. +   <title>Raid Boss Info</title>
  30. +<body>
  31. +   <br>
  32. +   <center>
  33. +       <img src="L2UI_CH3.herotower_deco" width=256 height=32>
  34. +       <table width=260>
  35. +           <tr>
  36. +               <td><font color="00C3FF">20-30 Level Raid Bosses</color>:</td>
  37. +               <td><font color="32C332"><a action="bypass -h Quest BossRespawn raidboss_20">Click Here</a></color></td>
  38. +           </tr>
  39. +           <tr>
  40. +               <td><font color="00C3FF">40-50 Level Raid Bosses</color>:</td>
  41. +               <td><font color="32C332"><a action="bypass -h Quest BossRespawn raidboss_40">Click Here</a></color></td>
  42. +           </tr>
  43. +           <tr>
  44. +               <td><font color="00C3FF">60-70 Level Raid Bosses</color>:</td>
  45. +               <td><font color="32C332"><a action="bypass -h Quest BossRespawn raidboss_60">Click Here</a></color></td>
  46. +           </tr>
  47. +           <tr>
  48. +               <td><font color="00C3FF">80-90 Level Raid Bosses</color>:</td>
  49. +               <td><font color="32C332"><a action="bypass -h Quest BossRespawn raidboss_80">Click Here</a></color></td>
  50. +           </tr>
  51. +       </table>
  52. +       <img src="L2UI_CH3.herotower_deco" width=256 height=32>
  53. +       <br>
  54. +   </center>
  55. +</body>
  56. +</html>
  57. \ No newline at end of file
  58. Index: data/scripts/custom/BossRespawn/BossRespawn.java
  59. ===================================================================
  60. --- data/scripts/custom/BossRespawn/BossRespawn.java    (revision 0)
  61. +++ data/scripts/custom/BossRespawn/BossRespawn.java    (revision 0)
  62. @@ -0,0 +1,206 @@
  63. +/*
  64. + * This program is free software: you can redistribute it and/or modify it under
  65. + * the terms of the GNU General Public License as published by the Free Software
  66. + * Foundation, either version 3 of the License, or (at your option) any later
  67. + * version.
  68. + *
  69. + * This program is distributed in the hope that it will be useful, but WITHOUT
  70. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  71. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  72. + * details.
  73. + *
  74. + * You should have received a copy of the GNU General Public License along with
  75. + * this program. If not, see <http://www.gnu.org/licenses/>.
  76. + */
  77. +
  78. +package custom.BossRespawn;
  79. +
  80. +import java.sql.Connection;
  81. +import java.sql.PreparedStatement;
  82. +import java.sql.ResultSet;
  83. +import java.text.SimpleDateFormat;
  84. +import java.util.Date;
  85. +import java.util.Map;
  86. +import java.util.logging.Level;
  87. +
  88. +import javolution.text.TextBuilder;
  89. +import javolution.util.FastMap;
  90. +
  91. +import com.l2jserver.L2DatabaseFactory;
  92. +import com.l2jserver.gameserver.instancemanager.GrandBossManager;
  93. +import com.l2jserver.gameserver.model.actor.L2Npc;
  94. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  95. +import com.l2jserver.gameserver.model.quest.Quest;
  96. +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  97. +import com.l2jserver.gameserver.templates.StatsSet;
  98. +
  99. +/**
  100. + *
  101. + * @author Dleogr
  102. + *
  103. + */
  104. +public class BossRespawn extends Quest
  105. +{
  106. +   private static final int NPC_ID = 93000;
  107. +   private static final boolean GM_ONLY = true;
  108. +   private static Map<Integer, String> GRAND_BOSSES = new FastMap<Integer, String>();
  109. +   private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
  110. +  
  111. +   public BossRespawn(int questid, String name, String descr)
  112. +   {
  113. +       super(questid, name, descr);
  114. +       addFirstTalkId(NPC_ID);
  115. +       addTalkId(NPC_ID);
  116. +       addStartNpc(NPC_ID);
  117. +      
  118. +       Connection con = null;
  119. +      
  120. +       try
  121. +       {
  122. +           con = L2DatabaseFactory.getInstance().getConnection();
  123. +           PreparedStatement statement = con.prepareStatement("SELECT `n`.`name`, `g`.`boss_id` FROM `npc` as `n` CROSS JOIN `grandboss_data` AS `g` ON `n`.`id` = `g`.`boss_id` GROUP BY `n`.`name` ORDER BY `g`.`respawn_time` DESC");
  124. +          
  125. +           ResultSet rset = statement.executeQuery();
  126. +          
  127. +           while (rset.next())
  128. +           {
  129. +               GRAND_BOSSES.put(rset.getInt("boss_id"), rset.getString("name"));
  130. +           }
  131. +          
  132. +           rset.close();
  133. +           statement.close();
  134. +       }
  135. +       catch (Exception e)
  136. +       {
  137. +           _log.log(Level.WARNING, "Could not restore grand bosses: " + e.getMessage(), e);
  138. +       }
  139. +       finally
  140. +       {
  141. +           L2DatabaseFactory.close(con);
  142. +       }
  143. +      
  144. +       _log.info("Loaded: " + GRAND_BOSSES.size() + " Grand Bosses");
  145. +   }
  146. +  
  147. +   @Override
  148. +   public String onFirstTalk(L2Npc npc, L2PcInstance player)
  149. +   {
  150. +       return "home.htm";
  151. +   }
  152. +  
  153. +   @Override
  154. +   public String onTalk(L2Npc npc, L2PcInstance player)
  155. +   {  
  156. +       return "main.htm";
  157. +   }
  158. +  
  159. +   @Override
  160. +   public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
  161. +   {
  162. +       if (event.equalsIgnoreCase("grandbosses"))
  163. +           sendGrandBosses(player);
  164. +       else if (event.equalsIgnoreCase("raidbosses"))
  165. +           return "raidbosses.htm";
  166. +       else if (event.startsWith("raidboss_"))
  167. +       {
  168. +           try
  169. +           {
  170. +               int level = Integer.parseInt(event.substring(9));
  171. +               if (level != 20 && level != 40 && level != 60 && level != 80)
  172. +                   return "Are you fackin insain?";
  173. +              
  174. +               sendRaidBosses(player, level);
  175. +           }
  176. +           catch (NumberFormatException nfe) {}
  177. +       }
  178. +      
  179. +       return null;
  180. +   }
  181. +  
  182. +   private void sendRaidBosses(L2PcInstance activeChar, int bosslevel)
  183. +   {
  184. +       TextBuilder tb = new TextBuilder();
  185. +       tb.append("<html><title>Raid Boss Info</title><body><br><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><table width=260>");
  186. +      
  187. +       Connection con = null;
  188. +      
  189. +       try
  190. +       {
  191. +           con = L2DatabaseFactory.getInstance().getConnection();
  192. +           PreparedStatement statement = con.prepareStatement("SELECT `n`.`name`, `n`.`level`, `r`.`respawn_time` FROM `npc` as `n` CROSS JOIN `raidboss_spawnlist` AS `r` ON `n`.`id` = `r`.`boss_id` WHERE `n`.`level` BETWEEN ? AND ? ORDER BY `n`.`level`");
  193. +           statement.setInt(1, bosslevel);
  194. +           statement.setInt(2, bosslevel + 10);
  195. +           ResultSet rset = statement.executeQuery();
  196. +          
  197. +           while (rset.next())
  198. +           {
  199. +               long delay = rset.getLong("respawn_time");
  200. +               String name = rset.getString("name");
  201. +               int level = rset.getInt("level");
  202. +               long currentTime = System.currentTimeMillis();
  203. +              
  204. +               if (delay <= currentTime)
  205. +                   tb.append("<tr><td><font color=\"00C3FF\">" + name + " (" + level + ")</color>:</td><td><font color=\"32C332\">" + (activeChar.isGM() && GM_ONLY ? "Is Alive" : "Information is hidden") + "</color></td></tr>");
  206. +              
  207. +               else
  208. +                   tb.append("<tr><td><font color=\"00C3FF\">" + name + " (" + level + ")</color>:</td><td><font color=\"9CC300\">" + (activeChar.isGM() && GM_ONLY ? sdf.format(new Date(delay)) : "Information is hidden") + "</color></td></tr>");
  209. +           }
  210. +          
  211. +           tb.append("</table><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br></center></body></html>");
  212. +          
  213. +           rset.close();
  214. +           statement.close();
  215. +          
  216. +           NpcHtmlMessage msg = new NpcHtmlMessage(NPC_ID);
  217. +           msg.setHtml(tb.toString());
  218. +           activeChar.sendPacket(msg);
  219. +          
  220. +       }
  221. +       catch (Exception e)
  222. +       {
  223. +           _log.log(Level.WARNING, "Could not restore grand bosses: " + e.getMessage(), e);
  224. +       }
  225. +      
  226. +       finally
  227. +       {
  228. +           L2DatabaseFactory.close(con);
  229. +       }
  230. +   }
  231. +  
  232. +   private void sendGrandBosses(L2PcInstance activeChar)
  233. +   {
  234. +       TextBuilder tb = new TextBuilder();
  235. +       tb.append("<html><title>Grand Boss Info</title><body><br><center><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><table width=260>");
  236. +      
  237. +       for (int bossId : GRAND_BOSSES.keySet())
  238. +       {
  239. +           String name = GRAND_BOSSES.get(bossId);
  240. +           StatsSet stats = GrandBossManager.getInstance().getStatsSet(bossId);
  241. +           if (stats == null)
  242. +           {
  243. +               activeChar.sendMessage("Stats for GrandBoss " + bossId + " not found!");
  244. +               continue;
  245. +           }
  246. +          
  247. +           long delay = stats.getLong("respawn_time");
  248. +           long currentTime = System.currentTimeMillis();
  249. +          
  250. +           if (delay <= currentTime)
  251. +               tb.append("<tr><td><font color=\"00C3FF\">" + name + "</color>:</td><td><font color=\"32C332\">" + (activeChar.isGM() && GM_ONLY ? "Is Alive" : "Information is hidden") + "</color></td></tr>");
  252. +          
  253. +           else
  254. +               tb.append("<tr><td><font color=\"00C3FF\">" + name + "</color>:</td><td><font color=\"9CC300\">" + (activeChar.isGM() && GM_ONLY ? sdf.format(new Date(delay)) : "Information is hidden") + "</color></td></tr>");
  255. +       }
  256. +      
  257. +       tb.append("</table><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32><br></center></body></html>");
  258. +      
  259. +       NpcHtmlMessage msg = new NpcHtmlMessage(NPC_ID);
  260. +       msg.setHtml(tb.toString());
  261. +       activeChar.sendPacket(msg);
  262. +   }
  263. +  
  264. +   public static void main(String[] args)
  265. +   {
  266. +       new BossRespawn(-1, "BossRespawn", "custom");
  267. +   }
  268. +}
  269. Index: data/scripts/custom/BossRespawn/main.htm
  270. ===================================================================
  271. --- data/scripts/custom/BossRespawn/main.htm    (revision 0)
  272. +++ data/scripts/custom/BossRespawn/main.htm    (revision 0)
  273. @@ -0,0 +1,21 @@
  274. +<html>
  275. +   <title>Grand Boss Info</title>
  276. +<body>
  277. +   <br>
  278. +   <center>
  279. +       <img src="L2UI_CH3.herotower_deco" width=256 height=32>
  280. +       <table width=260>
  281. +           <tr>
  282. +               <td><font color="00C3FF">Raid Bosses</color>:</td>
  283. +               <td><font color="32C332"><a action="bypass -h Quest BossRespawn raidbosses">Click Here</a></color></td>
  284. +           </tr>
  285. +           <tr>
  286. +               <td><font color="00C3FF">Grand Bosses</color>:</td>
  287. +               <td><font color="32C332"><a action="bypass -h Quest BossRespawn grandbosses">Click Here</a></color></td>
  288. +           </tr>
  289. +       </table>
  290. +       <img src="L2UI_CH3.herotower_deco" width=256 height=32>
  291. +       <br>
  292. +   </center>
  293. +</body>
  294. +</html>
  295. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment