Advertisement
tensador125

Rusacis Buffer Style God for player and pets

Jan 5th, 2024 (edited)
1,345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 27.19 KB | Gaming | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. diff --git java/Base/Data/XMLDocument.java java/Base/Data/XMLDocument.java
  4. new file mode 100644
  5. index 0000000..3f06c0f
  6. --- /dev/null
  7. +++ java/Base/Data/XMLDocument.java
  8. @@ -0,0 +1,121 @@
  9. +package Base.Data;
  10. +
  11. +
  12. +
  13. +import java.io.File;
  14. +import java.util.logging.Level;
  15. +import java.util.logging.Logger;
  16. +
  17. +import javax.xml.parsers.DocumentBuilderFactory;
  18. +import javax.xml.transform.OutputKeys;
  19. +import javax.xml.transform.Transformer;
  20. +import javax.xml.transform.TransformerException;
  21. +import javax.xml.transform.TransformerFactory;
  22. +import javax.xml.transform.dom.DOMSource;
  23. +import javax.xml.transform.stream.StreamResult;
  24. +
  25. +import net.sf.l2j.commons.data.StatSet;
  26. +
  27. +import org.w3c.dom.Document;
  28. +import org.w3c.dom.NamedNodeMap;
  29. +import org.w3c.dom.Node;
  30. +
  31. +/**
  32. + * An XML document, relying on a static and single DocumentBuilderFactory.
  33. + */
  34. +public abstract class XMLDocument
  35. +{
  36. +   protected static final Logger LOG = Logger.getLogger(XMLDocument.class.getName());
  37. +  
  38. +   protected Document document;
  39. +  
  40. +   private static final DocumentBuilderFactory BUILDER;
  41. +   static
  42. +   {
  43. +       BUILDER = DocumentBuilderFactory.newInstance();
  44. +       BUILDER.setValidating(false);
  45. +       BUILDER.setIgnoringComments(true);
  46. +   }
  47. +  
  48. +   abstract protected void load();
  49. +  
  50. +   abstract protected void parseDocument(Document doc, File f);
  51. +  
  52. +   public void loadDocument(String filePath)
  53. +   {
  54. +       loadDocument(new File(filePath));
  55. +   }
  56. +  
  57. +   public void writeDocument(Document doc, String fileName)
  58. +   {
  59. +       try
  60. +       {
  61. +           TransformerFactory transformerFactory = TransformerFactory.newInstance();
  62. +           Transformer transformer = transformerFactory.newTransformer();
  63. +           transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
  64. +           transformer.setOutputProperty(OutputKeys.INDENT, "yes");
  65. +           transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
  66. +          
  67. +           DOMSource source = new DOMSource(doc);
  68. +           StreamResult result = new StreamResult(new File(fileName));
  69. +          
  70. +           transformer.transform(source, result);
  71. +           LOG.info("XML file saved to " + fileName);
  72. +       }
  73. +       catch (TransformerException e)
  74. +       {
  75. +           LOG.warning("Error saving XML file: " + e.getMessage());
  76. +       }
  77. +   }
  78. +  
  79. +   /**
  80. +    * Parse an entire directory or file if found.
  81. +    * @param file
  82. +    */
  83. +   public void loadDocument(File file)
  84. +   {
  85. +       if (!file.exists())
  86. +       {
  87. +           LOG.severe("The following file or directory doesn't exist: " + file.getName());
  88. +           return;
  89. +       }
  90. +      
  91. +       if (file.isDirectory())
  92. +       {
  93. +           for (File f : file.listFiles())
  94. +           {
  95. +               loadDocument(f);
  96. +           }
  97. +       }
  98. +       else if (file.isFile())
  99. +       {
  100. +           try
  101. +           {
  102. +               parseDocument(BUILDER.newDocumentBuilder().parse(file), file);
  103. +           }
  104. +           catch (Exception e)
  105. +           {
  106. +               LOG.log(Level.SEVERE, "Error loading XML file " + file.getName(), e);
  107. +           }
  108. +       }
  109. +   }
  110. +  
  111. +   public Document getDocument()
  112. +   {
  113. +       return document;
  114. +   }
  115. +  
  116. +   /**
  117. +    * This method parses the content of a NamedNodeMap and feed the given StatsSet.
  118. +    * @param attrs : The NamedNodeMap to parse.
  119. +    * @param set : The StatsSet to feed.
  120. +    */
  121. +   public static void parseAndFeed(NamedNodeMap attrs, StatSet set)
  122. +   {
  123. +       for (int i = 0; i < attrs.getLength(); i++)
  124. +       {
  125. +           final Node attr = attrs.item(i);
  126. +           set.set(attr.getNodeName(), attr.getNodeValue());
  127. +       }
  128. +   }
  129. +}
  130. diff --git config/players.properties config/players.properties
  131. index 745d341..2bc9c2d 100644
  132. --- config/players.properties
  133. +++ config/players.properties
  134. @@ -235,4 +235,7 @@
  135.  # ExpertisePenalty, чтобы отключить штраф за уровень
  136.  # False : Игроки могут использовать экипировку S ранга с 1 уровня.
  137.  # True : Игроки не могут использовать экипировку S ранга с 1 уровня.
  138. -ExpertisePenalty = True
  139. \ No newline at end of file
  140. +ExpertisePenalty = True
  141. +
  142. +RadiusBufferTerius = 300
  143. +BufferTeriusAdenaCount = 10000
  144. \ No newline at end of file
  145. diff --git data/xml/TeriusBuffs.xml data/xml/TeriusBuffs.xml
  146. new file mode 100644
  147. index 0000000..d71f092
  148. --- /dev/null
  149. +++ data/xml/TeriusBuffs.xml
  150. @@ -0,0 +1,142 @@
  151. +<TeriusBuffs>
  152. +   <Terius category="Pet" petMinLevel="1" petMaxLevel="30">
  153. +       <Buffs id="1035" level="4"/>
  154. +      <Buffs id="1036" level="2"/>
  155. +      <Buffs id="1040" level="3"/>
  156. +      <Buffs id="1044" level="3"/>
  157. +      <Buffs id="1045" level="6"/>
  158. +      <Buffs id="1048" level="6"/>
  159. +      <Buffs id="1062" level="2"/>
  160. +      <Buffs id="1078" level="6"/>
  161. +      <Buffs id="1085" level="3"/>
  162. +      <Buffs id="1204" level="2"/>
  163. +      <Buffs id="1243" level="3"/>
  164. +      <Buffs id="1389" level="3"/>
  165. +   </Terius>
  166. +      <Terius category="Pet" petMinLevel="31" petMaxLevel="60">
  167. +       <Buffs id="1035" level="4"/>
  168. +      <Buffs id="1036" level="2"/>
  169. +      <Buffs id="1040" level="3"/>
  170. +      <Buffs id="1044" level="3"/>
  171. +      <Buffs id="1045" level="6"/>
  172. +      <Buffs id="1048" level="6"/>
  173. +      <Buffs id="1062" level="2"/>
  174. +      <Buffs id="1078" level="6"/>
  175. +      <Buffs id="1085" level="3"/>
  176. +      <Buffs id="1204" level="2"/>
  177. +      <Buffs id="1243" level="3"/>
  178. +      <Buffs id="1389" level="3"/>
  179. +   </Terius>
  180. +      <Terius category="Pet" petMinLevel="61" petMaxLevel="80">
  181. +       <Buffs id="1035" level="4"/>
  182. +      <Buffs id="1036" level="2"/>
  183. +      <Buffs id="1040" level="3"/>
  184. +      <Buffs id="1044" level="3"/>
  185. +      <Buffs id="1045" level="6"/>
  186. +      <Buffs id="1048" level="6"/>
  187. +      <Buffs id="1062" level="2"/>
  188. +      <Buffs id="1078" level="6"/>
  189. +      <Buffs id="1085" level="3"/>
  190. +      <Buffs id="1204" level="2"/>
  191. +      <Buffs id="1243" level="3"/>
  192. +      <Buffs id="1389" level="3"/>
  193. +   </Terius>
  194. +
  195. +
  196. +
  197. +
  198. +
  199. +
  200. +   <Terius category="Mage" playerMinLevel="1" playerMaxLevel="30">
  201. +       <Buffs id="1035" level="4"/>
  202. +      <Buffs id="1036" level="2"/>
  203. +      <Buffs id="1040" level="3"/>
  204. +      <Buffs id="1044" level="3"/>
  205. +      <Buffs id="1045" level="6"/>
  206. +      <Buffs id="1048" level="6"/>
  207. +      <Buffs id="1062" level="2"/>
  208. +      <Buffs id="1078" level="6"/>
  209. +      <Buffs id="1085" level="3"/>
  210. +      <Buffs id="1204" level="2"/>
  211. +      <Buffs id="1243" level="3"/>
  212. +      <Buffs id="1389" level="3"/>
  213. +   </Terius>
  214. +   <Terius category="Mage" playerMinLevel="31" playerMaxLevel="60">
  215. +       <Buffs id="1035" level="4"/>
  216. +      <Buffs id="1036" level="2"/>
  217. +      <Buffs id="1040" level="3"/>
  218. +      <Buffs id="1044" level="3"/>
  219. +      <Buffs id="1045" level="6"/>
  220. +      <Buffs id="1048" level="6"/>
  221. +      <Buffs id="1062" level="2"/>
  222. +      <Buffs id="1078" level="6"/>
  223. +      <Buffs id="1085" level="3"/>
  224. +      <Buffs id="1204" level="2"/>
  225. +      <Buffs id="1243" level="3"/>
  226. +      <Buffs id="1389" level="3"/>
  227. +   </Terius>
  228. +   <Terius category="Mage" playerMinLevel="61" playerMaxLevel="80">
  229. +       <Buffs id="1035" level="4"/>
  230. +      <Buffs id="1036" level="2"/>
  231. +      <Buffs id="1040" level="3"/>
  232. +      <Buffs id="1044" level="3"/>
  233. +      <Buffs id="1045" level="6"/>
  234. +      <Buffs id="1048" level="6"/>
  235. +      <Buffs id="1062" level="2"/>
  236. +      <Buffs id="1078" level="6"/>
  237. +      <Buffs id="1085" level="3"/>
  238. +      <Buffs id="1204" level="2"/>
  239. +
  240. +   </Terius>
  241. +   <Terius category="Fighter" playerMinLevel="1" playerMaxLevel="30">
  242. +      <Buffs id="1036" level="2"/>
  243. +      <Buffs id="1040" level="3"/>
  244. +      <Buffs id="1043" level="1"/>
  245. +      <Buffs id="1045" level="6"/>
  246. +      <Buffs id="1048" level="6"/>
  247. +      <Buffs id="1062" level="2"/>
  248. +      <Buffs id="1204" level="2"/>
  249. +      <Buffs id="1243" level="3"/>
  250. +      <Buffs id="1044" level="3"/>
  251. +      <Buffs id="1068" level="3"/>
  252. +      <Buffs id="1077" level="3"/>
  253. +      <Buffs id="1086" level="2"/>
  254. +      <Buffs id="1240" level="3"/>
  255. +      <Buffs id="1242" level="3"/>
  256. +      <Buffs id="1388" level="3"/>
  257. +   </Terius>
  258. +   <Terius category="Fighter" playerMinLevel="31" playerMaxLevel="60">
  259. +              <Buffs id="1036" level="2"/>
  260. +      <Buffs id="1040" level="3"/>
  261. +      <Buffs id="1043" level="1"/>
  262. +      <Buffs id="1045" level="6"/>
  263. +      <Buffs id="1048" level="6"/>
  264. +      <Buffs id="1062" level="2"/>
  265. +      <Buffs id="1204" level="2"/>
  266. +      <Buffs id="1243" level="3"/>
  267. +      <Buffs id="1044" level="3"/>
  268. +      <Buffs id="1068" level="3"/>
  269. +      <Buffs id="1077" level="3"/>
  270. +      <Buffs id="1086" level="2"/>
  271. +      <Buffs id="1240" level="3"/>
  272. +      <Buffs id="1242" level="3"/>
  273. +      <Buffs id="1388" level="3"/>
  274. +   </Terius>
  275. +   <Terius category="Fighter" playerMinLevel="61" playerMaxLevel="80">
  276. +      <Buffs id="1036" level="2"/>
  277. +      <Buffs id="1040" level="3"/>
  278. +      <Buffs id="1043" level="1"/>
  279. +      <Buffs id="1045" level="6"/>
  280. +      <Buffs id="1048" level="6"/>
  281. +      <Buffs id="1062" level="2"/>
  282. +      <Buffs id="1204" level="2"/>
  283. +      <Buffs id="1243" level="3"/>
  284. +      <Buffs id="1044" level="3"/>
  285. +      <Buffs id="1068" level="3"/>
  286. +      <Buffs id="1077" level="3"/>
  287. +      <Buffs id="1086" level="2"/>
  288. +      <Buffs id="1240" level="3"/>
  289. +      <Buffs id="1242" level="3"/>
  290. +      <Buffs id="1388" level="3"/>
  291. +   </Terius>
  292. +</TeriusBuffs>
  293. \ No newline at end of file
  294. diff --git java/Base/TeriusBuff/TeriusBuff.java java/Base/TeriusBuff/TeriusBuff.java
  295. new file mode 100644
  296. index 0000000..a217ae0
  297. --- /dev/null
  298. +++ java/Base/TeriusBuff/TeriusBuff.java
  299. @@ -0,0 +1,68 @@
  300. +package Base.TeriusBuff;
  301. +
  302. +import java.util.ArrayList;
  303. +import java.util.List;
  304. +
  305. +public class TeriusBuff {
  306. +    private final String category;
  307. +    private final int playerMinLevel;
  308. +    private final int playerMaxLevel;
  309. +    private final int petMinLevel;  // Agregado
  310. +    private final int petMaxLevel;  // Agregado
  311. +    private List<Buff> buffs;
  312. +
  313. +    public TeriusBuff(String category, int playerMinLevel, int playerMaxLevel, int petMinLevel, int petMaxLevel) {
  314. +        this.category = category;
  315. +        this.playerMinLevel = playerMinLevel;
  316. +        this.playerMaxLevel = playerMaxLevel;
  317. +        this.petMinLevel = petMinLevel;  // Agregado
  318. +        this.petMaxLevel = petMaxLevel;  // Agregado
  319. +        buffs = new ArrayList<>();
  320. +    }
  321. +
  322. +    public String getCategory() {
  323. +        return category;
  324. +    }
  325. +
  326. +    public int getPlayerMinLevel() {
  327. +        return playerMinLevel;
  328. +    }
  329. +
  330. +    public int getPlayerMaxLevel() {
  331. +        return playerMaxLevel;
  332. +    }
  333. +
  334. +    public int getPetMinLevel() {
  335. +        return petMinLevel;
  336. +    }
  337. +
  338. +    public int getPetMaxLevel() {
  339. +        return petMaxLevel;
  340. +    }
  341. +
  342. +    public List<Buff> getBuffs() {
  343. +        return buffs;
  344. +    }
  345. +
  346. +    public void addBuff(Buff buff) {
  347. +        buffs.add(buff);
  348. +    }
  349. +
  350. +    public static class Buff {
  351. +        private int id;
  352. +        private int level;
  353. +
  354. +        public Buff(int id, int level) {
  355. +            this.id = id;
  356. +            this.level = level;
  357. +        }
  358. +
  359. +        public int getId() {
  360. +            return id;
  361. +        }
  362. +
  363. +        public int getLevel() {
  364. +            return level;
  365. +        }
  366. +    }
  367. +}
  368. diff --git java/Base/TeriusBuff/TeriusBuffData.java java/Base/TeriusBuff/TeriusBuffData.java
  369. new file mode 100644
  370. index 0000000..2d81c26
  371. --- /dev/null
  372. +++ java/Base/TeriusBuff/TeriusBuffData.java
  373. @@ -0,0 +1,113 @@
  374. +package Base.TeriusBuff;
  375. +
  376. +import java.io.File;
  377. +import java.util.ArrayList;
  378. +import java.util.HashMap;
  379. +import java.util.List;
  380. +import java.util.Map;
  381. +
  382. +import org.w3c.dom.Document;
  383. +import org.w3c.dom.NamedNodeMap;
  384. +import org.w3c.dom.Node;
  385. +
  386. +import Base.Data.XMLDocument;
  387. +
  388. +public class TeriusBuffData extends XMLDocument {
  389. +    private Map<String, List<TeriusBuff>> teriusBuffsByCategory;
  390. +
  391. +    public TeriusBuffData() {
  392. +        teriusBuffsByCategory = new HashMap<>();
  393. +        load();
  394. +    }
  395. +
  396. +    public void reload() {
  397. +        teriusBuffsByCategory.clear();
  398. +        load();
  399. +    }
  400. +
  401. +    public static TeriusBuffData getInstance() {
  402. +        return SingletonHolder.INSTANCE;
  403. +    }
  404. +
  405. +    private static class SingletonHolder {
  406. +        protected static final TeriusBuffData INSTANCE = new TeriusBuffData();
  407. +    }
  408. +
  409. +    @Override
  410. +    protected void load() {
  411. +        loadDocument("./data/xml/TeriusBuffs.xml");
  412. +        LOG.info("TeriusBuffData: Loaded " + teriusBuffsByCategory.size() + " categories.");
  413. +    }
  414. +
  415. +    @Override
  416. +    protected void parseDocument(Document doc, File file) {
  417. +        try {
  418. +            final Node root = doc.getFirstChild();
  419. +
  420. +            for (Node node = root.getFirstChild(); node != null; node = node.getNextSibling()) {
  421. +                if (!"Terius".equalsIgnoreCase(node.getNodeName())) {
  422. +                    continue;
  423. +                }
  424. +
  425. +                NamedNodeMap attrs = node.getAttributes();
  426. +                String category = attrs.getNamedItem("category").getNodeValue();
  427. +                int playerMinLevel = 0;
  428. +                int playerMaxLevel = 0;
  429. +                int petMinLevel = 0;
  430. +                int petMaxLevel = 0;
  431. +
  432. +                if ("Pet".equalsIgnoreCase(category)) {
  433. +                    petMinLevel = parseOptionalInt(attrs.getNamedItem("petMinLevel"));
  434. +                    petMaxLevel = parseOptionalInt(attrs.getNamedItem("petMaxLevel"));
  435. +                } else {
  436. +                    playerMinLevel = parseOptionalInt(attrs.getNamedItem("playerMinLevel"));
  437. +                    playerMaxLevel = parseOptionalInt(attrs.getNamedItem("playerMaxLevel"));
  438. +                }
  439. +
  440. +                TeriusBuff teriusBuff = new TeriusBuff(category, playerMinLevel, playerMaxLevel, petMinLevel, petMaxLevel);
  441. +
  442. +                for (Node buffNode = node.getFirstChild(); buffNode != null; buffNode = buffNode.getNextSibling()) {
  443. +                    if (!"Buffs".equalsIgnoreCase(buffNode.getNodeName())) {
  444. +                        continue;
  445. +                    }
  446. +
  447. +                    NamedNodeMap buffAttrs = buffNode.getAttributes();
  448. +                    int id = Integer.parseInt(buffAttrs.getNamedItem("id").getNodeValue());
  449. +                    int level = Integer.parseInt(buffAttrs.getNamedItem("level").getNodeValue());
  450. +
  451. +                    TeriusBuff.Buff buff = new TeriusBuff.Buff(id, level);
  452. +                    teriusBuff.addBuff(buff);
  453. +                }
  454. +
  455. +                List<TeriusBuff> buffList = teriusBuffsByCategory.get(category);
  456. +                if (buffList == null) {
  457. +                    buffList = new ArrayList<>();
  458. +                    teriusBuffsByCategory.put(category, buffList);
  459. +                }
  460. +                buffList.add(teriusBuff);
  461. +            }
  462. +        } catch (Exception e) {
  463. +            e.printStackTrace();
  464. +        }
  465. +    }
  466. +
  467. +    
  468. + // Agrega este método a la clase TeriusBuffData
  469. +    private int parseOptionalInt(Node node) {
  470. +        return (node != null && node.getNodeValue() != null) ? Integer.parseInt(node.getNodeValue()) : 0;
  471. +    }
  472. +    
  473. +    
  474. +    
  475. +    public Map<String, List<TeriusBuff>> getTeriusBuffsByCategory() {
  476. +        return teriusBuffsByCategory;
  477. +    }
  478. + // Agrega este método a la clase TeriusBuffData
  479. +    public List<TeriusBuff> getTeriusBuffsForPet() {
  480. +        return teriusBuffsByCategory.get("Pet");
  481. +    }
  482. +
  483. +    public List<TeriusBuff> getTeriusBuffsByCategory(String category) {
  484. +        return teriusBuffsByCategory.get(category);
  485. +    }
  486. +}
  487. diff --git java/net/sf/l2j/Config.java java/net/sf/l2j/Config.java
  488. index cde5ba4..9c7549b 100644
  489. --- java/net/sf/l2j/Config.java
  490. +++ java/net/sf/l2j/Config.java
  491. @@ -52,6 +52,13 @@
  492.     public static final String SERVER_FILE = "./config/server.properties";
  493.     public static final String SIEGE_FILE = "./config/siege.properties";
  494.    
  495. +  
  496. +  
  497. +   public static int RADIUS_BUFFER_TERIUS;
  498. +   public static int TERIUS_BUFF_ADENA_COUNT; 
  499. +  
  500. +  
  501. +  
  502.     // --------------------------------------------------
  503.     // Clans settings
  504.     // --------------------------------------------------
  505. @@ -1907,6 +1914,10 @@
  506.     {
  507.         final ExProperties players = initProperties(PLAYERS_FILE);
  508.        
  509. +       RADIUS_BUFFER_TERIUS = Integer.parseInt(players.getProperty("RadiusBufferTerius", "130"));         
  510. +       TERIUS_BUFF_ADENA_COUNT = Integer.parseInt(players.getProperty("BufferTeriusAdenaCount", "1000"));         
  511. +      
  512. +      
  513.         EFFECT_CANCELING = players.getProperty("CancelLesserEffect", true);
  514.         HP_REGEN_MULTIPLIER = players.getProperty("HpRegenMultiplier", 1.);
  515.         MP_REGEN_MULTIPLIER = players.getProperty("MpRegenMultiplier", 1.);
  516. diff --git java/net/sf/l2j/gameserver/GameServer.java java/net/sf/l2j/gameserver/GameServer.java
  517. index 9d663cf..cdad3b2 100644
  518. --- java/net/sf/l2j/gameserver/GameServer.java
  519. +++ java/net/sf/l2j/gameserver/GameServer.java
  520. @@ -116,6 +116,7 @@
  521.  import net.sf.l2j.util.IPv4Filter;
  522.  
  523.  import Base.DropMaster.DropMaster;
  524. +import Base.TeriusBuff.TeriusBuffData;
  525.  
  526.  public class GameServer
  527.  {
  528. @@ -310,6 +311,10 @@
  529.         StringUtil.printSection("Spawns");
  530.         SpawnManager.getInstance().spawn();
  531.        
  532. +      
  533. +       StringUtil.printSection("Terius Buffer");
  534. +       TeriusBuffData.getInstance();
  535. +      
  536.         StringUtil.printSection("Handlers");
  537.         LOGGER.info("Loaded {} admin command handlers.", AdminCommandHandler.getInstance().size());
  538.         LOGGER.info("Loaded {} chat handlers.", ChatHandler.getInstance().size());
  539. diff --git java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReload.java java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReload.java
  540. index f325d85..d1ac3b2 100644
  541. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReload.java
  542. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReload.java
  543. @@ -29,6 +29,7 @@
  544.  import net.sf.l2j.gameserver.model.actor.Player;
  545.  
  546.  import Base.DropMaster.DropMaster;
  547. +import Base.TeriusBuff.TeriusBuffData;
  548.  
  549.  public class AdminReload implements IAdminCommandHandler
  550.  {
  551. @@ -78,6 +79,11 @@
  552.                     CrestCache.getInstance().reload();
  553.                     player.sendMessage("Crests have been reloaded.");
  554.                 }
  555. +               else if (type.startsWith("teriusbuffs"))
  556. +               {
  557. +                   TeriusBuffData.getInstance().reload();
  558. +                   player.sendMessage("Terius Buffs have been reloaded.");
  559. +               }
  560.                 else if (type.startsWith("cw"))
  561.                 {
  562.                     CursedWeaponManager.getInstance().reload();
  563. @@ -180,7 +186,7 @@
  564.     {
  565.         player.sendMessage("Usage : //reload <admin|announcement|buylist|config>");
  566.         player.sendMessage("Usage : //reload <crest|cw|dropmaster|door|htm|item|multisell|npc>");
  567. -       player.sendMessage("Usage : //reload <npcwalker|script|skill|teleport|zone>");
  568. +       player.sendMessage("Usage : //reload <npcwalker|teriusbuffs|script|skill|teleport|zone>");
  569.         player.sendMessage("Usage : //reload <spawnlist|sysstring|capsule>");
  570.     }
  571.    
  572. diff --git java/net/sf/l2j/gameserver/model/actor/instance/BufferTerius.java java/net/sf/l2j/gameserver/model/actor/instance/BufferTerius.java
  573. new file mode 100644
  574. index 0000000..26e80d1
  575. --- /dev/null
  576. +++ java/net/sf/l2j/gameserver/model/actor/instance/BufferTerius.java
  577. @@ -0,0 +1,187 @@
  578. +package net.sf.l2j.gameserver.model.actor.instance;
  579. +
  580. +import java.util.concurrent.ScheduledFuture;
  581. +
  582. +import net.sf.l2j.commons.pool.ThreadPool;
  583. +
  584. +import net.sf.l2j.Config;
  585. +import net.sf.l2j.gameserver.data.SkillTable;
  586. +import net.sf.l2j.gameserver.model.actor.Npc;
  587. +import net.sf.l2j.gameserver.model.actor.Player;
  588. +import net.sf.l2j.gameserver.model.actor.Summon;
  589. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  590. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  591. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  592. +import net.sf.l2j.gameserver.network.serverpackets.MoveToPawn;
  593. +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
  594. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  595. +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  596. +import net.sf.l2j.gameserver.skills.L2Skill;
  597. +
  598. +import Base.TeriusBuff.TeriusBuff;
  599. +import Base.TeriusBuff.TeriusBuff.Buff;
  600. +import Base.TeriusBuff.TeriusBuffData;
  601. +
  602. +import java.util.List;
  603. +
  604. +public class BufferTerius extends Folk {
  605. +    private ScheduledFuture<?> _aiTask;
  606. +
  607. +    @Override
  608. +    public void onInteract(Player player) {
  609. +        if (this != player.getTarget()) {
  610. +            player.setTarget(this);
  611. +            player.sendPacket(new MyTargetSelected(getObjectId(), 0));
  612. +            player.sendPacket(new ValidateLocation(this));
  613. +        }
  614. +
  615. +        // Rotate the player to face the instance
  616. +        player.sendPacket(new MoveToPawn(player, this, Npc.INTERACTION_DISTANCE));
  617. +
  618. +
  619. +
  620. +        showMainWindow(player);
  621. +
  622. +        // Send ActionFailed to the player to prevent getting stuck
  623. +        player.sendPacket(ActionFailed.STATIC_PACKET);
  624. +    }
  625. +
  626. +    public void showMainWindow(Player player) {
  627. +        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  628. +        html.setFile(player.getLocale(), "html/mods/TeriusBuff.htm");
  629. +        html.replace("%objectId%", String.valueOf(getObjectId()));
  630. +        html.replace("%npcname%", getName());
  631. +        player.sendPacket(html);
  632. +    }
  633. +
  634. +    private class TeriusAI implements Runnable {
  635. +        private final BufferTerius _caster;
  636. +
  637. +        protected TeriusAI(final BufferTerius caster) {
  638. +            _caster = caster;
  639. +        }
  640. +
  641. +        @Override
  642. +        public void run() {
  643. +            for (Player player : getKnownType(Player.class)) {
  644. +                int playerLevel = player.getStatus().getLevel();
  645. +                final Summon summon = player.getSummon();
  646. +                String playerClass = player.isMageClass() ? "Mage" : "Fighter";
  647. +
  648. +                List<TeriusBuff> buffs = TeriusBuffData.getInstance().getTeriusBuffsByCategory(playerClass);
  649. +                if (buffs != null) {
  650. +                    for (TeriusBuff buff : buffs) {
  651. +                        if (buff.getPlayerMinLevel() <= playerLevel && buff.getPlayerMaxLevel() >= playerLevel) {
  652. +                            TeriusCast(player, buff.getBuffs());
  653. +                          
  654. +                        }
  655. +                    }
  656. +                }
  657. +                List<TeriusBuff> petBuffs = TeriusBuffData.getInstance().getTeriusBuffsForPet();
  658. +if (summon != null) {
  659. +    if (petBuffs != null) {
  660. +        for (TeriusBuff buff : petBuffs) {
  661. +            
  662. +            int petLevel = summon.getStatus().getLevel();
  663. +            
  664. +            if (
  665. +                buff.getPetMinLevel() <= petLevel && buff.getPetMaxLevel() >= petLevel) {
  666. +                TeriusCastPet(player, buff.getBuffs());
  667. +            }
  668. +        }
  669. +    }
  670. +}
  671. +
  672. +                
  673. +            }
  674. +        }
  675. +        
  676. +  
  677. +
  678. +        private void TeriusCastPet(Player player, List<Buff> buffs) {
  679. +            final Summon summon = player.getSummon();
  680. +            if (summon != null) {
  681. +                if (summon.isDead() || !summon.isVisible() ||
  682. +                        !isIn3DRadius(summon, Config.RADIUS_BUFFER_TERIUS)) {
  683. +                    return;
  684. +                }
  685. +                boolean hasBuffed = false; // Variable para controlar si el jugador ha sido buffeado al menos una vez.
  686. +
  687. +                for (Buff buff : buffs) {
  688. +                    int skillId = buff.getId();
  689. +                    int skillLevel = buff.getLevel();
  690. +
  691. +                    L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLevel);
  692. +
  693. +                    if (skill == null || summon.getFirstEffect(skill) != null) {
  694. +                        continue;
  695. +                    }
  696. +
  697. +                    // Verificar si el jugador cumple la condición para cobrar adena.
  698. +                    if (player.getStatus().getLevel() >= 31 && player.getAdena() >= Config.TERIUS_BUFF_ADENA_COUNT) {
  699. +                        if (!hasBuffed) { // Solo cobrar adena una vez si ha habido al menos un buff exitoso.
  700. +                           // player.reduceAdena("Cobro", Config.TERIUS_BUFF_ADENA_COUNT, player, true);
  701. +                            player.destroyItemByItemId(57, Config.TERIUS_BUFF_ADENA_COUNT, true);
  702. +                            hasBuffed = true; // Marcar que el jugador ha sido buffeado.
  703. +                        }
  704. +                    }
  705. +
  706. +                    skill.getEffects(_caster, summon);
  707. +                    broadcastPacket(new MagicSkillUse(_caster, summon, skillId, skillLevel, 1000, 0));
  708. +                    player.setTarget(summon);
  709. +                }
  710. +            } else {
  711. +                player.sendMessage("No Tienes Summon");
  712. +            }
  713. +        }
  714. +
  715. +
  716. +
  717. +        private void TeriusCast(final Player player, List<Buff> buffs) {
  718. +            if (player.isDead() || !player.isVisible() || !isIn3DRadius(player, Config.RADIUS_BUFFER_TERIUS)) {
  719. +                return;
  720. +            }
  721. +
  722. +            // Verificar si el jugador tiene suficiente adena
  723. +            if (player.getStatus().getLevel() >= 31 && player.getAdena() < Config.TERIUS_BUFF_ADENA_COUNT) {
  724. +                return; // Ignorar al jugador si no tiene suficiente adena
  725. +            }
  726. +            
  727. +            
  728. +            boolean hasBuffed = false; // Variable para controlar si el jugador ha sido buffeado al menos una vez.
  729. +
  730. +            for (Buff buff : buffs) {
  731. +                int skillId = buff.getId();
  732. +                int skillLevel = buff.getLevel();
  733. +
  734. +                L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLevel);
  735. +
  736. +                if (skill == null || player.getFirstEffect(skill) != null) {
  737. +                    continue;
  738. +                }
  739. +
  740. +                // Verificar si el jugador cumple la condición para cobrar adena.
  741. +                if (player.getStatus().getLevel() >= 31 && player.getAdena() >= Config.TERIUS_BUFF_ADENA_COUNT) {
  742. +                    if (!hasBuffed) { // Solo cobrar adena una vez si ha habido al menos un buff exitoso.
  743. +                        // player.reduceAdena("Cobro", Config.TERIUS_BUFF_ADENA_COUNT, player, true);
  744. +                        player.destroyItemByItemId(57, Config.TERIUS_BUFF_ADENA_COUNT, true);
  745. +                        hasBuffed = true; // Marcar que el jugador ha sido buffeado.
  746. +                    }
  747. +                }
  748. +
  749. +                skill.getEffects(_caster, player);
  750. +                broadcastPacket(new MagicSkillUse(_caster, player, skillId, skillLevel, 1000, 0));
  751. +            }
  752. +        }
  753. +    }
  754. +
  755. +    public BufferTerius(final int objectId, final NpcTemplate template) {
  756. +        super(objectId, template);
  757. +
  758. +        if (_aiTask != null) {
  759. +            _aiTask.cancel(true);
  760. +        }
  761. +
  762. +        _aiTask = ThreadPool.scheduleAtFixedRate(new TeriusAI(this), 3000, 3000);
  763. +    }
  764. +}
  765.  
  766. diff --git data/locale/en_US/html/mods/TeriusBuff.htm data/locale/en_US/html/mods/TeriusBuff.htm
  767. new file mode 100644
  768. index 0000000..d71f092
  769. --- /dev/null
  770. +++ data/locale/en_US/html/mods/TeriusBuff.htm
  771. +<html><title>L2ServerName Buffer</title><body>
  772. +<center>
  773. +<br>
  774. +<br>
  775. +<br>
  776. +<br>
  777. +<img src="l2ui_ch3.herotower_deco" width=256 height=32>   
  778. +<br>
  779. +<center><img src="L2UI.SquareGray" width=300 height=1></center>       
  780. +<br1>
  781. +<center>L2ServerName.</center>
  782. +<br1>
  783. +El Npc Buffer Detecta a los jugadores cerca
  784. +<br1>
  785. +Dependiendo de tu lvl te dara x buffs
  786. +<br1>
  787. +Los Buffs son gratis hasta el nivel 31.
  788. +<br1>
  789. +Te buffean tanto a ti como a tu mascotaa.
  790. +<br1>
  791. +A partir del nivel 31 en adelante empieza a cobrar,
  792. +<br1>
  793. +10.000 de adena por cada vez que el npc te BUFFEA.
  794. +<br>
  795. +<center><img src="L2UI.SquareGray" width=300 height=1></center>
  796. +<br>
  797. +<br>
  798. +<br>
  799. +<br>
  800. +<br>
  801. +<br>
  802. +<br>
  803. +<br>
  804. +<br>
  805. +<br>
  806. +<br>
  807. +<br>
  808. +<br>
  809. +<br>
  810. +<br>
  811. +<center>Npc Creado Por: <font color="800080">Terius</font></center>
  812. +
  813. +</body>
  814. +</html>
  815.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement