Axelut

aCis Npc Skills Seller

May 10th, 2023
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: net.sf.l2j;Config.java
  2. ===================================================================
  3. --- net.sf.l2j;Config.java (revision 84)
  4. +++ net.sf.l2j;Config.java (working copy)
  5.  
  6. +   public static final String SKILLS_SELLER = "./config/aCis/NpcSkillSeller.properties";
  7.  
  8. +   /** Seller Npc Skills */
  9. +   public static int SELLER_SKILLS_NPCID;
  10. +   public static int SELLER_SKILLS_ITEM;
  11. +   public static String SELLER_SKILLS_MESSAGE_TEXT;
  12. +   public static int SELLER_SKILLS_COUNT;
  13.  
  14.  
  15.  
  16. +   private static final void loadSellerSkills() {
  17. +      
  18. +       final ExProperties NpcSkillSeller = initProperties(Config.SKILLS_SELLER);
  19. +      
  20. +       SELLER_SKILLS_NPCID = Integer.parseInt(NpcSkillSeller.getProperty("SellerSkillsNpcId", "1"));
  21. +       SELLER_SKILLS_ITEM = NpcSkillSeller.getProperty("SellerItemId", 57);
  22. +       SELLER_SKILLS_COUNT = NpcSkillSeller.getProperty("SellerItemCount", 100);
  23. +      
  24. +       SELLER_SKILLS_MESSAGE_TEXT = NpcSkillSeller.getProperty("ItemName", "Adena");
  25. +      
  26. +      
  27. +  
  28. +      
  29. +    }
  30.        
  31. -   // siege settings
  32. -   loadSieges();
  33.  
  34. +   // siege settings
  35. +   loadSieges();
  36.  
  37. +   loadSellerSkills();
  38.  
  39.  
  40. Index: net.sf.l2j.gameserver.model.actor.Npc.java
  41. ===================================================================
  42. ---  net.sf.l2j.gameserver.model.actor.Npc.java (revision 84)
  43. +++  net.sf.l2j.gameserver.model.actor.Npc.java (working copy)
  44.  
  45.     @Override
  46.     public void onAction(Player player)
  47.     {
  48.  
  49. +   if (getNpcId() == SkillSeller.NPC_ID)
  50. +   {
  51. +    ItemInstance i = player.getInventory().getItemByItemId(SkillSeller.ITEM_ID);
  52. +  
  53. +    if (i == null || i.getCount() < SkillSeller.ITEM_COUNT)
  54. +    {
  55. +     player.sendMessage("You need " + SkillSeller.ITEM_COUNT + " " + Config.SELLER_SKILLS_MESSAGE_TEXT + "to use this Npc.");
  56. +     player.sendPacket(new ActionFailed());
  57. +     return;
  58. +    }
  59. +   }
  60.  
  61.     // Set the target of the player
  62.     if (player.getTarget() != this)
  63.     player.setTarget(this);
  64.     else
  65.  
  66. Index: net.sf.l2j.gameserver.network.clientpackets.RequestBypassToServer.java
  67. ===================================================================
  68. --- net.sf.l2j.gameserver.network.clientpackets.RequestBypassToServer.java (revision 84)
  69. +++ net.sf.l2j.gameserver.network.clientpackets.RequestBypassToServer.java (working copy)
  70.  
  71. +          // L2SkillSeller
  72. +       if (_command.startsWith("skill"))
  73. +          {
  74. +           String b = _command.substring(5);
  75. +           int id = 0;
  76. +           try
  77. +           {
  78. +            id = Integer.parseInt(b);
  79. +           }
  80. +           catch (Exception e)
  81. +           {
  82. +            e.printStackTrace();
  83. +           }
  84. +  
  85. +           if (id == 0)
  86. +            return;
  87. +  
  88. +           L2Skill s = SkillTable.getInstance().getInfo(id, 10);
  89. +           ItemInstance i = player.getInventory().getItemByItemId(SkillSeller.ITEM_ID);
  90. +  
  91. +           if (i == null || i.getCount() < SkillSeller.ITEM_COUNT)
  92. +           {
  93. +            player.sendMessage("You don't have enought " + Config.SELLER_SKILLS_MESSAGE_TEXT);
  94. +            return;
  95. +           }
  96. +  
  97. +           player.getInventory().destroyItemByItemId("", SkillSeller.ITEM_ID, SkillSeller.ITEM_COUNT, player, null);
  98. +           player.sendMessage("You rewarded successfully with " + s.getName() + " Lvl:10, " + Config.SELLER_SKILLS_COUNT + " " + Config.SELLER_SKILLS_MESSAGE_TEXT + " dissapeared");
  99. +           player.addSkill(s, false);
  100. +           player.broadcastPacket(new SocialAction(player, 9));
  101. +          }
  102. +  
  103. +   }
  104.  
  105.  
  106. Index: net.sf.l2j.gameserver.model.actor.instance.SkillSeller.java
  107. ===================================================================
  108. --- net.sf.l2j.gameserver.model.actor.instance.SkillSeller.java (no exist)
  109. +++ net.sf.l2j.gameserver.model.actor.instance.SkillSeller.java (no exist)
  110.  
  111.  
  112. +   package net.sf.l2j.gameserver.model.actor.instance;
  113. +  
  114. +   import net.sf.l2j.Config;
  115. +   import net.sf.l2j.gameserver.data.SkillTable;
  116. +  
  117. +   import net.sf.l2j.gameserver.model.L2Skill;
  118. +   import net.sf.l2j.gameserver.model.actor.Npc;
  119. +   import net.sf.l2j.gameserver.model.actor.Player;
  120. +   import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  121. +   import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  122. +  
  123. +   public class SkillSeller extends Npc
  124. +   {
  125. +        public final static int NPC_ID = Config.SELLER_SKILLS_NPCID;
  126. +        public final static int ITEM_ID = Config.SELLER_SKILLS_ITEM;
  127. +        public final static int ITEM_COUNT = Config.SELLER_SKILLS_COUNT;
  128. +        
  129. +        private final int[] SKILL_IDS =
  130. +        {
  131. +        3134, 3132, 3124, 3125, 3133, 3135, 3136, 3137, 3138, 3139, 3140, 3141, 3134
  132. +        };
  133. +        
  134. +  
  135. +        
  136. +        public SkillSeller(int objectId, NpcTemplate template)
  137. +        {
  138. +         super(objectId, template);
  139. +        }
  140. +          
  141. +        @Override
  142. +        public void showChatWindow(Player j, int val)
  143. +        {
  144. +         if (j == null)
  145. +          return;
  146. +  
  147. +         StringBuilder t = new StringBuilder();
  148. +         NpcHtmlMessage n = new NpcHtmlMessage(getObjectId());
  149. +         sendHtml(t, n, j);
  150. +        
  151. +        }
  152. +        
  153. +        
  154. +        
  155. +        private void sendHtml(StringBuilder t, NpcHtmlMessage n, Player j)
  156. +        {
  157. +         t.append("<html><head><title>");
  158. +         t.append("L2Skill Seller");
  159. +         t.append("</title</head>");
  160. +         t.append("<body><center>");
  161. +         t.append("<br>Hello , do you want some special skills?");
  162. +         t.append("<br>Choose whatever you want but don't forget");
  163. +         t.append("<br>you need " + Config.SELLER_SKILLS_MESSAGE_TEXT + " Bars for each one");
  164. +         for (int i : SKILL_IDS)
  165. +         {
  166. +          L2Skill s = SkillTable.getInstance().getInfo(i, 10);
  167. +          String name = "";
  168. +          if (s != null)
  169. +           name = s.getName();
  170. +          if (name != "")
  171. +           t.append("<center><button value=\"" + name + " LvL:10\" action=\"bypass -h skill" + i + "\" width=204 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br>");
  172. +         }
  173. +         t.append("</center></body></html>");
  174. +         n.setHtml(t.toString());
  175. +         j.sendPacket(n);
  176. +        }
  177. +        
  178. +        
  179. +   }
  180. +
Add Comment
Please, Sign In to add comment