Guest User

Untitled

a guest
Dec 6th, 2022
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.29 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..a7ea576
  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. 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
  388. new file mode 100644
  389. index 0000000..6340ac5
  390. --- /dev/null
  391. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/L2PcPolymorph.java
  392. @@ -0,0 +1,188 @@
  393. +/*
  394. + * This program is free software: you can redistribute it and/or modify it under
  395. + * the terms of the GNU General Public License as published by the Free Software
  396. + * Foundation, either version 3 of the License, or (at your option) any later
  397. + * version.
  398. + *
  399. + * This program is distributed in the hope that it will be useful, but WITHOUT
  400. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  401. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  402. + * details.
  403. + *
  404. + * You should have received a copy of the GNU General Public License along with
  405. + * this program. If not, see <http://www.gnu.org/licenses/>.
  406. + */
  407. +package net.sf.l2j.gameserver.model.actor;
  408. +
  409. +import java.sql.Connection;
  410. +import java.sql.PreparedStatement;
  411. +import java.sql.ResultSet;
  412. +
  413. +import net.sf.l2j.commons.pool.ConnectionPool;
  414. +import net.sf.l2j.gameserver.enums.Paperdoll;
  415. +import net.sf.l2j.gameserver.model.CharSelectSlot;
  416. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  417. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  418. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  419. +import net.sf.l2j.gameserver.network.serverpackets.NpcInfoPolymorph;
  420. +
  421. +/**
  422. + * @author paytaly
  423. + */
  424. +public class L2PcPolymorph extends Npc
  425. +{
  426. + private CharSelectSlot _polymorphInfo;
  427. + private int _nameColor = 0xFFFFFF;
  428. + private int _titleColor = 0xFFFF77;
  429. + private String _visibleTitle = "";
  430. +
  431. + public L2PcPolymorph(int objectId, NpcTemplate template)
  432. + {
  433. + super(objectId, template);
  434. + setInvul(true);
  435. + }
  436. +
  437. + @Override
  438. + public boolean hasRandomAnimation()
  439. + {
  440. + return false;
  441. + }
  442. +
  443. + public CharSelectSlot getPolymorphInfo()
  444. + {
  445. + return _polymorphInfo;
  446. + }
  447. +
  448. + public void setPolymorphInfo(CharSelectSlot polymorphInfo)
  449. + {
  450. + _polymorphInfo = polymorphInfo;
  451. +
  452. + for (Object object : getKnownTypeInRadius(Player.class, 2000))
  453. + {
  454. + if (object instanceof Player)
  455. + {
  456. + sendInfo(((Player) object).getActingPlayer());
  457. + }
  458. + }
  459. + }
  460. +
  461. + public int getNameColor()
  462. + {
  463. + return _nameColor;
  464. + }
  465. +
  466. + public void setNameColor(int nameColor)
  467. + {
  468. + _nameColor = nameColor;
  469. + }
  470. +
  471. + public int getTitleColor()
  472. + {
  473. + return _titleColor;
  474. + }
  475. +
  476. + public void setTitleColor(int titleColor)
  477. + {
  478. + _titleColor = titleColor;
  479. + }
  480. +
  481. + public String getVisibleTitle()
  482. + {
  483. + return _visibleTitle;
  484. + }
  485. +
  486. + public void setVisibleTitle(String title)
  487. + {
  488. + _visibleTitle = title == null ? "" : title;
  489. + }
  490. +
  491. + @Override
  492. + public void sendInfo(Player activeChar)
  493. + {
  494. + if (getPolymorphInfo() == null)
  495. + {
  496. + super.sendInfo(activeChar);
  497. + return;
  498. + }
  499. +
  500. + activeChar.sendPacket(new NpcInfoPolymorph(this));
  501. + }
  502. +
  503. + @Override
  504. + public String getHtmlPath(int npcId, int val)
  505. + {
  506. + String pom = "" + npcId;
  507. + if (val != 0)
  508. + {
  509. + pom += "-" + val;
  510. + }
  511. + return "data/html/polymorph/" + pom + ".htm";
  512. + }
  513. +
  514. + @Override
  515. + public void showChatWindow(Player player, int val)
  516. + {
  517. + String filename = getHtmlPath(getNpcId(), val);
  518. +
  519. + // Send a Server->Client NpcHtmlMessage containing the text of the Npc to the Player
  520. + final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
  521. + html.setFile(filename);
  522. + html.replace("%objectId%", getObjectId());
  523. + html.replace("%ownername%", getPolymorphInfo() != null ? getPolymorphInfo().getName() : "");
  524. + player.sendPacket(html);
  525. +
  526. + // Send a Server->Client ActionFailed to the Player in order to avoid that the client wait another packet
  527. + player.sendPacket(ActionFailed.STATIC_PACKET);
  528. + }
  529. +
  530. + public static CharSelectSlot loadCharInfo(int objectId)
  531. + {
  532. + try (Connection con = ConnectionPool.getConnection();
  533. + PreparedStatement statement = con.prepareStatement("SELECT char_name, race, base_class, classid, sex, face, hairStyle, hairColor, clanid FROM characters WHERE obj_Id = ?"))
  534. + {
  535. + statement.setInt(1, objectId);
  536. +
  537. + try (ResultSet rs = statement.executeQuery())
  538. + {
  539. + if (rs.next())
  540. + {
  541. + final CharSelectSlot charInfo = new CharSelectSlot(objectId, rs.getString("char_name"));
  542. + charInfo.setRace(rs.getInt("race"));
  543. + charInfo.setBaseClassId(rs.getInt("base_class"));
  544. + charInfo.setClassId(rs.getInt("classid"));
  545. + charInfo.setSex(rs.getInt("sex"));
  546. + charInfo.setFace(rs.getInt("face"));
  547. + charInfo.setHairStyle(rs.getInt("hairStyle"));
  548. + charInfo.setHairColor(rs.getInt("hairColor"));
  549. + charInfo.setClanId(rs.getInt("clanid"));
  550. +
  551. + // Get the augmentation id for equipped weapon
  552. + int weaponObjId = charInfo.getPaperdollObjectId(Paperdoll.RHAND);
  553. + if (weaponObjId > 0)
  554. + {
  555. + try (PreparedStatement statementAugment = con.prepareStatement("SELECT attributes FROM augmentations WHERE item_id = ?"))
  556. + {
  557. + statementAugment.setInt(1, weaponObjId);
  558. + try (ResultSet rsAugment = statementAugment.executeQuery())
  559. + {
  560. + if (rsAugment.next())
  561. + {
  562. + int augment = rsAugment.getInt("attributes");
  563. + charInfo.setAugmentationId(augment == -1 ? 0 : augment);
  564. + }
  565. + }
  566. + }
  567. + }
  568. +
  569. + return charInfo;
  570. + }
  571. + }
  572. + }
  573. + catch (Exception e)
  574. + {
  575. +
  576. + }
  577. +
  578. + return null;
  579. + }
  580. +}
  581. \ No newline at end of file
  582. 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
  583. new file mode 100644
  584. index 0000000..6a6c21b
  585. --- /dev/null
  586. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2TopPKMonumentInstance.java
  587. @@ -0,0 +1,51 @@
  588. +/*
  589. + * This program is free software: you can redistribute it and/or modify it under
  590. + * the terms of the GNU General Public License as published by the Free Software
  591. + * Foundation, either version 3 of the License, or (at your option) any later
  592. + * version.
  593. + *
  594. + * This program is distributed in the hope that it will be useful, but WITHOUT
  595. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  596. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  597. + * details.
  598. + *
  599. + * You should have received a copy of the GNU General Public License along with
  600. + * this program. If not, see <http://www.gnu.org/licenses/>.
  601. + */
  602. +package net.sf.l2j.gameserver.model.actor.instance;
  603. +
  604. +import net.sf.l2j.Config;
  605. +import net.sf.l2j.gameserver.data.manager.CharacterKillingManager;
  606. +import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
  607. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  608. +
  609. +/**
  610. + * @author paytaly
  611. + */
  612. +public class L2TopPKMonumentInstance extends L2PcPolymorph
  613. +{
  614. + public L2TopPKMonumentInstance(int objectId, NpcTemplate template)
  615. + {
  616. + super(objectId, template);
  617. + }
  618. +
  619. + @Override
  620. + public void onSpawn()
  621. + {
  622. + super.onSpawn();
  623. + if (Config.CKM_ENABLED)
  624. + {
  625. + CharacterKillingManager.getInstance().addPKMorphListener(this);
  626. + }
  627. + }
  628. +
  629. + @Override
  630. + public void deleteMe()
  631. + {
  632. + super.deleteMe();
  633. + if (Config.CKM_ENABLED)
  634. + {
  635. + CharacterKillingManager.getInstance().removePKMorphListener(this);
  636. + }
  637. + }
  638. +}
  639. \ No newline at end of file
  640. 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
  641. new file mode 100644
  642. index 0000000..6235ee7
  643. --- /dev/null
  644. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/instance/L2TopPvPMonumentInstance.java
  645. @@ -0,0 +1,51 @@
  646. +/*
  647. + * This program is free software: you can redistribute it and/or modify it under
  648. + * the terms of the GNU General Public License as published by the Free Software
  649. + * Foundation, either version 3 of the License, or (at your option) any later
  650. + * version.
  651. + *
  652. + * This program is distributed in the hope that it will be useful, but WITHOUT
  653. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  654. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  655. + * details.
  656. + *
  657. + * You should have received a copy of the GNU General Public License along with
  658. + * this program. If not, see <http://www.gnu.org/licenses/>.
  659. + */
  660. +package net.sf.l2j.gameserver.model.actor.instance;
  661. +
  662. +import net.sf.l2j.Config;
  663. +import net.sf.l2j.gameserver.data.manager.CharacterKillingManager;
  664. +import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
  665. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  666. +
  667. +/**
  668. + * @author paytaly
  669. + */
  670. +public class L2TopPvPMonumentInstance extends L2PcPolymorph
  671. +{
  672. + public L2TopPvPMonumentInstance(int objectId, NpcTemplate template)
  673. + {
  674. + super(objectId, template);
  675. + }
  676. +
  677. + @Override
  678. + public void onSpawn()
  679. + {
  680. + super.onSpawn();
  681. + if (Config.CKM_ENABLED)
  682. + {
  683. + CharacterKillingManager.getInstance().addPvPMorphListener(this);
  684. + }
  685. + }
  686. +
  687. + @Override
  688. + public void deleteMe()
  689. + {
  690. + super.deleteMe();
  691. + if (Config.CKM_ENABLED)
  692. + {
  693. + CharacterKillingManager.getInstance().removePvPMorphListener(this);
  694. + }
  695. + }
  696. +}
  697. \ No newline at end of file
  698. 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
  699. new file mode 100644
  700. index 0000000..f447334
  701. --- /dev/null
  702. +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/network/serverpackets/NpcInfoPolymorph.java
  703. @@ -0,0 +1,203 @@
  704. +/*
  705. + * This program is free software: you can redistribute it and/or modify it under
  706. + * the terms of the GNU General Public License as published by the Free Software
  707. + * Foundation, either version 3 of the License, or (at your option) any later
  708. + * version.
  709. + *
  710. + * This program is distributed in the hope that it will be useful, but WITHOUT
  711. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  712. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  713. + * details.
  714. + *
  715. + * You should have received a copy of the GNU General Public License along with
  716. + * this program. If not, see <http://www.gnu.org/licenses/>.
  717. + */
  718. +package net.sf.l2j.gameserver.network.serverpackets;
  719. +
  720. +import net.sf.l2j.gameserver.data.sql.ClanTable;
  721. +import net.sf.l2j.gameserver.data.xml.PlayerData;
  722. +import net.sf.l2j.gameserver.enums.Paperdoll;
  723. +import net.sf.l2j.gameserver.model.CharSelectSlot;
  724. +import net.sf.l2j.gameserver.model.actor.L2PcPolymorph;
  725. +import net.sf.l2j.gameserver.model.actor.template.PlayerTemplate;
  726. +import net.sf.l2j.gameserver.model.pledge.Clan;
  727. +
  728. +/**
  729. + * @author paytaly
  730. + */
  731. +public final class NpcInfoPolymorph extends L2GameServerPacket
  732. +{
  733. + private final L2PcPolymorph _activeChar;
  734. + private final CharSelectSlot _morph;
  735. + private final PlayerTemplate _template;
  736. + private final Clan _clan;
  737. + private final int _x, _y, _z, _heading;
  738. + private final int _mAtkSpd, _pAtkSpd;
  739. + private final int _runSpd, _walkSpd;
  740. + private final float _moveMultiplier;
  741. +
  742. + public NpcInfoPolymorph(L2PcPolymorph cha)
  743. + {
  744. + _activeChar = cha;
  745. + _morph = cha.getPolymorphInfo();
  746. + _template = PlayerData.getInstance().getTemplate(_morph.getBaseClassId());
  747. + _clan = ClanTable.getInstance().getClan(_morph.getClanId());
  748. +
  749. + _x = _activeChar.getX();
  750. + _y = _activeChar.getY();
  751. + _z = _activeChar.getZ();
  752. + _heading = _activeChar.getHeading();
  753. +
  754. + _mAtkSpd = _activeChar.getStatus().getMAtkSpd();
  755. + _pAtkSpd = _activeChar.getStatus().getPAtkSpd();
  756. +
  757. + _moveMultiplier = _activeChar.getStatus().getMovementSpeedMultiplier();
  758. + _runSpd = (int) (_activeChar.getStatus().getMoveSpeed() / _moveMultiplier);
  759. + _walkSpd = (int) (_activeChar.getStatus().getBaseWalkSpeed() / _moveMultiplier);
  760. + }
  761. +
  762. + @Override
  763. + protected final void writeImpl()
  764. + {
  765. + writeC(0x03);
  766. + writeD(_x);
  767. + writeD(_y);
  768. + writeD(_z);
  769. + writeD(_heading);
  770. + writeD(_activeChar.getObjectId());
  771. + writeS(_morph.getName());
  772. + writeD(_morph.getRace());
  773. + writeD(_morph.getSex());
  774. +
  775. + writeD(_morph.getBaseClassId());
  776. +
  777. + writeD(_morph.getPaperdollObjectId(Paperdoll.HAIRALL));
  778. + writeD(_morph.getPaperdollObjectId(Paperdoll.HEAD));
  779. + writeD(_morph.getPaperdollObjectId(Paperdoll.RHAND));
  780. + writeD(_morph.getPaperdollObjectId(Paperdoll.LHAND));
  781. + writeD(_morph.getPaperdollObjectId(Paperdoll.GLOVES));
  782. + writeD(_morph.getPaperdollObjectId(Paperdoll.CHEST));
  783. + writeD(_morph.getPaperdollObjectId(Paperdoll.LEGS));
  784. + writeD(_morph.getPaperdollObjectId(Paperdoll.FEET));
  785. + writeD(_morph.getPaperdollObjectId(Paperdoll.CLOAK));
  786. + writeD(_morph.getPaperdollObjectId(Paperdoll.RHAND));
  787. + writeD(_morph.getPaperdollObjectId(Paperdoll.HAIR));
  788. + writeD(_morph.getPaperdollObjectId(Paperdoll.FACE));
  789. +
  790. + // c6 new h's
  791. + writeH(0x00);
  792. + writeH(0x00);
  793. + writeH(0x00);
  794. + writeH(0x00);
  795. + writeD(_morph.getAugmentationId());
  796. + writeH(0x00);
  797. + writeH(0x00);
  798. + writeH(0x00);
  799. + writeH(0x00);
  800. + writeH(0x00);
  801. + writeH(0x00);
  802. + writeH(0x00);
  803. + writeH(0x00);
  804. + writeH(0x00);
  805. + writeH(0x00);
  806. + writeH(0x00);
  807. + writeH(0x00);
  808. + writeD(0x00);
  809. + writeH(0x00);
  810. + writeH(0x00);
  811. + writeH(0x00);
  812. + writeH(0x00);
  813. +
  814. + writeD(0);
  815. + writeD(0);
  816. +
  817. + writeD(_mAtkSpd);
  818. + writeD(_pAtkSpd);
  819. +
  820. + writeD(0);
  821. + writeD(0);
  822. +
  823. + writeD(_runSpd);
  824. + writeD(_walkSpd);
  825. + writeD(_runSpd); // swim run speed
  826. + writeD(_walkSpd); // swim walk speed
  827. + writeD(_runSpd); // fl run speed
  828. + writeD(_walkSpd); // fl walk speed
  829. + writeD(_runSpd); // fly run speed
  830. + writeD(_walkSpd); // fly walk speed
  831. + writeF(_activeChar.getStatus().getMovementSpeedMultiplier());
  832. + writeF(_activeChar.getStatus().getAttackSpeedMultiplier());
  833. +
  834. + writeF(_template.getCollisionRadius());
  835. + writeF(_template.getCollisionHeight());
  836. +
  837. + writeD(_morph.getHairStyle());
  838. + writeD(_morph.getHairColor());
  839. + writeD(_morph.getFace());
  840. +
  841. + writeS(_activeChar.getVisibleTitle());
  842. +
  843. + if (_clan != null)
  844. + {
  845. + writeD(_clan.getClanId());
  846. + writeD(_clan.getCrestId());
  847. + writeD(_clan.getAllyId());
  848. + writeD(_clan.getAllyCrestId());
  849. + }
  850. + else
  851. + {
  852. + writeD(0);
  853. + writeD(0);
  854. + writeD(0);
  855. + writeD(0);
  856. + }
  857. +
  858. + writeD(0);
  859. +
  860. + writeC(1); // standing = 1 sitting = 0
  861. + writeC(_activeChar.isRunning() ? 1 : 0); // running = 1 walking = 0
  862. + writeC(_activeChar.isInCombat() ? 1 : 0);
  863. + writeC(_activeChar.isAlikeDead() ? 1 : 0);
  864. +
  865. + writeC(0); // invisible = 1 visible =0
  866. +
  867. + writeC(0); // 1 on strider 2 on wyvern 0 no mount
  868. + writeC(0); // 1 - sellshop
  869. +
  870. + writeH(0);
  871. +
  872. + writeC(0);
  873. +
  874. + writeD(_activeChar.getAbnormalEffect());
  875. +
  876. + writeC(0);
  877. + writeH(0); // Blue value for name (0 = white, 255 = pure blue)
  878. + writeD(_morph.getClassId());
  879. +
  880. + writeD(_activeChar.getStatus().getMaxCp());
  881. + writeD((int) _activeChar.getStatus().getMaxCp());
  882. + writeC((_morph.getEnchantEffect() > 127) ? 127 : _morph.getEnchantEffect());
  883. +
  884. + writeC(0x00); // team circle around feet 1= Blue, 2 = red
  885. +
  886. + writeD(_clan != null ? _clan.getCrestLargeId() : 0);
  887. + writeC(0); // Symbol on char menu ctrl+I
  888. + writeC(0); // Hero Aura
  889. +
  890. + writeC(0); // 0x01: Fishing Mode (Cant be undone by setting back to 0)
  891. + writeD(0);
  892. + writeD(0);
  893. + writeD(0);
  894. +
  895. + writeD(_activeChar.getNameColor());
  896. +
  897. + writeD(0x00); // isRunning() as in UserInfo?
  898. +
  899. + writeD(0);
  900. + writeD(0);
  901. +
  902. + writeD(_activeChar.getTitleColor());
  903. +
  904. + writeD(0x00);
  905. + }
  906. +}
  907. \ No newline at end of file
  908.  
Advertisement
Add Comment
Please, Sign In to add comment