warc222

[Share] Auto pilot Flying Gatekeeper v.0,1

Jan 14th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.98 KB | None | 0 0
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2, or (at your option)
  5. * any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  15. * 02111-1307, USA.
  16. *
  17. * http://www.gnu.org/copyleft/gpl.html
  18. */
  19. package net.sf.l2j.gameserver.model.actor.instance;
  20.  
  21. import javolution.text.TextBuilder;
  22.  
  23. import net.sf.l2j.gameserver.ai.CtrlIntention;
  24. import net.sf.l2j.gameserver.model.L2CharPosition;
  25. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  26. import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  27. import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
  28. import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  29. import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  30. import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  31. import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
  32. import net.sf.l2j.util.Rnd;
  33.  
  34. /**
  35. *
  36. * @author AbsolutePower
  37. *
  38. */
  39. public final class L2FWyrenInstance extends L2NpcInstance
  40. {
  41. public L2FWyrenInstance(int objectId, L2NpcTemplate template)
  42. {
  43. super(objectId, template);
  44. }
  45.  
  46. @Override
  47. public void onBypassFeedback(L2PcInstance p, String co)
  48. {
  49. if(co.startsWith("giran"))
  50. {
  51. ridefly(p);
  52. goToLocationDismountAndMessage(p,82698, 148638, -3473);
  53. }
  54. else if(co.startsWith("goddard"))
  55. {
  56. ridefly(p);
  57. goToLocationDismountAndMessage(p,147725, -56517, -2780);
  58. }
  59. else if(co.startsWith("aden"))
  60. {
  61. ridefly(p);
  62. goToLocationDismountAndMessage(p,147456, 26886, -2207);
  63. }
  64. p.sendPacket(ActionFailed.STATIC_PACKET);
  65.  
  66. }
  67.  
  68. @Override
  69. public void onAction(L2PcInstance player)
  70. {
  71. if (this != player.getTarget())
  72. {
  73. player.setTarget(this);
  74. player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
  75. player.sendPacket(new ValidateLocation(this));
  76. }
  77. else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false)) {
  78. SocialAction sa = new SocialAction(this, Rnd.get(8));
  79. broadcastPacket(sa);
  80. player.setCurrentFolkNPC(this);
  81. showMessageWindow(player);
  82. player.sendPacket(ActionFailed.STATIC_PACKET);
  83. }
  84. else
  85. {
  86. player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  87. player.sendPacket(ActionFailed.STATIC_PACKET);
  88. }
  89. }
  90. private void showMessageWindow(L2PcInstance p)
  91. {
  92. NpcHtmlMessage nhm = new NpcHtmlMessage(5);
  93. TextBuilder tb = new TextBuilder("");
  94.  
  95. if (p.isSitting() || p.isAlikeDead() || p.isInCombat() || p.isInOlympiadMode() || p.isAcademyMember()
  96. || p.isAfraid() || p.isInCraftMode() || p.isInJail() || p.getPrivateStoreType() != 0)
  97. {
  98. p.sendMessage("You can't use the gk now!");
  99. return;
  100. }
  101.  
  102. tb.append("<html><head><title>CustomGateKeeper</title></head><body>");
  103. tb.append("<center>");
  104. tb.append("<img src=\"L2Font-e.mini_logo-e\" width=200 height=120 align=center>");
  105. tb.append("</center>");
  106. tb.append("<center>");
  107. tb.append("<td valign=\"top\"><font color=\"FFFFFF\">" + p.getName()+" Choose your destination!</font><br>");
  108. tb.append("<button value=\"Giran\" action=\"bypass -h npc_" + getObjectId() + "_giran\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>");
  109. tb.append("<button value=\"Goddard\" action=\"bypass -h npc_" + getObjectId() + "_goddard\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>");
  110. tb.append("<button value=\"Aden\" action=\"bypass -h npc_" + getObjectId() + "_aden\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>");
  111. tb.append("</center>");
  112. tb.append("<center>");
  113. tb.append("<img src=\"L2Font-e.mini_logo-e\" width=200 height=120 align=center>");
  114. tb.append("<font color=\"FFFFFF\">Coded By AbsolutePower</font>");
  115. tb.append("</center>");
  116. tb.append("</body></html>");
  117.  
  118. nhm.setHtml(tb.toString());
  119. p.sendPacket(nhm);
  120.  
  121. p.sendPacket(ActionFailed.STATIC_PACKET);
  122. }
  123.  
  124. private void goToLocationDismountAndMessage(L2PcInstance p,int x,int y,int z)
  125. {
  126. p.teleToLocation(x, y, z);
  127. wait(1,false);
  128. p.dismount();
  129. p.sendPacket(new ExShowScreenMessage(p.getName() +" you arrived at your destination ", 4000));
  130. p.setXYZ(x, y, z);
  131. }
  132.  
  133. private void ridefly(L2PcInstance p)
  134. {
  135. int x,y,z;
  136. final int px = p.getX();
  137. final int py = p.getY();
  138. final int pz = p.getZ();
  139.  
  140. double ph = p.getHeading() / 182.044444444;
  141. ph += 90;
  142.  
  143. if (ph > 90)
  144. ph -= 90;
  145.  
  146. ph = (Math.PI * ph) / 90;
  147.  
  148. x = (int) (px + (1 * Math.cos(ph)));
  149. y = (int) (py + (1 * Math.cos(ph)));
  150. z = (int) (pz + (5000 * Math.cos(ph)));
  151.  
  152. p.mount(12621, 0, false);
  153.  
  154. p.abortAttack();
  155. p.abortCast();
  156. p.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  157. p.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(x, y, z, 0));
  158. p.abortAttack();
  159. p.abortCast();
  160. p.setXYZ(x, y, z);
  161. p.broadcastPacket(new ValidateLocation(p));
  162. wait(1,false);
  163. }
  164.  
  165. private void wait(int i ,boolean min)
  166. {
  167.  
  168. if(min)
  169. try
  170. {
  171. Thread.sleep(i * 60000);
  172. }
  173. catch (InterruptedException ie)
  174. {
  175. ie.printStackTrace();
  176. }
  177. else
  178.  
  179. try
  180. {
  181. Thread.sleep(i * 1000);
  182. }
  183. catch (InterruptedException ie)
  184. {
  185. ie.printStackTrace();
  186. }
  187.  
  188. }
  189. }
Advertisement
Add Comment
Please, Sign In to add comment