Guest User

Untitled

a guest
Dec 6th, 2022
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.58 KB | None | 0 0
  1. diff --git a/aCis_gameserver/java/net/sf/l2j/Config.java b/aCis_gameserver/java/net/sf/l2j/Config.java
  2. index d63fabd..3282c6d 100644
  3. --- a/aCis_gameserver/java/net/sf/l2j/Config.java
  4. +++ b/aCis_gameserver/java/net/sf/l2j/Config.java
  5. @@ -46,6 +46,16 @@
  6. public static final String VALORANT_RESTRICT_FILE = "./config/ValorantRestricts.properties";
  7. public static final String GRAND_BOSS_FILE = "./config/GrandBoss.properties";
  8.  
  9. + /** Character Killing Monument settings */
  10. + public static boolean CKM_ENABLED;
  11. + public static long CKM_CYCLE_LENGTH;
  12. + public static String CKM_PVP_NPC_TITLE;
  13. + public static int CKM_PVP_NPC_TITLE_COLOR;
  14. + public static int CKM_PVP_NPC_NAME_COLOR;
  15. + public static String CKM_PK_NPC_TITLE;
  16. + public static int CKM_PK_NPC_TITLE_COLOR;
  17. + public static int CKM_PK_NPC_NAME_COLOR;
  18. +
  19. public static List<Integer> BOW_IDS = new ArrayList<>();
  20. public static List<Integer> DUAL_IDS = new ArrayList<>();
  21. public static List<Integer> SWORD_IDS = new ArrayList<>();
  22. @@ -2744,6 +2754,14 @@
  23. FORBIDDEN_WORDS = custom.getProperty("ForbiddenWords", "").split(",");
  24. ENABLE_BAN_FROM_EVENT = custom.getProperty("EnableEventBans", true);
  25. BANNED_EVENT_PLAYERS = custom.getProperty("BannedEventPlayers", "").split(",");
  26. + CKM_ENABLED = custom.getProperty("CKMEnabled", false);
  27. + CKM_CYCLE_LENGTH = custom.getProperty("CKMCycleLength", 86400000);
  28. + CKM_PVP_NPC_TITLE = custom.getProperty("CKMPvPNpcTitle", "%kills% PvPs in the last 24h");
  29. + CKM_PVP_NPC_TITLE_COLOR = Integer.decode("0x" + custom.getProperty("CKMPvPNpcTitleColor", "88AA88"));
  30. + CKM_PVP_NPC_NAME_COLOR = Integer.decode("0x" + custom.getProperty("CKMPvPNpcNameColor", "FFFFFF"));
  31. + CKM_PK_NPC_TITLE = custom.getProperty("CKMPKNpcTitle", "%kills% PKs in the last 24h");
  32. + CKM_PK_NPC_TITLE_COLOR = Integer.decode("0x" + custom.getProperty("CKMPKNpcTitleColor", "00CCFF"));
  33. + CKM_PK_NPC_NAME_COLOR = Integer.decode("0x" + custom.getProperty("CKMPKNpcNameColor", "FFFFFF"));
  34. }
  35.  
  36. private static final void loadGrandBoss()
  37. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/GameServer.java b/aCis_gameserver/java/net/sf/l2j/gameserver/GameServer.java
  38. index 61483fb..f536c3a 100644
  39. --- a/aCis_gameserver/java/net/sf/l2j/gameserver/GameServer.java
  40. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/GameServer.java
  41. @@ -33,6 +33,7 @@
  42. import net.sf.l2j.gameserver.data.manager.BuyListManager;
  43. import net.sf.l2j.gameserver.data.manager.CastleManager;
  44. import net.sf.l2j.gameserver.data.manager.CastleManorManager;
  45. +import net.sf.l2j.gameserver.data.manager.CharacterKillingManager;
  46. import net.sf.l2j.gameserver.data.manager.ClanHallManager;
  47. import net.sf.l2j.gameserver.data.manager.CoupleManager;
  48. import net.sf.l2j.gameserver.data.manager.CursedWeaponManager;
  49. @@ -383,6 +384,10 @@
  50. System.out.println("FarmZoneScheduler class has been loaded with "+FarmZoneScheduler.getInstance().farmZones.size()+" zones.");
  51. }
  52. FakeOnline.restoreFakePlayers();
  53. + if (Config.CKM_ENABLED)
  54. + {
  55. + CharacterKillingManager.getInstance().init();
  56. + }
  57.  
  58. StringUtil.printSection("GrandBosses");
  59. if(Config.ANT_QUEEN_ENABLE)
  60. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/data/manager/CharacterKillingManager.java b/aCis_gameserver/java/net/sf/l2j/gameserver/data/manager/CharacterKillingManager.java
  61. new file mode 100644
  62. index 0000000..b622fb1
  63. --- /dev/null
  64. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/data/manager/CharacterKillingManager.java
  65. @@ -0,0 +1,321 @@
  66. +/*
  67. + * This program is free software: you can redistribute it and/or modify it under
  68. + * the terms of the GNU General Public License as published by the Free Software
  69. + * Foundation, either version 3 of the License, or (at your option) any later
  70. + * version.
  71. + *
  72. + * This program is distributed in the hope that it will be useful, but WITHOUT
  73. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  74. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  75. + * details.
  76. + *
  77. + * You should have received a copy of the GNU General Public License along with
  78. + * this program. If not, see <http://www.gnu.org/licenses/>.
  79. + */
  80. +package net.sf.l2j.gameserver.data.manager;
  81. +
  82. +import java.sql.Connection;
  83. +import java.sql.PreparedStatement;
  84. +import java.sql.ResultSet;
  85. +import java.sql.Statement;
  86. +import java.util.List;
  87. +import java.util.concurrent.CopyOnWriteArrayList;
  88. +import java.util.concurrent.ScheduledFuture;
  89. +import java.util.concurrent.TimeUnit;
  90. +import java.util.logging.Level;
  91. +import java.util.logging.Logger;
  92. +
  93. +import net.sf.l2j.Config;
  94. +import net.sf.l2j.commons.pool.ConnectionPool;
  95. +import net.sf.l2j.commons.pool.ThreadPool;
  96. +import net.sf.l2j.gameserver.model.CharSelectSlot;
  97. +import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
  98. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  99. +
  100. +/**
  101. + * @author paytaly
  102. + */
  103. +public final class CharacterKillingManager
  104. +{
  105. + private static final Logger _log = Logger.getLogger(CharacterKillingManager.class.getName());
  106. +
  107. + private int _cycle = 0;
  108. + private long _cycleStart = 0L;
  109. + private int _winnerPvPKills;
  110. + private int _winnerPvPKillsCount;
  111. + private int _winnerPKKills;
  112. + private int _winnerPKKillsCount;
  113. +
  114. + private volatile CharSelectSlot _winnerPvPKillsInfo;
  115. + private volatile CharSelectSlot _winnerPKKillsInfo;
  116. +
  117. + private ScheduledFuture<?> _scheduledKillingCycleTask = null;
  118. +
  119. + private List<L2PcPolymorph> pvpMorphListeners = new CopyOnWriteArrayList<>();
  120. + private List<L2PcPolymorph> pkMorphListeners = new CopyOnWriteArrayList<>();
  121. +
  122. + protected CharacterKillingManager()
  123. + {
  124. + }
  125. +
  126. + public synchronized void init()
  127. + {
  128. + try (Connection con = ConnectionPool.getConnection();
  129. + PreparedStatement st = con.prepareStatement("SELECT cycle, cycle_start, winner_pvpkills, winner_pvpkills_count, winner_pkkills, winner_pkkills_count FROM character_kills_info ORDER BY cycle_start DESC LIMIT 1");
  130. + ResultSet rs = st.executeQuery())
  131. + {
  132. + if (rs.next())
  133. + {
  134. + _cycle = rs.getInt("cycle");
  135. + _cycleStart = rs.getLong("cycle_start");
  136. + _winnerPvPKills = rs.getInt("winner_pvpkills");
  137. + _winnerPvPKillsCount = rs.getInt("winner_pvpkills_count");
  138. + _winnerPKKills = rs.getInt("winner_pkkills");
  139. + _winnerPKKillsCount = rs.getInt("winner_pkkills_count");
  140. + }
  141. + }
  142. + catch (Exception e)
  143. + {
  144. + _log.log(Level.WARNING, "Could not load characters killing cycle: " + e.getMessage(), e);
  145. + }
  146. +
  147. + broadcastMorphUpdate();
  148. +
  149. + if (_scheduledKillingCycleTask != null)
  150. + {
  151. + _scheduledKillingCycleTask.cancel(true);
  152. + }
  153. + long millisToNextCycle = (_cycleStart + Config.CKM_CYCLE_LENGTH) - System.currentTimeMillis();
  154. + _scheduledKillingCycleTask = ThreadPool.schedule(new CharacterKillingCycleTask(), millisToNextCycle);
  155. +
  156. + _log.info(getClass().getSimpleName() + ": Started! Cycle: " + _cycle + " - Next cycle in: " + _scheduledKillingCycleTask.getDelay(TimeUnit.SECONDS) + "s");
  157. + }
  158. +
  159. + public synchronized void newKillingCycle()
  160. + {
  161. + _cycleStart = System.currentTimeMillis();
  162. + computateCyclePvPWinner();
  163. + computateCyclePKWinner();
  164. + refreshKillingSnapshot();
  165. +
  166. + try (Connection con = ConnectionPool.getConnection();
  167. + PreparedStatement st = con.prepareStatement("INSERT INTO character_kills_info (cycle_start, winner_pvpkills, winner_pvpkills_count, winner_pkkills, winner_pkkills_count) VALUES (?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS))
  168. + {
  169. + st.setLong(1, _cycleStart);
  170. + st.setInt(2, _winnerPvPKills);
  171. + st.setInt(3, _winnerPvPKillsCount);
  172. + st.setInt(4, _winnerPKKills);
  173. + st.setInt(5, _winnerPKKillsCount);
  174. + st.execute();
  175. +
  176. + try (ResultSet rs = st.getGeneratedKeys())
  177. + {
  178. + if (rs.next())
  179. + {
  180. + _cycle = rs.getInt(1);
  181. + }
  182. + }
  183. + }
  184. + catch (Exception e)
  185. + {
  186. + _log.log(Level.WARNING, "Could not create characters killing cycle: " + e.getMessage(), e);
  187. + }
  188. +
  189. + broadcastMorphUpdate();
  190. +
  191. + if (_scheduledKillingCycleTask != null)
  192. + {
  193. + _scheduledKillingCycleTask.cancel(true);
  194. + }
  195. + _scheduledKillingCycleTask = ThreadPool.schedule(new CharacterKillingCycleTask(), Config.CKM_CYCLE_LENGTH);
  196. + }
  197. +
  198. + private void computateCyclePvPWinner()
  199. + {
  200. + _winnerPvPKills = 0;
  201. + _winnerPvPKillsCount = 0;
  202. + _winnerPvPKillsInfo = null;
  203. +
  204. + try (Connection con = ConnectionPool.getConnection();
  205. + PreparedStatement st = con.prepareStatement("SELECT c.obj_Id, (c.pvpkills - COALESCE(ck.pvpkills, 0)) pvpkills FROM characters c LEFT JOIN character_kills_snapshot ck ON ck.charId = c.obj_Id WHERE accesslevel = 0 ORDER BY pvpkills DESC LIMIT 1");
  206. + ResultSet rs = st.executeQuery();)
  207. + {
  208. + if (rs.next())
  209. + {
  210. + int kills = rs.getInt(2);
  211. + if (kills > 0)
  212. + {
  213. + _winnerPvPKills = rs.getInt(1);
  214. + _winnerPvPKillsCount = kills;
  215. + }
  216. + }
  217. + }
  218. + catch (Exception e)
  219. + {
  220. + _log.log(Level.WARNING, "Could not computate characters killing cycle winners: " + e.getMessage(), e);
  221. + }
  222. + }
  223. +
  224. + private void computateCyclePKWinner()
  225. + {
  226. + _winnerPKKills = 0;
  227. + _winnerPKKillsCount = 0;
  228. + _winnerPKKillsInfo = null;
  229. +
  230. + try (Connection con = ConnectionPool.getConnection();
  231. + PreparedStatement st = con.prepareStatement("SELECT c.obj_Id, (c.pkkills - COALESCE(ck.pkkills, 0)) pkkills FROM characters c LEFT JOIN character_kills_snapshot ck ON ck.charId = c.obj_Id WHERE accesslevel = 0 ORDER BY pkkills DESC LIMIT 1");
  232. + ResultSet rs = st.executeQuery();)
  233. + {
  234. + if (rs.next())
  235. + {
  236. + int kills = rs.getInt(2);
  237. + if (kills > 0)
  238. + {
  239. + _winnerPKKills = rs.getInt(1);
  240. + _winnerPKKillsCount = kills;
  241. + }
  242. + }
  243. + }
  244. + catch (Exception e)
  245. + {
  246. + _log.log(Level.WARNING, "Could not computate characters killing cycle winners: " + e.getMessage(), e);
  247. + }
  248. + }
  249. +
  250. + private static void refreshKillingSnapshot()
  251. + {
  252. + try (Connection con = ConnectionPool.getConnection();
  253. + PreparedStatement stTruncate = con.prepareStatement("TRUNCATE TABLE character_kills_snapshot");
  254. + PreparedStatement stRefresh = con.prepareStatement("INSERT INTO character_kills_snapshot (charId, pvpkills, pkkills) SELECT obj_Id, pvpkills, pkkills FROM characters WHERE (pvpkills > 0 OR pkkills > 0) AND accesslevel = 0"))
  255. + {
  256. + stTruncate.executeUpdate();
  257. + stRefresh.executeUpdate();
  258. + }
  259. + catch (Exception e)
  260. + {
  261. + _log.log(Level.WARNING, "Could not refresh characters killing snapshot: " + e.getMessage(), e);
  262. + }
  263. + }
  264. +
  265. + public void broadcastMorphUpdate()
  266. + {
  267. + final CharSelectSlot winnerPvPKillsInfo = getWinnerPvPKillsInfo();
  268. + for (L2PcPolymorph npc : pvpMorphListeners)
  269. + {
  270. + broadcastPvPMorphUpdate(npc, winnerPvPKillsInfo);
  271. + }
  272. +
  273. + final CharSelectSlot winnerPKKillsInfo = getWinnerPKKillsInfo();
  274. + for (L2PcPolymorph npc : pkMorphListeners)
  275. + {
  276. + broadcastPKMorphUpdate(npc, winnerPKKillsInfo);
  277. + }
  278. + }
  279. +
  280. + private void broadcastPvPMorphUpdate(L2PcPolymorph npc, CharSelectSlot winnerPvPKillsInfo)
  281. + {
  282. + if (winnerPvPKillsInfo == null)
  283. + {
  284. + npc.setPolymorphInfo(null);
  285. + return;
  286. + }
  287. + npc.setVisibleTitle(Config.CKM_PVP_NPC_TITLE.replaceAll("%kills%", String.valueOf(_winnerPvPKillsCount)));
  288. + npc.setTitleColor(Config.CKM_PVP_NPC_TITLE_COLOR);
  289. + npc.setNameColor(Config.CKM_PVP_NPC_NAME_COLOR);
  290. + npc.setPolymorphInfo(winnerPvPKillsInfo);
  291. + npc.broadcastPacket(new SocialAction(npc, 16));
  292. + }
  293. +
  294. + private void broadcastPKMorphUpdate(L2PcPolymorph npc, CharSelectSlot winnerPKKillsInfo)
  295. + {
  296. + if (winnerPKKillsInfo == null)
  297. + {
  298. + npc.setPolymorphInfo(null);
  299. + return;
  300. + }
  301. + npc.setVisibleTitle(Config.CKM_PK_NPC_TITLE.replaceAll("%kills%", String.valueOf(_winnerPKKillsCount)));
  302. + npc.setTitleColor(Config.CKM_PK_NPC_TITLE_COLOR);
  303. + npc.setNameColor(Config.CKM_PK_NPC_NAME_COLOR);
  304. + npc.setPolymorphInfo(winnerPKKillsInfo);
  305. + npc.broadcastPacket(new SocialAction(npc, 16));
  306. + }
  307. +
  308. + public boolean addPvPMorphListener(L2PcPolymorph npc)
  309. + {
  310. + if (npc == null)
  311. + {
  312. + return false;
  313. + }
  314. + broadcastPvPMorphUpdate(npc, getWinnerPvPKillsInfo());
  315. + return pvpMorphListeners.add(npc);
  316. + }
  317. +
  318. + public boolean removePvPMorphListener(L2PcPolymorph npc)
  319. + {
  320. + return pvpMorphListeners.remove(npc);
  321. + }
  322. +
  323. + public boolean addPKMorphListener(L2PcPolymorph npc)
  324. + {
  325. + if (npc == null)
  326. + {
  327. + return false;
  328. + }
  329. + broadcastPKMorphUpdate(npc, getWinnerPKKillsInfo());
  330. + return pkMorphListeners.add(npc);
  331. + }
  332. +
  333. + public boolean removePKMorphListener(L2PcPolymorph npc)
  334. + {
  335. + return pkMorphListeners.remove(npc);
  336. + }
  337. +
  338. + private CharSelectSlot getWinnerPvPKillsInfo()
  339. + {
  340. + if (_winnerPvPKills != 0 && _winnerPvPKillsInfo == null)
  341. + {
  342. + synchronized (this)
  343. + {
  344. + if (_winnerPvPKillsInfo == null)
  345. + {
  346. + _winnerPvPKillsInfo = L2PcPolymorph.loadCharInfo(_winnerPvPKills);
  347. + }
  348. + }
  349. + }
  350. + return _winnerPvPKillsInfo;
  351. + }
  352. +
  353. + private CharSelectSlot getWinnerPKKillsInfo()
  354. + {
  355. + if (_winnerPKKills != 0 && _winnerPKKillsInfo == null)
  356. + {
  357. + synchronized (this)
  358. + {
  359. + if (_winnerPKKillsInfo == null)
  360. + {
  361. + _winnerPKKillsInfo = L2PcPolymorph.loadCharInfo(_winnerPKKills);
  362. + }
  363. + }
  364. + }
  365. + return _winnerPKKillsInfo;
  366. + }
  367. +
  368. + protected static class CharacterKillingCycleTask implements Runnable
  369. + {
  370. + @Override
  371. + public void run()
  372. + {
  373. + CharacterKillingManager.getInstance().newKillingCycle();
  374. + }
  375. + }
  376. +
  377. + public static CharacterKillingManager getInstance()
  378. + {
  379. + return SingletonHolder._instance;
  380. + }
  381. +
  382. + private static class SingletonHolder
  383. + {
  384. + protected static final CharacterKillingManager _instance = new CharacterKillingManager();
  385. + }
  386. +}
  387. \ No newline at end of file
  388. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/L2PcPolymorph.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/L2PcPolymorph.java
  389. new file mode 100644
  390. index 0000000..a2ae249
  391. --- /dev/null
  392. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/L2PcPolymorph.java
  393. @@ -0,0 +1,192 @@
  394. +/*
  395. + * This program is free software: you can redistribute it and/or modify it under
  396. + * the terms of the GNU General Public License as published by the Free Software
  397. + * Foundation, either version 3 of the License, or (at your option) any later
  398. + * version.
  399. + *
  400. + * This program is distributed in the hope that it will be useful, but WITHOUT
  401. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  402. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  403. + * details.
  404. + *
  405. + * You should have received a copy of the GNU General Public License along with
  406. + * this program. If not, see <http://www.gnu.org/licenses/>.
  407. + */
  408. +package net.sf.l2j.gameserver.model.actor;
  409. +
  410. +import java.sql.Connection;
  411. +import java.sql.PreparedStatement;
  412. +import java.sql.ResultSet;
  413. +import java.util.logging.Level;
  414. +import java.util.logging.Logger;
  415. +
  416. +import net.sf.l2j.commons.pool.ConnectionPool;
  417. +import net.sf.l2j.gameserver.enums.Paperdoll;
  418. +import net.sf.l2j.gameserver.model.CharSelectSlot;
  419. +import net.sf.l2j.gameserver.model.WorldObject;
  420. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  421. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  422. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  423. +import net.sf.l2j.gameserver.network.serverpackets.NpcInfoPolymorph;
  424. +
  425. +/**
  426. + * @author paytaly
  427. + */
  428. +public class L2PcPolymorph extends Npc
  429. +{
  430. + private static final Logger _log = Logger.getLogger(L2PcPolymorph.class.getName());
  431. + private CharSelectSlot _polymorphInfo;
  432. + private int _nameColor = 0xFFFFFF;
  433. + private int _titleColor = 0xFFFF77;
  434. + private String _visibleTitle = "";
  435. +
  436. + public L2PcPolymorph(int objectId, NpcTemplate template)
  437. + {
  438. + super(objectId, template);
  439. + setInvul(true);
  440. + }
  441. +
  442. + @Override
  443. + public boolean hasRandomAnimation()
  444. + {
  445. + return false;
  446. + }
  447. +
  448. + public CharSelectSlot getPolymorphInfo()
  449. + {
  450. + return _polymorphInfo;
  451. + }
  452. +
  453. + public void setPolymorphInfo(CharSelectSlot polymorphInfo)
  454. + {
  455. + _polymorphInfo = polymorphInfo;
  456. +
  457. + for (WorldObject object : getKnownType(Player.class))
  458. + {
  459. + if (object instanceof Player)
  460. + {
  461. + sendInfo(object.getActingPlayer());
  462. + }
  463. + }
  464. + }
  465. +
  466. + public int getNameColor()
  467. + {
  468. + return _nameColor;
  469. + }
  470. +
  471. + public void setNameColor(int nameColor)
  472. + {
  473. + _nameColor = nameColor;
  474. + }
  475. +
  476. + public int getTitleColor()
  477. + {
  478. + return _titleColor;
  479. + }
  480. +
  481. + public void setTitleColor(int titleColor)
  482. + {
  483. + _titleColor = titleColor;
  484. + }
  485. +
  486. + public String getVisibleTitle()
  487. + {
  488. + return _visibleTitle;
  489. + }
  490. +
  491. + public void setVisibleTitle(String title)
  492. + {
  493. + _visibleTitle = title == null ? "" : title;
  494. + }
  495. +
  496. + @Override
  497. + public void sendInfo(Player activeChar)
  498. + {
  499. + if (getPolymorphInfo() == null)
  500. + {
  501. + super.sendInfo(activeChar);
  502. + return;
  503. + }
  504. +
  505. + activeChar.sendPacket(new NpcInfoPolymorph(this));
  506. + }
  507. +
  508. + @Override
  509. + public String getHtmlPath(int npcId, int val)
  510. + {
  511. + String pom = "" + npcId;
  512. + if (val != 0)
  513. + {
  514. + pom += "-" + val;
  515. + }
  516. + return "data/html/polymorph/" + pom + ".htm";
  517. + }
  518. +
  519. + @Override
  520. + public void showChatWindow(Player player, int val)
  521. + {
  522. + String filename = getHtmlPath(getNpcId(), val);
  523. +
  524. + // Send a Server->Client NpcHtmlMessage containing the text of the Npc to the Player
  525. + final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  526. + html.setFile(filename);
  527. + html.replace("%objectId%", getObjectId());
  528. + html.replace("%ownername%", getPolymorphInfo() != null ? getPolymorphInfo().getName() : "");
  529. + player.sendPacket(html);
  530. +
  531. + // Send a Server->Client ActionFailed to the Player in order to avoid that the client wait another packet
  532. + player.sendPacket(ActionFailed.STATIC_PACKET);
  533. + }
  534. +
  535. + public static CharSelectSlot loadCharInfo(int objectId)
  536. + {
  537. + try (Connection con = ConnectionPool.getConnection();
  538. + PreparedStatement statement = con.prepareStatement("SELECT char_name, race, base_class, classid, sex, face, hairStyle, hairColor, clanid FROM characters WHERE obj_Id = ?"))
  539. + {
  540. + statement.setInt(1, objectId);
  541. +
  542. + try (ResultSet rs = statement.executeQuery())
  543. + {
  544. + if (rs.next())
  545. + {
  546. + final CharSelectSlot charInfo = new CharSelectSlot(objectId, rs.getString("char_name"));
  547. + charInfo.setRace(rs.getInt("race"));
  548. + charInfo.setBaseClassId(rs.getInt("base_class"));
  549. + charInfo.setClassId(rs.getInt("classid"));
  550. + charInfo.setSex(rs.getInt("sex"));
  551. + charInfo.setFace(rs.getInt("face"));
  552. + charInfo.setHairStyle(rs.getInt("hairStyle"));
  553. + charInfo.setHairColor(rs.getInt("hairColor"));
  554. + charInfo.setClanId(rs.getInt("clanid"));
  555. +
  556. + // Get the augmentation id for equipped weapon
  557. + int weaponObjId = charInfo.getPaperdollObjectId(Paperdoll.RHAND);
  558. + if (weaponObjId > 0)
  559. + {
  560. + try (PreparedStatement statementAugment = con.prepareStatement("SELECT attributes FROM augmentations WHERE item_oid = ?"))
  561. + {
  562. + statementAugment.setInt(1, weaponObjId);
  563. + try (ResultSet rsAugment = statementAugment.executeQuery())
  564. + {
  565. + if (rsAugment.next())
  566. + {
  567. + int augment = rsAugment.getInt("attributes");
  568. + charInfo.setAugmentationId(augment == -1 ? 0 : augment);
  569. + }
  570. + }
  571. + }
  572. + }
  573. +
  574. + return charInfo;
  575. + }
  576. + }
  577. + }
  578. + catch (Exception e)
  579. + {
  580. + _log.log(Level.WARNING, "Could not Load characters killing snapshot: " + e.getMessage(), e);
  581. + }
  582. +
  583. + return null;
  584. + }
  585. +}
  586. \ No newline at end of file
  587. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2TopPKMonumentInstance.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2TopPKMonumentInstance.java
  588. new file mode 100644
  589. index 0000000..6a6c21b
  590. --- /dev/null
  591. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2TopPKMonumentInstance.java
  592. @@ -0,0 +1,51 @@
  593. +/*
  594. + * This program is free software: you can redistribute it and/or modify it under
  595. + * the terms of the GNU General Public License as published by the Free Software
  596. + * Foundation, either version 3 of the License, or (at your option) any later
  597. + * version.
  598. + *
  599. + * This program is distributed in the hope that it will be useful, but WITHOUT
  600. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  601. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  602. + * details.
  603. + *
  604. + * You should have received a copy of the GNU General Public License along with
  605. + * this program. If not, see <http://www.gnu.org/licenses/>.
  606. + */
  607. +package net.sf.l2j.gameserver.model.actor.instance;
  608. +
  609. +import net.sf.l2j.Config;
  610. +import net.sf.l2j.gameserver.data.manager.CharacterKillingManager;
  611. +import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
  612. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  613. +
  614. +/**
  615. + * @author paytaly
  616. + */
  617. +public class L2TopPKMonumentInstance extends L2PcPolymorph
  618. +{
  619. + public L2TopPKMonumentInstance(int objectId, NpcTemplate template)
  620. + {
  621. + super(objectId, template);
  622. + }
  623. +
  624. + @Override
  625. + public void onSpawn()
  626. + {
  627. + super.onSpawn();
  628. + if (Config.CKM_ENABLED)
  629. + {
  630. + CharacterKillingManager.getInstance().addPKMorphListener(this);
  631. + }
  632. + }
  633. +
  634. + @Override
  635. + public void deleteMe()
  636. + {
  637. + super.deleteMe();
  638. + if (Config.CKM_ENABLED)
  639. + {
  640. + CharacterKillingManager.getInstance().removePKMorphListener(this);
  641. + }
  642. + }
  643. +}
  644. \ No newline at end of file
  645. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2TopPvPMonumentInstance.java b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2TopPvPMonumentInstance.java
  646. new file mode 100644
  647. index 0000000..6235ee7
  648. --- /dev/null
  649. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2TopPvPMonumentInstance.java
  650. @@ -0,0 +1,51 @@
  651. +/*
  652. + * This program is free software: you can redistribute it and/or modify it under
  653. + * the terms of the GNU General Public License as published by the Free Software
  654. + * Foundation, either version 3 of the License, or (at your option) any later
  655. + * version.
  656. + *
  657. + * This program is distributed in the hope that it will be useful, but WITHOUT
  658. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  659. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  660. + * details.
  661. + *
  662. + * You should have received a copy of the GNU General Public License along with
  663. + * this program. If not, see <http://www.gnu.org/licenses/>.
  664. + */
  665. +package net.sf.l2j.gameserver.model.actor.instance;
  666. +
  667. +import net.sf.l2j.Config;
  668. +import net.sf.l2j.gameserver.data.manager.CharacterKillingManager;
  669. +import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
  670. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  671. +
  672. +/**
  673. + * @author paytaly
  674. + */
  675. +public class L2TopPvPMonumentInstance extends L2PcPolymorph
  676. +{
  677. + public L2TopPvPMonumentInstance(int objectId, NpcTemplate template)
  678. + {
  679. + super(objectId, template);
  680. + }
  681. +
  682. + @Override
  683. + public void onSpawn()
  684. + {
  685. + super.onSpawn();
  686. + if (Config.CKM_ENABLED)
  687. + {
  688. + CharacterKillingManager.getInstance().addPvPMorphListener(this);
  689. + }
  690. + }
  691. +
  692. + @Override
  693. + public void deleteMe()
  694. + {
  695. + super.deleteMe();
  696. + if (Config.CKM_ENABLED)
  697. + {
  698. + CharacterKillingManager.getInstance().removePvPMorphListener(this);
  699. + }
  700. + }
  701. +}
  702. \ No newline at end of file
  703. diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/NpcInfoPolymorph.java b/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/NpcInfoPolymorph.java
  704. new file mode 100644
  705. index 0000000..1322c34
  706. --- /dev/null
  707. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/NpcInfoPolymorph.java
  708. @@ -0,0 +1,203 @@
  709. +/*
  710. + * This program is free software: you can redistribute it and/or modify it under
  711. + * the terms of the GNU General Public License as published by the Free Software
  712. + * Foundation, either version 3 of the License, or (at your option) any later
  713. + * version.
  714. + *
  715. + * This program is distributed in the hope that it will be useful, but WITHOUT
  716. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  717. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  718. + * details.
  719. + *
  720. + * You should have received a copy of the GNU General Public License along with
  721. + * this program. If not, see <http://www.gnu.org/licenses/>.
  722. + */
  723. +package net.sf.l2j.gameserver.network.serverpackets;
  724. +
  725. +import net.sf.l2j.gameserver.data.sql.ClanTable;
  726. +import net.sf.l2j.gameserver.data.xml.PlayerData;
  727. +import net.sf.l2j.gameserver.enums.Paperdoll;
  728. +import net.sf.l2j.gameserver.model.CharSelectSlot;
  729. +import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
  730. +import net.sf.l2j.gameserver.model.actor.template.PlayerTemplate;
  731. +import net.sf.l2j.gameserver.model.pledge.Clan;
  732. +
  733. +/**
  734. + * @author paytaly
  735. + */
  736. +public final class NpcInfoPolymorph extends L2GameServerPacket
  737. +{
  738. + private final L2PcPolymorph _activeChar;
  739. + private final CharSelectSlot _morph;
  740. + private final PlayerTemplate _template;
  741. + private final Clan _clan;
  742. + private final int _x, _y, _z, _heading;
  743. + private final int _mAtkSpd, _pAtkSpd;
  744. + private final int _runSpd, _walkSpd;
  745. + private final float _moveMultiplier;
  746. +
  747. + public NpcInfoPolymorph(L2PcPolymorph cha)
  748. + {
  749. + _activeChar = cha;
  750. + _morph = cha.getPolymorphInfo();
  751. + _template = PlayerData.getInstance().getTemplate(_morph.getBaseClassId());
  752. + _clan = ClanTable.getInstance().getClan(_morph.getClanId());
  753. +
  754. + _x = _activeChar.getX();
  755. + _y = _activeChar.getY();
  756. + _z = _activeChar.getZ();
  757. + _heading = _activeChar.getHeading();
  758. +
  759. + _mAtkSpd = _activeChar.getStatus().getMAtkSpd();
  760. + _pAtkSpd = _activeChar.getStatus().getPAtkSpd();
  761. +
  762. + _moveMultiplier = _activeChar.getStatus().getMovementSpeedMultiplier();
  763. + _runSpd = (int) (_activeChar.getStatus().getMoveSpeed() / _moveMultiplier);
  764. + _walkSpd = (int) (_activeChar.getStatus().getBaseWalkSpeed() / _moveMultiplier);
  765. + }
  766. +
  767. + @Override
  768. + protected final void writeImpl()
  769. + {
  770. + writeC(0x03);
  771. + writeD(_x);
  772. + writeD(_y);
  773. + writeD(_z);
  774. + writeD(_heading);
  775. + writeD(_activeChar.getObjectId());
  776. + writeS(_morph.getName());
  777. + writeD(_morph.getRace());
  778. + writeD(_morph.getSex());
  779. +
  780. + writeD(_morph.getBaseClassId());
  781. +
  782. + writeD(_morph.getPaperdollItemId(Paperdoll.HAIRALL));
  783. + writeD(_morph.getPaperdollItemId(Paperdoll.HEAD));
  784. + writeD(_morph.getPaperdollItemId(Paperdoll.RHAND));
  785. + writeD(_morph.getPaperdollItemId(Paperdoll.LHAND));
  786. + writeD(_morph.getPaperdollItemId(Paperdoll.GLOVES));
  787. + writeD(_morph.getPaperdollItemId(Paperdoll.CHEST));
  788. + writeD(_morph.getPaperdollItemId(Paperdoll.LEGS));
  789. + writeD(_morph.getPaperdollItemId(Paperdoll.FEET));
  790. + writeD(_morph.getPaperdollItemId(Paperdoll.CLOAK));
  791. + writeD(_morph.getPaperdollItemId(Paperdoll.RHAND));
  792. + writeD(_morph.getPaperdollItemId(Paperdoll.HAIR));
  793. + writeD(_morph.getPaperdollItemId(Paperdoll.FACE));
  794. +
  795. + // c6 new h's
  796. + writeH(0x00);
  797. + writeH(0x00);
  798. + writeH(0x00);
  799. + writeH(0x00);
  800. + writeD(_morph.getAugmentationId());
  801. + writeH(0x00);
  802. + writeH(0x00);
  803. + writeH(0x00);
  804. + writeH(0x00);
  805. + writeH(0x00);
  806. + writeH(0x00);
  807. + writeH(0x00);
  808. + writeH(0x00);
  809. + writeH(0x00);
  810. + writeH(0x00);
  811. + writeH(0x00);
  812. + writeH(0x00);
  813. + writeD(0x00);
  814. + writeH(0x00);
  815. + writeH(0x00);
  816. + writeH(0x00);
  817. + writeH(0x00);
  818. +
  819. + writeD(0);
  820. + writeD(0);
  821. +
  822. + writeD(_mAtkSpd);
  823. + writeD(_pAtkSpd);
  824. +
  825. + writeD(0);
  826. + writeD(0);
  827. +
  828. + writeD(_runSpd);
  829. + writeD(_walkSpd);
  830. + writeD(_runSpd); // swim run speed
  831. + writeD(_walkSpd); // swim walk speed
  832. + writeD(_runSpd); // fl run speed
  833. + writeD(_walkSpd); // fl walk speed
  834. + writeD(_runSpd); // fly run speed
  835. + writeD(_walkSpd); // fly walk speed
  836. + writeF(_activeChar.getStatus().getMovementSpeedMultiplier());
  837. + writeF(_activeChar.getStatus().getAttackSpeedMultiplier());
  838. +
  839. + writeF(_template.getCollisionRadius());
  840. + writeF(_template.getCollisionHeight());
  841. +
  842. + writeD(_morph.getHairStyle());
  843. + writeD(_morph.getHairColor());
  844. + writeD(_morph.getFace());
  845. +
  846. + writeS(_activeChar.getVisibleTitle());
  847. +
  848. + if (_clan != null)
  849. + {
  850. + writeD(_clan.getClanId());
  851. + writeD(_clan.getCrestId());
  852. + writeD(_clan.getAllyId());
  853. + writeD(_clan.getAllyCrestId());
  854. + }
  855. + else
  856. + {
  857. + writeD(0);
  858. + writeD(0);
  859. + writeD(0);
  860. + writeD(0);
  861. + }
  862. +
  863. + writeD(0);
  864. +
  865. + writeC(1); // standing = 1 sitting = 0
  866. + writeC(_activeChar.isRunning() ? 1 : 0); // running = 1 walking = 0
  867. + writeC(_activeChar.isInCombat() ? 1 : 0);
  868. + writeC(_activeChar.isAlikeDead() ? 1 : 0);
  869. +
  870. + writeC(0); // invisible = 1 visible =0
  871. +
  872. + writeC(0); // 1 on strider 2 on wyvern 0 no mount
  873. + writeC(0); // 1 - sellshop
  874. +
  875. + writeH(0);
  876. +
  877. + writeC(0);
  878. +
  879. + writeD(_activeChar.getAbnormalEffect());
  880. +
  881. + writeC(0);
  882. + writeH(0); // Blue value for name (0 = white, 255 = pure blue)
  883. + writeD(_morph.getClassId());
  884. +
  885. + writeD(_activeChar.getStatus().getMaxCp());
  886. + writeD((int) _activeChar.getStatus().getMaxCp());
  887. + writeC((_morph.getEnchantEffect() > 127) ? 127 : _morph.getEnchantEffect());
  888. +
  889. + writeC(0x00); // team circle around feet 1= Blue, 2 = red
  890. +
  891. + writeD(_clan != null ? _clan.getCrestLargeId() : 0);
  892. + writeC(0); // Symbol on char menu ctrl+I
  893. + writeC(0); // Hero Aura
  894. +
  895. + writeC(0); // 0x01: Fishing Mode (Cant be undone by setting back to 0)
  896. + writeD(0);
  897. + writeD(0);
  898. + writeD(0);
  899. +
  900. + writeD(_activeChar.getNameColor());
  901. +
  902. + writeD(0x00); // isRunning() as in UserInfo?
  903. +
  904. + writeD(0);
  905. + writeD(0);
  906. +
  907. + writeD(_activeChar.getTitleColor());
  908. +
  909. + writeD(0x00);
  910. + }
  911. +}
  912. \ No newline at end of file
  913.  
Advertisement
Add Comment
Please, Sign In to add comment