Advertisement
L2Nidus

QuestKimeraWeb

Aug 10th, 2019
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 10.35 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. diff --git .gitignore .gitignore
  4. new file mode 100644
  5. index 0000000..ae3c172
  6. --- /dev/null
  7. +++ .gitignore
  8. @@ -0,0 +1 @@
  9. +/bin/
  10. diff --git java/net/sf/l2j/gameserver/scripting/quests/Q1003_MataMata.java java/net/sf/l2j/gameserver/scripting/quests/Q1003_MataMata.java
  11. new file mode 100644
  12. index 0000000..daf73be
  13. --- /dev/null
  14. +++ java/net/sf/l2j/gameserver/scripting/quests/Q1003_MataMata.java
  15. @@ -0,0 +1,215 @@
  16. +/*
  17. + * Copyright (C) 2004-2014 L2J DataPack
  18. + *
  19. + * This file is part of L2J DataPack.
  20. + *
  21. + * L2J DataPack is free software: you can redistribute it and/or modify
  22. + * it under the terms of the GNU General Public License as published by
  23. + * the Free Software Foundation, either version 3 of the License, or
  24. + * (at your option) any later version.
  25. + *
  26. + * L2J DataPack is distributed in the hope that it will be useful,
  27. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  29. + * General Public License for more details.
  30. + *
  31. + * You should have received a copy of the GNU General Public License
  32. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  33. + */
  34. +package net.sf.l2j.gameserver.scripting.quests;
  35. +
  36. +import net.sf.l2j.gameserver.model.actor.Npc;
  37. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  38. +import net.sf.l2j.gameserver.scripting.Quest;
  39. +import net.sf.l2j.gameserver.scripting.QuestState;
  40. +
  41. +/**
  42. + * @author Kimeraweb <br>
  43. + * @nota: Heredamos "Quest" con extends.<br>
  44. + *        Esto significa que todo lo que hay en Quest.java es como si ya estuviera aqui escrito
  45. + */
  46. +public class Q1003_MataMata extends Quest
  47. +{
  48. +   // Es de buena costumbre anteceder de un guion los nombres de las variables de la clase.
  49. +   // Se llaman de la clase porque se declaran fueran de los metodos y desde los metodos se pueden acceder a ellas.
  50. +   // Si son constantes, se usa el nombre completo en mayusculas, ejemplo: float PI = 3.141689;
  51. +   private final int _mobId = 18342, _npcId = 50009; // El mob es el gremlin de Lv1
  52. +   private int _conteo; // Lleva la cuenta de los mobs muertos
  53. +  
  54. +   /**
  55. +    * @param questId
  56. +    * @param descr
  57. +    */
  58. +   public Q1003_MataMata(int questId, String descr)
  59. +   {
  60. +       // "super" sirve para enviar a la superclase de la que se hereda (Quest) el valor de las variables
  61. +       super(questId, descr);
  62. +      
  63. +       // NPC que comienza la Quest.
  64. +       // Este metodo est� sobrecargado. Significa que hay otro metodo con el mismo nombre pero con parametros distintos.
  65. +       // En este caso, se acepta un numero indefinido de parametros de tipo int, ejemplo addStartNpc(1000009,10100,10101,10200);
  66. +       // Otro parametro que acepta es el objeto Collection que contenga objetos Integer: Collection<Integer> pjs = MiInstancia.getCollection();
  67. +       // Mas info en http://kimeraweb.com.es/SCJP/tema42.php
  68. +       addStartNpc(_npcId);
  69. +      
  70. +       // Muestra el primer dialogo del NPC cuando son clicados. Es decir, sustituyen el dialogo por defecto si el PJ esta haciendo una Quest donde interviene este NPC
  71. +       // addFirstTalkId() ;
  72. +      
  73. +       // A�ade el NPC a esta Quest para poder leer sus links con los eventos
  74. +       // Esta sobrecargado. Tambien acepta un numero indefinido de parametros de tipo int y un objeto Collection que contenga objetos Integer.
  75. +       addTalkId(_npcId);
  76. +      
  77. +       // A�ade este NPC un escuchador, para saber cuando este NPC ha muerto
  78. +       // Esta sobrecargado. Acepta numero indeterminado de parametros de tipo int.
  79. +       // Acepta un objeto Collection que contengan objetos Integer.
  80. +       addKillId(_mobId);
  81. +      
  82. +       // A�ade este NPC un escuchador, para saber cuando esta siendo atacado
  83. +       // Acepta numero de parametros indeterminados int, y un Collection de objetos Integer
  84. +       // addAttackId(int npcId);
  85. +      
  86. +       // A�ade al NPC la ventana de aprender skilles
  87. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  88. +       // addAcquireSkillId(int npcId);
  89. +      
  90. +       // Cuando este mob es spawneado, este NPC lo sabe
  91. +       // Soporta un numero indeterminado de parametros de tipo int y una coleccion que contega objetos Integer
  92. +       // addSpawnId(int npcId);
  93. +      
  94. +       // El NPC ve a un objetivo cualquiera ejecutando una skill
  95. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  96. +       // addSkillSeeId(int npcId)
  97. +      
  98. +       // Acciones que emprendera el NPC cuando se termine un casteo
  99. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  100. +       // addSpellFinishedId(int... npcIds)
  101. +      
  102. +       // Al salir de una zona...
  103. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  104. +       // addTrapActionId(int npcId)
  105. +      
  106. +       // Se ha visto castear una skill (sin importar quien lo haya hecho)
  107. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  108. +       // addFactionCallId(int npcId)
  109. +      
  110. +       // Alguien entro en el rango agro del npc
  111. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  112. +       // addAggroRangeEnterId(int npcId)
  113. +      
  114. +       // Este NPC, al ver un mob...
  115. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  116. +       // addSeeCreatureId(int npcId)
  117. +      
  118. +       // Al entrar en la zona...
  119. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  120. +       // addEnterZoneId(int zoneId)
  121. +      
  122. +       // Al salir de una zona
  123. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  124. +       // addExitZoneId(int zoneId)
  125. +      
  126. +       // Este NPC recibe un evento de otro NPC
  127. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  128. +       // addEventReceivedId(int... npcIds)
  129. +      
  130. +       // Cuando el NPC deja de moverse
  131. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  132. +       // addMoveFinishedId(int... npcIds)
  133. +      
  134. +       // Cuando un NPC Walker llega al siguiente nodo
  135. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  136. +       // addNodeArrivedId(int... npcIds)
  137. +      
  138. +       // Cuando un NPC Walker termina su ruta
  139. +       // Soporta un numero indeterminado de parametros de tipo int y una Coleccion que contenga objetos Integer.
  140. +       // addRouteFinishedId(int... npcIds)
  141. +   }
  142. +  
  143. +   /**
  144. +    * A continuacion los metodos invocados al usar los add. Puedes encontrar la lista de ellos en la clase Quest a partir de la linea 1144
  145. +    */
  146. +  
  147. +   /**
  148. +    * This function is called whenever a player clicks to the "Quest" link of an NPC that is registered for the quest.
  149. +    * @param npc this parameter contains a reference to the exact instance of the NPC that the player is talking with.
  150. +    * @param talker this parameter contains a reference to the exact instance of the player who is talking to the NPC.
  151. +    * @return the text returned by the event (may be {@code null}, a filename or just text)
  152. +    */
  153. +   @SuppressWarnings("null")
  154. +   @Override
  155. +   public String onTalk(Npc npc, Player player)
  156. +   {
  157. +       String htmltext = "<html><head><title>Personal Trainer</title></head><body>";
  158. +       QuestState st = player.getQuestState(Q1003_MataMata.class.getSimpleName());
  159. +       st.setState(Quest.STATE_CREATED);
  160. +      
  161. +       if (st.getState() != Quest.STATE_STARTED)
  162. +       {
  163. +           // Inicializo las variables globales de la quest
  164. +           st.set("Q1003_Pvez", String.valueOf(System.currentTimeMillis())); // Primera vez que participo
  165. +           st.set("Q1003_Uvez", "0"); // Ultima vez que participo
  166. +           st.set("Q1003_MobsMuertos", "0"); // Mobs muertos en total
  167. +       }
  168. +      
  169. +       // Si el PJ ya estaba jugando antes (State.STARTED), cargamos los avances hechos
  170. +       if (st.getState() == Quest.STATE_STARTED)
  171. +       {
  172. +           _conteo = Integer.valueOf(st.get("Q1003_MobsMuertos"));
  173. +
  174. +       }
  175. +      
  176. +       htmltext = htmltext + "No dejes de hacerlo cada dia y la recompensa sera mayor!";
  177. +       return htmltext + "</body></html>";
  178. +   }
  179. +  
  180. +   /**
  181. +    * This function is called whenever a player kills a NPC that is registered for the quest.
  182. +    * @param npc this parameter contains a reference to the exact instance of the NPC that got killed.
  183. +    * @param killer this parameter contains a reference to the exact instance of the player who killed the NPC.
  184. +    * @param isSummon this parameter if it's {@code false} it denotes that the attacker was indeed the player, else it specifies that the killer was the player's pet.
  185. +    * @return the text returned by the event (may be {@code null}, a filename or just text)
  186. +    */
  187. +   @Override
  188. +   public String onKill(Npc npc, Player killer, boolean isSummon)
  189. +   {
  190. +       QuestState st = killer.getQuestState(Q1003_MataMata.class.getSimpleName());
  191. +       st.playSound(QuestState.SOUND_ITEMGET);
  192. +       _conteo++;
  193. +       // Grabo la hora en que mato el ultimo mob
  194. +       st.set("Q1003_Uvez", String.valueOf(System.currentTimeMillis()));
  195. +       // Grabo la cantidad de mobs que lleva muertos
  196. +       st.set("Q1003_MobsMuertos", String.valueOf(_conteo));
  197. +      
  198. +       if (st.getState() == Quest.STATE_CREATED)
  199. +       {
  200. +           st.setState(Quest.STATE_STARTED); // State.STARTED indicara que el PJ ya ha estado matando mobs
  201. +       }
  202. +      
  203. +       // Le damos una adena por cada 100 mobs que mate, como premio a su persistencia :p
  204. +       // Dividimos los dias que lleva matando mobs y multiplicamos el premio por los dias consecutivos
  205. +       if ((_conteo % 100) == 0)
  206. +       {
  207. +           // Antes de dar el premio bonificado, verificamos la ultima vez que entro
  208. +           if ((System.currentTimeMillis() - Long.valueOf(st.get("Q1003_Pvez"))) > 86400000)
  209. +           {
  210. +               String htmltext = "Ya ha pasado mas de un dia desde tu ultimo entrenamiento!<br>Has perdido tu bonificacion!<br><br>";
  211. +               st.set("Q1003_Pvez", String.valueOf(System.currentTimeMillis()));
  212. +           }
  213. +
  214. +           int bonus = (int) ((System.currentTimeMillis() - (Long.valueOf(st.get("Q1003_Pvez")))) / 86400000);
  215. +           if (bonus < 1)
  216. +           {
  217. +               bonus = 1;
  218. +           }
  219. +           killer.sendMessage("Juega cada dia para acumular bonos a los premios! Bonos acumulados: " + String.valueOf(bonus));
  220. +           killer.addItem("Q1003_MataMata", 57, 1 * bonus, killer, true);
  221. +          
  222. +       }
  223. +       return null;
  224. +   }
  225. +  
  226. +   public static void main(String[] args)
  227. +   {
  228. +       new Q1003_MataMata(1003, Q1003_MataMata.class.getSimpleName());
  229. +   }
  230. +}
  231. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement