Guest User

Faction System {Core}

a guest
Aug 25th, 2016
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.39 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 5)
  6. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
  7. @@ -313,8 +313,8 @@
  8. private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
  9.  
  10. 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,nobless,power_grade,last_recom_date) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  11. - private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,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=?,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=?";
  12. - 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, 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=?";
  13. + private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,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=?,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=?,ffaction=?,sfaction=? WHERE obj_id=?";
  14. + 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, 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,ffaction,sfaction FROM characters WHERE obj_id=?";
  15.  
  16. 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";
  17. private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
  18. @@ -446,6 +446,9 @@
  19. private boolean _noble = false;
  20. private boolean _hero = false;
  21.  
  22. + private boolean _isffaction = false;
  23. + private boolean _issfaction = false;
  24. +
  25. private L2Npc _currentFolkNpc = null;
  26.  
  27. private int _questNpcObject = 0;
  28. @@ -4203,6 +4206,34 @@
  29. return;
  30. }
  31.  
  32. + if (Config.FACTION_SYSTEM_ALLOW_REWARD_FOR_EACH_PVP && Config.FACTION_SYSTEM_ENABLE)
  33. + {
  34. + if ((issfaction() && targetPlayer.issfaction()) || (isffaction() && targetPlayer.isffaction()))
  35. + {
  36. + sendMessage("Cannot Get PvP Reward From The Same Faction.");
  37. + sendPacket(ActionFailed.STATIC_PACKET);
  38. + return;
  39. + }
  40. + else
  41. + {
  42. + int itemReward = Config.FACTION_SYSTEM_PVP_ITEM_REWARD_AMOUNT;
  43. + int idReward = Config.FACTION_SYSTEM_PVP_ITEM_REWARD_ID;
  44. + addItem("Loot", idReward, itemReward, this, true);
  45. + sendMessage("You Won " + itemReward + " " + idReward + " From Your Kill.");
  46. + }
  47. + }
  48. + // pvp?
  49. + if (checkIfPvP(target) || (isffaction() && targetPlayer.issfaction()) || (issfaction() && targetPlayer.isffaction()))
  50. + {
  51. + getPvpKills();
  52. + return;
  53. + }
  54. +
  55. + if (targetPlayer.issfaction() || targetPlayer.isffaction())
  56. + {
  57. + return;
  58. + }
  59. +
  60. // If in duel and you kill (only can kill l2summon), do nothing
  61. if (isInDuel() && targetPlayer.isInDuel())
  62. return;
  63. @@ -4237,6 +4268,11 @@
  64. sendPacket(new UserInfo(this));
  65. }
  66. }
  67. +
  68. + if (Config.FACTION_SYSTEM_ENABLE)
  69. + {
  70. + return;
  71. + }
  72. // Otherwise, killer is considered as a PKer.
  73. else if (targetPlayer.getKarma() == 0 && targetPlayer.getPvpFlag() == 0)
  74. {
  75. @@ -4254,6 +4290,10 @@
  76.  
  77. public void updatePvPStatus()
  78. {
  79. + if (!issfaction() || !isffaction())
  80. + {
  81. + return;
  82. + }
  83. if (isInsideZone(ZoneId.PVP))
  84. return;
  85.  
  86. @@ -5493,6 +5533,8 @@
  87. player.setPkKills(rset.getInt("pkkills"));
  88. player.setOnlineTime(rset.getLong("onlinetime"));
  89. player.setNoble(rset.getInt("nobless") == 1, false);
  90. + player.setffaction(rset.getInt("ffaction") == 1 ? true : false);
  91. + player.setsfaction(rset.getInt("sfaction") == 1 ? true : false);
  92.  
  93. player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
  94. if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
  95. @@ -5922,7 +5964,9 @@
  96. statement.setLong(47, getClanCreateExpiryTime());
  97. statement.setString(48, getName());
  98. statement.setLong(49, getDeathPenaltyBuffLevel());
  99. - statement.setInt(50, getObjectId());
  100. + statement.setInt(50, isffaction() ? 1 : 0);
  101. + statement.setInt(51, issfaction() ? 1 : 0);
  102. + statement.setInt(52, getObjectId());
  103.  
  104. statement.execute();
  105. statement.close();
  106. @@ -6612,6 +6656,12 @@
  107. @Override
  108. public boolean isAutoAttackable(L2Character attacker)
  109. {
  110. + if ((attacker instanceof L2PcInstance) && ((L2PcInstance) attacker).isffaction())
  111. + return true;
  112. +
  113. + if ((attacker instanceof L2PcInstance) && ((L2PcInstance) attacker).issfaction())
  114. + return true;
  115. +
  116. // Check if the attacker isn't the L2PcInstance Pet
  117. if (attacker == this || attacker == getPet())
  118. return false;
  119. @@ -6991,7 +7041,7 @@
  120. }
  121.  
  122. // Check if the target is attackable
  123. - if (!target.isAttackable() && !getAccessLevel().allowPeaceAttack())
  124. + if (!target.isAttackable() && !getAccessLevel().allowPeaceAttack() && (Config.FACTION_SYSTEM_ENABLE == false))
  125. {
  126. // If target is not attackable, send ActionFailed
  127. sendPacket(ActionFailed.STATIC_PACKET);
  128. @@ -7270,6 +7320,9 @@
  129. */
  130. public boolean checkPvpSkill(L2Object target, L2Skill skill)
  131. {
  132. + if (issfaction() || isffaction())
  133. + return true;
  134. +
  135. if (skill == null || target == null)
  136. return false;
  137.  
  138. @@ -8272,6 +8325,26 @@
  139. sendPacket(sl);
  140. }
  141.  
  142. + public boolean isffaction()
  143. + {
  144. + return _isffaction;
  145. + }
  146. +
  147. + public boolean issfaction()
  148. + {
  149. + return _issfaction;
  150. + }
  151. +
  152. + public void setffaction(boolean value)
  153. + {
  154. + _isffaction = value;
  155. + }
  156. +
  157. + public void setsfaction(boolean value)
  158. + {
  159. + _issfaction = value;
  160. + }
  161. +
  162. /**
  163. * 1. Add the specified class ID as a subclass (up to the maximum number of <b>three</b>) for this character.<BR>
  164. * 2. This method no longer changes the active _classIndex of the player. This is only done by the calling of setActiveClass() method as that should be the only way to do so.
  165. Index: java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java
  166. ===================================================================
  167. --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (revision 5)
  168. +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/Escape.java (working copy)
  169. @@ -14,6 +14,7 @@
  170. */
  171. package net.sf.l2j.gameserver.handler.usercommandhandlers;
  172.  
  173. +import net.sf.l2j.Config;
  174. import net.sf.l2j.gameserver.datatables.SkillTable;
  175. import net.sf.l2j.gameserver.handler.IUserCommandHandler;
  176. import net.sf.l2j.gameserver.instancemanager.GrandBossManager;
  177. @@ -31,6 +32,15 @@
  178. @Override
  179. public boolean useUserCommand(int id, L2PcInstance activeChar)
  180. {
  181. + if (Config.FACTION_SYSTEM_ENABLE)
  182. + {
  183. + if (activeChar.isffaction() || activeChar.issfaction())
  184. + {
  185. + activeChar.sendMessage("You Cannot Use This Command.");
  186. + return false;
  187. + }
  188. + }
  189. +
  190. if (activeChar.isCastingNow() || activeChar.isSitting() || activeChar.isMovementDisabled() || activeChar.isOutOfControl() || activeChar.isInOlympiadMode() || activeChar.inObserverMode() || activeChar.isFestivalParticipant() || activeChar.isInJail() || GrandBossManager.getInstance().isInBossZone(activeChar))
  191. {
  192. activeChar.sendMessage("Your current state doesn't allow you to use the /unstuck command.");
  193. Index: java/net/sf/l2j/gameserver/model/actor/L2Character.java
  194. ===================================================================
  195. --- java/net/sf/l2j/gameserver/model/actor/L2Character.java (revision 5)
  196. +++ java/net/sf/l2j/gameserver/model/actor/L2Character.java (working copy)
  197. @@ -571,8 +571,21 @@
  198. return;
  199. }
  200.  
  201. + if (((L2PcInstance) this).isffaction() && ((L2PcInstance) target).isffaction() && Config.FACTION_SYSTEM_ENABLE)
  202. + {
  203. + ((L2PcInstance) this).sendMessage("Cant attack a player from your faction");
  204. + sendPacket(ActionFailed.STATIC_PACKET);
  205. + return;
  206. + }
  207. + if (((L2PcInstance) this).issfaction() && ((L2PcInstance) target).issfaction() && Config.FACTION_SYSTEM_ENABLE)
  208. + {
  209. + ((L2PcInstance) this).sendMessage("Cant attack a player from your faction");
  210. + sendPacket(ActionFailed.STATIC_PACKET);
  211. + return;
  212. + }
  213. +
  214. // Checking if target has moved to peace zone
  215. - if (isInsidePeaceZone(this, target))
  216. + if (isInsidePeaceZone(this, target) && !Config.FACTION_SYSTEM_ENABLE)
  217. {
  218. getAI().setIntention(CtrlIntention.ACTIVE);
  219. sendPacket(ActionFailed.STATIC_PACKET);
  220. @@ -1091,6 +1104,30 @@
  221.  
  222. boolean doit = false;
  223.  
  224. + if ((target instanceof L2PcInstance) && (this instanceof L2PcInstance))
  225. + {
  226. + if (((L2PcInstance) this).isffaction() && (((L2PcInstance) target).isffaction() && Config.FACTION_SYSTEM_ENABLE))
  227. + {
  228. + ((L2PcInstance) this).sendMessage("You Cannot Attack a Player From Your Faction!");
  229. + sendPacket(ActionFailed.STATIC_PACKET);
  230. + return;
  231. + }
  232. + else if (((L2PcInstance) this).isffaction() && ((((L2PcInstance) target).isffaction() && Config.FACTION_SYSTEM_ENABLE && (skill.getSkillType() == L2SkillType.BUFF)) || (skill.getSkillType() == L2SkillType.HOT) || (skill.getSkillType() == L2SkillType.HEAL) || (skill.getSkillType() == L2SkillType.COMBATPOINTHEAL) || (skill.getSkillType() == L2SkillType.HEAL_PERCENT) || (skill.getSkillType() == L2SkillType.MANAHEAL) || (skill.getSkillType() == L2SkillType.MANAHEAL_PERCENT) || (skill.getSkillType() == L2SkillType.BALANCE_LIFE) || (skill.getSkillType() == L2SkillType.CONT)))
  233. + {
  234. + return;
  235. + }
  236. + if (((L2PcInstance) this).issfaction() && ((L2PcInstance) target).issfaction())
  237. + {
  238. + ((L2PcInstance) this).sendMessage("You Cannot Attack a Player From Your Faction!");
  239. + sendPacket(ActionFailed.STATIC_PACKET);
  240. + return;
  241. + }
  242. + else if (((L2PcInstance) this).issfaction() && ((((L2PcInstance) target).issfaction() && Config.FACTION_SYSTEM_ENABLE && (skill.getSkillType() == L2SkillType.BUFF)) || (skill.getSkillType() == L2SkillType.HOT) || (skill.getSkillType() == L2SkillType.HEAL) || (skill.getSkillType() == L2SkillType.COMBATPOINTHEAL) || (skill.getSkillType() == L2SkillType.HEAL_PERCENT) || (skill.getSkillType() == L2SkillType.MANAHEAL) || (skill.getSkillType() == L2SkillType.MANAHEAL_PERCENT) || (skill.getSkillType() == L2SkillType.BALANCE_LIFE) || (skill.getSkillType() == L2SkillType.CONT)))
  243. + {
  244. + return;
  245. + }
  246. + }
  247. +
  248. // AURA skills should always be using caster as target
  249. switch (skill.getTargetType())
  250. {
  251. @@ -1579,7 +1616,17 @@
  252. {
  253. if (!isDead() || isTeleporting())
  254. return;
  255. -
  256. + if ((this instanceof L2PcInstance) && (((L2PcInstance) this).isffaction() && Config.FACTION_SYSTEM_ENABLE))
  257. + {
  258. + teleToLocation(Config.FACTION_SYSTEM_FIRST_FACTION_BASE_SPAWN_X, Config.FACTION_SYSTEM_FIRST_FACTION_BASE_SPAWN_Y, Config.FACTION_SYSTEM_FIRST_FACTION_BASE_SPAWN_Z, 0);
  259. + }
  260. + else
  261. + {
  262. + if ((this instanceof L2PcInstance) && (((L2PcInstance) this).issfaction() && Config.FACTION_SYSTEM_ENABLE))
  263. + {
  264. + teleToLocation(Config.FACTION_SYSTEM_SECOND_FACTION_BASE_SPAWN_X, Config.FACTION_SYSTEM_SECOND_FACTION_BASE_SPAWN_Y, Config.FACTION_SYSTEM_SECOND_FACTION_BASE_SPAWN_Z, 0);
  265. + }
  266. + }
  267. setIsDead(false);
  268.  
  269. _status.setCurrentHp(getMaxHp() * Config.RESPAWN_RESTORE_HP);
  270. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelAnswerStart.java
  271. ===================================================================
  272. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelAnswerStart.java (revision 5)
  273. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelAnswerStart.java (working copy)
  274. @@ -14,6 +14,7 @@
  275. */
  276. package net.sf.l2j.gameserver.network.clientpackets;
  277.  
  278. +import net.sf.l2j.Config;
  279. import net.sf.l2j.gameserver.instancemanager.DuelManager;
  280. import net.sf.l2j.gameserver.model.L2CommandChannel;
  281. import net.sf.l2j.gameserver.model.L2Party;
  282. @@ -69,6 +70,12 @@
  283. return;
  284. }
  285.  
  286. + if ((Config.FACTION_SYSTEM_ENABLE && activeChar.issfaction()) || activeChar.isffaction())
  287. + {
  288. + activeChar.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
  289. + return;
  290. + }
  291. +
  292. if (_partyDuel == 1)
  293. {
  294. // Player must be a party leader, the target can't be of the same party.
  295. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestSendFriendMsg.java
  296. ===================================================================
  297. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestSendFriendMsg.java (revision 5)
  298. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestSendFriendMsg.java (working copy)
  299. @@ -59,6 +59,17 @@
  300. return;
  301. }
  302.  
  303. + if (targetPlayer.issfaction() && activeChar.isffaction())
  304. + {
  305. + activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  306. + return;
  307. + }
  308. + if (targetPlayer.isffaction() && activeChar.issfaction())
  309. + {
  310. + activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  311. + return;
  312. + }
  313. +
  314. if (Config.LOG_CHAT)
  315. {
  316. LogRecord record = new LogRecord(Level.INFO, _message);
  317. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java
  318. ===================================================================
  319. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java (revision 5)
  320. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreSell.java (working copy)
  321. @@ -21,6 +21,7 @@
  322. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.PrivateStoreType;
  323. import net.sf.l2j.gameserver.model.tradelist.TradeList;
  324. import net.sf.l2j.gameserver.network.SystemMessageId;
  325. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  326.  
  327. public final class RequestPrivateStoreSell extends L2GameClientPacket
  328. {
  329. @@ -77,6 +78,16 @@
  330. if (storePlayer.getPrivateStoreType() != PrivateStoreType.BUY)
  331. return;
  332.  
  333. + if (Config.FACTION_SYSTEM_ENABLE && Config.FACTION_SYSTEM_ALLOW_BUY_BETWEEN_FACTIONS)
  334. + {
  335. + if ((storePlayer.issfaction() && player.isffaction()) || (storePlayer.isffaction() && player.issfaction()))
  336. + {
  337. + player.sendMessage("You Cant Sell on a Different Faction");
  338. + sendPacket(ActionFailed.STATIC_PACKET);
  339. + return;
  340. + }
  341. + }
  342. +
  343. if (player.isCursedWeaponEquipped())
  344. return;
  345.  
  346. Index: java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java
  347. ===================================================================
  348. --- java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java (revision 5)
  349. +++ java/net/sf/l2j/gameserver/handler/skillhandlers/SummonFriend.java (working copy)
  350. @@ -73,6 +73,19 @@
  351. continue;
  352. }
  353.  
  354. + if (player.isffaction())
  355. + {
  356. + player.sendMessage("You Cannot Use This Skill.");
  357. + player.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
  358. + return;
  359. + }
  360. + if (player.issfaction())
  361. + {
  362. + player.sendMessage("You Cannot Use This Skill.");
  363. + player.sendPacket(SystemMessageId.YOUR_TARGET_IS_IN_AN_AREA_WHICH_BLOCKS_SUMMONING);
  364. + return;
  365. + }
  366. +
  367. // Send a request for Summon Friend skill.
  368. if (skill.getId() == 1403)
  369. {
  370. Index: java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java
  371. ===================================================================
  372. --- java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (revision 5)
  373. +++ java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (working copy)
  374. @@ -59,6 +59,18 @@
  375. return;
  376. }
  377.  
  378. + L2PcInstance player2 = (L2PcInstance) target;
  379. + if (player2.issfaction() && player.isffaction() && Config.FACTION_SYSTEM_ENABLE && Config.FACTION_SYSTEM_ALLOW_TRADE_BETWEEN_FACTIONS)
  380. + {
  381. + player.sendMessage("You Cant Trade with the Different Faction");
  382. + return;
  383. + }
  384. + if (player2.isffaction() && player.issfaction() && Config.FACTION_SYSTEM_ENABLE && Config.FACTION_SYSTEM_ALLOW_TRADE_BETWEEN_FACTIONS)
  385. + {
  386. + player.sendMessage("You Cant Trade with the Different Faction");
  387. + return;
  388. + }
  389. +
  390. // Alt game - Karma punishment
  391. if (!Config.KARMA_PLAYER_CAN_TRADE && (player.getKarma() > 0 || target.getKarma() > 0))
  392. {
  393. Index: java/net/sf/l2j/gameserver/network/clientpackets/AnswerTradeRequest.java
  394. ===================================================================
  395. --- java/net/sf/l2j/gameserver/network/clientpackets/AnswerTradeRequest.java (revision 5)
  396. +++ java/net/sf/l2j/gameserver/network/clientpackets/AnswerTradeRequest.java (working copy)
  397. @@ -14,6 +14,7 @@
  398. */
  399. package net.sf.l2j.gameserver.network.clientpackets;
  400.  
  401. +import net.sf.l2j.Config;
  402. import net.sf.l2j.gameserver.model.L2World;
  403. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  404. import net.sf.l2j.gameserver.network.SystemMessageId;
  405. @@ -46,6 +47,17 @@
  406. final L2PcInstance partner = player.getActiveRequester();
  407. if (partner == null || L2World.getInstance().getPlayer(partner.getObjectId()) == null)
  408. {
  409. + L2PcInstance player2 = player.getActiveRequester();
  410. + if (player2.issfaction() && player.isffaction() && Config.FACTION_SYSTEM_ENABLE && Config.FACTION_SYSTEM_ALLOW_TRADE_BETWEEN_FACTIONS)
  411. + {
  412. + player.sendMessage("You Cant Trade With The Other Faction");
  413. + return;
  414. + }
  415. + if (player2.isffaction() && player.issfaction() && Config.FACTION_SYSTEM_ENABLE && Config.FACTION_SYSTEM_ALLOW_TRADE_BETWEEN_FACTIONS)
  416. + {
  417. + player.sendMessage("You Cant Trade With The Other Faction");
  418. + return;
  419. + }
  420. // Trade partner not found, cancel trade
  421. player.sendPacket(new SendTradeDone(0));
  422. player.sendPacket(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
  423. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java
  424. ===================================================================
  425. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java (revision 5)
  426. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestPrivateStoreBuy.java (working copy)
  427. @@ -24,6 +24,7 @@
  428. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.PrivateStoreType;
  429. import net.sf.l2j.gameserver.model.tradelist.TradeList;
  430. import net.sf.l2j.gameserver.network.SystemMessageId;
  431. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  432. import net.sf.l2j.gameserver.util.Util;
  433.  
  434. public final class RequestPrivateStoreBuy extends L2GameClientPacket
  435. @@ -86,6 +87,16 @@
  436. if (storeList == null)
  437. return;
  438.  
  439. + if (Config.FACTION_SYSTEM_ENABLE && Config.FACTION_SYSTEM_ALLOW_BUY_BETWEEN_FACTIONS)
  440. + {
  441. + if ((storePlayer.issfaction() && player.isffaction()) || (storePlayer.isffaction() && player.issfaction()))
  442. + {
  443. + player.sendMessage("You Cannot Buy From an Other Faction");
  444. + sendPacket(ActionFailed.STATIC_PACKET);
  445. + return;
  446. + }
  447. + }
  448. +
  449. if (!player.getAccessLevel().allowTransaction())
  450. {
  451. player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
  452. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java
  453. ===================================================================
  454. --- java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java (revision 0)
  455. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java (working copy)
  456. @@ -0,0 +1,329 @@
  457. +/*
  458. + * This program is free software: you can redistribute it and/or modify it under
  459. + * the terms of the GNU General Public License as published by the Free Software
  460. + * Foundation, either version 3 of the License, or (at your option) any later
  461. + * version.
  462. + *
  463. + * This program is distributed in the hope that it will be useful, but WITHOUT
  464. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  465. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  466. + * details.
  467. + *
  468. + * You should have received a copy of the GNU General Public License along with
  469. + * this program. If not, see <http://www.gnu.org/licenses/>.
  470. + */
  471. +package net.sf.l2j.gameserver.model.actor.instance;
  472. +
  473. +import java.sql.Connection;
  474. +import java.sql.PreparedStatement;
  475. +import java.sql.ResultSet;
  476. +import java.util.StringTokenizer;
  477. +
  478. +import net.sf.l2j.Config;
  479. +import net.sf.l2j.L2DatabaseFactory;
  480. +import net.sf.l2j.commons.random.Rnd;
  481. +import net.sf.l2j.gameserver.ai.CtrlIntention;
  482. +import net.sf.l2j.gameserver.model.L2World;
  483. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  484. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  485. +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
  486. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  487. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  488. +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  489. +
  490. +/**
  491. + * @Last_Author Stefoulis15 & CaFi
  492. + */
  493. +public class L2FactionInstance extends L2NpcInstance
  494. +{
  495. + public L2FactionInstance(int objectId, NpcTemplate template)
  496. + {
  497. + super(objectId, template);
  498. + }
  499. +
  500. + @Override
  501. + public void onBypassFeedback(L2PcInstance player, String command)
  502. + {
  503. + player.sendPacket(ActionFailed.STATIC_PACKET);
  504. + StringTokenizer st = new StringTokenizer(command, " ");
  505. + String actualCommand = st.nextToken();
  506. + String val = "";
  507. + if (st.countTokens() >= 1)
  508. + {
  509. + val = st.nextToken();
  510. + }
  511. + if (actualCommand.equalsIgnoreCase("delevel"))
  512. + {
  513. + setTarget(player);
  514. + int lvl = player.getLevel();
  515. + if (lvl > 40)
  516. + {
  517. + if (val.equalsIgnoreCase("1"))
  518. + {
  519. + long delexp = 0;
  520. + delexp = player.getStat().getExp() - player.getStat().getExpForLevel(lvl - 1);
  521. + player.getStat().addExp(-delexp);
  522. + player.broadcastKarma();
  523. + player.sendMessage("Delevel was Successfull.");
  524. + }
  525. + else
  526. + {
  527. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  528. + html.setFile("data/html/mods/Faction/delevel.htm");
  529. + html.replace("%lvl%", String.valueOf(player.getLevel()));
  530. + sendHtmlMessage(player, html);
  531. + }
  532. + }
  533. + else
  534. + {
  535. + player.sendMessage("You have to be at least level 40 to use the delevel faction.");
  536. + }
  537. + return;
  538. + }
  539. + else if (actualCommand.equalsIgnoreCase("levelup"))
  540. + {
  541. + setTarget(player);
  542. + int lvl = player.getLevel();
  543. + if (val.equalsIgnoreCase("1"))
  544. + {
  545. + long addexp = 0;
  546. + addexp = player.getStat().getExpForLevel(lvl + 1) - player.getStat().getExp();
  547. + player.getStat().addExp(addexp);
  548. + player.broadcastKarma();
  549. + player.sendMessage("Level Up was Successfull.");
  550. + }
  551. + else
  552. + {
  553. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  554. + html.setFile("data/html/mods/Faction/levelup.htm");
  555. + html.replace("%lvl%", String.valueOf(player.getLevel()));
  556. + sendHtmlMessage(player, html);
  557. + }
  558. + }
  559. + else if (actualCommand.equalsIgnoreCase("setnobless"))
  560. + {
  561. + setTarget(player);
  562. + if (player.isNoble())
  563. + {
  564. + player.sendMessage("You have allready nobless status.");
  565. + player.sendPacket(ActionFailed.STATIC_PACKET);
  566. + }
  567. + else
  568. + {
  569. + player.setNoble(true, true);
  570. + Connection connection = null;
  571. + try
  572. + {
  573. + connection = L2DatabaseFactory.getInstance().getConnection();
  574. + PreparedStatement statement = connection.prepareStatement("SELECT obj_id FROM characters where char_name=?");
  575. + statement.setString(1, player.getName());
  576. + ResultSet rset = statement.executeQuery();
  577. + int objId = 0;
  578. + if (rset.next())
  579. + {
  580. + objId = rset.getInt(1);
  581. + }
  582. + rset.close();
  583. + statement.close();
  584. + if (objId == 0)
  585. + {
  586. + connection.close();
  587. + return;
  588. + }
  589. + statement = connection.prepareStatement("UPDATE characters SET nobless=1 WHERE obj_id=?");
  590. + statement.setInt(1, objId);
  591. + statement.execute();
  592. + statement.close();
  593. + connection.close();
  594. + }
  595. + catch (Exception e)
  596. + {
  597. + _log.warning("Could not set Nobless status of char.");
  598. + }
  599. + System.out.println("##KvN Engine## : Player " + player.getName() + " has gain noble status");
  600. + player.sendMessage("You Gaine Nobless Status.");
  601. + }
  602. + }
  603. + else if (actualCommand.equalsIgnoreCase("setffaction"))
  604. + {
  605. + setTarget(player);
  606. + if (player.isffaction())
  607. + {
  608. + player.sendMessage("You are allready a " + Config.FACTION_SYSTEM_FIRST_FACTION_NAME + " faction.");
  609. + player.sendPacket(ActionFailed.STATIC_PACKET);
  610. + }
  611. + else
  612. + {
  613. + if (player.issfaction())
  614. + {
  615. + player.sendMessage("You Cant Change Faction.");
  616. + player.sendPacket(ActionFailed.STATIC_PACKET);
  617. + }
  618. + else
  619. + {
  620. + // int getnoobs = L2World.getInstance().getAllnoobPlayers().size();
  621. + // int getkoofs = L2World.getInstance().getAllkoofPlayers().size();
  622. + // if (getkoofs > getnoobs)
  623. + {
  624. + // player.sendMessage("It is more " + Config.KOOF_NAME_TEAM + " members online.");
  625. + // player.sendPacket(ActionFailed.STATIC_PACKET);
  626. + // } else
  627. + // {
  628. + player.setffaction(true);
  629. + Connection connection = null;
  630. + try
  631. + {
  632. + connection = L2DatabaseFactory.getInstance().getConnection();
  633. + PreparedStatement statement = connection.prepareStatement("SELECT obj_id FROM characters where char_name=?");
  634. + statement.setString(1, player.getName());
  635. + ResultSet rset = statement.executeQuery();
  636. + int objId = 0;
  637. + if (rset.next())
  638. + {
  639. + objId = rset.getInt(1);
  640. + }
  641. + rset.close();
  642. + statement.close();
  643. + if (objId == 0)
  644. + {
  645. + connection.close();
  646. + return;
  647. + }
  648. + statement = connection.prepareStatement("UPDATE characters SET koof=1 WHERE obj_id=?");
  649. + statement.setInt(1, objId);
  650. + statement.execute();
  651. + statement.close();
  652. + connection.close();
  653. + }
  654. + catch (Exception e)
  655. + {
  656. + _log.warning("Could not set koof status of char:");
  657. + }
  658. + System.out.println("##KvN Engine## : Player " + player.getName() + " has choose " + Config.FACTION_SYSTEM_FIRST_FACTION_NAME + " faction");
  659. + if (player.isffaction() == true)
  660. + {
  661. + player.broadcastUserInfo();
  662. + player.sendMessage("You are fighiting now for " + Config.FACTION_SYSTEM_FIRST_FACTION_TITLE_COLOR + " faction ");
  663. + player.getAppearance().setNameColor(Config.FACTION_SYSTEM_FIRST_FACTION_NAME_COLOR);
  664. + player.getAppearance().setTitleColor(Config.FACTION_SYSTEM_FIRST_FACTION_TITLE_COLOR);
  665. + player.teleToLocation(146334, 25767, -2013, 0);
  666. + }
  667. + }
  668. + }
  669. + }
  670. + }
  671. + else if (actualCommand.equalsIgnoreCase("setsfaction"))
  672. + {
  673. + setTarget(player);
  674. + if (player.issfaction())
  675. + {
  676. + player.sendMessage("You are allready a " + Config.FACTION_SYSTEM_SECOND_FACTION_NAME + " faction.");
  677. + player.sendPacket(ActionFailed.STATIC_PACKET);
  678. + }
  679. + else
  680. + {
  681. + if (player.isffaction())
  682. + {
  683. + player.sendMessage("You cant change faction.");
  684. + player.sendPacket(ActionFailed.STATIC_PACKET);
  685. + }
  686. + else
  687. + {
  688. + @SuppressWarnings("unused")
  689. + int getnoobs = L2World.getInstance().getAllnoobPlayers().size();
  690. + @SuppressWarnings("unused")
  691. + int getkoofs = L2World.getInstance().getAllkoofPlayers().size();
  692. + // if (getnoobs > getkoofs)
  693. + {
  694. + // player.sendMessage("It is more " + Config.NOOB_NAME_TEAM + " members online.");
  695. + // player.sendPacket(ActionFailed.STATIC_PACKET);
  696. + // } else
  697. + // {
  698. + player.setsfaction(true);
  699. + try (Connection con = L2DatabaseFactory.getInstance().getConnection())
  700. + {
  701. + PreparedStatement statement = con.prepareStatement("SELECT obj_id FROM characters where char_name=?");
  702. + statement.setString(1, player.getName());
  703. + ResultSet rset = statement.executeQuery();
  704. + int objId = 0;
  705. + if (rset.next())
  706. + {
  707. + objId = rset.getInt(1);
  708. + }
  709. + rset.close();
  710. + statement.close();
  711. + if (objId == 0)
  712. + {
  713. + con.close();
  714. + return;
  715. + }
  716. + statement = con.prepareStatement("UPDATE characters SET noob=1 WHERE obj_id=?");
  717. + statement.setInt(1, objId);
  718. + statement.execute();
  719. + statement.close();
  720. + con.close();
  721. + }
  722. + catch (Exception e)
  723. + {
  724. + _log.warning("Could not set noob status of char:");
  725. + }
  726. + System.out.println("##KvN Engine## : player " + player.getName() + " Has choose " + Config.FACTION_SYSTEM_SECOND_FACTION_NAME + " Faction");
  727. + if (player.issfaction() == true)
  728. + {
  729. + player.broadcastUserInfo();
  730. + player.sendMessage("You are fighiting now for " + Config.FACTION_SYSTEM_SECOND_FACTION_NAME + " faction ");
  731. + player.getAppearance().setNameColor(Config.FACTION_SYSTEM_SECOND_FACTION_NAME_COLOR);
  732. + player.getAppearance().setTitleColor(Config.FACTION_SYSTEM_SECOND_FACTION_TITLE_COLOR);
  733. + player.teleToLocation(59669, -42221, -2992, 0);
  734. + }
  735. + }
  736. + }
  737. + }
  738. + }
  739. + else
  740. + {
  741. + super.onBypassFeedback(player, command);
  742. + }
  743. + }
  744. +
  745. + @Override
  746. + public void onAction(L2PcInstance player)
  747. + {
  748. + if (this != player.getTarget())
  749. + {
  750. + player.setTarget(this);
  751. + player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
  752. + player.sendPacket(new ValidateLocation(this));
  753. + }
  754. + else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false))
  755. + {
  756. + SocialAction sa = new SocialAction(player, Rnd.get(8));
  757. + broadcastPacket(sa);
  758. + player.setCurrentFolkNPC(this);
  759. + showMessageWindow(player);
  760. + player.sendPacket(ActionFailed.STATIC_PACKET);
  761. + }
  762. + else
  763. + {
  764. + player.getAI().setIntention(CtrlIntention.INTERACT, this);
  765. + player.sendPacket(ActionFailed.STATIC_PACKET);
  766. + }
  767. + }
  768. +
  769. + private void showMessageWindow(L2PcInstance player)
  770. + {
  771. + NpcHtmlMessage html = new NpcHtmlMessage(1);
  772. + html.setFile("data/html/mods/Faction/faction.htm");
  773. + html.replace("%objectId%", String.valueOf(getObjectId()));
  774. + html.replace("%npcname%", getName());
  775. + player.sendPacket(html);
  776. + }
  777. +
  778. + private void sendHtmlMessage(L2PcInstance player, NpcHtmlMessage html)
  779. + {
  780. + html.replace("%objectId%", String.valueOf(getObjectId()));
  781. + html.replace("%npcname%", getName());
  782. + html.replace("%npcId%", String.valueOf(getNpcId()));
  783. + player.sendPacket(html);
  784. + }
  785. +}
  786. \ No newline at end of file
  787. Index: java/net/sf/l2j/gameserver/model/L2Clan.java
  788. ===================================================================
  789. --- java/net/sf/l2j/gameserver/model/L2Clan.java (revision 5)
  790. +++ java/net/sf/l2j/gameserver/model/L2Clan.java (working copy)
  791. @@ -1656,6 +1656,17 @@
  792. return false;
  793. }
  794.  
  795. + if (activeChar.isffaction() && target.issfaction() && Config.FACTION_SYSTEM_ENABLE)
  796. + {
  797. + activeChar.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
  798. + return false;
  799. + }
  800. + if (activeChar.issfaction() && target.isffaction() && Config.FACTION_SYSTEM_ENABLE)
  801. + {
  802. + activeChar.sendPacket(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET);
  803. + return false;
  804. + }
  805. +
  806. if (activeChar.getObjectId() == target.getObjectId())
  807. {
  808. activeChar.sendPacket(SystemMessageId.CANNOT_INVITE_YOURSELF);
  809. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java
  810. ===================================================================
  811. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java (revision 5)
  812. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelStart.java (working copy)
  813. @@ -14,6 +14,7 @@
  814. */
  815. package net.sf.l2j.gameserver.network.clientpackets;
  816.  
  817. +import net.sf.l2j.Config;
  818. import net.sf.l2j.gameserver.model.L2CommandChannel;
  819. import net.sf.l2j.gameserver.model.L2Party;
  820. import net.sf.l2j.gameserver.model.L2World;
  821. @@ -48,6 +49,12 @@
  822. return;
  823. }
  824.  
  825. + if ((Config.FACTION_SYSTEM_ENABLE && activeChar.issfaction()) || activeChar.isffaction())
  826. + {
  827. + activeChar.sendPacket(SystemMessageId.YOU_ARE_UNABLE_TO_REQUEST_A_DUEL_AT_THIS_TIME);
  828. + return;
  829. + }
  830. +
  831. // Check if duel is possible.
  832. if (!activeChar.canDuel())
  833. {
  834. Index: java/net/sf/l2j/gameserver/model/L2World.java
  835. ===================================================================
  836. --- java/net/sf/l2j/gameserver/model/L2World.java (revision 5)
  837. +++ java/net/sf/l2j/gameserver/model/L2World.java (working copy)
  838. @@ -52,6 +52,8 @@
  839. private final Map<Integer, L2Object> _objects = new ConcurrentHashMap<>();
  840. private final Map<Integer, L2PetInstance> _pets = new ConcurrentHashMap<>();
  841. private final Map<Integer, L2PcInstance> _players = new ConcurrentHashMap<>();
  842. + private Map<String, L2PcInstance> _allkoofPlayers = new ConcurrentHashMap<>();
  843. + private Map<String, L2PcInstance> _allnoobPlayers = new ConcurrentHashMap<>();
  844.  
  845. private final L2WorldRegion[][] _worldRegions = new L2WorldRegion[REGIONS_X + 1][REGIONS_Y + 1];
  846.  
  847. @@ -115,6 +117,16 @@
  848. return _players.values();
  849. }
  850.  
  851. + public Collection<L2PcInstance> getAllkoofPlayers()
  852. + {
  853. + return _allkoofPlayers.values();
  854. + }
  855. +
  856. + public Collection<L2PcInstance> getAllnoobPlayers()
  857. + {
  858. + return _allnoobPlayers.values();
  859. + }
  860. +
  861. public L2PcInstance getPlayer(String name)
  862. {
  863. return getPlayer(CharNameTable.getInstance().getIdByName(name));
  864. @@ -140,6 +152,16 @@
  865. return _pets.get(ownerId);
  866. }
  867.  
  868. + public int getAllkoofPlayersCount()
  869. + {
  870. + return _allkoofPlayers.size();
  871. + }
  872. +
  873. + public int getAllnoobPlayersCount()
  874. + {
  875. + return _allnoobPlayers.size();
  876. + }
  877. +
  878. /**
  879. * Add a L2Object in the world.<BR>
  880. * <BR>
  881. @@ -181,6 +203,14 @@
  882. tmp.logout();
  883. return;
  884. }
  885. + if (((L2PcInstance) object).isffaction())
  886. + {
  887. + _allkoofPlayers.put(player.getName().toLowerCase(), player);
  888. + }
  889. + else if (((L2PcInstance) object).issfaction())
  890. + {
  891. + _allnoobPlayers.put(player.getName().toLowerCase(), player);
  892. + }
  893. _players.putIfAbsent(player.getObjectId(), player);
  894. }
  895. }
  896. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  897. ===================================================================
  898. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 5)
  899. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
  900. @@ -80,6 +80,18 @@
  901. return;
  902. }
  903.  
  904. + if (Config.FACTION_SYSTEM_NEW_CHAR_SET_NOBLESSE)
  905. + {
  906. + if (!activeChar.isNoble())
  907. + activeChar.setNoble(true, false);
  908. + }
  909. +
  910. + if (Config.FACTION_SYSTEM_NEW_CHAR_SET_HERO)
  911. + {
  912. + if (!activeChar.isHero())
  913. + activeChar.setHero(true);
  914. + }
  915. +
  916. if (activeChar.isGM())
  917. {
  918. if (Config.GM_STARTUP_INVULNERABLE && AdminCommandAccessRights.getInstance().hasAccess("admin_invul", activeChar.getAccessLevel()))
  919. @@ -97,6 +109,21 @@
  920. GmListTable.getInstance().addGm(activeChar, true);
  921. }
  922.  
  923. + if (activeChar.isffaction() && Config.FACTION_SYSTEM_ENABLE)
  924. + {
  925. + activeChar.getAppearance().setNameColor(Config.FACTION_SYSTEM_FIRST_FACTION_NAME_COLOR);
  926. + activeChar.sendMessage("Welcome " + activeChar.getName() + " You Are Fighting " + Config.FACTION_SYSTEM_FIRST_FACTION_NAME + " Faction");
  927. + activeChar.setTitle(Config.FACTION_SYSTEM_FIRST_FACTION_NAME);
  928. + activeChar.getAppearance().setTitleColor(Config.FACTION_SYSTEM_FIRST_FACTION_TITLE_COLOR);
  929. + }
  930. + if (activeChar.issfaction() && Config.FACTION_SYSTEM_ENABLE)
  931. + {
  932. + activeChar.getAppearance().setNameColor(Config.FACTION_SYSTEM_SECOND_FACTION_NAME_COLOR);
  933. + activeChar.sendMessage("Welcome " + activeChar.getName() + " You Are Fighting " + Config.FACTION_SYSTEM_SECOND_FACTION_NAME + " Faction");
  934. + activeChar.setTitle(Config.FACTION_SYSTEM_SECOND_FACTION_NAME);
  935. + activeChar.getAppearance().setTitleColor(Config.FACTION_SYSTEM_SECOND_FACTION_TITLE_COLOR);
  936. + }
  937. +
  938. // Set dead status if applies
  939. if (activeChar.getCurrentHp() < 0.5)
  940. activeChar.setIsDead(true);
  941. Index: java/net/sf/l2j/gameserver/network/clientpackets/SendWarehouseDepositList.java
  942. ===================================================================
  943. --- java/net/sf/l2j/gameserver/network/clientpackets/SendWarehouseDepositList.java (revision 5)
  944. +++ java/net/sf/l2j/gameserver/network/clientpackets/SendWarehouseDepositList.java (working copy)
  945. @@ -101,7 +101,7 @@
  946. return;
  947.  
  948. // Freight price from config or normal price per item slot (30)
  949. - final int fee = _items.length * 30;
  950. + final int fee = _items.length * Config.FACTION_SYSTEM_ALT_WAREHOUSE_FEE;
  951. int currentAdena = player.getAdena();
  952. int slots = 0;
  953.  
  954. @@ -132,7 +132,7 @@
  955. }
  956.  
  957. // Check if enough adena and charge the fee
  958. - if (currentAdena < fee || !player.reduceAdena(warehouse.getName(), fee, manager, false))
  959. + if (currentAdena < Config.FACTION_SYSTEM_ALT_WAREHOUSE_FEE || !player.reduceAdena(warehouse.getName(), fee, manager, false))
  960. {
  961. sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
  962. return;
  963. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
  964. ===================================================================
  965. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 5)
  966. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
  967. @@ -70,6 +70,17 @@
  968. return;
  969. }
  970.  
  971. + if (target.isffaction() && requestor.issfaction())
  972. + {
  973. + requestor.sendPacket(SystemMessageId.INCORRECT_TARGET);
  974. + return;
  975. + }
  976. + if (target.issfaction() && requestor.isffaction())
  977. + {
  978. + requestor.sendPacket(SystemMessageId.INCORRECT_TARGET);
  979. + return;
  980. + }
  981. +
  982. if (target.getClient().isDetached())
  983. {
  984. requestor.sendMessage("The player you tried to invite is in offline mode.");
  985. Index: java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java
  986. ===================================================================
  987. --- java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java (revision 5)
  988. +++ java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java (working copy)
  989. @@ -142,9 +142,27 @@
  990. sendPacket(CharCreateOk.STATIC_PACKET);
  991.  
  992. L2World.getInstance().addObject(newChar);
  993. -
  994. + if (Config.FACTION_SYSTEM_NEW_CHAR_LEVEL_75)
  995. + {
  996. + newChar.addExpAndSp(804219972L, 99999999);
  997. + }
  998. + else if (Config.FACTION_SYSTEM_NEW_CHAR_LEVEL_80)
  999. + {
  1000. + newChar.addExpAndSp(4200000000L, 99999999);
  1001. + }
  1002. + else if (Config.FACTION_SYSTEM_NEW_CHAR_LEVEL_85)
  1003. + {
  1004. + newChar.addExpAndSp(19827360000L, 99999999);
  1005. + }
  1006. newChar.addAdena("Init", Config.STARTING_ADENA, null, false);
  1007. - newChar.setXYZInvisible(template.getSpawnX(), template.getSpawnY(), template.getSpawnZ());
  1008. + if (Config.FACTION_SYSTEM_ALLOW_ALT_NEW_CHAR_SPAWN)
  1009. + {
  1010. + newChar.setXYZInvisible(Config.FACTION_SYSTEM_NEW_CHAR_SPAWN_X, Config.FACTION_SYSTEM_NEW_CHAR_SPAWN_Y, Config.FACTION_SYSTEM_NEW_CHAR_SPAWN_Z);
  1011. + }
  1012. + else
  1013. + {
  1014. + newChar.setXYZInvisible(template.getSpawnX(), template.getSpawnY(), template.getSpawnZ());
  1015. + }
  1016. newChar.setTitle("");
  1017.  
  1018. newChar.registerShortCut(new L2ShortCut(0, 0, 3, 2, -1, 1)); // attack shortcut
  1019. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestAnswerJoinParty.java
  1020. ===================================================================
  1021. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestAnswerJoinParty.java (revision 5)
  1022. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestAnswerJoinParty.java (working copy)
  1023. @@ -44,6 +44,14 @@
  1024. return;
  1025.  
  1026. final L2PcInstance requestor = player.getActiveRequester();
  1027. + if (player.issfaction() && requestor.isffaction())
  1028. + {
  1029. + return;
  1030. + }
  1031. + if (player.isffaction() && requestor.issfaction())
  1032. + {
  1033. + return;
  1034. + }
  1035. if (requestor == null)
  1036. return;
  1037.  
  1038. Index: java/net/sf/l2j/gameserver/GameServer.java
  1039. ===================================================================
  1040. --- java/net/sf/l2j/gameserver/GameServer.java (revision 5)
  1041. +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
  1042. @@ -274,7 +274,19 @@
  1043.  
  1044. StringUtil.printSection("Quests & Scripts");
  1045. ScriptManager.getInstance();
  1046. -
  1047. + if (Config.FACTION_SYSTEM_ENABLE)
  1048. + {
  1049. + System.out.println("####################################");
  1050. + System.out.println("## Faction System is Activated. ##");
  1051. + System.out.println("####################################");
  1052. + }
  1053. + else
  1054. + {
  1055. + System.out.println("###################################");
  1056. + System.out.println("## Faction System is Disabled. ##");
  1057. + System.out.println("###################################");
  1058. + }
  1059. +
  1060. if (Config.ALLOW_BOAT)
  1061. {
  1062. BoatManager.getInstance();
  1063. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java
  1064. ===================================================================
  1065. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java (revision 5)
  1066. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestFriendInvite.java (working copy)
  1067. @@ -14,6 +14,7 @@
  1068. */
  1069. package net.sf.l2j.gameserver.network.clientpackets;
  1070.  
  1071. +import net.sf.l2j.Config;
  1072. import net.sf.l2j.gameserver.model.BlockList;
  1073. import net.sf.l2j.gameserver.model.L2World;
  1074. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  1075. @@ -48,6 +49,18 @@
  1076. return;
  1077. }
  1078.  
  1079. + if (friend.issfaction() && activeChar.isffaction() && Config.FACTION_SYSTEM_ENABLE)
  1080. + {
  1081. + // Target is wrong.
  1082. + activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  1083. + return;
  1084. + }
  1085. + else if (friend.isffaction() && activeChar.issfaction() && Config.FACTION_SYSTEM_ENABLE)
  1086. + {
  1087. + // Target is wrong.
  1088. + activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  1089. + return;
  1090. + }
  1091. if (friend == activeChar)
  1092. {
  1093. // You cannot add yourself to your own friend list.
  1094. Index: java/net/sf/l2j/Config.java
  1095. ===================================================================
  1096. --- java/net/sf/l2j/Config.java (revision 5)
  1097. +++ java/net/sf/l2j/Config.java (working copy)
  1098. @@ -495,6 +495,38 @@
  1099. public static boolean STORE_SKILL_COOLTIME;
  1100. public static int BUFFS_MAX_AMOUNT;
  1101.  
  1102. + /** faction */
  1103. + public static boolean FACTION_SYSTEM_ENABLE;
  1104. + public static int FACTION_SYSTEM_FIRST_FACTION_TITLE_COLOR;
  1105. + public static int FACTION_SYSTEM_SECOND_FACTION_TITLE_COLOR;
  1106. + public static String FACTION_SYSTEM_FIRST_FACTION_NAME;
  1107. + public static String FACTION_SYSTEM_SECOND_FACTION_NAME;
  1108. + public static boolean FACTION_SYSTEM_NEW_CHAR_ALLOW_ALT_SPAWN;
  1109. + public static int FACTION_SYSTEM_NEW_CHAR_SPAWN_X;
  1110. + public static int FACTION_SYSTEM_NEW_CHAR_SPAWN_Y;
  1111. + public static int FACTION_SYSTEM_NEW_CHAR_SPAWN_Z;
  1112. + public static int FACTION_SYSTEM_FIRST_FACTION_BASE_SPAWN_X;
  1113. + public static int FACTION_SYSTEM_FIRST_FACTION_BASE_SPAWN_Y;
  1114. + public static int FACTION_SYSTEM_FIRST_FACTION_BASE_SPAWN_Z;
  1115. + public static int FACTION_SYSTEM_SECOND_FACTION_BASE_SPAWN_X;
  1116. + public static int FACTION_SYSTEM_SECOND_FACTION_BASE_SPAWN_Y;
  1117. + public static int FACTION_SYSTEM_SECOND_FACTION_BASE_SPAWN_Z;
  1118. + public static boolean FACTION_SYSTEM_NEW_CHAR_LEVEL_75;
  1119. + public static boolean FACTION_SYSTEM_NEW_CHAR_LEVEL_80;
  1120. + public static boolean FACTION_SYSTEM_NEW_CHAR_LEVEL_85;
  1121. + public static boolean FACTION_SYSTEM_ALLOW_TRADE_BETWEEN_FACTIONS;
  1122. + public static boolean FACTION_SYSTEM_NEW_CHAR_SET_NOBLESSE;
  1123. + public static boolean FACTION_SYSTEM_NEW_CHAR_SET_HERO;
  1124. + public static int FACTION_SYSTEM_FIRST_FACTION_NAME_COLOR;
  1125. + public static int FACTION_SYSTEM_SECOND_FACTION_NAME_COLOR;
  1126. + public static int FACTION_SYSTEM_ALT_WAREHOUSE_FEE;
  1127. + public static boolean FACTION_SYSTEM_ALLOW_REWARD_FOR_EACH_PVP;
  1128. + public static int FACTION_SYSTEM_PVP_ITEM_REWARD_ID;
  1129. + public static int FACTION_SYSTEM_PVP_ITEM_REWARD_AMOUNT;
  1130. + public static int FACTION_SYSTEM_ANNOUNCE_DELAY;
  1131. + public static boolean FACTION_SYSTEM_ALLOW_BUY_BETWEEN_FACTIONS;
  1132. + public static boolean FACTION_SYSTEM_ALLOW_ALT_NEW_CHAR_SPAWN;
  1133. +
  1134. // --------------------------------------------------
  1135. // Server
  1136. // --------------------------------------------------
  1137. @@ -1080,6 +1112,36 @@
  1138.  
  1139. BUFFS_MAX_AMOUNT = players.getProperty("MaxBuffsAmount", 20);
  1140. STORE_SKILL_COOLTIME = players.getProperty("StoreSkillCooltime", true);
  1141. + FACTION_SYSTEM_ENABLE = players.getProperty("FactionSystemEnable", false);
  1142. + FACTION_SYSTEM_FIRST_FACTION_TITLE_COLOR = Integer.decode("0x" + players.getProperty("FirstFactionTitleColor", ""));
  1143. + FACTION_SYSTEM_SECOND_FACTION_TITLE_COLOR = Integer.decode("0x" + players.getProperty("SecondFactionTitleColor", ""));
  1144. + FACTION_SYSTEM_FIRST_FACTION_NAME = players.getProperty("FirstFactionName", "Villagers");
  1145. + FACTION_SYSTEM_SECOND_FACTION_NAME = players.getProperty("SecondFactionName", "Pirates");
  1146. + FACTION_SYSTEM_NEW_CHAR_ALLOW_ALT_SPAWN = players.getProperty("NewCharAltSpawn", false);
  1147. + FACTION_SYSTEM_NEW_CHAR_SPAWN_X = players.getProperty("NewCharSpawnX", 0);
  1148. + FACTION_SYSTEM_NEW_CHAR_SPAWN_Y = players.getProperty("NewCharSpawnY", 0);
  1149. + FACTION_SYSTEM_NEW_CHAR_SPAWN_Z = players.getProperty("NewCharSpawnZ", 0);
  1150. + FACTION_SYSTEM_FIRST_FACTION_BASE_SPAWN_X = players.getProperty("FirstFactionBaseSpawnX", 0);
  1151. + FACTION_SYSTEM_FIRST_FACTION_BASE_SPAWN_Y = players.getProperty("FirstFactionBaseSpawnY", 0);
  1152. + FACTION_SYSTEM_FIRST_FACTION_BASE_SPAWN_Z = players.getProperty("FirstFactionBaseSpawnZ", 0);
  1153. + FACTION_SYSTEM_SECOND_FACTION_BASE_SPAWN_X = players.getProperty("SecondFactionBaseSpawnX", 0);
  1154. + FACTION_SYSTEM_SECOND_FACTION_BASE_SPAWN_Y = players.getProperty("SecondFactionBaseSpawnY", 0);
  1155. + FACTION_SYSTEM_SECOND_FACTION_BASE_SPAWN_Z = players.getProperty("SecondFactionBaseSpawnZ", 0);
  1156. + FACTION_SYSTEM_NEW_CHAR_LEVEL_75 = players.getProperty("NewCharLevel75", false);
  1157. + FACTION_SYSTEM_NEW_CHAR_LEVEL_80 = players.getProperty("NewCharLevel80", false);
  1158. + FACTION_SYSTEM_NEW_CHAR_LEVEL_85 = players.getProperty("NewCharLevel85", false);
  1159. + FACTION_SYSTEM_ALLOW_TRADE_BETWEEN_FACTIONS = players.getProperty("AllowTradeBetweenFactions", false);
  1160. + FACTION_SYSTEM_NEW_CHAR_SET_NOBLESSE = players.getProperty("NewCharSetNoblesse", false);
  1161. + FACTION_SYSTEM_NEW_CHAR_SET_HERO = Boolean.parseBoolean(players.getProperty("NewCharSetHero", "False"));
  1162. + FACTION_SYSTEM_FIRST_FACTION_NAME_COLOR = Integer.decode("0x" + players.getProperty("FirstFactionNameColor", ""));
  1163. + FACTION_SYSTEM_SECOND_FACTION_NAME_COLOR = Integer.decode("0x" + players.getProperty("SecondFactionNameColor", ""));
  1164. + FACTION_SYSTEM_ALT_WAREHOUSE_FEE = players.getProperty("AltWarehouseDepositFee", 0);
  1165. + FACTION_SYSTEM_ALLOW_REWARD_FOR_EACH_PVP = players.getProperty("AllowPvPReward", false);
  1166. + FACTION_SYSTEM_PVP_ITEM_REWARD_ID = players.getProperty("PvPRewardID", 57);
  1167. + FACTION_SYSTEM_PVP_ITEM_REWARD_AMOUNT = players.getProperty("PvPRewardAmount", 1);
  1168. + FACTION_SYSTEM_ANNOUNCE_DELAY = Integer.parseInt(players.getProperty("AnnouncePlayersDelay", ""));
  1169. + FACTION_SYSTEM_ALLOW_BUY_BETWEEN_FACTIONS = players.getProperty("AllowBuyBetweenFactions", false);
  1170. + FACTION_SYSTEM_ALLOW_ALT_NEW_CHAR_SPAWN = players.getProperty("AllowAltSpawnForNewChars", false);
  1171.  
  1172. // server
  1173. ExProperties server = load(SERVER_FILE);
  1174. Index: config/players.properties
  1175. ===================================================================
  1176. --- config/players.properties (revision 5)
  1177. +++ config/players.properties (working copy)
  1178. @@ -294,4 +294,88 @@
  1179. MaxBuffsAmount = 20
  1180.  
  1181. # Store buffs/debuffs on user logout?
  1182. -StoreSkillCooltime = True
  1183. \ No newline at end of file
  1184. +StoreSkillCooltime = True
  1185. +
  1186. +EnableManaPotionSupport = False
  1187. +
  1188. +# ---------------------------------------------------------------------------
  1189. +# Faction System By Stefoulis15
  1190. +# ---------------------------------------------------------------------------
  1191. +# Faction System is Something Really Unique. You Must Have Full Knowledge of What You Are Doing When Activating It.
  1192. +# Faction System Cannot Work With TvT Events , CTF , DM , KOTH And Others.
  1193. +
  1194. +# Enable Stefoulis15 Faction System?
  1195. +FactionSystemEnable = False
  1196. +
  1197. +# Annnounce Faction Players
  1198. +# Values Are In Minutes
  1199. +AnnouncePlayersDelay =
  1200. +
  1201. +# Set The Faction Name of The First Faction.
  1202. +FirstFactionName = Villagers
  1203. +
  1204. +# Set The Faction Name of The Second Faction.
  1205. +SecondFactionName = Pirates
  1206. +
  1207. +# Allow Alternative Spawn Place For New Created Characters
  1208. +AllowAltSpawnForNewChars = False
  1209. +
  1210. +# Set The Spawn Location of New Created Characters
  1211. +NewCharSpawnX =
  1212. +NewCharSpawnY =
  1213. +NewCharSpawnZ =
  1214. +
  1215. +# Set The Base of The First Faction
  1216. +FirstFactionBaseSpawnX =
  1217. +FirstFactionBaseSpawnY =
  1218. +FirstFactionBaseSpawnZ =
  1219. +
  1220. +# Set The Base of The Second Faction
  1221. +SecondFactionBaseSpawnX =
  1222. +SecondFactionBaseSpawnY =
  1223. +SecondFactionBaseSpawnZ =
  1224. +
  1225. +# Set All The New Characters At the Selected Level On Their Creation?
  1226. +NewCharLevel75 = False
  1227. +NewCharLevel80 = False
  1228. +NewCharLevel85 = False
  1229. +
  1230. +# Allow Trade Between Two Factions?
  1231. +AllowTradeBetweenFactions = False
  1232. +
  1233. +# Allow Buy Between Two Factions?
  1234. +AllowBuyBetweenFactions = False
  1235. +
  1236. +# Set All The New Characters Noblesse , On Their Creation?
  1237. +NewCharSetNoblesse = False
  1238. +
  1239. +# Set All The New Characters Heroes , On Their Creation?
  1240. +NewCharSetHero = False
  1241. +
  1242. +# Set The Name Color of The First Faction
  1243. +# Values Must Be In RGB
  1244. +FirstFactionNameColor =
  1245. +
  1246. +# Set The Name Color of The Second Creation
  1247. +# Values Must Be In RGB
  1248. +SecondFactionNameColor =
  1249. +
  1250. +# Set The Title Color of The First Faction
  1251. +# Values Must Be In RGB
  1252. +FirstFactionTitleColor =
  1253. +
  1254. +# Set The Title Color of The Second Faction
  1255. +# Values Must Be In RGB
  1256. +SecondFactionTitleColor =
  1257. +
  1258. +# Set The Alternative Warehouse Deposit Fee
  1259. +AltWarehouseDepositFee = 0
  1260. +
  1261. +# Allow Reward for Each PvP?
  1262. +AllowPvPReward = False
  1263. +
  1264. +# Set The Item You Want as a Reward
  1265. +PvPRewardID = 57
  1266. +
  1267. +# Set The Amount of The Reward
  1268. +PvPRewardAmount = 1
  1269. \ No newline at end of file
Add Comment
Please, Sign In to add comment