Advertisement
LIONN

Npc AIO Shop

Jan 1st, 2013
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 11.44 KB | None | 0 0
  1. Index: data/html/mods/Aio Shop/start.htm
  2. ===================================================================
  3. --- data/html/mods/Aio Shop/start.htm   (revision 0)
  4. +++ data/html/mods/Aio Shop/start.htm   (working copy)
  5. @@ -0,0 +1,36 @@
  6. +<html>
  7. +   <title>Aio Shop</title>
  8. +   <body>
  9. +       <br>
  10. +       <center><img src=L2UI.SquareWhite width=276 height=1></center>
  11. +       <center>
  12. +           <table width=256>
  13. +               <tr>
  14. +                   <td><img src=L2UI.GM_Icon width=32 height=32></td>
  15. +                   <td width=192 align=center>
  16. +                       <font color="LEVEL">%servername%</font><br1>Bem Vindo ao Aio Shop!
  17. +                   </td>
  18. +                   <td><img src=L2UI.GM_Icon width=32 height=32></td>
  19. +               </tr>
  20. +           </table>
  21. +       </center>
  22. +       <br>
  23. +       <center><img src=L2UI.SquareWhite width=276 height=1></center>
  24. +       <br>
  25. +       <center>
  26. +           <font color=99FF66>Quando voce faz um AIO, seu personagem nao<br1>
  27. +           podera dar hits ou usar skills fora da cidade.</font><br1>
  28. +           <font color=FF0055>Use um personagem alternativo para isso!</font><br>
  29. +           <img src=L2UI_CH3.herotower_deco width=256 height=32><br>
  30. +           <font color=FF9900>Os precos dos pacotes de dias sao em<br1>
  31. +           "Gold Bar" e os dias sao cumulativos.</font><br>
  32. +           <button value="30 Dias [10 GB]" action="bypass -h npc_%objectId%_add_aio 3470 10 30" width=100 height=15 back="sek.cbui94" fore="sek.cbui92"><br>
  33. +           <button value="60 Dias [20 GB]" action="bypass -h npc_%objectId%_add_aio 3470 20 60" width=100 height=15 back="sek.cbui94" fore="sek.cbui92"><br>
  34. +           <button value="180 Dias [40 GB]" action="bypass -h npc_%objectId%_add_aio 3470 40 180" width=100 height=15 back="sek.cbui94" fore="sek.cbui92"><br>
  35. +           <button value="365 Dias [80 GB]" action="bypass -h npc_%objectId%_add_aio 3470 80 365" width=100 height=15 back="sek.cbui94" fore="sek.cbui92"><br>
  36. +           <font color=0099FF>Se voce clicar em "Remover AIO" seu status AIO<br1>
  37. +           sera removido e voce perdera os creditos restantes.</font>
  38. +           <button value="Remover Aio" action="bypass -h npc_%objectId%_remove_aio" width=100 height=15 back="sek.cbui94" fore="sek.cbui92"><br>
  39. +       </center>
  40. +   </body>
  41. +</html>
  42. #P L2jFrozen_GameServer
  43. Index: head-src/com/l2jfrozen/Config.java
  44. ===================================================================
  45. --- head-src/com/l2jfrozen/Config.java  (revision 972)
  46. +++ head-src/com/l2jfrozen/Config.java  (working copy)
  47. @@ -572,6 +572,8 @@
  48.     public static int AIO_TCOLOR;
  49.     public static boolean ALLOW_AIO_USE_GK;
  50.     public static boolean ALLOW_AIO_USE_CM;
  51. +   public static int DUAL_AIO_ID;
  52. +
  53.     public static boolean ANNOUNCE_CASTLE_LORDS;
  54.    
  55.     /** Configuration to allow custom items to be given on character creation */
  56. @@ -672,6 +674,8 @@
  57.             AIO_TCOLOR = Integer.decode("0x" + otherSettings.getProperty("AioTitleColor", "88AA88"));
  58.             ALLOW_AIO_USE_GK = Boolean.parseBoolean(otherSettings.getProperty("AllowAioUseGk", "False"));
  59.             ALLOW_AIO_USE_CM = Boolean.parseBoolean(otherSettings.getProperty("AllowAioUseClassMaster", "False"));
  60. +           DUAL_AIO_ID = Integer.parseInt(otherSettings.getProperty("DualAioItemId", "6580"));
  61. +
  62.             ANNOUNCE_CASTLE_LORDS = Boolean.parseBoolean(otherSettings.getProperty("AnnounceCastleLords", "False"));
  63.             if(ENABLE_AIO_SYSTEM) //create map if system is enabled
  64.             {
  65. Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2AioSellerInstance.java
  66. ===================================================================
  67. --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2AioSellerInstance.java (revision 0)
  68. +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2AioSellerInstance.java (working copy)
  69. @@ -0,0 +1,227 @@
  70. +/* This program is free software; you can redistribute it and/or modify
  71. + * it under the terms of the GNU General Public License as published by
  72. + * the Free Software Foundation; either version 2, or (at your option)
  73. + * any later version.
  74. + *
  75. + * This program is distributed in the hope that it will be useful,
  76. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  77. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  78. + * GNU General Public License for more details.
  79. + *
  80. + * You should have received a copy of the GNU General Public License
  81. + * along with this program; if not, write to the Free Software
  82. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  83. + * 02111-1307, USA.
  84. + *
  85. + * http://www.gnu.org/copyleft/gpl.html
  86. + */
  87. +package com.l2jfrozen.gameserver.model.actor.instance;
  88. +
  89. +import java.util.StringTokenizer;
  90. +
  91. +import com.l2jfrozen.Config;
  92. +import com.l2jfrozen.gameserver.ai.CtrlIntention;
  93. +import com.l2jfrozen.gameserver.network.SystemMessageId;
  94. +import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
  95. +import com.l2jfrozen.gameserver.network.serverpackets.EtcStatusUpdate;
  96. +import com.l2jfrozen.gameserver.network.serverpackets.InventoryUpdate;
  97. +import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
  98. +import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
  99. +import com.l2jfrozen.gameserver.network.serverpackets.SystemMessage;
  100. +import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
  101. +import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
  102. +
  103. +/**
  104. + * Aio Shop e um re-make do Mod Aio Seller. De uma versao para outra, muitas coisas mudaram e isto altera o modo de usar do mod por completo!
  105. + * Agora e possivel alterar a template, o item, o preco e o tempo via html. Em resumo, esta nova versao do codigo esta bem mais flexivel.
  106. + * Faca um bom uso!
  107. + * @author RedHoT
  108. + * @version 1.0.7
  109. + */
  110. +public class L2AioSellerInstance extends L2FolkInstance
  111. +{
  112. +   public L2AioSellerInstance(int objectId, L2NpcTemplate template)
  113. +   {
  114. +       super(objectId, template);
  115. +   }
  116. +
  117. +   @Override
  118. +   public void onAction(L2PcInstance player)
  119. +   {
  120. +       if (!canTarget(player))
  121. +           return;
  122. +
  123. +       player.setLastFolkNPC(this);
  124. +
  125. +       // Check if the L2PcInstance already target the L2NpcInstance
  126. +       if (this != player.getTarget())
  127. +       {
  128. +           // Set the target of the L2PcInstance player
  129. +           player.setTarget(this);
  130. +
  131. +           // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
  132. +           MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
  133. +           player.sendPacket(my);
  134. +           my = null;
  135. +
  136. +           // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
  137. +           player.sendPacket(new ValidateLocation(this));
  138. +       }
  139. +       else
  140. +       {
  141. +           // Calculate the distance between the L2PcInstance and the L2NpcInstance
  142. +           if (!canInteract(player))
  143. +           {
  144. +               // Notify the L2PcInstance AI with AI_INTENTION_INTERACT
  145. +               player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  146. +           }
  147. +           else
  148. +           {
  149. +               showMessageWindow(player);
  150. +           }
  151. +       }
  152. +       // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  153. +       player.sendPacket(ActionFailed.STATIC_PACKET);
  154. +   }
  155. +
  156. +   private void showMessageWindow(L2PcInstance player)
  157. +   {
  158. +       String filename = "data/html/mods/Aio Shop/start.htm";
  159. +
  160. +       NpcHtmlMessage html = new NpcHtmlMessage(1);
  161. +       html.setFile(filename);
  162. +       html.replace("%objectId%", String.valueOf(getObjectId()));
  163. +       html.replace("%servername%", Config.ALT_Server_Name);
  164. +       player.sendPacket(html);
  165. +       filename = null;
  166. +       html = null;
  167. +   }
  168. +
  169. +   @Override
  170. +   public void onBypassFeedback(L2PcInstance player, String command)
  171. +   {
  172. +       if (command.startsWith("add_aio"))
  173. +       {
  174. +           StringTokenizer st = new StringTokenizer(command);
  175. +           st.nextToken();
  176. +
  177. +           String priceId = null, priceCount = null, time = null;
  178. +           int aioPriceId = 0, aioPriceCount = 0, aioTime = 0;
  179. +
  180. +           if (st.hasMoreTokens())
  181. +           {
  182. +               priceId = st.nextToken();
  183. +               priceCount = st.nextToken();
  184. +               time = st.nextToken();
  185. +
  186. +               try
  187. +               {
  188. +                   aioPriceId = Integer.parseInt(priceId);
  189. +                   aioPriceCount = Integer.parseInt(priceCount);
  190. +                   aioTime = Integer.parseInt(time);
  191. +               }
  192. +               catch(NumberFormatException e) {}
  193. +           }
  194. +           else
  195. +           {
  196. +               _log.warning("Could not update aio status of player " + player.getName());
  197. +               return;
  198. +           }
  199. +
  200. +           makeAioCharacter(player, aioPriceId, aioPriceCount, aioTime);
  201. +       }
  202. +       else if (command.startsWith("remove_aio"))
  203. +           removeAio(player);
  204. +
  205. +       showMessageWindow(player);
  206. +   }
  207. +
  208. +  
  209. +   public void makeAioCharacter(L2PcInstance player, int itemId, int itemCount, int aioTime)
  210. +   {
  211. +       L2ItemInstance itemInstance = player.getInventory().getItemByItemId(itemId);
  212. +
  213. +       if (itemInstance == null || !itemInstance.isStackable() && player.getInventory().getInventoryItemCount(itemId, -1) < (itemCount))
  214. +       {
  215. +            player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
  216. +           return;
  217. +       }
  218. +       else if (itemInstance.isStackable())
  219. +       {
  220. +           if (!player.destroyItemByItemId("Aio", itemId, itemCount, player.getTarget(), true))
  221. +           {
  222. +                player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
  223. +               return;
  224. +           }
  225. +       }
  226. +       else
  227. +           for (int i = 0; i < (itemCount); i++)
  228. +               player.destroyItemByItemId("Aio", itemId, 1, player.getTarget(), true);
  229. +
  230. +       doAio(player, aioTime);
  231. +   }
  232. +   public void doAio(L2PcInstance player, int days)
  233. +   {
  234. +       if(player == null)
  235. +           return;
  236. +
  237. +        int daysLeft = player.getAioEndTime() <= 0 ? 0 : (int) ((player.getAioEndTime() - System.currentTimeMillis()) / 86400000);
  238. +       player.setAio(true);
  239. +       player.setEndTime("aio", days + daysLeft);
  240. +
  241. +       player.getStat().addExp(player.getStat().getExpForLevel(81));
  242. +
  243. +       if(Config.ALLOW_AIO_NCOLOR && player.isAio())
  244. +           player.getAppearance().setNameColor(Config.AIO_NCOLOR);
  245. +
  246. +       if(Config.ALLOW_AIO_TCOLOR && player.isAio())
  247. +           player.getAppearance().setTitleColor(Config.AIO_TCOLOR);
  248. +
  249. +       /* Give Aio Dual */
  250. +       L2ItemInstance item;
  251. +       if(player.getInventory().getItemByItemId(Config.DUAL_AIO_ID) == null)
  252. +       {
  253. +           item = player.getInventory().addItem("", Config.DUAL_AIO_ID, 1, player, null);
  254. +           InventoryUpdate iu = new InventoryUpdate();
  255. +           iu.addItem(item);
  256. +           player.sendPacket(iu);
  257. +       }
  258. +
  259. +       player.rewardAioSkills();
  260. +       player.sendPacket(new EtcStatusUpdate(player));
  261. +       player.sendSkillList();
  262. +       player.broadcastUserInfo();
  263. +
  264. +       player.sendMessage("You are now an Aio, Congratulations!");
  265. +   }
  266. +
  267. +   public void removeAio(L2PcInstance player)
  268. +   {
  269. +       if(!player.isAio())
  270. +       {
  271. +           player.sendMessage("You are not an AIO.");
  272. +           return;
  273. +       }
  274. +
  275. +       player.setAio(false);
  276. +       player.setAioEndTime(0);
  277. +
  278. +       player.getAppearance().setNameColor(0xFFFFFF);
  279. +       player.getAppearance().setTitleColor(0xFFFF77);
  280. +
  281. +       /* Remove Aio Dual */
  282. +       L2ItemInstance item;
  283. +       player.getWarehouse().destroyItemByItemId("", Config.DUAL_AIO_ID, 1, player, null);
  284. +       item = player.getInventory().destroyItemByItemId("", Config.DUAL_AIO_ID, 1, player, null);
  285. +       InventoryUpdate iu = new InventoryUpdate();
  286. +       iu.addItem(item);
  287. +       player.sendPacket(iu);
  288. +              
  289. +       player.lostAioSkills();
  290. +       player.sendPacket(new EtcStatusUpdate(player));
  291. +       player.sendSkillList();
  292. +       player.broadcastUserInfo();
  293. +
  294. +       player.sendMessage("Now You are not an Aio..");
  295. +   }
  296. +}
  297. Index: config/head/other.properties
  298. ===================================================================
  299. --- config/head/other.properties    (revision 972)
  300. +++ config/head/other.properties    (working copy)
  301. @@ -225,6 +225,9 @@
  302.  # Aio Buffers can speak to Class Master?
  303.  AllowAioUseClassMaster = False
  304.  
  305. +# ID Item for Reward AIO's in Transformation
  306. +DualAioItemId = 6580
  307. +
  308.  # Announce castle lords on enter game. default = false
  309.  AnnounceCastleLords = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement