Advertisement
Guest User

Religion CORE

a guest
Apr 21st, 2011
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.41 KB | None | 0 0
  1. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2ReligionManagerInstance.java
  2. ===================================================================
  3. --- java/net/sf/l2j/gameserver/model/actor/instance/L2ReligionManagerInstance.java (revision 0)
  4. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2ReligionManagerInstance.java (revision 0)
  5. @@ -0,0 +1,82 @@
  6. +/* This program is free software; you can redistribute it and/or modify
  7. + * it under the terms of the GNU General Public License as published by
  8. + * the Free Software Foundation; either version 2, or (at your option)
  9. + * any later version.
  10. + *
  11. + * This program is distributed in the hope that it will be useful,
  12. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. + * GNU General Public License for more details.
  15. + *
  16. + * You should have received a copy of the GNU General Public License
  17. + * along with this program; if not, write to the Free Software
  18. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. + * 02111-1307, USA.
  20. + *
  21. + * http://www.gnu.org/copyleft/gpl.html
  22. + */
  23. +package net.sf.l2j.gameserver.model.actor.instance;
  24. +
  25. +import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
  26. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  27. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  28. +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
  29. +/**
  30. + *
  31. + * @author Anarchy
  32. + */
  33. +public class L2ReligionManagerInstance extends L2NpcInstance
  34. +{
  35. + public static String religion1name = "Xristianoi"; // This is nothing, it will be deleted after next update.
  36. + public static String religion2name = "Mousoulmanoi"; // This is nothing, it will be deleted after next update.
  37. + public L2ReligionManagerInstance(int objectId, L2NpcTemplate template)
  38. + {
  39. + super(objectId, template);
  40. + }
  41. +
  42. + @Override
  43. + public void onBypassFeedback(L2PcInstance player, String command)
  44. + {
  45. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  46. + if (command.equals("setReligion1"))
  47. + {
  48. + if (!player.isReligion1() && !player.isReligion2())
  49. + {
  50. + player.setReligion1(true);
  51. + player.sendMessage("You have successfully selected your religion.");
  52. + }
  53. + else
  54. + {
  55. + player.sendMessage("You have already selected your religion.");
  56. + }
  57. + }
  58. + if (command.equals("setReligion2"))
  59. + {
  60. + if (!player.isReligion1() && !player.isReligion2())
  61. + {
  62. + player.setReligion2(true);
  63. + player.sendMessage("You have successfully selected your religion.");
  64. + }
  65. + else
  66. + {
  67. + player.sendMessage("You have already selected your religion.");
  68. + }
  69. + }
  70. + }
  71. +
  72. + @Override
  73. + public String getHtmlPath(int npcId, int val)
  74. + {
  75. + String pom = "";
  76. + if (val == 0)
  77. + {
  78. + pom = "" + npcId;
  79. + }
  80. + else
  81. + {
  82. + pom = npcId + "-" + val;
  83. + }
  84. +
  85. + return "data/html/religion/" + pom + ".htm";
  86. + }
  87. +}
  88. Index: java/net/sf/l2j/gameserver/GameServer.java
  89. ===================================================================
  90. --- java/net/sf/l2j/gameserver/GameServer.java (revision 76)
  91. +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
  92. @@ -167,6 +167,7 @@
  93. GmListTable.getInstance();
  94. RaidBossPointsManager.getInstance();
  95. L2PetDataTable.getInstance().loadPetsData();
  96. + ReligionLeaders.getInstance();
  97.  
  98. printSection("Clans");
  99. ClanTable.getInstance();
  100. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  101. ===================================================================
  102. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 76)
  103. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
  104. @@ -42,8 +42,10 @@
  105. import net.sf.l2j.gameserver.model.L2World;
  106. import net.sf.l2j.gameserver.model.actor.L2Character;
  107. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  108. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.SkillDat;
  109. import net.sf.l2j.gameserver.model.entity.ClanHall;
  110. import net.sf.l2j.gameserver.model.entity.Couple;
  111. +import net.sf.l2j.gameserver.model.entity.ReligionWars;
  112. import net.sf.l2j.gameserver.model.entity.Siege;
  113. import net.sf.l2j.gameserver.model.quest.Quest;
  114. import net.sf.l2j.gameserver.network.SystemMessageId;
  115. @@ -84,7 +86,49 @@
  116. protected void runImpl()
  117. {
  118. L2PcInstance activeChar = getClient().getActiveChar();
  119. -
  120. +
  121. + ReligionWars wars = new ReligionWars();
  122. + if (activeChar.isReligion1())
  123. + {
  124. + wars._religion1players.add(activeChar);
  125. + }
  126. + if (activeChar.isReligion2())
  127. + {
  128. + wars._religion2players.add(activeChar);
  129. + }
  130. + if (!activeChar.isReligion1Leader())
  131. + {
  132. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  133. + activeChar.removeSkill(leaderskill, true);
  134. + }
  135. + if (!activeChar.isReligion2Leader())
  136. + {
  137. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  138. + activeChar.removeSkill(leaderskill, true);
  139. + }
  140. + if (activeChar.isReligion1Leader())
  141. + {
  142. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  143. + activeChar.addSkill(leaderskill, true);
  144. + }
  145. + if (activeChar.isReligion2Leader())
  146. + {
  147. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  148. + activeChar.addSkill(leaderskill, true);
  149. + }
  150. + if (activeChar.isReligion1Leader() || activeChar.isReligion2Leader())
  151. + {
  152. + wars.setLeadersColors();
  153. + }
  154. + if (activeChar.isReligion1())
  155. + {
  156. + activeChar.setTitle("Religion 1");
  157. + }
  158. + if (activeChar.isReligion2())
  159. + {
  160. + activeChar.setTitle("Religion 2");
  161. + }
  162. +
  163. if (activeChar == null)
  164. {
  165. _log.warning("EnterWorld failed! activeChar is null...");
  166. Index: java/net/sf/l2j/gameserver/ReligionLeaders.java
  167. ===================================================================
  168. --- java/net/sf/l2j/gameserver/ReligionLeaders.java (revision 0)
  169. +++ java/net/sf/l2j/gameserver/ReligionLeaders.java (revision 0)
  170. @@ -0,0 +1,56 @@
  171. +/* This program is free software; you can redistribute it and/or modify
  172. + * it under the terms of the GNU General Public License as published by
  173. + * the Free Software Foundation; either version 2, or (at your option)
  174. + * any later version.
  175. + *
  176. + * This program is distributed in the hope that it will be useful,
  177. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  178. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  179. + * GNU General Public License for more details.
  180. + *
  181. + * You should have received a copy of the GNU General Public License
  182. + * along with this program; if not, write to the Free Software
  183. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  184. + * 02111-1307, USA.
  185. + *
  186. + * http://www.gnu.org/copyleft/gpl.html
  187. + */
  188. +package net.sf.l2j.gameserver;
  189. +
  190. +import net.sf.l2j.gameserver.model.entity.ReligionWars;
  191. +
  192. +/**
  193. + *
  194. + * @author Anarchy
  195. + */
  196. +public class ReligionLeaders
  197. +{
  198. +
  199. + public static ReligionLeaders getInstance()
  200. + {
  201. + return SingletonHolder._instance;
  202. + }
  203. +
  204. + private static class SingletonHolder
  205. + {
  206. + protected static final ReligionLeaders _instance = new ReligionLeaders();
  207. + }
  208. +
  209. + private ReligionLeaders()
  210. + {
  211. + ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
  212. + {
  213. + public void run()
  214. + {
  215. + ReligionWars wars = new ReligionWars();
  216. +
  217. + if (wars._religion1players.isEmpty() || wars._religion2players.isEmpty())
  218. + {
  219. + return;
  220. + }
  221. +
  222. + wars.setReligionsLeaders();
  223. + }
  224. + }, 86400000, 86400000); // Every 24 hours.
  225. + }
  226. +}
  227. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  228. ===================================================================
  229. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 76)
  230. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  231. @@ -70,6 +70,7 @@
  232. import net.sf.l2j.gameserver.datatables.SkillTreeTable;
  233. import net.sf.l2j.gameserver.handler.IItemHandler;
  234. import net.sf.l2j.gameserver.handler.ItemHandler;
  235. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminHeal;
  236. import net.sf.l2j.gameserver.instancemanager.CastleManager;
  237. import net.sf.l2j.gameserver.instancemanager.CoupleManager;
  238. import net.sf.l2j.gameserver.instancemanager.CursedWeaponsManager;
  239. @@ -214,6 +215,14 @@
  240. */
  241. public final class L2PcInstance extends L2Playable
  242. {
  243. + // Religions.
  244. + public boolean _religion1 = false;
  245. + public boolean _religion2 = false;
  246. + public boolean _religion1leader = false;
  247. + public boolean _religion2leader = false;
  248. + public boolean _inReligionWar = false;
  249. + public int plgetx = 0, plgety = 0, plgetz = 0;
  250. +
  251. // Character Skill SQL String Definitions:
  252. private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? AND class_index=?";
  253. private static final String ADD_NEW_SKILL = "INSERT INTO character_skills (char_obj_id,skill_id,skill_level,class_index) VALUES (?,?,?,?)";
  254. @@ -228,8 +237,8 @@
  255.  
  256. // Character SQL String Definitions:
  257. private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,obj_Id,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,last_recom_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  258. - private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE obj_id=?";
  259. - private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE obj_id=?";
  260. + private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,religion1=?,religion2=?,religion1leader=?,religion2leader=? WHERE obj_id=?";
  261. + private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,religion1,religion2,religion1leader,religion2leader FROM characters WHERE obj_id=?";
  262.  
  263. // Character Subclass SQL String Definitions:
  264. private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
  265. @@ -4467,6 +4476,24 @@
  266.  
  267. stopWaterTask();
  268.  
  269. + if (_inReligionWar)
  270. + {
  271. + try
  272. + {
  273. + Thread.sleep(1000);
  274. + }
  275. + catch (InterruptedException e)
  276. + { }
  277. + doRevive();
  278. + L2Skill skill = SkillTable.getInstance().getInfo(1323, 1);
  279. + skill.getEffects(this, this);
  280. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  281. + if (isReligion1Leader() || isReligion2Leader())
  282. + {
  283. + leaderskill.getEffects(this, this);
  284. + }
  285. + }
  286. +
  287. if (isPhoenixBlessed())
  288. reviveRequest(this, null, false);
  289. else if (isAffected(CharEffectList.EFFECT_FLAG_CHARM_OF_COURAGE) && this.isInSiege())
  290. @@ -4599,13 +4626,26 @@
  291. if (isInDuel() && targetPlayer.isInDuel()) return;
  292.  
  293. // If in Arena, do nothing
  294. - if (isInsideZone(ZONE_PVP) || targetPlayer.isInsideZone(ZONE_PVP))
  295. + if ((isInsideZone(ZONE_PVP) || targetPlayer.isInsideZone(ZONE_PVP)) && (!_inReligionWar && !targetPlayer._inReligionWar))
  296. return;
  297. +
  298. + if ((isInsideZone(ZONE_PVP) || targetPlayer.isInsideZone(ZONE_PVP) && (_inReligionWar && targetPlayer._inReligionWar)))
  299. + {
  300. + increasePvpKillsBy2();
  301. + return;
  302. + }
  303.  
  304. // Check if it's pvp
  305. if ((checkIfPvP(target) && targetPlayer.getPvpFlag() != 0)
  306. || (isInsideZone(ZONE_PVP) && targetPlayer.isInsideZone(ZONE_PVP)))
  307. + {
  308. + if (_inReligionWar && targetPlayer._inReligionWar)
  309. + {
  310. + increasePvpKillsBy2();
  311. + return;
  312. + }
  313. increasePvpKills();
  314. + }
  315. // Target player doesn't have pvp flag set
  316. else
  317. {
  318. @@ -4617,6 +4657,11 @@
  319. && getPledgeType() != L2Clan.SUBUNIT_ACADEMY)
  320. {
  321. // 'Both way war' -> 'PvP Kill'
  322. + if (_inReligionWar && targetPlayer._inReligionWar)
  323. + {
  324. + increasePvpKillsBy2();
  325. + return;
  326. + }
  327. increasePvpKills();
  328. return;
  329. }
  330. @@ -4625,10 +4670,23 @@
  331. if (targetPlayer.getKarma() > 0)
  332. {
  333. if (Config.KARMA_AWARD_PK_KILL)
  334. + {
  335. + if (_inReligionWar && targetPlayer._inReligionWar)
  336. + {
  337. + increasePvpKillsBy2();
  338. + return;
  339. + }
  340. +
  341. increasePvpKills();
  342. + }
  343. }
  344. - else if (targetPlayer.getPvpFlag() == 0)
  345. + else if (targetPlayer.getPvpFlag() == 0 && (!_inReligionWar && !targetPlayer._inReligionWar))
  346. increasePkKillsAndKarma(targetPlayer.getLevel());
  347. +
  348. + if (targetPlayer.getPvpFlag() == 0 && (_inReligionWar && targetPlayer._inReligionWar))
  349. + {
  350. + increasePvpKillsBy2();
  351. + }
  352. }
  353. }
  354.  
  355. @@ -4636,6 +4694,12 @@
  356. * Increase the pvp kills count and send the info to the player
  357. *
  358. */
  359. + public void increasePvpKillsBy2()
  360. + {
  361. + addItem("Religion Reward", 3470, 1, this, true);
  362. + setPvpKills(getPvpKills() + 2);
  363. + sendPacket(new UserInfo(this));
  364. + }
  365. public void increasePvpKills()
  366. {
  367. // Add karma to attacker and increase its PK counter
  368. @@ -5190,7 +5254,6 @@
  369. public void setClan(L2Clan clan)
  370. {
  371. _clan = clan;
  372. - setTitle("");
  373.  
  374. if (clan == null)
  375. {
  376. @@ -5885,6 +5948,10 @@
  377. player.setOnlineTime(rset.getLong("onlinetime"));
  378. player.setNewbie(rset.getInt("newbie")==1);
  379. player.setNoble(rset.getInt("nobless")==1);
  380. + player.setReligion1(rset.getInt("religion1")==1);
  381. + player.setReligion2(rset.getInt("religion2")==1);
  382. + player.setReligion1Leader(rset.getInt("religion1leader")==1);
  383. + player.setReligion2Leader(rset.getInt("religion2leader")==1);
  384.  
  385. player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
  386. if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
  387. @@ -6352,7 +6419,11 @@
  388. statement.setLong(47, getClanCreateExpiryTime());
  389. statement.setString(48, getName());
  390. statement.setLong(49, getDeathPenaltyBuffLevel());
  391. - statement.setInt(50, getObjectId());
  392. + statement.setInt(50, isReligion1() ? 1 : 0);
  393. + statement.setInt(51, isReligion2() ? 1 : 0);
  394. + statement.setInt(52, isReligion1Leader() ? 1 : 0);
  395. + statement.setInt(53, isReligion2Leader() ? 1 : 0);
  396. + statement.setInt(54, getObjectId());
  397.  
  398. statement.execute();
  399. statement.close();
  400. @@ -11189,4 +11260,45 @@
  401. break;
  402. }*/
  403. }
  404. + public boolean isReligion1()
  405. + {
  406. + return _religion1;
  407. + }
  408. +
  409. + public boolean isReligion2()
  410. + {
  411. + return _religion2;
  412. + }
  413. +
  414. + public void setReligion1(boolean i)
  415. + {
  416. + setTitle("Religion 1");
  417. + _religion1 = i;
  418. + }
  419. +
  420. + public void setReligion2(boolean i)
  421. + {
  422. + setTitle("Religion 2");
  423. + _religion2 = i;
  424. + }
  425. +
  426. + public boolean isReligion1Leader()
  427. + {
  428. + return _religion1leader;
  429. + }
  430. +
  431. + public boolean isReligion2Leader()
  432. + {
  433. + return _religion2leader;
  434. + }
  435. +
  436. + public void setReligion1Leader(boolean i)
  437. + {
  438. + _religion1leader = i;
  439. + }
  440. +
  441. + public void setReligion2Leader(boolean i)
  442. + {
  443. + _religion2leader = i;
  444. + }
  445. }
  446. \ No newline at end of file
  447. Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  448. ===================================================================
  449. --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 76)
  450. +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
  451. @@ -68,6 +68,7 @@
  452. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminTest;
  453. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminUnblockIp;
  454. import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminZone;
  455. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminReligion;
  456.  
  457. public class AdminCommandHandler
  458. {
  459. @@ -131,6 +132,7 @@
  460. registerAdminCommandHandler(new AdminTest());
  461. registerAdminCommandHandler(new AdminUnblockIp());
  462. registerAdminCommandHandler(new AdminZone());
  463. + registerAdminCommandHandler(new AdminReligion());
  464. }
  465.  
  466. public void registerAdminCommandHandler(IAdminCommandHandler handler)
  467. Index: java/net/sf/l2j/gameserver/model/entity/ReligionWars.java
  468. ===================================================================
  469. --- java/net/sf/l2j/gameserver/model/entity/ReligionWars.java (revision 0)
  470. +++ java/net/sf/l2j/gameserver/model/entity/ReligionWars.java (revision 0)
  471. @@ -0,0 +1,220 @@
  472. +/* This program is free software; you can redistribute it and/or modify
  473. + * it under the terms of the GNU General Public License as published by
  474. + * the Free Software Foundation; either version 2, or (at your option)
  475. + * any later version.
  476. + *
  477. + * This program is distributed in the hope that it will be useful,
  478. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  479. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  480. + * GNU General Public License for more details.
  481. + *
  482. + * You should have received a copy of the GNU General Public License
  483. + * along with this program; if not, write to the Free Software
  484. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  485. + * 02111-1307, USA.
  486. + *
  487. + * http://www.gnu.org/copyleft/gpl.html
  488. + */
  489. +package net.sf.l2j.gameserver.model.entity;
  490. +
  491. +import java.util.Vector;
  492. +
  493. +import net.sf.l2j.gameserver.Announcements;
  494. +import net.sf.l2j.gameserver.datatables.SkillTable;
  495. +import net.sf.l2j.gameserver.model.L2Skill;
  496. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  497. +/**
  498. + *
  499. + * @author Anarchy
  500. + */
  501. +public class ReligionWars
  502. +{
  503. + public static Vector<L2PcInstance> _religion1players = new Vector<L2PcInstance>();
  504. + public static Vector<L2PcInstance> _religion2players = new Vector<L2PcInstance>();
  505. + public static boolean _religionWarActive = false;
  506. + public static int rel1x = 149960,
  507. + rel1y = 46759,
  508. + rel1z = -3413,
  509. + rel2x = 148959,
  510. + rel2y = 46752,
  511. + rel2z = -3415,
  512. + toppvps1 = 0,
  513. + toppvps2 = 0;
  514. +
  515. + public void setLeadersColors()
  516. + {
  517. + for (L2PcInstance leader : _religion1players)
  518. + {
  519. + if (leader.isReligion1Leader())
  520. + {
  521. + leader.getAppearance().setNameColor(0x0000FF);
  522. + leader.broadcastUserInfo();
  523. + }
  524. + }
  525. + for (L2PcInstance leader : _religion2players)
  526. + {
  527. + if (leader.isReligion2Leader())
  528. + {
  529. + leader.getAppearance().setNameColor(0xFF0000);
  530. + leader.broadcastUserInfo();
  531. + }
  532. + }
  533. + }
  534. + public void setReligionsLeaders()
  535. + {
  536. + for (L2PcInstance leader : _religion1players)
  537. + {
  538. + if (leader.isReligion1Leader())
  539. + {
  540. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  541. + leader.removeSkill(leaderskill, true);
  542. + toppvps1 = 0;
  543. + leader.setReligion1Leader(false);
  544. + }
  545. + }
  546. + for (L2PcInstance leader : _religion2players)
  547. + {
  548. + if (leader.isReligion2Leader())
  549. + {
  550. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  551. + leader.removeSkill(leaderskill, true);
  552. + toppvps2 = 0;
  553. + leader.setReligion2Leader(false);
  554. + }
  555. + }
  556. + for (L2PcInstance player : _religion1players)
  557. + {
  558. + if (player.getPvpKills() > toppvps1)
  559. + {
  560. + player.setReligion1Leader(true);
  561. + toppvps1 = player.getPvpKills();
  562. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  563. + player.addSkill(leaderskill, true);
  564. + if (!_religionWarActive)
  565. + {
  566. + setLeadersColors();
  567. + }
  568. + player.sendMessage("You are now your religion leader!");
  569. + }
  570. + }
  571. + for (L2PcInstance player : _religion2players)
  572. + {
  573. + if (player.getPvpKills() > toppvps2)
  574. + {
  575. + player.setReligion2Leader(true);
  576. + toppvps2 = player.getPvpKills();
  577. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  578. + player.addSkill(leaderskill, true);
  579. + if (!_religionWarActive)
  580. + {
  581. + setLeadersColors();
  582. + }
  583. + player.sendMessage("You are now your religion leader!");
  584. + }
  585. + }
  586. + }
  587. + public void warningAnnounces()
  588. + {
  589. + Announcements.getInstance().announceToAll("A religion war is starting!");
  590. + Announcements.getInstance().announceToAll("Be prepared, you will be teleported to your base in a while!");
  591. + }
  592. + public void teleportPlayersToBase()
  593. + {
  594. + _religionWarActive = true;
  595. + getPosition();
  596. + for (L2PcInstance player : _religion1players)
  597. + {
  598. + if (!player.isReligion1Leader())
  599. + {
  600. + player.getAppearance().setNameColor(0x0000FF);
  601. + player.broadcastUserInfo();
  602. + }
  603. + player.teleToLocation(rel1x, rel1y, rel1z);
  604. + player.sendMessage("You have been teleported to your base.");
  605. + player._inReligionWar = true;
  606. + L2Skill skill = SkillTable.getInstance().getInfo(1323, 1);
  607. + skill.getEffects(player, player);
  608. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  609. + if (player.isReligion1Leader())
  610. + {
  611. + leaderskill.getEffects(player, player);
  612. + player.getAppearance().setNameColor(0x000000);
  613. + player.broadcastUserInfo();
  614. + }
  615. + }
  616. + for (L2PcInstance player : _religion2players)
  617. + {
  618. + if (!player.isReligion2Leader())
  619. + {
  620. + player.getAppearance().setNameColor(0x0000FF);
  621. + player.broadcastUserInfo();
  622. + }
  623. + player.teleToLocation(rel2x, rel2y, rel2z);
  624. + player.sendMessage("You have been teleported to your base.");
  625. + player._inReligionWar = true;
  626. + L2Skill skill = SkillTable.getInstance().getInfo(1323, 1);
  627. + skill.getEffects(player, player);
  628. + L2Skill leaderskill = SkillTable.getInstance().getInfo(7029, 1);
  629. + if (player.isReligion2Leader())
  630. + {
  631. + leaderskill.getEffects(player, player);
  632. + player.getAppearance().setNameColor(0x000000);
  633. + player.broadcastUserInfo();
  634. + }
  635. + }
  636. + }
  637. + public void getPosition()
  638. + {
  639. + for (L2PcInstance player : _religion1players)
  640. + {
  641. + player.plgetx = player.getX();
  642. + player.plgety = player.getY();
  643. + player.plgetz = player.getZ();
  644. + }
  645. + for (L2PcInstance player : _religion2players)
  646. + {
  647. + player.plgetx = player.getX();
  648. + player.plgety = player.getY();
  649. + player.plgetz = player.getZ();
  650. + }
  651. + }
  652. + public void teleportBack()
  653. + {
  654. + _religionWarActive = false;
  655. + Announcements.getInstance().announceToAll("The war has ended.");
  656. + for (L2PcInstance player : _religion1players)
  657. + {
  658. + player.teleToLocation(player.plgetx, player.plgety, player.plgetz);
  659. + player.sendMessage("You have been teleported back to where you were. The war has ended.");
  660. + if (!player.isReligion1Leader())
  661. + {
  662. + player.getAppearance().setNameColor(0xFFFFFF);
  663. + }
  664. + player.plgetx = 0;
  665. + player.plgety = 0;
  666. + player.plgetz = 0;
  667. + if (player.isReligion1Leader())
  668. + {
  669. + setLeadersColors();
  670. + }
  671. + player._inReligionWar = false;
  672. + }
  673. + for (L2PcInstance player : _religion2players)
  674. + {
  675. + player.teleToLocation(player.plgetx, player.plgety, player.plgetz);
  676. + player.sendMessage("You have been teleported back to where you were. The war has ended.");
  677. + if (!player.isReligion2Leader())
  678. + {
  679. + player.getAppearance().setNameColor(0xFFFFFF);
  680. + }
  681. + player.plgetx = 0;
  682. + player.plgety = 0;
  683. + player.plgetz = 0;
  684. + if (player.isReligion2Leader())
  685. + {
  686. + setLeadersColors();
  687. + }
  688. + player._inReligionWar = false;
  689. + }
  690. + }
  691. +}
  692. Index: java/net/sf/l2j/gameserver/network/clientpackets/Logout.java
  693. ===================================================================
  694. --- java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (revision 76)
  695. +++ java/net/sf/l2j/gameserver/network/clientpackets/Logout.java (working copy)
  696. @@ -25,6 +25,7 @@
  697. import net.sf.l2j.gameserver.SevenSignsFestival;
  698. import net.sf.l2j.gameserver.model.L2Party;
  699. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  700. +import net.sf.l2j.gameserver.model.entity.ReligionWars;
  701. import net.sf.l2j.gameserver.network.SystemMessageId;
  702. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  703. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  704. @@ -49,6 +50,16 @@
  705.  
  706. if (player == null)
  707. return;
  708. +
  709. + ReligionWars wars = new ReligionWars();
  710. + if (player.isReligion1() && wars._religion1players.contains(player));
  711. + {
  712. + wars._religion1players.remove(player);
  713. + }
  714. + if (player.isReligion2() && wars._religion2players.contains(player));
  715. + {
  716. + wars._religion2players.remove(player);
  717. + }
  718.  
  719. player.getInventory().updateDatabase();
  720.  
  721. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReligion.java
  722. ===================================================================
  723. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReligion.java (revision 0)
  724. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReligion.java (revision 0)
  725. @@ -0,0 +1,90 @@
  726. +/* This program is free software; you can redistribute it and/or modify
  727. + * it under the terms of the GNU General Public License as published by
  728. + * the Free Software Foundation; either version 2, or (at your option)
  729. + * any later version.
  730. + *
  731. + * This program is distributed in the hope that it will be useful,
  732. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  733. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  734. + * GNU General Public License for more details.
  735. + *
  736. + * You should have received a copy of the GNU General Public License
  737. + * along with this program; if not, write to the Free Software
  738. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  739. + * 02111-1307, USA.
  740. + *
  741. + * http://www.gnu.org/copyleft/gpl.html
  742. + */
  743. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  744. +
  745. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  746. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  747. +import net.sf.l2j.gameserver.model.entity.ReligionWars;
  748. +
  749. +/**
  750. + *
  751. + * @author Anarchy
  752. + */
  753. +public class AdminReligion implements IAdminCommandHandler
  754. +{
  755. + private final String[] ADMIN_COMMANDS = { "admin_startreligionwar", "admin_stopreligionwar", "admin_warnreligionwar", "admin_setreligionsleaders" };
  756. + public boolean useAdminCommand(String command, L2PcInstance activeChar)
  757. + {
  758. + ReligionWars wars = new ReligionWars();
  759. + if (command.equals("admin_startreligionwar"))
  760. + {
  761. + if (wars._religionWarActive)
  762. + {
  763. + activeChar.sendMessage("You can't run 2 another religion wars at the same time.");
  764. + return false;
  765. + }
  766. + if (wars._religion1players.isEmpty() || wars._religion2players.isEmpty())
  767. + {
  768. + activeChar.sendMessage("There are not enough religion players online.");
  769. + return false;
  770. + }
  771. +
  772. + wars.teleportPlayersToBase();
  773. + return true;
  774. + }
  775. + if (command.equals("admin_stopreligionwar"))
  776. + {
  777. + if (!wars._religionWarActive)
  778. + {
  779. + activeChar.sendMessage("There is not religion war active.");
  780. + return false;
  781. + }
  782. +
  783. + wars.teleportBack();
  784. + return true;
  785. + }
  786. + if (command.equals("admin_warnreligionwar"))
  787. + {
  788. + if (wars._religionWarActive)
  789. + {
  790. + activeChar.sendMessage("You can't warn the players while the war is running.");
  791. + return false;
  792. + }
  793. +
  794. + wars.warningAnnounces();
  795. + return true;
  796. + }
  797. + if (command.equals("admin_setreligionsleaders"))
  798. + {
  799. + if (wars._religion1players.isEmpty() || wars._religion2players.isEmpty())
  800. + {
  801. + activeChar.sendMessage("Cannot set a leader for each religion because there are not enough religion players online.");
  802. + return false;
  803. + }
  804. +
  805. + wars.setReligionsLeaders();
  806. + return true;
  807. + }
  808. +
  809. + return true;
  810. + }
  811. + public String[] getAdminCommandList()
  812. + {
  813. + return ADMIN_COMMANDS;
  814. + }
  815. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement