Advertisement
Guest User

AvD Triple Faction Mod

a guest
Aug 15th, 2011
1,318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 126.54 KB | None | 0 0
  1. Index: config/factions.properties
  2. ===================================================================
  3. --- config/factions.properties  (revision 0)
  4. +++ config/factions.properties  (revision 0)
  5. @@ -0,0 +1,110 @@
  6. +#=============================================================
  7. +#                      Faction Engine
  8. +#=============================================================
  9. +#Enable Triple Faction Engine by Kic2Ass
  10. +FactionEngineEnabled = True
  11. +
  12. +#Faction Names
  13. +Team1Name = Angels
  14. +Team2Name = Demons
  15. +Team3Name = Fallens
  16. +#Team Name Colors in RGB format.
  17. +Team1ColorName = 00FFFF
  18. +Team2ColorName = 00FF00
  19. +Team3ColorName = 00FF00
  20. +
  21. +#Custom levels at start and for subclass.
  22. +StartingLevel = 75
  23. +StartingLevelSubClass = 75
  24. +
  25. +#Enable or Disable Item Rewards in Pvp and Pk
  26. +FactionPlayerGetItemByPvP = True
  27. +#Item Amount (Player will receive - (FactionEngineAmmountItemRewardPvp * Faction Flags Number))
  28. +FactionEngineAmmountItemRewardPvp = 1
  29. +#Item ID, which player will receive in PVP
  30. +FactionPvPItemRewardID = 57
  31. +
  32. +#Enable or Disable Item Rewards in Pvp and Pk for Party members
  33. +FactionPlayerGetItemByPvPInParty = True
  34. +#Party Reward only for support classes
  35. +PartyRewardOnlySupportClass = True
  36. +#Default 100%
  37. +Chance = 100
  38. +#Reward item ids
  39. +PartyReward1 = 57
  40. +PartyReward2 = 57
  41. +PartyReward3 = 57
  42. +PartyReward4 = 57
  43. +PartyReward5 = 57
  44. +PartyReward6 = 57
  45. +PartyReward7 = 57
  46. +PartyReward8 = 57
  47. +PartyReward9 = 57
  48. +PartyReward10 = 57
  49. +#Reward amounts
  50. +PartyAmount1 = 1
  51. +PartyAmount2 = 2
  52. +PartyAmount3 = 3
  53. +PartyAmount4 = 5
  54. +PartyAmount5 = 4
  55. +PartyAmount6 = 6
  56. +PartyAmount7 = 8
  57. +PartyAmount8 = 7
  58. +PartyAmount9 = 9
  59. +PartyAmount10 = 10
  60. +
  61. +#Enable or Disable skill points and ancient adena reward by capturing enemy flag
  62. +FactionPlayerGetSpAAFlag = True
  63. +#Skill points amount, which player will receive by capturing enemy flag (first - clan level 1-5)(second - clan level 5-7)(third - clan level 7-8)(no clan - third)
  64. +FactionEngineAmmountSpFirstFlag = 1000
  65. +FactionEngineAmmountSpSecondFlag = 500
  66. +FactionEngineAmmountSpThirdFlag = 250
  67. +#Ancient Adena amount, which player will receive by capturing enemy flag (first - clan level 1-5)(second - clan level 5-7)(third - clan level 7-8)
  68. +FactionEngineAmmountAAFirstFlag = 15
  69. +FactionEngineAmmountAASecondFlag = 10
  70. +FactionEngineAmmountAAThirdFlag = 5
  71. +
  72. +#Enable or Disable experience gain in PVP
  73. +FactionPlayerGetExp = True
  74. +#Experience reward in PVP (first - lvl75-76)(second - lvl76-78)(third - lvl 78-80)
  75. +FactionExpRewardInPvpFirst = 1000000
  76. +FactionExpRewardInPvpSecond = 500000
  77. +FactionExpRewardInPvpThird = 250000
  78. +#Faction points reward by capturing enemy base
  79. +FactionPointsRewardFlag = 5
  80. +#Faction points reward by killing enemy faction member
  81. +FactionPointsRewardPvp = 3
  82. +
  83. +#Team1 Faction Base location
  84. +FactionTeam1BaseX = 147453
  85. +FactionTeam1BaseY = 27502
  86. +FactionTeam1BaseZ = -2204
  87. +#Team2 Faction Base location
  88. +FactionTeam2BaseX = 147741
  89. +FactionTeam2BaseY = -55566
  90. +FactionTeam2BaseZ = -2734
  91. +#Team3 Faction Base location
  92. +FactionTeam3BaseX = 147741
  93. +FactionTeam3BaseY = -55566
  94. +FactionTeam3BaseZ = -2734
  95. +#Spawn location for newbies (Faction engine must be enabled)
  96. +FactionCustomSpawnX = 147453
  97. +FactionCustomSpawnY = 27502
  98. +FactionCustomSpawnZ = -2204
  99. +
  100. +#Enable or Disable .online command to see online status of all factions
  101. +EnableOnlinePlayersVC = True
  102. +#Show online status of all factions on login
  103. +EnableOnlinePlayersEnterworld = True
  104. +
  105. +#Enable or Disable anti pvp farm by IP protection
  106. +EnableProtectionIP = True
  107. +#Enable or Disable anti pvp farm on same clan
  108. +EnableProtectionClan = True
  109. +#Enable or Disable anti pvp farm on same ally
  110. +EnableProtectionAlly = True
  111. +#Enable or Disable anti pvp farm by PDef protection (If target Pdef is less than "ProtectionArmourAmount" , player won't be rewarded)
  112. +EnableProtectionArmour = True
  113. +ProtectionArmourAmount = 300
  114. \ No newline at end of file
  115. Index: java/net/sf/l2j/Config.java
  116. ===================================================================
  117. --- java/net/sf/l2j/Config.java (revision 128)
  118. +++ java/net/sf/l2j/Config.java (working copy)
  119. @@ -60,10 +60,83 @@
  120.     public static final String  SERVER_FILE = "./config/server.properties";
  121.     public static final String  SIEGE_FILE = "./config/siege.properties";
  122.     public static final String  TELNET_FILE = "./config/telnet.properties";
  123. +   public static final String  FACTION_ENGINE_FILE = "./config/factions.properties";
  124.    
  125.     /**--------------------------------------------------
  126.     // Variable Definitions
  127.     //-------------------------------------------------*/
  128. +  
  129. +   //--------------------------------------------------
  130. +   // Faction Engine Configurations
  131. +   //--------------------------------------------------
  132. +   public static boolean FACTION_ONLYSUPPORTS;
  133. +   public static boolean FACTION_ENGINE_ENABLED;
  134. +   public static boolean FACTION_ALLOW_ITEM_REWARD_PARTY;
  135. +   public static boolean FACTION_ALLOW_ITEM_REWARD;
  136. +   public static boolean FACTION_ALLOW_EXP_REWARD;
  137. +   public static boolean FACTION_ALLOW_SP_REWARD_FLAG;
  138. +   public static int FACTION_ITEM_NUMBER_REWARD_ON_PVP;
  139. +   public static int FACTION_TEAM1_COLOR;
  140. +   public static int FACTION_TEAM2_COLOR;
  141. +   public static int FACTION_TEAM3_COLOR;
  142. +   public static int FACTION_START_LVL;
  143. +   public static int FACTION_START_LVL_SUB;
  144. +   public static int FACTION_CHANCE;
  145. +   public static int FACTION_PARTY_REWARD1;
  146. +   public static int FACTION_PARTY_REWARD2;
  147. +   public static int FACTION_PARTY_REWARD3;
  148. +   public static int FACTION_PARTY_REWARD4;
  149. +   public static int FACTION_PARTY_REWARD5;
  150. +   public static int FACTION_PARTY_REWARD6;
  151. +   public static int FACTION_PARTY_REWARD7;
  152. +   public static int FACTION_PARTY_REWARD8;
  153. +   public static int FACTION_PARTY_REWARD9;
  154. +   public static int FACTION_PARTY_REWARD10;
  155. +   public static int FACTION_PARTY_REWARD_AMMOUNT1;
  156. +   public static int FACTION_PARTY_REWARD_AMMOUNT2;
  157. +   public static int FACTION_PARTY_REWARD_AMMOUNT3;
  158. +   public static int FACTION_PARTY_REWARD_AMMOUNT4;
  159. +   public static int FACTION_PARTY_REWARD_AMMOUNT5;
  160. +   public static int FACTION_PARTY_REWARD_AMMOUNT6;
  161. +   public static int FACTION_PARTY_REWARD_AMMOUNT7;
  162. +   public static int FACTION_PARTY_REWARD_AMMOUNT8;
  163. +   public static int FACTION_PARTY_REWARD_AMMOUNT9;
  164. +   public static int FACTION_PARTY_REWARD_AMMOUNT10;
  165. +   public static String FACTION_TEAM1_NAME;
  166. +   public static String FACTION_TEAM2_NAME;
  167. +   public static String FACTION_TEAM3_NAME;   
  168. +   public static int FACTION_TEAM1_BASE_X;
  169. +   public static int FACTION_TEAM1_BASE_Y;
  170. +   public static int FACTION_TEAM1_BASE_Z;
  171. +   public static int FACTION_TEAM2_BASE_X;
  172. +   public static int FACTION_TEAM2_BASE_Y;
  173. +   public static int FACTION_TEAM2_BASE_Z;
  174. +   public static int FACTION_TEAM3_BASE_X;
  175. +   public static int FACTION_TEAM3_BASE_Y;
  176. +   public static int FACTION_TEAM3_BASE_Z;
  177. +   public static int FACTION_CUSTOM_SPAWN_X;
  178. +   public static int FACTION_CUSTOM_SPAWN_Y;
  179. +   public static int FACTION_CUSTOM_SPAWN_Z;
  180. +   public static int FACTION_ITEM_REWARD_ID_PVP;
  181. +   public static int FACTION_SP_REWARD_FIRST_FLAG;
  182. +   public static int FACTION_SP_REWARD_SECOND_FLAG;
  183. +   public static int FACTION_SP_REWARD_THIRD_FLAG;
  184. +   public static int FACTION_AA_REWARD_FIRST_FLAG;
  185. +   public static int FACTION_AA_REWARD_SECOND_FLAG;
  186. +   public static int FACTION_AA_REWARD_THIRD_FLAG;
  187. +   public static int FACTION_EXP_REWARD_PVP_FIRST;
  188. +   public static int FACTION_EXP_REWARD_PVP_SECOND;
  189. +   public static int FACTION_EXP_REWARD_PVP_THIRD;
  190. +   public static int FACTION_POINTS_PVP;
  191. +   public static int FACTION_POINTS_FLAG;
  192. +   public static boolean ENABLE_ONLINE_VC;
  193. +   public static boolean ENABLE_ONLINE_PLAYERS_ON_ENTERWORLD;
  194. +   public static boolean ENABLE_DUALBOX_PROTECTION_IP;
  195. +   public static boolean ENABLE_DUALBOX_PROTECTION_CLAN;
  196. +   public static boolean ENABLE_DUALBOX_PROTECTION_ALLY;
  197. +   public static boolean ENABLE_DUALBOX_PROTECTION_ARM;
  198. +   public static int PROTECTION_ARMOUR_AMOUNT;
  199.    
  200.     //--------------------------------------------------
  201.     // Clans settings
  202. @@ -690,7 +763,91 @@
  203.         if (Server.serverMode == Server.MODE_GAMESERVER)
  204.         {
  205.             _log.info("Loading gameserver configuration files.");
  206. +          
  207. +      
  208. +           // Load Faction Engine Config File
  209. +           try
  210. +           {
  211. +               Properties factionEngine            = new Properties();
  212. +               InputStream is                      = new FileInputStream(new File(FACTION_ENGINE_FILE));
  213. +               factionEngine.load(is);
  214. +               is.close();
  215.  
  216. +               FACTION_ENGINE_ENABLED = Boolean.parseBoolean(factionEngine.getProperty("FactionEngineEnabled", "False"));
  217. +               FACTION_TEAM1_NAME = factionEngine.getProperty("Team1Name", "Angels");
  218. +               FACTION_TEAM2_NAME = factionEngine.getProperty("Team2Name", "Demons");
  219. +               FACTION_TEAM3_NAME = factionEngine.getProperty("Team3Name", "Fallens");            
  220. +               FACTION_TEAM1_COLOR = Integer.decode("0x" + factionEngine.getProperty("Team1ColorName", "000000"));
  221. +               FACTION_TEAM2_COLOR = Integer.decode("0x" + factionEngine.getProperty("Team2ColorName", "000000"));
  222. +               FACTION_TEAM3_COLOR = Integer.decode("0x" + factionEngine.getProperty("Team3ColorName", "000000"));
  223. +               FACTION_START_LVL = Integer.parseInt(factionEngine.getProperty("StartingLevel", "1"));
  224. +               FACTION_START_LVL_SUB = Integer.parseInt(factionEngine.getProperty("StartingLevelSubClass", "40"));
  225. +               FACTION_ALLOW_ITEM_REWARD = Boolean.parseBoolean(factionEngine.getProperty("FactionPlayerGetItemByPvP", "False"));
  226. +               FACTION_ITEM_NUMBER_REWARD_ON_PVP = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountItemRewardPvp", "3"));
  227. +               FACTION_ITEM_REWARD_ID_PVP = Integer.parseInt(factionEngine.getProperty("FactionPvPItemRewardID", "57"));
  228. +               FACTION_ALLOW_ITEM_REWARD_PARTY = Boolean.parseBoolean(factionEngine.getProperty("FactionPlayerGetItemByPvPInParty", "False"));
  229. +               FACTION_ONLYSUPPORTS = Boolean.parseBoolean(factionEngine.getProperty("PartyRewardOnlySupportClass", "False"));
  230. +               FACTION_CHANCE = Integer.parseInt(factionEngine.getProperty("Chance", "100"));
  231. +                FACTION_PARTY_REWARD1 = Integer.parseInt(factionEngine.getProperty("PartyReward1", "57"));
  232. +                FACTION_PARTY_REWARD2 = Integer.parseInt(factionEngine.getProperty("PartyReward2", "57"));
  233. +                FACTION_PARTY_REWARD3 = Integer.parseInt(factionEngine.getProperty("PartyReward3", "57"));
  234. +                FACTION_PARTY_REWARD4 = Integer.parseInt(factionEngine.getProperty("PartyReward4", "57"));
  235. +                FACTION_PARTY_REWARD5 = Integer.parseInt(factionEngine.getProperty("PartyReward5", "57"));
  236. +                FACTION_PARTY_REWARD6 = Integer.parseInt(factionEngine.getProperty("PartyReward6", "57"));
  237. +                FACTION_PARTY_REWARD7 = Integer.parseInt(factionEngine.getProperty("PartyReward7", "57"));
  238. +                FACTION_PARTY_REWARD8 = Integer.parseInt(factionEngine.getProperty("PartyReward8", "57"));
  239. +                FACTION_PARTY_REWARD9 = Integer.parseInt(factionEngine.getProperty("PartyReward9", "57"));
  240. +                FACTION_PARTY_REWARD10 = Integer.parseInt(factionEngine.getProperty("PartyReward10", "57"));
  241. +                FACTION_PARTY_REWARD_AMMOUNT1 = Integer.parseInt(factionEngine.getProperty("PartyAmount1", "1"));
  242. +                FACTION_PARTY_REWARD_AMMOUNT2 = Integer.parseInt(factionEngine.getProperty("PartyAmount2", "1"));
  243. +                FACTION_PARTY_REWARD_AMMOUNT3 = Integer.parseInt(factionEngine.getProperty("PartyAmount3", "1"));
  244. +                FACTION_PARTY_REWARD_AMMOUNT4 = Integer.parseInt(factionEngine.getProperty("PartyAmount4", "1"));
  245. +                FACTION_PARTY_REWARD_AMMOUNT5 = Integer.parseInt(factionEngine.getProperty("PartyAmount5", "1"));
  246. +                FACTION_PARTY_REWARD_AMMOUNT6 = Integer.parseInt(factionEngine.getProperty("PartyAmount6", "1"));
  247. +                FACTION_PARTY_REWARD_AMMOUNT7 = Integer.parseInt(factionEngine.getProperty("PartyAmount7", "1"));
  248. +                FACTION_PARTY_REWARD_AMMOUNT8 = Integer.parseInt(factionEngine.getProperty("PartyAmount8", "1"));
  249. +                FACTION_PARTY_REWARD_AMMOUNT9 = Integer.parseInt(factionEngine.getProperty("PartyAmount9", "1"));
  250. +               FACTION_PARTY_REWARD_AMMOUNT10 = Integer.parseInt(factionEngine.getProperty("PartyAmount10", "1"));
  251. +               FACTION_ALLOW_SP_REWARD_FLAG = Boolean.parseBoolean(factionEngine.getProperty("FactionPlayerGetSpAAFlag", "False"));
  252. +               FACTION_SP_REWARD_FIRST_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountSpFirstFlag", "1000"));
  253. +               FACTION_SP_REWARD_SECOND_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountSpSecondFlag", "500"));
  254. +               FACTION_SP_REWARD_THIRD_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountSpThirdFlag", "250"));
  255. +               FACTION_AA_REWARD_FIRST_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountAAFirstFlag", "1000"));
  256. +               FACTION_AA_REWARD_SECOND_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountAASecondFlag", "500"));
  257. +               FACTION_AA_REWARD_THIRD_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountAAThirdFlag", "250"));
  258. +               FACTION_ALLOW_EXP_REWARD = Boolean.parseBoolean(factionEngine.getProperty("FactionPlayerGetExp", "False"));
  259. +               FACTION_EXP_REWARD_PVP_FIRST = Integer.parseInt(factionEngine.getProperty("FactionExpRewardInPvpFirst", "1000000"));
  260. +               FACTION_EXP_REWARD_PVP_SECOND = Integer.parseInt(factionEngine.getProperty("FactionExpRewardInPvpSecond", "500000"));
  261. +               FACTION_EXP_REWARD_PVP_THIRD = Integer.parseInt(factionEngine.getProperty("FactionExpRewardInPvpThird", "250000"));
  262. +               FACTION_POINTS_FLAG = Integer.parseInt(factionEngine.getProperty("FactionPointsRewardFlag", "5"));
  263. +               FACTION_POINTS_PVP = Integer.parseInt(factionEngine.getProperty("FactionPointsRewardPvp", "3"));
  264. +               FACTION_TEAM1_BASE_X = Integer.parseInt(factionEngine.getProperty("FactionTeam1BaseX", "0"));
  265. +               FACTION_TEAM1_BASE_Y = Integer.parseInt(factionEngine.getProperty("FactionTeam1BaseY", "0"));
  266. +               FACTION_TEAM1_BASE_Z = Integer.parseInt(factionEngine.getProperty("FactionTeam1BaseZ", "0"));
  267. +               FACTION_TEAM2_BASE_X = Integer.parseInt(factionEngine.getProperty("FactionTeam2BaseX", "0"));
  268. +               FACTION_TEAM2_BASE_Y = Integer.parseInt(factionEngine.getProperty("FactionTeam2BaseY", "0"));
  269. +               FACTION_TEAM2_BASE_Z = Integer.parseInt(factionEngine.getProperty("FactionTeam2BaseZ", "0"));
  270. +               FACTION_TEAM3_BASE_X = Integer.parseInt(factionEngine.getProperty("FactionTeam3BaseX", "0"));
  271. +               FACTION_TEAM3_BASE_Y = Integer.parseInt(factionEngine.getProperty("FactionTeam3BaseY", "0"));
  272. +               FACTION_TEAM3_BASE_Z = Integer.parseInt(factionEngine.getProperty("FactionTeam3BaseZ", "0"));              
  273. +               FACTION_CUSTOM_SPAWN_X = Integer.parseInt(factionEngine.getProperty("FactionCustomSpawnX", "0"));
  274. +               FACTION_CUSTOM_SPAWN_Y = Integer.parseInt(factionEngine.getProperty("FactionCustomSpawnY", "0"));
  275. +               FACTION_CUSTOM_SPAWN_Z = Integer.parseInt(factionEngine.getProperty("FactionCustomSpawnZ", "0"));
  276. +               ENABLE_ONLINE_VC = Boolean.parseBoolean(factionEngine.getProperty("EnableOnlinePlayersVC", "False"));
  277. +               ENABLE_ONLINE_PLAYERS_ON_ENTERWORLD = Boolean.parseBoolean(factionEngine.getProperty("EnableOnlinePlayersEnterworld", "False"));
  278. +               ENABLE_DUALBOX_PROTECTION_IP = Boolean.parseBoolean(factionEngine.getProperty("EnableProtectionIP", "False"));
  279. +               ENABLE_DUALBOX_PROTECTION_CLAN = Boolean.parseBoolean(factionEngine.getProperty("EnableProtectionClan", "False"));
  280. +               ENABLE_DUALBOX_PROTECTION_ALLY = Boolean.parseBoolean(factionEngine.getProperty("EnableProtectionAlly", "False"));
  281. +               ENABLE_DUALBOX_PROTECTION_ARM = Boolean.parseBoolean(factionEngine.getProperty("EnableProtectionArmour", "False"));
  282. +               PROTECTION_ARMOUR_AMOUNT = Integer.parseInt(factionEngine.getProperty("ProtectionArmourAmount", "0"));
  283. +           }
  284. +           catch (Exception e)
  285. +           {
  286. +               e.printStackTrace();
  287. +               throw new Error("Server failed to load "+FACTION_ENGINE_FILE+" file.");
  288. +           }
  289. +          
  290.             // Clans settings
  291.             try
  292.             {
  293. Index: java/net/sf/l2j/gameserver/GameServer.java
  294. ===================================================================
  295. --- java/net/sf/l2j/gameserver/GameServer.java  (revision 128)
  296. +++ java/net/sf/l2j/gameserver/GameServer.java  (working copy)
  297. @@ -68,6 +68,7 @@
  298. import net.sf.l2j.gameserver.handler.ItemHandler;
  299. import net.sf.l2j.gameserver.handler.SkillHandler;
  300. import net.sf.l2j.gameserver.handler.UserCommandHandler;
  301. +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  302. import net.sf.l2j.gameserver.idfactory.IdFactory;
  303. import net.sf.l2j.gameserver.instancemanager.AuctionManager;
  304. import net.sf.l2j.gameserver.instancemanager.BoatManager;
  305. @@ -102,6 +103,9 @@
  306. import net.sf.l2j.status.Status;
  307. import net.sf.l2j.util.IPv4Filter;
  308.  
  309. +import net.sf.l2j.gameserver.model.entity.FactionMaps;
  310. +import net.sf.l2j.gameserver.model.actor.instance.L2TpFlagInstance;
  311. +
  312. import org.mmocore.network.SelectorConfig;
  313. import org.mmocore.network.SelectorThread;
  314.  
  315. @@ -209,6 +213,15 @@
  316.         printSection("Olympiad");
  317.         Olympiad.getInstance();
  318.         Hero.getInstance();
  319. +      
  320. +       printSection("Faction Engine");
  321. +       if (Config.FACTION_ENGINE_ENABLED)
  322. +       {
  323. +           FactionMaps.loadCurrentMap();
  324. +           L2TpFlagInstance.spawnFlags();
  325. +       }
  326. +       else
  327. +           System.out.println("Faction Engine is currently disabled.");
  328.        
  329.         printSection("Cache");
  330.         HtmCache.getInstance();
  331. @@ -255,6 +268,7 @@
  332.         _log.config("ItemHandler: Loaded " + ItemHandler.getInstance().size() + " handlers.");
  333.         _log.config("SkillHandler: Loaded " + SkillHandler.getInstance().size() + " handlers.");
  334.         _log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
  335. +       _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
  336.                        
  337.         if (Config.ALLOW_WEDDING)
  338.             CoupleManager.getInstance();
  339. Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
  340. ===================================================================
  341. --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java    (revision 128)
  342. +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java    (working copy)
  343. @@ -15,8 +15,13 @@
  344. package net.sf.l2j.gameserver.handler.chathandlers;
  345.  
  346. import java.util.Collection;
  347. +import java.util.StringTokenizer;
  348. +import java.util.logging.Logger;
  349.  
  350. +import net.sf.l2j.Config;
  351. import net.sf.l2j.gameserver.handler.IChatHandler;
  352. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  353. +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
  354. import net.sf.l2j.gameserver.model.BlockList;
  355. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  356. import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  357. @@ -29,6 +34,7 @@
  358. public class ChatAll implements IChatHandler
  359. {
  360.     private static final int[] COMMAND_IDS = { 0 };
  361. +   private static Logger _log = Logger.getLogger(ChatAll.class.getName());
  362.  
  363.     /**
  364.      * Handle chat type 'all'
  365. @@ -36,16 +42,53 @@
  366.      */
  367.     public void handleChat(int type, L2PcInstance activeChar, String params, String text)
  368.     {
  369. -       CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  370. -       Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  371. -
  372. -       for (L2PcInstance player : plrs)
  373. +       boolean vcd_used = false;
  374. +       if (text.startsWith("."))
  375.         {
  376. -           if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
  377. -               player.sendPacket(cs);
  378. +           StringTokenizer st = new StringTokenizer(text);
  379. +           IVoicedCommandHandler vch;
  380. +           String command = "";
  381. +          
  382. +           if (st.countTokens() > 1)
  383. +           {
  384. +               command = st.nextToken().substring(1);
  385. +               params = text.substring(command.length() + 2);
  386. +               vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
  387. +           }
  388. +           else
  389. +           {
  390. +               command = text.substring(1);
  391. +               if (Config.DEBUG)
  392. +                   _log.info("Command: " + command);
  393. +               vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
  394. +           }
  395. +          
  396. +           if (vch != null)
  397. +           {
  398. +               vch.useVoicedCommand(command, activeChar, params);
  399. +               vcd_used = true;
  400. +           }
  401. +           else
  402. +           {
  403. +               if (Config.DEBUG)
  404. +                   _log.warning("No handler registered for bypass '" + command + "'");
  405. +               vcd_used = false;
  406. +           }
  407.         }
  408. +      
  409. +       if (!vcd_used)
  410. +       {
  411. +           CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  412. +           Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
  413. +
  414. +           for (L2PcInstance player : plrs)
  415. +           {
  416. +               if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
  417. +                   player.sendPacket(cs);
  418. +           }
  419.            
  420. -       activeChar.sendPacket(cs);
  421. +           activeChar.sendPacket(cs);
  422. +       }
  423.     }
  424.  
  425.     /**
  426. Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
  427. ===================================================================
  428. --- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java   (revision 0)
  429. +++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java   (revision 0)
  430. @@ -0,0 +1,43 @@
  431. +/*
  432. + * This program is free software; you can redistribute it and/or modify
  433. + * it under the terms of the GNU General Public License as published by
  434. + * the Free Software Foundation; either version 2, or (at your option)
  435. + * any later version.
  436. + *
  437. + * This program is distributed in the hope that it will be useful,
  438. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  439. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  440. + * GNU General Public License for more details.
  441. + *
  442. + * You should have received a copy of the GNU General Public License
  443. + * along with this program; if not, write to the Free Software
  444. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  445. + * 02111-1307, USA.
  446. + *
  447. + * http://www.gnu.org/copyleft/gpl.html
  448. + */
  449. +package net.sf.l2j.gameserver.handler;
  450. +
  451. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  452. +
  453. +/**
  454. + * This class ...
  455. + *
  456. + * @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:09 $
  457. + */
  458. +public interface IVoicedCommandHandler
  459. +{
  460. +    /**
  461. +     * this is the worker method that is called when someone uses an admin command.
  462. +     * @param activeChar
  463. +     * @param command
  464. +     * @return command success
  465. +     */
  466. +    public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target);
  467. +
  468. +    /**
  469. +     * this method is called at initialization to register all the item ids automatically
  470. +     * @return all known itemIds
  471. +     */
  472. +    public String[] getVoicedCommandList();
  473. +}
  474. \ No newline at end of file
  475. Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  476. ===================================================================
  477. --- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java    (revision 0)
  478. +++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java    (revision 0)
  479. @@ -0,0 +1,83 @@
  480. +/*
  481. + * This program is free software; you can redistribute it and/or modify
  482. + * it under the terms of the GNU General Public License as published by
  483. + * the Free Software Foundation; either version 2, or (at your option)
  484. + * any later version.
  485. + *
  486. + * This program is distributed in the hope that it will be useful,
  487. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  488. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  489. + * GNU General Public License for more details.
  490. + *
  491. + * You should have received a copy of the GNU General Public License
  492. + * along with this program; if not, write to the Free Software
  493. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  494. + * 02111-1307, USA.
  495. + *
  496. + * http://www.gnu.org/copyleft/gpl.html
  497. + */
  498. +package net.sf.l2j.gameserver.handler;
  499. +
  500. +import java.util.Map;
  501. +import java.util.logging.Logger;
  502. +
  503. +import javolution.util.FastMap;
  504. +import net.sf.l2j.Config;
  505. +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.OnlinePlayers;
  506. +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Points;
  507. +
  508. +public class VoicedCommandHandler
  509. +{
  510. +    private static Logger _log = Logger.getLogger(ItemHandler.class.getName());
  511. +
  512. +    private static VoicedCommandHandler             _instance;
  513. +    private Map<String, IVoicedCommandHandler>      _datatable;
  514. +
  515. +    public static VoicedCommandHandler getInstance()
  516. +    {
  517. +        if (_instance == null)
  518. +            _instance = new VoicedCommandHandler();
  519. +              
  520. +        return _instance;
  521. +    }
  522. +
  523. +    private VoicedCommandHandler()
  524. +    {
  525. +        _datatable = new FastMap<String, IVoicedCommandHandler>();
  526. +
  527. +       if (Config.FACTION_ENGINE_ENABLED)
  528. +       {
  529. +           if (Config.ENABLE_ONLINE_VC)
  530. +               registerVoicedCommandHandler(new OnlinePlayers());
  531. +           registerVoicedCommandHandler(new Points());
  532. +       }
  533. +    }
  534. +
  535. +    public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
  536. +    {
  537. +        String[] ids = handler.getVoicedCommandList();
  538. +        for (int i = 0; i < ids.length; i++)
  539. +            {
  540. +                if (Config.DEBUG) _log.fine("Adding handler for command "+ids[i]);
  541. +                        _datatable.put(ids[i], handler);
  542. +            }
  543. +    }
  544. +
  545. +    public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
  546. +    {
  547. +        String command = voicedCommand;
  548. +              
  549. +        if (voicedCommand.indexOf(" ") != -1)
  550. +            command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
  551. +              
  552. +        if (Config.DEBUG)
  553. +            _log.fine("getting handler for command: "+command+" -> "+(_datatable.get(command) != null));
  554. +
  555. +        return _datatable.get(command);
  556. +    }
  557. +
  558. +    public int size()
  559. +    {
  560. +        return _datatable.size();
  561. +    }
  562. +}
  563. \ No newline at end of file
  564. Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/OnlinePlayers.java
  565. ===================================================================
  566. --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/OnlinePlayers.java (revision 0)
  567. +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/OnlinePlayers.java (revision 0)
  568. @@ -0,0 +1,44 @@
  569. +/*
  570. + * This program is free software: you can redistribute it and/or modify it under
  571. + * the terms of the GNU General Public License as published by the Free Software
  572. + * Foundation, either version 3 of the License, or (at your option) any later
  573. + * version.
  574. + *
  575. + * This program is distributed in the hope that it will be useful, but WITHOUT
  576. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  577. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  578. + * details.
  579. + *
  580. + * You should have received a copy of the GNU General Public License along with
  581. + * this program. If not, see <http://www.gnu.org/licenses/>.
  582. + */
  583. +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  584. +
  585. +import net.sf.l2j.Config;
  586. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  587. +import net.sf.l2j.gameserver.model.L2World;
  588. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  589. +
  590. +public class OnlinePlayers implements IVoicedCommandHandler
  591. +{
  592. +    private static final String[] _voicedCommands = { "online" };
  593. +
  594. +    public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  595. +    { 
  596. +        if (command.equalsIgnoreCase("online"))
  597. +        {
  598. +           activeChar.sendMessage("--------------------------------------------------------------");
  599. +           activeChar.sendMessage(Config.FACTION_TEAM1_NAME + ": " + L2World.getInstance().getAllteam1Players().size());
  600. +           activeChar.sendMessage(Config.FACTION_TEAM2_NAME + ": " + L2World.getInstance().getAllteam2Players().size());
  601. +           activeChar.sendMessage(Config.FACTION_TEAM3_NAME + ": " + L2World.getInstance().getAllteam3Players().size());
  602. +           activeChar.sendMessage("Total: " + L2World.getInstance().getAllPlayersCount() + " online.");
  603. +           activeChar.sendMessage("--------------------------------------------------------------");
  604. +        }
  605. +       return false;
  606. +    }
  607. +
  608. +    public String[] getVoicedCommandList()
  609. +    {
  610. +        return _voicedCommands;
  611. +    }
  612. +}
  613. \ No newline at end of file
  614. Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Points.java
  615. ===================================================================
  616. --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Points.java    (revision 0)
  617. +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Points.java    (revision 0)
  618. @@ -0,0 +1,69 @@
  619. +/*
  620. + * This program is free software: you can redistribute it and/or modify it under
  621. + * the terms of the GNU General Public License as published by the Free Software
  622. + * Foundation, either version 3 of the License, or (at your option) any later
  623. + * version.
  624. + *
  625. + * This program is distributed in the hope that it will be useful, but WITHOUT
  626. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  627. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  628. + * details.
  629. + *
  630. + * You should have received a copy of the GNU General Public License along with
  631. + * this program. If not, see <http://www.gnu.org/licenses/>.
  632. + */
  633. +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  634. +
  635. +import net.sf.l2j.Config;
  636. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  637. +import net.sf.l2j.gameserver.model.L2World;
  638. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  639. +import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
  640. +
  641. +public class Points implements IVoicedCommandHandler
  642. +{
  643. +    private static final String[] _voicedCommands = { "points" };
  644. +
  645. +    public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  646. +    {
  647. +        if (command.equalsIgnoreCase("points"))
  648. +        {
  649. +           int team1 = 0;
  650. +           int team2 = 0;
  651. +           int team3 = 0;
  652. +           for (L2PcInstance zaidejas1 : L2World.getInstance().getAllteam1Players())
  653. +               team1 = zaidejas1.getFactionPoints();
  654. +           for (L2PcInstance zaidejas2 : L2World.getInstance().getAllteam2Players())
  655. +               team2 = zaidejas2.getFactionPoints();
  656. +           for (L2PcInstance zaidejas3 : L2World.getInstance().getAllteam3Players())
  657. +               team3 = zaidejas3.getFactionPoints();
  658. +
  659. +           int taskai = 0;
  660. +           if (activeChar.getFactionId() == 1)
  661. +               taskai = team1;
  662. +           if (activeChar.getFactionId() == 2)
  663. +               taskai = team2;
  664. +           if (activeChar.getFactionId() == 3)
  665. +               taskai = team3;
  666. +           if (activeChar.getFactionId() > 0)
  667. +           {
  668. +               activeChar.sendMessage("--------------------------------------------------------------");
  669. +               activeChar.sendMessage("Your points: " + activeChar.getFactionPoints());
  670. +               activeChar.sendMessage("Your faction points: " + taskai);
  671. +               activeChar.sendMessage("Winning Faction members will get special reward!");
  672. +               activeChar.sendMessage("--------------------------------------------------------------");
  673. +           }
  674. +           else
  675. +           {
  676. +               activeChar.sendPacket(new PlaySound("monsound5.frintessa_shout2"));
  677. +               activeChar.sendMessage("Please chose your faction at Faction manager!");
  678. +           }
  679. +        }
  680. +       return false;
  681. +    }
  682. +
  683. +    public String[] getVoicedCommandList()
  684. +    {
  685. +        return _voicedCommands;
  686. +    }
  687. +}
  688. \ No newline at end of file
  689. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java
  690. ===================================================================
  691. --- java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java  (revision 0)
  692. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java  (revision 0)
  693. @@ -0,0 +1,309 @@
  694. +/*
  695. + * This program is free software; you can redistribute it and/or modify
  696. + * it under the terms of the GNU General Public License as published by
  697. + * the Free Software Foundation; either version 2, or (at your option)
  698. + * any later version.
  699. + *
  700. + * This program is distributed in the hope that it will be useful,
  701. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  702. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  703. + * GNU General Public License for more details.
  704. + *
  705. + * You should have received a copy of the GNU General Public License
  706. + * along with this program; if not, write to the Free Software
  707. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  708. + * 02111-1307, USA.
  709. + *
  710. + * http://www.gnu.org/copyleft/gpl.html
  711. + */
  712. +package net.sf.l2j.gameserver.model.actor.instance;
  713. +
  714. +import java.sql.Connection;
  715. +import java.sql.PreparedStatement;
  716. +import java.sql.ResultSet;
  717. +import java.util.StringTokenizer;
  718. +import java.util.logging.Logger;
  719. +
  720. +import net.sf.l2j.Config;
  721. +import net.sf.l2j.L2DatabaseFactory;
  722. +import net.sf.l2j.gameserver.ThreadPoolManager;
  723. +import net.sf.l2j.gameserver.ai.CtrlIntention;
  724. +import net.sf.l2j.gameserver.datatables.MapRegionTable;
  725. +import net.sf.l2j.gameserver.model.L2World;
  726. +import net.sf.l2j.gameserver.model.base.Experience;
  727. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  728. +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
  729. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  730. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  731. +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  732. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  733. +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
  734. +import net.sf.l2j.util.StringUtil;
  735. +import net.sf.l2j.util.Rnd;
  736. +
  737. +public final class L2FactionInstance extends L2NpcInstance
  738. +{
  739. +    public L2FactionInstance(int objectId, L2NpcTemplate template)
  740. +    {
  741. +        super(objectId, template);
  742. +    }
  743. +
  744. +    private final static Logger _log = Logger.getLogger(L2FactionInstance.class.getName());
  745. +  
  746. +   int team1Count = L2World.getInstance().getAllteam1Players().size();
  747. +   int team2Count = L2World.getInstance().getAllteam2Players().size();
  748. +   int team3Count = L2World.getInstance().getAllteam3Players().size();
  749. +
  750. +    @Override
  751. +    public void onBypassFeedback(final L2PcInstance player, String command)
  752. +    {
  753. +       StringTokenizer st = new StringTokenizer(command, " ");
  754. +       String actualCommand = st.nextToken();
  755. +       int val = 0;
  756. +       if (st.countTokens() >= 1)
  757. +           val = Integer.valueOf(st.nextToken());
  758. +      
  759. +       if (actualCommand.equalsIgnoreCase("setfaction"))
  760. +       {
  761. +           if (val < 1)
  762. +               return;
  763. +
  764. +           if (val == 1)
  765. +           {
  766. +               if (player.getFactionId() == 2 && (team1Count - team2Count > 3))
  767. +               {
  768. +                   player.sendMessage("Too many players in " + Config.FACTION_TEAM1_NAME + " faction. Come back later.");
  769. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  770. +                   return;
  771. +               }
  772. +               else if (player.getFactionId() == 3 && (team1Count - team3Count > 3))
  773. +               {
  774. +                   player.sendMessage("Too many players in " + Config.FACTION_TEAM1_NAME + " faction. Come back later.");
  775. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  776. +                   return;
  777. +               }
  778. +               else if (val == player.getFactionId())
  779. +               {
  780. +                   player.sendMessage("You already belong to " + Config.FACTION_TEAM1_NAME + " faction.");
  781. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  782. +                   return;
  783. +               }
  784. +
  785. +               if (player.getFactionId() == 2)
  786. +               {
  787. +                   L2World.getInstance().getAllTeam2().remove(player.getName().toLowerCase());
  788. +                   L2World.getInstance().getAllTeam1().put(player.getName().toLowerCase(),player);
  789. +                   player.sendMessage("[" + Config.FACTION_TEAM2_NAME + "] Goodbye!");
  790. +                   player.sendMessage("[" + Config.FACTION_TEAM1_NAME + "] For Faction Glory!");
  791. +               }
  792. +               else if (player.getFactionId() == 3)
  793. +               {
  794. +                   L2World.getInstance().getAllTeam3().remove(player.getName().toLowerCase());
  795. +                   L2World.getInstance().getAllTeam1().put(player.getName().toLowerCase(),player);
  796. +                   player.sendMessage("[" + Config.FACTION_TEAM3_NAME + "] Goodbye!");
  797. +                   player.sendMessage("[" + Config.FACTION_TEAM1_NAME + "] For Faction Glory!");
  798. +               }              
  799. +               else if (player.getFactionId() == 0)
  800. +               {
  801. +                   L2World.getInstance().getAllTeam1().put(player.getName().toLowerCase(),player);
  802. +                   player.sendMessage("[" + Config.FACTION_TEAM1_NAME + "] For Faction Glory!");
  803. +               }
  804. +               player.getParty().removePartyMember(player);
  805. +               player.getAppearance().setNameColor(Config.FACTION_TEAM1_COLOR);
  806. +               player.getAppearance().setTitleColor(Config.FACTION_TEAM1_COLOR);
  807. +               player.broadcastUserInfo();
  808. +           }
  809. +           else if (val == 2)
  810. +           {
  811. +               if (player.getFactionId() == 1 && (team2Count - team1Count > 3))
  812. +               {
  813. +                   player.sendMessage("Too many players in " + Config.FACTION_TEAM2_NAME + " faction. Come back later.");
  814. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  815. +                   return;
  816. +               }
  817. +               else if (player.getFactionId() == 3 && (team2Count - team3Count > 3))
  818. +               {
  819. +                   player.sendMessage("Too many players in " + Config.FACTION_TEAM2_NAME + " faction. Come back later.");
  820. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  821. +                   return;
  822. +               }
  823. +               else if (val == player.getFactionId())
  824. +               {
  825. +                   player.sendMessage("You already belong to " + Config.FACTION_TEAM2_NAME + " faction.");
  826. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  827. +                   return;
  828. +               }              
  829. +
  830. +               if (player.getFactionId() == 1)
  831. +               {
  832. +                   L2World.getInstance().getAllTeam1().remove(player.getName().toLowerCase());
  833. +                   L2World.getInstance().getAllTeam2().put(player.getName().toLowerCase(),player);
  834. +                   player.sendMessage("[" + Config.FACTION_TEAM1_NAME + "] Goodbye!");
  835. +                   player.sendMessage("[" + Config.FACTION_TEAM2_NAME + "] For Faction Glory!");
  836. +               }
  837. +               else if (player.getFactionId() == 3)
  838. +               {
  839. +                   L2World.getInstance().getAllTeam3().remove(player.getName().toLowerCase());
  840. +                   L2World.getInstance().getAllTeam2().put(player.getName().toLowerCase(),player);
  841. +                   player.sendMessage("[" + Config.FACTION_TEAM3_NAME + "] Goodbye!");
  842. +                   player.sendMessage("[" + Config.FACTION_TEAM2_NAME + "] For Faction Glory!");
  843. +               }              
  844. +               else if (player.getFactionId() == 0)
  845. +               {
  846. +                   L2World.getInstance().getAllTeam2().put(player.getName().toLowerCase(),player);
  847. +                   player.sendMessage("[" + Config.FACTION_TEAM2_NAME + "] For Faction Glory!");
  848. +               }
  849. +               player.getParty().removePartyMember(player);
  850. +               player.getAppearance().setNameColor(Config.FACTION_TEAM2_COLOR);
  851. +               player.getAppearance().setTitleColor(Config.FACTION_TEAM2_COLOR);
  852. +               player.broadcastUserInfo();
  853. +           }
  854. +           else
  855. +           {
  856. +               if (player.getFactionId() == 1 && (team3Count - team1Count > 3))
  857. +               {
  858. +                   player.sendMessage("Too many players in " + Config.FACTION_TEAM3_NAME + " faction. Come back later.");
  859. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  860. +                   return;
  861. +               }
  862. +               else if (player.getFactionId() == 2 && (team3Count - team2Count > 3))
  863. +               {
  864. +                   player.sendMessage("Too many players in " + Config.FACTION_TEAM3_NAME + " faction. Come back later.");
  865. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  866. +                   return;
  867. +               }
  868. +               else if (val == player.getFactionId())
  869. +               {
  870. +                   player.sendMessage("You already belong to " + Config.FACTION_TEAM3_NAME + " faction.");
  871. +                   player.sendPacket(ActionFailed.STATIC_PACKET);
  872. +                   return;
  873. +               }              
  874. +
  875. +               if (player.getFactionId() == 1)
  876. +               {
  877. +                   L2World.getInstance().getAllTeam1().remove(player.getName().toLowerCase());
  878. +                   L2World.getInstance().getAllTeam3().put(player.getName().toLowerCase(),player);
  879. +                   player.sendMessage("[" + Config.FACTION_TEAM1_NAME + "] Goodbye!");
  880. +                   player.sendMessage("[" + Config.FACTION_TEAM3_NAME + "] For Faction Glory!");
  881. +               }
  882. +               else if (player.getFactionId() == 2)
  883. +               {
  884. +                   L2World.getInstance().getAllTeam2().remove(player.getName().toLowerCase());
  885. +                   L2World.getInstance().getAllTeam3().put(player.getName().toLowerCase(),player);
  886. +                   player.sendMessage("[" + Config.FACTION_TEAM2_NAME + "] Goodbye!");
  887. +                   player.sendMessage("[" + Config.FACTION_TEAM3_NAME + "] For Faction Glory!");
  888. +               }              
  889. +               else if (player.getFactionId() == 0)
  890. +               {
  891. +                   L2World.getInstance().getAllTeam3().put(player.getName().toLowerCase(),player);
  892. +                   player.sendMessage("[" + Config.FACTION_TEAM3_NAME + "] For Faction Glory!");
  893. +               }
  894. +               player.getParty().removePartyMember(player);
  895. +               player.getAppearance().setNameColor(Config.FACTION_TEAM3_COLOR);
  896. +               player.getAppearance().setTitleColor(Config.FACTION_TEAM3_COLOR);
  897. +               player.broadcastUserInfo();
  898. +           }
  899. +          
  900. +           Connection connection = null;
  901. +           try
  902. +           {
  903. +               connection = L2DatabaseFactory.getInstance().getConnection();
  904. +               PreparedStatement statement = connection.prepareStatement("UPDATE characters SET factionId=? WHERE char_name=?");
  905. +               statement.setInt(1, val);
  906. +               statement.setString(2, player.getName());
  907. +               statement.execute();
  908. +               statement.close();
  909. +               connection.close();
  910. +           }
  911. +           catch (Exception e)
  912. +           {
  913. +               _log.info("Couldn't set player faction:" + val + " " + e);
  914. +           }
  915. +           finally{try{connection.close();}catch (Exception e){}}
  916. +
  917. +           player.setFactionId(val);
  918. +           player.broadcastUserInfo();
  919. +           if (player.getLevel() < 5)
  920. +               player.addExpAndSp(Experience.LEVEL[Config.FACTION_START_LVL], 0);
  921. +       }
  922. +       else
  923. +           super.onBypassFeedback(player, command);
  924. +    }
  925. +
  926. +    @Override
  927. +    public void onAction(L2PcInstance player)
  928. +    {
  929. +       if (this != player.getTarget())
  930. +       {
  931. +           player.setTarget(this);
  932. +           player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
  933. +           player.sendPacket(new ValidateLocation(this));
  934. +       }
  935. +       else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false))
  936. +       {
  937. +           SocialAction sa = new SocialAction(getObjectId(), Rnd.get(8));
  938. +           broadcastPacket(sa);
  939. +           player.setLastFolkNPC(this);
  940. +           showMessageWindow(player);
  941. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  942. +       }
  943. +       else
  944. +       {
  945. +           player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  946. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  947. +       }
  948. +    }
  949. +  
  950. +    private void showMessageWindow(L2PcInstance player)
  951. +    {
  952. +       NpcHtmlMessage html = new NpcHtmlMessage(1);
  953. +       final StringBuilder strBuffer = StringUtil.startAppend(3500, "<html><title>Faction Manager</title><body><center>");
  954. +        if (player.getFactionId() != 0)
  955. +       {
  956. +           strBuffer.append("You belong to: <font color=\"LEVEL\">%faction%</font> faction.<br>");
  957. +           strBuffer.append("Currently avaible factions:<br>");
  958. +           strBuffer.append("<img src=\"L2UI_CH3.onscrmsg_pattern01_2\" width=300 height=32 align=left>");
  959. +       }
  960. +       else
  961. +       {
  962. +           strBuffer.append("</center>");
  963. +           strBuffer.append("Welcome to L2CLAW Faction game, <font color=\"LEVEL\">%charname%</font>.<br>");
  964. +           strBuffer.append("Please chose your faction, for which you will fight on. Don't worry, you will be able to change your faction at any time.<br><center>");
  965. +           strBuffer.append("<img src=\"L2UI_CH3.onscrmsg_pattern01_2\" width=300 height=32 align=left>");
  966. +       }
  967. +       if (player.getFactionId() == 1)
  968. +       {
  969. +           strBuffer.append("<button value=\"" + Config.FACTION_TEAM2_NAME + "\" action=\"bypass -h npc_%objectId%_setfaction 2\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  970. +           strBuffer.append("<button value=\"" + Config.FACTION_TEAM3_NAME + "\" action=\"bypass -h npc_%objectId%_setfaction 3\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  971. +       }
  972. +       else if (player.getFactionId() == 2)
  973. +       {
  974. +           strBuffer.append("<button value=\"" + Config.FACTION_TEAM1_NAME + "\" action=\"bypass -h npc_%objectId%_setfaction 1\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  975. +           strBuffer.append("<button value=\"" + Config.FACTION_TEAM3_NAME + "\" action=\"bypass -h npc_%objectId%_setfaction 3\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  976. +       }
  977. +       else if (player.getFactionId() == 3)
  978. +       {
  979. +           strBuffer.append("<button value=\"" + Config.FACTION_TEAM1_NAME + "\" action=\"bypass -h npc_%objectId%_setfaction 1\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  980. +           strBuffer.append("<button value=\"" + Config.FACTION_TEAM2_NAME + "\" action=\"bypass -h npc_%objectId%_setfaction 2\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  981. +       }
  982. +       else
  983. +       {
  984. +           strBuffer.append("<button value=\"" + Config.FACTION_TEAM1_NAME + "\" action=\"bypass -h npc_%objectId%_setfaction 1\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  985. +           strBuffer.append("<button value=\"" + Config.FACTION_TEAM2_NAME + "\" action=\"bypass -h npc_%objectId%_setfaction 2\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  986. +           strBuffer.append("<button value=\"" + Config.FACTION_TEAM3_NAME + "\" action=\"bypass -h npc_%objectId%_setfaction 3\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  987. +       }
  988. +       strBuffer.append("<img src=\"L2UI_CH3.onscrmsg_pattern01_2\" width=300 height=32 align=left>");
  989. +       strBuffer.append("</center></body></html>");
  990. +       html.setHtml(strBuffer.toString());
  991. +       html.replace("%objectId%", String.valueOf(getObjectId()));
  992. +       html.replace("%npcname%", getName());
  993. +       html.replace("%charname%", player.getName());
  994. +       if (player.getFactionId() == 1)
  995. +           html.replace("%faction%", Config.FACTION_TEAM1_NAME);
  996. +       else if (player.getFactionId() == 2)
  997. +           html.replace("%faction%", Config.FACTION_TEAM2_NAME);
  998. +       else if (player.getFactionId() == 3)
  999. +           html.replace("%faction%", Config.FACTION_TEAM3_NAME);
  1000. +       player.sendPacket(html);
  1001. +    }
  1002. +}
  1003. \ No newline at end of file
  1004. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2FactTeleporterInstance.java
  1005. ===================================================================
  1006. --- java/net/sf/l2j/gameserver/model/actor/instance/L2FactTeleporterInstance.java   (revision 0)
  1007. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2FactTeleporterInstance.java   (revision 0)
  1008. @@ -0,0 +1,178 @@
  1009. +/*
  1010. + * This program is free software; you can redistribute it and/or modify
  1011. + * it under the terms of the GNU General Public License as published by
  1012. + * the Free Software Foundation; either version 2, or (at your option)
  1013. + * any later version.
  1014. + *
  1015. + * This program is distributed in the hope that it will be useful,
  1016. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1017. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1018. + * GNU General Public License for more details.
  1019. + *
  1020. + * You should have received a copy of the GNU General Public License
  1021. + * along with this program; if not, write to the Free Software
  1022. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  1023. + * 02111-1307, USA.
  1024. + *
  1025. + * http://www.gnu.org/copyleft/gpl.html
  1026. + */
  1027. +package net.sf.l2j.gameserver.model.actor.instance;
  1028. +
  1029. +import java.util.StringTokenizer;
  1030. +import java.util.logging.Logger;
  1031. +
  1032. +import net.sf.l2j.Config;
  1033. +import javolution.util.FastSet;
  1034. +import net.sf.l2j.gameserver.ai.CtrlIntention;
  1035. +import net.sf.l2j.gameserver.model.L2Object;
  1036. +import net.sf.l2j.gameserver.model.L2World;
  1037. +import net.sf.l2j.gameserver.model.entity.FactionMaps;
  1038. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  1039. +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
  1040. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  1041. +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
  1042. +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  1043. +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
  1044. +import net.sf.l2j.util.StringUtil;
  1045. +import net.sf.l2j.util.Rnd;
  1046. +
  1047. +/**
  1048. + *
  1049. + * @author Mindee
  1050. + *
  1051. + */
  1052. +
  1053. +public class L2FactTeleporterInstance extends L2NpcInstance
  1054. +{
  1055. +    public L2FactTeleporterInstance(int objectId, L2NpcTemplate template)
  1056. +    {
  1057. +        super(objectId, template);
  1058. +    }
  1059. +
  1060. +    private final static Logger _log = Logger.getLogger(L2FactTeleporterInstance.class.getName());
  1061. +  
  1062. +   public static FastSet<L2TpFlagInstance> _tpTeam1Flags = new FastSet<L2TpFlagInstance>();
  1063. +   public static FastSet<L2TpFlagInstance> _tpTeam2Flags = new FastSet<L2TpFlagInstance>();
  1064. +   public static FastSet<L2TpFlagInstance> _tpTeam3Flags = new FastSet<L2TpFlagInstance>();
  1065. +  
  1066. +    @Override
  1067. +    public void onBypassFeedback(final L2PcInstance player, String command)
  1068. +    {
  1069. +       StringTokenizer st = new StringTokenizer(command, " ");
  1070. +       String actualCommand = st.nextToken();
  1071. +       int val = 0;
  1072. +       if (st.countTokens() >= 1)
  1073. +           val = Integer.valueOf(st.nextToken());
  1074. +      
  1075. +       if (actualCommand.equalsIgnoreCase("teletoflag"))
  1076. +       {
  1077. +           teleToFlag(val,player);
  1078. +       }
  1079. +       else
  1080. +           super.onBypassFeedback(player, command);
  1081. +    }
  1082. +  
  1083. +   public void teleToFlag(int objId, L2PcInstance plajer)
  1084. +   {
  1085. +       L2Object object = L2World.getInstance().findObject(objId);
  1086. +       if (object != null && object instanceof L2TpFlagInstance)
  1087. +       {
  1088. +           L2TpFlagInstance kristalas = (L2TpFlagInstance) object;
  1089. +           if (plajer.getFactionId() == kristalas.getFlagFactionId())
  1090. +               plajer.teleToLocation(kristalas.getX() + 50,kristalas.getY(),kristalas.getZ() + 50);
  1091. +       }
  1092. +       else
  1093. +       {
  1094. +           plajer.sendMessage("Can't communicate with flag location. It doesn't exist or it was occupied.");
  1095. +           return;
  1096. +       }
  1097. +   }
  1098. +  
  1099. +   @Override
  1100. +    public void onAction(L2PcInstance player)
  1101. +    {
  1102. +       if (this != player.getTarget())
  1103. +       {
  1104. +           player.setTarget(this);
  1105. +           player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
  1106. +           player.sendPacket(new ValidateLocation(this));
  1107. +       }
  1108. +       else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false))
  1109. +       {
  1110. +           SocialAction sa = new SocialAction(getObjectId(), Rnd.get(8));
  1111. +           broadcastPacket(sa);
  1112. +           player.setLastFolkNPC(this);
  1113. +           showMessageWindow(player);
  1114. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  1115. +       }
  1116. +       else
  1117. +       {
  1118. +           player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
  1119. +           player.sendPacket(ActionFailed.STATIC_PACKET);
  1120. +       }
  1121. +    }
  1122. +
  1123. +    private void showMessageWindow(L2PcInstance player)
  1124. +    {
  1125. +       NpcHtmlMessage html = new NpcHtmlMessage(1);
  1126. +       final StringBuilder strBuffer = StringUtil.startAppend(3500, "<html><title>Faction Teleporter</title><body><center>");
  1127. +       if (player.getFactionId() == 0)
  1128. +           strBuffer.append("Please chose your faction and then come back!<br>");
  1129. +       else if (FactionMaps.isVoting() && player.getFactionId() != 0)
  1130. +           strBuffer.append("Map voting is in progress.<br>");
  1131. +       else
  1132. +       {
  1133. +           strBuffer.append("Current map is: <font color=\"LEVEL\">" + FactionMaps.getMapName() + "</font><br>");
  1134. +           strBuffer.append("Voting for next map will begin in: " + FactionMaps.getDelayUntilVoting() + "<br>");
  1135. +           strBuffer.append("Unoccupyable flags belonging to <font color=\"LEVEL\">%faction%</font> faction:<br>");
  1136. +           if (player.getFactionId() == 1)
  1137. +               for (L2TpFlagInstance unFlag : _tpTeam1Flags)
  1138. +               {
  1139. +                   if (unFlag.isUnoccupayable() == 1)
  1140. +                       strBuffer.append("<button value=\"" + unFlag.getFlagName() + "\" action=\"bypass -h npc_%objectId%_teletoflag " + unFlag.getObjectId() + "\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  1141. +               }
  1142. +           else if (player.getFactionId() == 2)
  1143. +               for (L2TpFlagInstance unFlag : _tpTeam2Flags)
  1144. +               {
  1145. +                   if (unFlag.isUnoccupayable() == 1)
  1146. +                       strBuffer.append("<button value=\"" + unFlag.getFlagName() + "\" action=\"bypass -h npc_%objectId%_teletoflag " + unFlag.getObjectId() + "\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  1147. +               }
  1148. +           else if (player.getFactionId() == 3)
  1149. +               for (L2TpFlagInstance unFlag : _tpTeam3Flags)
  1150. +               {
  1151. +                   if (unFlag.isUnoccupayable() == 1)
  1152. +                       strBuffer.append("<button value=\"" + unFlag.getFlagName() + "\" action=\"bypass -h npc_%objectId%_teletoflag " + unFlag.getObjectId() + "\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  1153. +               }
  1154. +           strBuffer.append("Flags occupied by <font color=\"LEVEL\">%faction%</font> faction:<br>");
  1155. +           if (player.getFactionId() == 1)
  1156. +               for (L2TpFlagInstance unFlag : _tpTeam1Flags)
  1157. +               {
  1158. +                   if (unFlag.isUnoccupayable() == 0)
  1159. +                       strBuffer.append("<button value=\"" + unFlag.getFlagName() + "\" action=\"bypass -h npc_%objectId%_teletoflag " + unFlag.getObjectId() + "\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  1160. +               }
  1161. +           else if (player.getFactionId() == 2)
  1162. +               for (L2TpFlagInstance unFlag : _tpTeam2Flags)
  1163. +               {
  1164. +                   if (unFlag.isUnoccupayable() == 0)
  1165. +                       strBuffer.append("<button value=\"" + unFlag.getFlagName() + "\" action=\"bypass -h npc_%objectId%_teletoflag " + unFlag.getObjectId() + "\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  1166. +               }
  1167. +           else if (player.getFactionId() == 3)
  1168. +               for (L2TpFlagInstance unFlag : _tpTeam3Flags)
  1169. +               {
  1170. +                   if (unFlag.isUnoccupayable() == 0)
  1171. +                       strBuffer.append("<button value=\"" + unFlag.getFlagName() + "\" action=\"bypass -h npc_%objectId%_teletoflag " + unFlag.getObjectId() + "\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  1172. +               }
  1173. +       }
  1174. +       strBuffer.append("</center></body></html>");
  1175. +       html.setHtml(strBuffer.toString());
  1176. +       html.replace("%objectId%", String.valueOf(getObjectId()));
  1177. +       html.replace("%npcname%", getName());
  1178. +       if (player.getFactionId() == 1)
  1179. +           html.replace("%faction%", Config.FACTION_TEAM1_NAME);
  1180. +       else if (player.getFactionId() == 2)
  1181. +           html.replace("%faction%", Config.FACTION_TEAM2_NAME);
  1182. +       else if (player.getFactionId() == 3)
  1183. +           html.replace("%faction%", Config.FACTION_TEAM3_NAME);
  1184. +       player.sendPacket(html);
  1185. +    }
  1186. +}
  1187. \ No newline at end of file
  1188. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
  1189. ===================================================================
  1190. --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (revision 128)
  1191. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
  1192. @@ -220,6 +220,10 @@
  1193.  import net.sf.l2j.util.Point3D;
  1194.  import net.sf.l2j.util.Rnd;
  1195.  
  1196. +import net.sf.l2j.gameserver.model.actor.instance.L2FactTeleporterInstance;
  1197. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  1198. +import net.sf.l2j.gameserver.util.Broadcast;
  1199. +
  1200.  /**
  1201.   * This class represents all player characters in the world.
  1202.   * There is always a client-thread connected to this (except if a player-store is activated upon logout).<BR><BR>
  1203. @@ -240,8 +244,8 @@
  1204.  
  1205.     // Character SQL String Definitions:
  1206.     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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
  1207. -   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=?";
  1208. -   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=?";
  1209. +   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=?,factionId=? WHERE obj_id=?";
  1210. +   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,factionId FROM characters WHERE obj_id=?";
  1211.      
  1212.     // Character Subclass SQL String Definitions:
  1213.     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";
  1214. @@ -344,6 +348,10 @@
  1215.     private int _karma;
  1216.     private int _pvpKills;
  1217.     private int _pkKills;
  1218. +
  1219. +   private int _factionPoints;
  1220. +   private int uberKills = 0;
  1221. +
  1222.     private byte _pvpFlag;
  1223.     private byte _siegeState = 0;
  1224.     private int _curWeightPenalty = 0;
  1225. @@ -424,6 +432,31 @@
  1226.     private int _obsZ;
  1227.     private boolean _observerMode = false;
  1228.  
  1229. +   public boolean _votedForMap = false;
  1230. +   public void setVotedForMap(boolean a)
  1231. +   {
  1232. +       _votedForMap = a;
  1233. +   }
  1234. +  
  1235. +   public void setFactionPoints(int factionPoints)
  1236. +   {
  1237. +       _factionPoints = factionPoints;
  1238. +   }
  1239. +
  1240. +   public int getFactionPoints()
  1241. +   {
  1242. +       return _factionPoints;
  1243. +   }
  1244. +
  1245. +   public boolean votedForMap()
  1246. +   {
  1247. +       return _votedForMap;
  1248. +   }
  1249. +
  1250. +   public int _oldX = 0;
  1251. +   public int _oldY = 0;
  1252. +   public int _oldZ = 0;
  1253. +
  1254.     /** Stored from last ValidatePosition **/
  1255.     private Point3D _lastServerPosition = new Point3D(0, 0, 0);
  1256.  
  1257. @@ -455,6 +488,13 @@
  1258.  
  1259.     /** Last NPC Id talked on a quest */
  1260.     private int _questNpcObject = 0;
  1261. +  
  1262. +   public void setIP(String ip)
  1263. +   {
  1264. +       IP = ip;
  1265. +   }
  1266. +  
  1267. +   public String IP;
  1268.  
  1269.     /** The table containing all Quests began by the L2PcInstance */
  1270.     private Map<String, QuestState> _quests = new FastMap<String, QuestState>();
  1271. @@ -552,6 +592,32 @@
  1272.     private long _recentFakeDeathEndTime = 0;
  1273.     private boolean _isFakeDeath;
  1274.    
  1275. +   public int ArNePk = 0;
  1276. +  
  1277. +   public int getArNePk()
  1278. +   {
  1279. +       return this.ArNePk;
  1280. +   }
  1281. +   public void setArNePk(int i)
  1282. +   {
  1283. +       ArNePk=i;
  1284. +   }
  1285. +  
  1286. +   public int factionId = 0;
  1287. +   public int getFactionId()
  1288. +   {
  1289. +       return this.factionId;
  1290. +   }
  1291. +   public void setFactionId(int i)
  1292. +   {
  1293. +       factionId=i;
  1294. +   }
  1295. +   public int isInFaction = 0;
  1296. +   public int inWorld()
  1297. +   {
  1298. +       return isInFaction;
  1299. +   }
  1300. +
  1301.     /** The fists L2Weapon of the L2PcInstance (used when no weapon is equipped) */
  1302.     private L2Weapon _fistsWeaponItem;
  1303.  
  1304. @@ -562,6 +628,21 @@
  1305.     private int _expertisePenalty = 0;
  1306.  
  1307.     private L2ItemInstance _activeEnchantItem = null;
  1308. +  
  1309. +   public boolean checkPvpCond(L2Character target)
  1310. +   {
  1311. +       L2PcInstance target1 = (L2PcInstance)target;
  1312. +       if (target1.IP.equals(IP) && Config.ENABLE_DUALBOX_PROTECTION_IP && Config.FACTION_ENGINE_ENABLED)
  1313. +           return false;
  1314. +       if((getClanId() > 0 && target1.getClanId() > 0 && getClanId() == target1.getClanId()) && Config.ENABLE_DUALBOX_PROTECTION_CLAN && Config.FACTION_ENGINE_ENABLED)
  1315. +           return false;
  1316. +       if((getAllyId() > 0 && target1.getAllyId() > 0 && getAllyId() == target1.getAllyId()) && Config.ENABLE_DUALBOX_PROTECTION_ALLY && Config.FACTION_ENGINE_ENABLED)
  1317. +           return false;
  1318. +       if(target.getStat().getPDef(target) < Config.PROTECTION_ARMOUR_AMOUNT && Config.ENABLE_DUALBOX_PROTECTION_ARM && Config.FACTION_ENGINE_ENABLED)
  1319. +           return false;          
  1320. +      
  1321. +       return true;
  1322. +   }
  1323.  
  1324.     protected boolean _inventoryDisable = false;
  1325.  
  1326. @@ -1627,15 +1708,20 @@
  1327.  
  1328.     public void updatePvPFlag(int value)
  1329.     {
  1330. -       if (getPvpFlag() == value)
  1331. -           return;
  1332. -      
  1333. -       setPvpFlag(value);
  1334. -       sendPacket(new UserInfo(this));
  1335. -      
  1336. -       Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
  1337. -       for (L2PcInstance target : plrs)
  1338. -           target.sendPacket(new RelationChanged(this, getRelation(target), isAutoAttackable(target)));
  1339. +       if(!Config.FACTION_ENGINE_ENABLED)
  1340. +       {
  1341. +           if (getPvpFlag() == value)
  1342. +               return;
  1343. +
  1344. +           setPvpFlag(value);
  1345. +           sendPacket(new UserInfo(this));
  1346. +
  1347. +           Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
  1348. +           for (L2PcInstance target : plrs)
  1349. +               target.sendPacket(new RelationChanged(this, getRelation(target), isAutoAttackable(target)));
  1350. +       }
  1351. +       else
  1352. +           setArNePk(1);
  1353.     }
  1354.    
  1355.     @Override
  1356. @@ -3087,7 +3173,7 @@
  1357.                 if (!isGM() && !_inventory.validateCapacity(0, item.isQuestItem()) && createdItem.isDropable() && (!createdItem.isStackable() || createdItem.getLastChange() != L2ItemInstance.MODIFIED))
  1358.                     dropItem("InvDrop", createdItem, null, true);
  1359.                 // Cursed Weapon
  1360. -               else if(CursedWeaponsManager.getInstance().isCursed(createdItem.getItemId()))
  1361. +               else if (CursedWeaponsManager.getInstance().isCursed(createdItem.getItemId()))
  1362.                     CursedWeaponsManager.getInstance().activate(this, createdItem);
  1363.                
  1364.                 return createdItem;
  1365. @@ -3754,7 +3840,7 @@
  1366.                    
  1367.                     if (Config.GEODATA > 0)
  1368.                     {
  1369. -                       if(GeoData.getInstance().canSeeTarget(player, this))
  1370. +                       if (GeoData.getInstance().canSeeTarget(player, this))
  1371.                             player.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, this);
  1372.                     }
  1373.                     else
  1374. @@ -4212,14 +4298,14 @@
  1375.              ItemTable.getInstance().destroyItem("Consume", target, this, null);
  1376.          }
  1377.         // Cursed Weapons are not distributed
  1378. -       else if(CursedWeaponsManager.getInstance().isCursed(target.getItemId()))
  1379. +       else if (CursedWeaponsManager.getInstance().isCursed(target.getItemId()))
  1380.         {
  1381.             addItem("Pickup", target, null, true);
  1382.         }
  1383.         else
  1384.         {
  1385.             // if item is instance of L2ArmorType or L2WeaponType broadcast an "Attention" system message
  1386. -           if(target.getItemType() instanceof L2ArmorType || target.getItemType() instanceof L2WeaponType)
  1387. +           if (target.getItemType() instanceof L2ArmorType || target.getItemType() instanceof L2WeaponType)
  1388.             {
  1389.                 if (target.getEnchantLevel() > 0)
  1390.                 {
  1391. @@ -4635,6 +4721,7 @@
  1392.  
  1393.         // Clear the pvp flag
  1394.         setPvpFlag(0);
  1395. +       uberKills = 0;
  1396.  
  1397.         // Unsummon Cubics
  1398.         if (!_cubics.isEmpty())
  1399. @@ -4800,33 +4887,177 @@
  1400.         if (isInsideZone(ZONE_PVP) || targetPlayer.isInsideZone(ZONE_PVP))
  1401.             return;
  1402.  
  1403. -        // Check if it's pvp
  1404. -       if ((checkIfPvP(target) && targetPlayer.getPvpFlag() != 0)
  1405. -               || (isInsideZone(ZONE_PVP) && targetPlayer.isInsideZone(ZONE_PVP)))
  1406. -            increasePvpKills();
  1407. -       // Target player doesn't have pvp flag set
  1408. +       if (!Config.FACTION_ENGINE_ENABLED)
  1409. +       {
  1410. +           // Check if it's pvp
  1411. +           if ((checkIfPvP(target) && targetPlayer.getPvpFlag() != 0)
  1412. +                   || (isInsideZone(ZONE_PVP) && targetPlayer.isInsideZone(ZONE_PVP)))
  1413. +               increasePvpKills();
  1414. +           // Target player doesn't have pvp flag set
  1415. +           else
  1416. +           {
  1417. +               // check about wars
  1418. +               if (targetPlayer.getClan() != null && getClan() != null
  1419. +                       && getClan().isAtWarWith(targetPlayer.getClanId())
  1420. +                       && targetPlayer.getClan().isAtWarWith(getClanId())
  1421. +                       && targetPlayer.getPledgeType() != L2Clan.SUBUNIT_ACADEMY
  1422. +                       && getPledgeType() != L2Clan.SUBUNIT_ACADEMY)
  1423. +               {
  1424. +                   // 'Both way war' -> 'PvP Kill'
  1425. +                   increasePvpKills();
  1426. +                   return;
  1427. +               }
  1428. +
  1429. +               // 'No war' or 'One way war' -> 'Normal PK'
  1430. +               if (targetPlayer.getKarma() > 0)
  1431. +               {
  1432. +                   if (Config.KARMA_AWARD_PK_KILL)
  1433. +                       increasePvpKills();
  1434. +               }
  1435. +               else if (targetPlayer.getPvpFlag() == 0)
  1436. +                   increasePkKillsAndKarma(targetPlayer.getLevel());
  1437. +           }
  1438. +       }
  1439.         else
  1440.         {
  1441. -           // check about wars
  1442. -           if (targetPlayer.getClan() != null && getClan() != null
  1443. -                   && getClan().isAtWarWith(targetPlayer.getClanId())
  1444. -                   && targetPlayer.getClan().isAtWarWith(getClanId())
  1445. -                   && targetPlayer.getPledgeType() != L2Clan.SUBUNIT_ACADEMY
  1446. -                   && getPledgeType() != L2Clan.SUBUNIT_ACADEMY)
  1447. +           if (Config.FACTION_ALLOW_ITEM_REWARD)
  1448.             {
  1449. -               // 'Both way war' -> 'PvP Kill'
  1450. -               increasePvpKills();
  1451. -               return;
  1452. +               if (getFactionId() == targetPlayer.getFactionId())
  1453. +               {
  1454. +                   sendMessage("You can't get the item reward from the same faction!");
  1455. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1456. +                   return;
  1457. +               }
  1458. +               else if (targetPlayer.getFactionId() == 0)
  1459. +               {
  1460. +                   sendMessage("You can't get the item reward from player, who doesn't belong to any faction!");
  1461. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1462. +                   return;
  1463. +               }
  1464. +               else if (getFactionId() == 0)
  1465. +               {
  1466. +                   sendMessage("There is no rewards for non-faction players.");
  1467. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1468. +                   return;
  1469. +               }
  1470. +               else if (!checkPvpCond(target) && (target instanceof L2PcInstance))
  1471. +               {
  1472. +                   GmListTable.broadcastMessageToGMs(getName() + " - tried to cheat in pvp!");
  1473. +                   sendMessage("You didn't meet the pvp conditions or you tried to cheat!");
  1474. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1475. +                   return;
  1476. +               }
  1477. +               else
  1478. +               {
  1479. +                   int points = getFactionPoints();
  1480. +                   int count = Config.FACTION_ITEM_NUMBER_REWARD_ON_PVP;
  1481. +                   if (getFactionId() == 1)
  1482. +                       count *= L2FactTeleporterInstance._tpTeam1Flags.size();
  1483. +                   else if (getFactionId() == 2)
  1484. +                       count *= L2FactTeleporterInstance._tpTeam2Flags.size();
  1485. +                   else if (getFactionId() == 3)
  1486. +                       count *= L2FactTeleporterInstance._tpTeam3Flags.size();
  1487. +                      
  1488. +                   addItem("Loot", Config.FACTION_ITEM_REWARD_ID_PVP, count, this, true);
  1489. +                   setFactionPoints(points + 1);
  1490. +               }
  1491.             }
  1492. +          
  1493. +           if (Config.FACTION_ALLOW_ITEM_REWARD_PARTY && (Rnd.get(100) < Config.FACTION_CHANCE) && getParty() != null)
  1494. +           {
  1495. +               if (getFactionId() == targetPlayer.getFactionId())
  1496. +               {
  1497. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1498. +                   return;
  1499. +               }
  1500. +               else if (targetPlayer.getFactionId() == 0)
  1501. +               {
  1502. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1503. +                   return;
  1504. +               }
  1505. +               else if (getFactionId() == 0)
  1506. +               {
  1507. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1508. +                   return;
  1509. +               }
  1510. +               else if (!checkPvpCond(target) && (target instanceof L2PcInstance))
  1511. +               {
  1512. +                   GmListTable.broadcastMessageToGMs(getName() + " - tried to cheat in pvp!");
  1513. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1514. +                   return;
  1515. +               }
  1516. +               else
  1517. +               {
  1518. +                   for (L2PcInstance member : getParty().getPartyMembers())
  1519. +                   {
  1520. +                       int[][] items = { {Config.FACTION_PARTY_REWARD1, Config.FACTION_PARTY_REWARD_AMMOUNT1}, {Config.FACTION_PARTY_REWARD2, Config.FACTION_PARTY_REWARD_AMMOUNT2}, {Config.FACTION_PARTY_REWARD3, Config.FACTION_PARTY_REWARD_AMMOUNT3}, {Config.FACTION_PARTY_REWARD4, Config.FACTION_PARTY_REWARD_AMMOUNT4}, {Config.FACTION_PARTY_REWARD5, Config.FACTION_PARTY_REWARD_AMMOUNT5}, {Config.FACTION_PARTY_REWARD6, Config.FACTION_PARTY_REWARD_AMMOUNT6}, {Config.FACTION_PARTY_REWARD7, Config.FACTION_PARTY_REWARD_AMMOUNT7}, {Config.FACTION_PARTY_REWARD8, Config.FACTION_PARTY_REWARD_AMMOUNT8}, {Config.FACTION_PARTY_REWARD9, Config.FACTION_PARTY_REWARD_AMMOUNT9}, {Config.FACTION_PARTY_REWARD10, Config.FACTION_PARTY_REWARD_AMMOUNT10} };
  1521. +                       int[] ar = items[Rnd.get(10)];
  1522.  
  1523. -            // 'No war' or 'One way war' -> 'Normal PK'
  1524. -            if (targetPlayer.getKarma() > 0)
  1525. +                       if (Config.FACTION_ONLYSUPPORTS && member.getClassId().getId() == 116 || member.getClassId().getId() == 115 ||member.getClassId().getId() == 112 ||member.getClassId().getId() == 105 ||member.getClassId().getId() == 98 ||member.getClassId().getId() == 97)
  1526. +                       {
  1527. +                           member.addItem("Loot",  ar[0], ar[1], this, true);
  1528. +                           member.sendMessage("You have earned a support class party reward!");
  1529. +                       }
  1530. +                       else
  1531. +                       {
  1532. +                           member.addItem("Loot",  ar[0], ar[1], this, true);
  1533. +                           member.sendMessage("You have earned a party reward!");
  1534. +                       }
  1535. +                   }
  1536. +               }
  1537. +           }
  1538. +          
  1539. +           if (Config.FACTION_ALLOW_EXP_REWARD)
  1540.             {
  1541. -               if (Config.KARMA_AWARD_PK_KILL)
  1542. -                    increasePvpKills();
  1543. +               if (getFactionId() == targetPlayer.getFactionId())
  1544. +               {
  1545. +                   sendMessage("You can't earn experience from the same faction!");
  1546. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1547. +                   return;
  1548. +               }
  1549. +               else if (targetPlayer.getFactionId() == 0)
  1550. +               {
  1551. +                   sendMessage("You can't earn experience from player, who doesn't belong to any faction!");
  1552. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1553. +                   return;
  1554. +               }
  1555. +               else if (getFactionId() == 0)
  1556. +               {
  1557. +                   sendMessage("You can't earn experience from other players, while you're member of non-faction.");
  1558. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1559. +                   return;
  1560. +               }
  1561. +               else if (!checkPvpCond(target) && (target instanceof L2PcInstance))
  1562. +               {
  1563. +                   GmListTable.broadcastMessageToGMs(getName() + " - tried to cheat in pvp!");
  1564. +                   sendMessage("You didn't meet the pvp conditions or you tried to cheat!");
  1565. +                   sendPacket(ActionFailed.STATIC_PACKET);
  1566. +                   return;
  1567. +               }
  1568. +               else
  1569. +               {
  1570. +                   if (getLevel() < 76)
  1571. +                       addExpAndSp(Config.FACTION_EXP_REWARD_PVP_FIRST, 0);
  1572. +                   else if (getLevel() >= 76 && getLevel() < 78)
  1573. +                       addExpAndSp(Config.FACTION_EXP_REWARD_PVP_SECOND, 0);
  1574. +                   else
  1575. +                       addExpAndSp(Config.FACTION_EXP_REWARD_PVP_THIRD, 0);
  1576. +               }
  1577.             }
  1578. -           else if (targetPlayer.getPvpFlag() == 0)
  1579. -                increasePkKillsAndKarma(targetPlayer.getLevel());
  1580. +      
  1581. +           if (checkPvpCond(target) && (target instanceof L2PcInstance))
  1582. +           {
  1583. +               int points = getFactionPoints();
  1584. +               setFactionPoints(points + Config.FACTION_POINTS_PVP);
  1585. +               sendMessage("You received " + Config.FACTION_POINTS_PVP + " points for killing an member of enemy Faction!");
  1586. +               if (targetPlayer.getArNePk() > 0)
  1587. +               {
  1588. +                   increasePvpKills();
  1589. +                   targetPlayer.setArNePk(0);
  1590. +               }
  1591. +               else
  1592. +                   increasePkKillsAndKarma(targetPlayer.getLevel());
  1593. +           }
  1594.         }
  1595.     }
  1596.  
  1597. @@ -4836,11 +5067,102 @@
  1598.       */
  1599.      public void increasePvpKills()
  1600.      {
  1601. -        // Add karma to attacker and increase its PK counter
  1602. -        setPvpKills(getPvpKills() + 1);
  1603. -
  1604. -        // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
  1605. -        sendPacket(new UserInfo(this));
  1606. +       if (!Config.FACTION_ENGINE_ENABLED)
  1607. +           // Add karma to attacker and increase its PK counter
  1608. +           setPvpKills(getPvpKills() + 1);
  1609. +       else
  1610. +       {
  1611. +           uberKills++;
  1612. +           String text="";
  1613. +
  1614. +           if (uberKills >= 4)
  1615. +           {
  1616. +               switch (uberKills)
  1617. +               {
  1618. +                   case 4:
  1619. +                       text=getName() + " : Rampage!";
  1620. +                       break;
  1621. +                   case 6:
  1622. +                       text=getName() + " : Dominating!";
  1623. +                       break;
  1624. +                   case 8:
  1625. +                       text=getName() + " : Killing Spree!";
  1626. +                       break;
  1627. +                   case 10:
  1628. +                       text=getName() + " : Monsterrr Kill!";
  1629. +                       if (getFactionId() == 1)
  1630. +                           Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 10 kills without death!");
  1631. +                       else if (getFactionId() == 2)
  1632. +                           Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 10 kills without death!");
  1633. +                       else
  1634. +                           Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 10 kills without death!");
  1635. +                       break;
  1636. +                   case 12:
  1637. +                       text=getName() + " : Unstoppable!";
  1638. +                       if (getFactionId() == 1)
  1639. +                           Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 12 kills without death!");
  1640. +                       else if (getFactionId() == 2)
  1641. +                           Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 12 kills without death!");
  1642. +                       else
  1643. +                           Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 12 kills without death!");
  1644. +                       break;
  1645. +                   case 14:
  1646. +                       text=getName() + " : Ultra Kill!";
  1647. +                       if (getFactionId() == 1)
  1648. +                           Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 14 kills without death!");
  1649. +                       else if (getFactionId() == 2)
  1650. +                           Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 14 kills without death!");
  1651. +                       else
  1652. +                           Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 14 kills without death!");
  1653. +                       break;
  1654. +                   case 16:
  1655. +                       text=getName() + " : GOD LIKE!";
  1656. +                       if (getFactionId() == 1)
  1657. +                           Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 16 kills without death!");
  1658. +                       else if (getFactionId() == 2)
  1659. +                           Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 16 kills without death!");
  1660. +                       else
  1661. +                           Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 16 kills without death!");
  1662. +                       break;
  1663. +                   case 18:
  1664. +                       text=getName() + " : Wicked Sick!";
  1665. +                       if (getFactionId() == 1)
  1666. +                           Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 18 kills without death!");
  1667. +                       else if (getFactionId() == 2)
  1668. +                           Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 18 kills without death!");
  1669. +                       else
  1670. +                           Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 18 kills without death!");
  1671. +                       break;
  1672. +                   case 20:
  1673. +                       text=getName() + " : Ludicrous Kill!";
  1674. +                       if (getFactionId() == 1)
  1675. +                           Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 20 kills without death!");
  1676. +                       else if (getFactionId() == 2)
  1677. +                           Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 20 kills without death!");
  1678. +                       else
  1679. +                           Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 20 kills without death!");
  1680. +                       break;
  1681. +                   case 25:
  1682. +                       text=getName() + " : HOLY SHIT!";
  1683. +                       if (getFactionId() == 1)
  1684. +                           Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 25 kills without death!");
  1685. +                       else if (getFactionId() == 2)
  1686. +                           Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 25 kills without death!");
  1687. +                       else
  1688. +                           Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 25 kills without death!");
  1689. +                       break;             
  1690. +               }
  1691. +               ExShowScreenMessage exshowscrn = new ExShowScreenMessage(text,4500);
  1692. +               Broadcast.toAllOnlinePlayers(exshowscrn);
  1693. +           }
  1694. +      
  1695. +           // Add karma to attacker and increase its PK counter
  1696. +           setPkKills(getPkKills() + 1);
  1697. +           setPvpKills(getPvpKills() + 1);
  1698. +       }
  1699. +      
  1700. +       // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
  1701. +       sendPacket(new UserInfo(this));
  1702.      }
  1703.  
  1704.      /**
  1705. @@ -4850,52 +5172,57 @@
  1706.       */
  1707.      public void increasePkKillsAndKarma(int targLVL)
  1708.      {
  1709. -        int baseKarma           = Config.KARMA_MIN_KARMA;
  1710. -        int newKarma            = baseKarma;
  1711. -        int karmaLimit          = Config.KARMA_MAX_KARMA;
  1712. +       if (!Config.FACTION_ENGINE_ENABLED)
  1713. +       {
  1714. +           int baseKarma           = Config.KARMA_MIN_KARMA;
  1715. +           int newKarma            = baseKarma;
  1716. +           int karmaLimit          = Config.KARMA_MAX_KARMA;
  1717.  
  1718. -        int pkLVL               = getLevel();
  1719. -        int pkPKCount           = getPkKills();
  1720. +           int pkLVL               = getLevel();
  1721. +           int pkPKCount           = getPkKills();
  1722.  
  1723. -        int lvlDiffMulti = 0;
  1724. -        int pkCountMulti = 0;
  1725. +           int lvlDiffMulti = 0;
  1726. +           int pkCountMulti = 0;
  1727.  
  1728. -        // Check if the attacker has a PK counter greater than 0
  1729. -        if (pkPKCount > 0)
  1730. -            pkCountMulti = pkPKCount / 2;
  1731. -        else
  1732. -            pkCountMulti = 1;
  1733. +           // Check if the attacker has a PK counter greater than 0
  1734. +           if (pkPKCount > 0)
  1735. +               pkCountMulti = pkPKCount / 2;
  1736. +           else
  1737. +               pkCountMulti = 1;
  1738.          
  1739. -        if (pkCountMulti < 1)
  1740. -           pkCountMulti = 1;
  1741. +           if (pkCountMulti < 1)
  1742. +               pkCountMulti = 1;
  1743.  
  1744. -        // Calculate the level difference Multiplier between attacker and killed L2PcInstance
  1745. -        if (pkLVL > targLVL)
  1746. -            lvlDiffMulti = pkLVL / targLVL;
  1747. -        else
  1748. -            lvlDiffMulti = 1;
  1749. +           // Calculate the level difference Multiplier between attacker and killed L2PcInstance
  1750. +           if (pkLVL > targLVL)
  1751. +               lvlDiffMulti = pkLVL / targLVL;
  1752. +           else
  1753. +               lvlDiffMulti = 1;
  1754.          
  1755. -        if (lvlDiffMulti < 1)
  1756. -           lvlDiffMulti = 1;
  1757. +           if (lvlDiffMulti < 1)
  1758. +               lvlDiffMulti = 1;
  1759.  
  1760. -        // Calculate the new Karma of the attacker : newKarma = baseKarma*pkCountMulti*lvlDiffMulti
  1761. -        newKarma *= pkCountMulti;
  1762. -        newKarma *= lvlDiffMulti;
  1763. +           // Calculate the new Karma of the attacker : newKarma = baseKarma*pkCountMulti*lvlDiffMulti
  1764. +           newKarma *= pkCountMulti;
  1765. +           newKarma *= lvlDiffMulti;
  1766.  
  1767. -        // Make sure newKarma is less than karmaLimit and higher than baseKarma
  1768. -        if (newKarma < baseKarma)
  1769. -           newKarma = baseKarma;
  1770. +           // Make sure newKarma is less than karmaLimit and higher than baseKarma
  1771. +           if (newKarma < baseKarma)
  1772. +               newKarma = baseKarma;
  1773.          
  1774. -        if (newKarma > karmaLimit)
  1775. -           newKarma = karmaLimit;
  1776. +           if (newKarma > karmaLimit)
  1777. +               newKarma = karmaLimit;
  1778.  
  1779. -        // Fix to prevent overflow (=> karma has a  max value of 2 147 483 647)
  1780. -        if (getKarma() > (Integer.MAX_VALUE - newKarma))
  1781. -            newKarma = Integer.MAX_VALUE - getKarma();
  1782. +           // Fix to prevent overflow (=> karma has a  max value of 2 147 483 647)
  1783. +           if (getKarma() > (Integer.MAX_VALUE - newKarma))
  1784. +               newKarma = Integer.MAX_VALUE - getKarma();
  1785.  
  1786. -        // Add karma to attacker and increase its PK counter
  1787. -       setPkKills(getPkKills() + 1);
  1788. -        setKarma(getKarma() + newKarma);
  1789. +           // Add karma to attacker and increase its PK counter
  1790. +           setPkKills(getPkKills() + 1);
  1791. +           setKarma(getKarma() + newKarma);
  1792. +       }
  1793. +       else
  1794. +           setPkKills(getPkKills() + 1);
  1795.  
  1796.          // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
  1797.          sendPacket(new UserInfo(this));
  1798. @@ -6098,6 +6425,7 @@
  1799.                 player.setOnlineTime(rset.getLong("onlinetime"));
  1800.                 player.setNewbie(rset.getInt("newbie")==1);
  1801.                 player.setNoble(rset.getInt("nobless")==1);
  1802. +               player.setFactionId(rset.getInt("factionId"));
  1803.  
  1804.                 player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
  1805.                 if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
  1806. @@ -6571,7 +6899,13 @@
  1807.             statement.setLong(47, getClanCreateExpiryTime());
  1808.             statement.setString(48, getName());
  1809.             statement.setLong(49, getDeathPenaltyBuffLevel());
  1810. -           statement.setInt(50, getObjectId());
  1811. +           if (Config.FACTION_ENGINE_ENABLED)
  1812. +           {
  1813. +               statement.setInt(50, getFactionId());
  1814. +               statement.setInt(51, getObjectId());
  1815. +           }
  1816. +           else
  1817. +               statement.setInt(50, getObjectId());
  1818.  
  1819.             statement.execute();
  1820.             statement.close();
  1821. @@ -7329,6 +7663,23 @@
  1822.         // Check if the attacker isn't the L2PcInstance Pet
  1823.         if (attacker == this || attacker == getPet())
  1824.             return false;
  1825. +          
  1826. +       L2PcInstance player = null;
  1827. +       if (attacker instanceof L2PcInstance)
  1828. +           player = (L2PcInstance) attacker;
  1829. +       if (attacker instanceof L2SummonInstance)
  1830. +           player = ((L2SummonInstance) attacker).getOwner();
  1831. +      
  1832. +       if (player != null && Config.FACTION_ENGINE_ENABLED)
  1833. +       {
  1834. +           if (!isInsidePeaceZone(this, player))
  1835. +           {
  1836. +               if (getFactionId() == 0 || player.getFactionId() == 0)
  1837. +                   return false;
  1838. +               if (getFactionId() != player.getFactionId())
  1839. +                   return true;
  1840. +           }
  1841. +       }
  1842.  
  1843.         // TODO: check for friendly mobs
  1844.         // Check if the attacker is a L2MonsterInstance
  1845. @@ -7352,7 +7703,7 @@
  1846.         if (getClan() != null && attacker != null && getClan().isMember(attacker.getObjectId()))
  1847.             return false;
  1848.  
  1849. -        if(attacker instanceof L2Playable && isInsideZone(ZONE_PEACE))
  1850. +        if (attacker instanceof L2Playable && isInsideZone(ZONE_PEACE))
  1851.              return false;
  1852.  
  1853.         // Check if the L2PcInstance has Karma
  1854. @@ -7685,6 +8036,27 @@
  1855.                 return false;
  1856.             }
  1857.            
  1858. +            boolean cond = true;
  1859. +           L2PcInstance trgtF = null;
  1860. +           if (target instanceof L2PcInstance)
  1861. +               trgtF = (L2PcInstance)target;
  1862. +           else if (target instanceof L2SummonInstance)
  1863. +               trgtF = ((L2SummonInstance)target).getOwner();
  1864. +           if (trgtF != null && Config.FACTION_ENGINE_ENABLED)
  1865. +           {
  1866. +               if (trgtF.getFactionId() == getFactionId())
  1867. +                   cond = false;
  1868. +               if (trgtF.getFactionId() == 0 || getFactionId() == 0)
  1869. +                   cond = false;
  1870. +               if (trgtF.isInOlympiadMode() && isInOlympiadMode())
  1871. +                   cond = true;
  1872. +           }
  1873. +           if (!cond)
  1874. +           {
  1875. +               sendPacket(ActionFailed.STATIC_PACKET);
  1876. +               return false;
  1877. +           }
  1878. +          
  1879.             if (isInOlympiadMode() && !isOlympiadStart())
  1880.             {
  1881.                 // if L2PcInstance is in Olympia and the match isn't already start, send a Server->Client packet ActionFailed
  1882. @@ -8000,6 +8372,9 @@
  1883.            
  1884.             if (skill.isPvpSkill()) // pvp skill
  1885.             {
  1886. +               if (getFactionId() != ((L2PcInstance)target).getFactionId() && !isInsidePeaceZone(this, ((L2PcInstance)target)))
  1887. +                   return true;
  1888. +
  1889.                 // in clan war player can attack whites even with sleep etc.
  1890.                 if (getClan() != null && ((L2PcInstance)target).getClan() != null)
  1891.                 {
  1892. @@ -8008,12 +8383,15 @@
  1893.                 }
  1894.                
  1895.                 // target's pvp flag is not set and target has no karma
  1896. -               if (((L2PcInstance)target).getPvpFlag() == 0 && ((L2PcInstance)target).getKarma() == 0)
  1897. +               if (((L2PcInstance)target).getPvpFlag() == 0 && ((L2PcInstance)target).getKarma() == 0 && !Config.FACTION_ENGINE_ENABLED)
  1898.                     return false;
  1899.             }
  1900.             else if ((skilldat != null && !skilldat.isCtrlPressed() && skill.isOffensive() && !srcIsSummon)
  1901.                 || (skilldatpet != null && !skilldatpet.isCtrlPressed() && skill.isOffensive() && srcIsSummon))
  1902.             {
  1903. +               if (getFactionId() != ((L2PcInstance)target).getFactionId() && !isInsidePeaceZone(this, ((L2PcInstance)target)))
  1904. +                   return true;
  1905. +
  1906.                 // in clan war player can attack whites even with sleep etc.
  1907.                 if (getClan() != null && ((L2PcInstance)target).getClan() != null)
  1908.                 {
  1909. @@ -8022,7 +8400,7 @@
  1910.                 }
  1911.                
  1912.                 // target's pvp flag is not set and target has no karma
  1913. -               if (((L2PcInstance)target).getPvpFlag() == 0 && ((L2PcInstance)target).getKarma() == 0)
  1914. +               if (((L2PcInstance)target).getPvpFlag() == 0 && ((L2PcInstance)target).getKarma() == 0 && !Config.FACTION_ENGINE_ENABLED)
  1915.                     return false;
  1916.             }
  1917.         }
  1918. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2TpFlagInstance.java
  1919. ===================================================================
  1920. --- java/net/sf/l2j/gameserver/model/actor/instance/L2TpFlagInstance.java   (revision 0)
  1921. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2TpFlagInstance.java   (revision 0)
  1922. @@ -0,0 +1,330 @@
  1923. +/*
  1924. + * This program is free software: you can redistribute it and/or modify it under
  1925. + * the terms of the GNU General Public License as published by the Free Software
  1926. + * Foundation, either version 3 of the License, or (at your option) any later
  1927. + * version.
  1928. + *
  1929. + * This program is distributed in the hope that it will be useful, but WITHOUT
  1930. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1931. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  1932. + * details.
  1933. + *
  1934. + * You should have received a copy of the GNU General Public License along with
  1935. + * this program. If not, see <http://www.gnu.org/licenses/>.
  1936. + */
  1937. +package net.sf.l2j.gameserver.model.actor.instance;
  1938. +
  1939. +import java.sql.Connection;
  1940. +import java.sql.PreparedStatement;
  1941. +import java.sql.ResultSet;
  1942. +import java.util.logging.Logger;
  1943. +
  1944. +import net.sf.l2j.Config;
  1945. +import net.sf.l2j.L2DatabaseFactory;
  1946. +import net.sf.l2j.gameserver.Announcements;
  1947. +import net.sf.l2j.gameserver.ai.CtrlIntention;
  1948. +import net.sf.l2j.gameserver.datatables.NpcTable;
  1949. +import net.sf.l2j.gameserver.idfactory.IdFactory;
  1950. +import net.sf.l2j.gameserver.model.L2Skill;
  1951. +import net.sf.l2j.gameserver.model.actor.L2Character;
  1952. +import net.sf.l2j.gameserver.model.actor.L2Npc;
  1953. +import net.sf.l2j.gameserver.model.entity.FactionMaps;
  1954. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  1955. +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
  1956. +import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
  1957. +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  1958. +import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
  1959. +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
  1960. +import net.sf.l2j.gameserver.util.Broadcast;
  1961. +
  1962. +public final class L2TpFlagInstance extends L2Npc
  1963. +{
  1964. +    private final static Logger _log = Logger.getLogger(L2FactTeleporterInstance.class.getName());
  1965. +  
  1966. +    private int _faction=0;
  1967. +    private int _occupayable=0;
  1968. +    private String _title = "";
  1969. +    private String _flagPlace = "";
  1970. +  
  1971. +    public L2TpFlagInstance(int objectId, L2NpcTemplate template)
  1972. +   {
  1973. +       super(objectId, template);
  1974. +    }
  1975. +  
  1976. +   public static void spawnFlags()
  1977. +   {
  1978. +       Connection con = null;
  1979. +
  1980. +       try
  1981. +       {
  1982. +           con = L2DatabaseFactory.getInstance().getConnection();
  1983. +           PreparedStatement statement = con.prepareStatement("SELECT * FROM faction_crystals WHERE mapId=?");
  1984. +           statement.setInt(1, FactionMaps.getMapId());
  1985. +           ResultSet rset = statement.executeQuery();
  1986. +
  1987. +           while (rset.next())
  1988. +           {
  1989. +               String _titlea = "";
  1990. +               if (rset.getInt("factionId") == 1)
  1991. +                   _titlea = Config.FACTION_TEAM1_NAME + " Faction";
  1992. +               else if (rset.getInt("factionId") == 2)
  1993. +                   _titlea = Config.FACTION_TEAM2_NAME + " Faction";
  1994. +               else if (rset.getInt("factionId") == 3)
  1995. +                   _titlea = Config.FACTION_TEAM3_NAME + " Faction";
  1996. +              
  1997. +               L2TpFlagInstance flag = new L2TpFlagInstance(IdFactory.getInstance().getNextId(),NpcTable.getInstance().getTemplate(31217));
  1998. +               flag.setTitle(_titlea);
  1999. +               flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp());
  2000. +               flag.setHeading(0);
  2001. +               flag.setName(rset.getString("flagName"));
  2002. +               flag.setFlagName(rset.getString("flagName"));
  2003. +               flag.setFlagFactionId(rset.getInt("factionId"));
  2004. +               flag.spawnMe(rset.getInt("x"),rset.getInt("y"),rset.getInt("z") + 50);
  2005. +               if (rset.getInt("factionId") != 0)
  2006. +               {
  2007. +                   if (rset.getInt("factionId") == 1)
  2008. +                       L2FactTeleporterInstance._tpTeam1Flags.add(flag);
  2009. +                   else if (rset.getInt("factionId") == 2)
  2010. +                       L2FactTeleporterInstance._tpTeam2Flags.add(flag);
  2011. +                   else
  2012. +                       L2FactTeleporterInstance._tpTeam3Flags.add(flag);
  2013. +                   flag.setIsInvul(true);
  2014. +                   flag.setIsUnoccupayable(1);
  2015. +               }
  2016. +               _log.info("Spawned flag: " + rset.getString("flagName"));
  2017. +           }
  2018. +
  2019. +           rset.close();
  2020. +           statement.close();
  2021. +       }
  2022. +       catch (Exception e)
  2023. +       {
  2024. +           _log.warning("Something is wrong with flags:" + e);
  2025. +       }
  2026. +       finally
  2027. +       {
  2028. +           try {con.close();} catch (Exception e){}
  2029. +       }
  2030. +       Announcements.getInstance().announceToAll("Spawned faction map: " + FactionMaps.getMapName());
  2031. +   }
  2032. +  
  2033. +   public void setFlagName(String a)
  2034. +   {
  2035. +       _flagPlace = a;
  2036. +   }
  2037. +  
  2038. +   public String getFlagName()
  2039. +   {
  2040. +       return _flagPlace;
  2041. +   }
  2042. +  
  2043. +    @Override
  2044. +   public boolean isAttackable()
  2045. +    {
  2046. +        return true;
  2047. +    }
  2048. +
  2049. +   @Override
  2050. +   public boolean isAutoAttackable(L2Character attacker)
  2051. +   {
  2052. +       return true;
  2053. +   }
  2054. +  
  2055. +    @Override
  2056. +   public boolean doDie(L2Character killer)
  2057. +    {
  2058. +       L2PcInstance player = null;
  2059. +       if (killer instanceof L2PcInstance)
  2060. +           player = (L2PcInstance) killer;
  2061. +       else if (killer instanceof L2SummonInstance)
  2062. +           player = ((L2SummonInstance) killer).getOwner();
  2063. +          
  2064. +       int _faktjon = 0;
  2065. +       String _name = "";
  2066. +          
  2067. +       _faktjon = player.getFactionId();
  2068. +       if (_faktjon == 1)
  2069. +           _title = Config.FACTION_TEAM1_NAME + " Faction";
  2070. +       else if (_faktjon == 2)
  2071. +           _title = Config.FACTION_TEAM2_NAME + " Faction";
  2072. +       else if (_faktjon == 3)
  2073. +           _title = Config.FACTION_TEAM3_NAME + " Faction";
  2074. +       else
  2075. +           _title = "No Faction";
  2076. +          
  2077. +       if (!super.doDie(killer))
  2078. +           return false;
  2079. +
  2080. +       if (player != null)
  2081. +           player.sendPacket(new PlaySound("skillsound7.pig_skill"));
  2082. +          
  2083. +       if (getFlagFactionId() == 1)
  2084. +       {
  2085. +           L2FactTeleporterInstance._tpTeam1Flags.remove(this);
  2086. +           Broadcast.sendMessToAllTeam1Players("[" + Config.FACTION_TEAM1_NAME + "] We just lost " + _flagPlace + " flag on " + FactionMaps.getMapName() + ". Go defend it!");
  2087. +           if (_faktjon == 2)
  2088. +               Broadcast.sendMessToAllTeam2Players("[" + Config.FACTION_TEAM2_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
  2089. +           else if (_faktjon == 3)
  2090. +               Broadcast.sendMessToAllTeam3Players("[" + Config.FACTION_TEAM3_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
  2091. +       }
  2092. +       else if (getFlagFactionId() == 2)
  2093. +       {
  2094. +           L2FactTeleporterInstance._tpTeam2Flags.remove(this);
  2095. +           Broadcast.sendMessToAllTeam2Players("[" + Config.FACTION_TEAM2_NAME + "] We just lost " + _flagPlace + " flag on " + FactionMaps.getMapName() + ". Go defend it!");
  2096. +           if (_faktjon == 1)
  2097. +               Broadcast.sendMessToAllTeam1Players("[" + Config.FACTION_TEAM1_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
  2098. +           else if (_faktjon == 3)
  2099. +               Broadcast.sendMessToAllTeam3Players("[" + Config.FACTION_TEAM3_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
  2100. +       }
  2101. +       else if (getFlagFactionId() == 3)
  2102. +       {
  2103. +           L2FactTeleporterInstance._tpTeam3Flags.remove(this);
  2104. +           Broadcast.sendMessToAllTeam3Players("[" + Config.FACTION_TEAM3_NAME + "] We just lost " + _flagPlace + " flag on " + FactionMaps.getMapName() + ". Go defend it!");
  2105. +           if (_faktjon == 1)
  2106. +               Broadcast.sendMessToAllTeam1Players("[" + Config.FACTION_TEAM1_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
  2107. +           else if (_faktjon == 2)
  2108. +               Broadcast.sendMessToAllTeam2Players("[" + Config.FACTION_TEAM2_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
  2109. +       }
  2110. +       else if (getFlagFactionId() == 0)
  2111. +       {
  2112. +           if (_faktjon == 1)
  2113. +               Broadcast.sendMessToAllTeam1Players("[" + Config.FACTION_TEAM1_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
  2114. +           else if (_faktjon == 2)
  2115. +               Broadcast.sendMessToAllTeam2Players("[" + Config.FACTION_TEAM2_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
  2116. +           else if (_faktjon == 3)
  2117. +               Broadcast.sendMessToAllTeam3Players("[" + Config.FACTION_TEAM3_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
  2118. +       }
  2119. +      
  2120. +       L2TpFlagInstance flag = new L2TpFlagInstance(IdFactory.getInstance().getNextId(),NpcTable.getInstance().getTemplate(31217));
  2121. +       _name = this.getName();
  2122. +       flag.setTitle(_title);
  2123. +       flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp());
  2124. +       flag.setHeading(0);
  2125. +       flag.setName(_name);
  2126. +       flag.setFlagName(_name);
  2127. +       flag.setIsUnoccupayable(0);
  2128. +       flag.setFlagFactionId(_faktjon);
  2129. +       flag.spawnMe(this.getX(), this.getY(), this.getZ());
  2130. +       deleteMe();
  2131. +      
  2132. +       if (_faktjon == 1)
  2133. +           L2FactTeleporterInstance._tpTeam1Flags.add(flag);
  2134. +       else if (_faktjon == 2)
  2135. +           L2FactTeleporterInstance._tpTeam2Flags.add(flag);
  2136. +       else if (_faktjon == 3)
  2137. +           L2FactTeleporterInstance._tpTeam3Flags.add(flag);
  2138. +          
  2139. +       if (Config.FACTION_ALLOW_SP_REWARD_FLAG)
  2140. +       {
  2141. +           if (player.getClan() != null)
  2142. +           {
  2143. +               if (player.getClan().getLevel() < 5)
  2144. +               {
  2145. +                   player.addExpAndSp(0, Config.FACTION_SP_REWARD_FIRST_FLAG);
  2146. +                   player.addItem("Loot", 5575, Config.FACTION_AA_REWARD_FIRST_FLAG, this, true);
  2147. +               }
  2148. +               else if (player.getClan().getLevel() >= 5 && player.getClan().getLevel() < 7)
  2149. +               {
  2150. +                   player.addExpAndSp(0, Config.FACTION_SP_REWARD_SECOND_FLAG);
  2151. +                   player.addItem("Loot", 5575, Config.FACTION_AA_REWARD_SECOND_FLAG, this, true);
  2152. +               }
  2153. +               else
  2154. +               {
  2155. +                   player.addExpAndSp(0, Config.FACTION_SP_REWARD_THIRD_FLAG);
  2156. +                   player.addItem("Loot", 5575, Config.FACTION_AA_REWARD_THIRD_FLAG, this, true);
  2157. +               }
  2158. +           }
  2159. +           else
  2160. +           {
  2161. +               player.addExpAndSp(0, Config.FACTION_SP_REWARD_THIRD_FLAG);
  2162. +               player.addItem("Loot", 5575, Config.FACTION_AA_REWARD_THIRD_FLAG, this, true);
  2163. +           }
  2164. +           int points = player.getFactionPoints();
  2165. +           player.setFactionPoints(points + Config.FACTION_POINTS_FLAG);
  2166. +            player.sendMessage("You received " + Config.FACTION_POINTS_FLAG + " points for capturing enemy flag!");
  2167. +          
  2168. +       }
  2169. +
  2170. +        return true;
  2171. +    }
  2172. +
  2173. +    @Override
  2174. +   public void onForcedAttack(L2PcInstance player)
  2175. +   {
  2176. +       onAction(player);
  2177. +   }
  2178. +
  2179. +   public void setIsUnoccupayable(int a)
  2180. +   {
  2181. +           _occupayable = a;
  2182. +   }
  2183. +
  2184. +   public int isUnoccupayable()
  2185. +   {
  2186. +       return _occupayable;
  2187. +   }
  2188. +
  2189. +   @Override
  2190. +   public void onAction(L2PcInstance player)
  2191. +   {
  2192. +       if (player == null || !canTarget(player))
  2193. +           return;
  2194. +      
  2195. +           // Check if the L2PcInstance already target the L2NpcInstance
  2196. +       if (this != player.getTarget())
  2197. +       {
  2198. +           // Set the target of the L2PcInstance player
  2199. +           player.setTarget(this);
  2200. +
  2201. +           // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
  2202. +           MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
  2203. +           player.sendPacket(my);
  2204. +
  2205. +           // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
  2206. +           StatusUpdate su = new StatusUpdate(getObjectId());
  2207. +           su.addAttribute(StatusUpdate.CUR_HP, (int)getStatus().getCurrentHp() );
  2208. +           su.addAttribute(StatusUpdate.MAX_HP, getMaxHp() );
  2209. +           player.sendPacket(su);
  2210. +
  2211. +           // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
  2212. +           player.sendPacket(new ValidateLocation(this));
  2213. +       }
  2214. +       else
  2215. +       {
  2216. +           if (isAutoAttackable(player) && Math.abs(player.getZ() - getZ()) < 100)
  2217. +               player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
  2218. +           else
  2219. +           {
  2220. +               // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
  2221. +               player.sendPacket(ActionFailed.STATIC_PACKET);
  2222. +           }
  2223. +       }
  2224. +   }
  2225. +  
  2226. +   public int getFlagFactionId()
  2227. +   {
  2228. +       return _faction;
  2229. +   }
  2230. +  
  2231. +   public void setFlagFactionId(int i)
  2232. +   {
  2233. +       _faction = i;
  2234. +   }
  2235. +  
  2236. +    @Override
  2237. +   public void reduceCurrentHp(double damage, L2Character attacker, L2Skill skill)
  2238. +    {
  2239. +       L2PcInstance plajor = null;
  2240. +       boolean cord = false;
  2241. +       if (attacker instanceof L2PcInstance)
  2242. +           plajor = (L2PcInstance) attacker;
  2243. +       else if (attacker instanceof L2SummonInstance)
  2244. +           plajor = ((L2SummonInstance) attacker).getOwner();
  2245. +          
  2246. +       if (plajor.getFactionId() != getFlagFactionId() && plajor.getFactionId() != 0)
  2247. +           cord = true;
  2248. +              
  2249. +       if (cord)
  2250. +           super.reduceCurrentHp(damage, attacker, skill);
  2251. +    }
  2252. +}
  2253. \ No newline at end of file
  2254. Index: java/net/sf/l2j/gameserver/model/actor/L2Character.java
  2255. ===================================================================
  2256. --- java/net/sf/l2j/gameserver/model/actor/L2Character.java (revision 128)
  2257. +++ java/net/sf/l2j/gameserver/model/actor/L2Character.java (working copy)
  2258. @@ -116,6 +116,9 @@
  2259.  import net.sf.l2j.util.Point3D;
  2260.  import net.sf.l2j.util.Rnd;
  2261.  
  2262. +import net.sf.l2j.gameserver.model.actor.instance.L2TpFlagInstance;
  2263. +import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
  2264. +
  2265.  /**
  2266.   * L2Character is the mother class of all character objects of the world (PC, NPC...) :<br><br>
  2267.   * <b><u> Instances using it </u> :</b>
  2268. @@ -593,6 +596,29 @@
  2269.  
  2270.         if (this instanceof L2PcInstance)
  2271.         {
  2272. +           L2PcInstance player = (L2PcInstance) this;
  2273. +           L2PcInstance trgtF = null;
  2274. +           boolean cond = true;
  2275. +          
  2276. +           if (target instanceof L2PcInstance)
  2277. +               trgtF = (L2PcInstance) target;
  2278. +           else if (target instanceof L2SummonInstance)
  2279. +               trgtF = ((L2SummonInstance)target).getOwner();
  2280. +
  2281. +           if (trgtF != null && Config.FACTION_ENGINE_ENABLED)
  2282. +           {
  2283. +               if (trgtF.getFactionId() == player.getFactionId())
  2284. +                   cond = false;
  2285. +               if (trgtF.getFactionId() == 0 || player.getFactionId() == 0)
  2286. +                   cond = false;
  2287. +               if (isInsidePeaceZone(this, trgtF))
  2288. +                   cond = false;
  2289. +               if (trgtF.isInOlympiadMode() && player.isInOlympiadMode())
  2290. +                   cond = true;
  2291. +           }
  2292. +           if (!cond)
  2293. +               return;
  2294. +      
  2295.             if (((L2PcInstance)this).inObserverMode())
  2296.             {
  2297.                 sendPacket(new SystemMessage(SystemMessageId.OBSERVERS_CANNOT_PARTICIPATE));
  2298. @@ -1730,7 +1756,8 @@
  2299.  
  2300.         // Stop Regeneration task, and removes all current effects
  2301.         getStatus().stopHpMpRegeneration();
  2302.         stopAllEffectsExceptThoseThatLastThroughDeath();
  2303. +
  2304.        
  2305.         calculateRewards(killer);
  2306.  
  2307. @@ -1803,12 +1830,16 @@
  2308.             {  
  2309.                 restorefull = true;
  2310.                 ((L2Playable)this).stopPhoenixBlessing(null);  
  2311. -           }  
  2312. +           }
  2313. +           else if (this instanceof L2PcInstance && ((L2PcInstance) this).getFactionId() != 0 && Config.FACTION_ENGINE_ENABLED)
  2314. +               restorefull = true;
  2315.            
  2316.             if (restorefull)  
  2317.             {
  2318.                 _status.setCurrentHp(getMaxHp());
  2319.                 _status.setCurrentMp(getMaxMp());
  2320. +               if (Config.FACTION_ENGINE_ENABLED)
  2321. +                   _status.setCurrentCp(getMaxCp());
  2322.             }
  2323.             else
  2324.                 _status.setCurrentHp(getMaxHp() * Config.RESPAWN_RESTORE_HP);
  2325. Index: java/net/sf/l2j/gameserver/model/base/SubClass.java
  2326. ===================================================================
  2327. --- java/net/sf/l2j/gameserver/model/base/SubClass.java (revision 128)
  2328. +++ java/net/sf/l2j/gameserver/model/base/SubClass.java (working copy)
  2329. @@ -18,6 +18,8 @@
  2330.   */
  2331.  package net.sf.l2j.gameserver.model.base;
  2332.  
  2333. +import net.sf.l2j.Config;
  2334. +
  2335.  /**
  2336.   * Character Sub-Class Definition
  2337.   * <BR>
  2338. @@ -28,9 +30,9 @@
  2339.  public final class SubClass
  2340.  {
  2341.      private PlayerClass _class;
  2342. -    private long _exp = Experience.LEVEL[40];
  2343. +    private long _exp = Experience.LEVEL[Config.FACTION_START_LVL_SUB];
  2344.      private int _sp = 0;
  2345. -    private byte _level = 40;
  2346. +    private byte _level = (byte)Config.FACTION_START_LVL_SUB;
  2347.      private int _classIndex = 1;
  2348.  
  2349.      public SubClass(int classId, long exp, int sp, byte level, int classIndex)
  2350. Index: java/net/sf/l2j/gameserver/model/CharEffectList.java
  2351. ===================================================================
  2352. --- java/net/sf/l2j/gameserver/model/CharEffectList.java    (revision 128)
  2353. +++ java/net/sf/l2j/gameserver/model/CharEffectList.java    (working copy)
  2354. @@ -363,8 +363,16 @@
  2355.         // Exit them
  2356.         for (L2Effect e : effects)
  2357.         {
  2358. -           if (e != null)
  2359. -               e.exit(true);
  2360. +           if (!Config.FACTION_ENGINE_ENABLED)
  2361. +           {
  2362. +               if (e != null)
  2363. +                   e.exit(true);
  2364. +           }
  2365. +           else
  2366. +           {
  2367. +               if (e != null && e.getSkill().isDebuff())
  2368. +                   e.exit(true);
  2369. +           }
  2370.         }
  2371.     }
  2372.    
  2373. Index: java/net/sf/l2j/gameserver/model/entity/FactionMaps.java
  2374. ===================================================================
  2375. --- java/net/sf/l2j/gameserver/model/entity/FactionMaps.java    (revision 0)
  2376. +++ java/net/sf/l2j/gameserver/model/entity/FactionMaps.java    (revision 0)
  2377. @@ -0,0 +1,337 @@
  2378. +/*
  2379. + * This program is free software: you can redistribute it and/or modify it under
  2380. + * the terms of the GNU General Public License as published by the Free Software
  2381. + * Foundation, either version 3 of the License, or (at your option) any later
  2382. + * version.
  2383. + *
  2384. + * This program is distributed in the hope that it will be useful, but WITHOUT
  2385. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2386. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  2387. + * details.
  2388. + *
  2389. + * You should have received a copy of the GNU General Public License along with
  2390. + * this program. If not, see <http://www.gnu.org/licenses/>.
  2391. + */
  2392. +package net.sf.l2j.gameserver.model.entity;
  2393. +
  2394. +import java.sql.Connection;
  2395. +import java.sql.PreparedStatement;
  2396. +import java.sql.ResultSet;
  2397. +import java.util.Calendar;
  2398. +import java.util.logging.Logger;
  2399. +
  2400. +import net.sf.l2j.Config;
  2401. +import net.sf.l2j.L2DatabaseFactory;
  2402. +import net.sf.l2j.gameserver.Announcements;
  2403. +import net.sf.l2j.gameserver.ThreadPoolManager;
  2404. +import net.sf.l2j.gameserver.datatables.MapRegionTable;
  2405. +import net.sf.l2j.gameserver.model.L2World;
  2406. +import net.sf.l2j.gameserver.model.actor.instance.L2FactTeleporterInstance;
  2407. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  2408. +import net.sf.l2j.gameserver.model.actor.instance.L2TpFlagInstance;
  2409. +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
  2410. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  2411. +import net.sf.l2j.gameserver.util.Broadcast;
  2412. +import net.sf.l2j.util.StringUtil;
  2413. +
  2414. +/**
  2415. + * @author DarthVader
  2416. + */
  2417. +public class FactionMaps
  2418. +{
  2419. +    private final static Logger _log = Logger.getLogger(FactionMaps.class.getName());
  2420. +   public static int _mapId = 0;
  2421. +   public static String _mapName = "";
  2422. +   public static boolean _voting = false;
  2423. +   public static int[] _mapVotes = new int[10];
  2424. +   public static String[] _mapNames = new String[10];
  2425. +   private static long _nextMapIn = 0;
  2426. +  
  2427. +   public static boolean isVoting()
  2428. +   {
  2429. +       return _voting;
  2430. +   }
  2431. +  
  2432. +   public static int getMapId()
  2433. +   {
  2434. +       return _mapId;
  2435. +   }
  2436. +  
  2437. +   public static String getMapName()
  2438. +   {
  2439. +       return _mapName;
  2440. +   }
  2441. +  
  2442. +   public static String getDelayUntilVoting()
  2443. +   {
  2444. +       long trim = _nextMapIn - Calendar.getInstance().getTimeInMillis();
  2445. +       int h = 0;
  2446. +       int m = 0;
  2447. +       int s = 0;
  2448. +       int k = 1/2;
  2449. +       h = 0;
  2450. +       m = 0;
  2451. +       s = 0;
  2452. +
  2453. +       if (trim/3600000 >= 1)
  2454. +       {
  2455. +           h = Math.round(trim/3600000-k);
  2456. +           trim -=h*3600000;
  2457. +       }
  2458. +       if (trim/60 >= 1)
  2459. +       {
  2460. +           m = Math.round(trim/60000-k);
  2461. +           trim -=m*60000;
  2462. +       }
  2463. +       if (trim/1000 >= 1)
  2464. +       {
  2465. +           s = Math.round(trim/1000-k);
  2466. +       }
  2467. +       return h + "h. " + m + "m. " + s + "s.";
  2468. +   }
  2469. +  
  2470. +   public static void loadCurrentMap()
  2471. +   {
  2472. +       Connection con = null;
  2473. +       try
  2474. +       {
  2475. +           con = L2DatabaseFactory.getInstance().getConnection();
  2476. +           PreparedStatement stmt = con.prepareStatement("SELECT mapId,map_name FROM faction_maps WHERE current=1");
  2477. +           ResultSet rset = stmt.executeQuery();
  2478. +           while (rset.next())
  2479. +           {
  2480. +               _mapId = rset.getInt("mapId");
  2481. +               _mapName = rset.getString("map_name");
  2482. +           }
  2483. +           rset.close();
  2484. +           stmt.close();
  2485. +       }
  2486. +       catch (Exception e) { _log.warning("Load current map: "+ e); }
  2487. +       finally { try { con.close(); } catch (Exception e) {} }
  2488. +       ThreadPoolManager.getInstance().scheduleGeneral(new Runnable(){public void run(){endVoting(true);}}, 1000);
  2489. +   }
  2490. +  
  2491. +   public static void beginVoting()
  2492. +   {
  2493. +       for (L2TpFlagInstance flag : L2FactTeleporterInstance._tpTeam1Flags)
  2494. +           flag.deleteMe();
  2495. +       for (L2TpFlagInstance flag : L2FactTeleporterInstance._tpTeam2Flags)
  2496. +           flag.deleteMe();
  2497. +       for (L2TpFlagInstance flag : L2FactTeleporterInstance._tpTeam3Flags)
  2498. +           flag.deleteMe();
  2499. +       L2FactTeleporterInstance._tpTeam1Flags.clear();
  2500. +       L2FactTeleporterInstance._tpTeam2Flags.clear();
  2501. +       L2FactTeleporterInstance._tpTeam3Flags.clear();
  2502. +       for (L2PcInstance plajer : L2World.getInstance().getAllPlayers().values())
  2503. +       {
  2504. +           if (plajer.getFactionId() == 1)
  2505. +               plajer.teleToLocation(Config.FACTION_TEAM1_BASE_X, Config.FACTION_TEAM1_BASE_Y, Config.FACTION_TEAM1_BASE_Z);
  2506. +           else if (plajer.getFactionId() == 2)
  2507. +               plajer.teleToLocation(Config.FACTION_TEAM2_BASE_X, Config.FACTION_TEAM2_BASE_Y, Config.FACTION_TEAM2_BASE_Z);
  2508. +           else if (plajer.getFactionId() == 3)
  2509. +               plajer.teleToLocation(Config.FACTION_TEAM3_BASE_X, Config.FACTION_TEAM3_BASE_Y, Config.FACTION_TEAM3_BASE_Z);
  2510. +           else   
  2511. +               plajer.teleToLocation(Config.FACTION_CUSTOM_SPAWN_X, Config.FACTION_CUSTOM_SPAWN_Y, Config.FACTION_CUSTOM_SPAWN_Z);
  2512. +  
  2513. +           plajer.setVotedForMap(false);
  2514. +       }
  2515. +       Announcements.getInstance().announceToAll("Round ended.");
  2516. +       Announcements.getInstance().announceToAll("Voting for next faction map has begun. It will end in 60 seconds.");
  2517. +       _voting = true;
  2518. +       NpcHtmlMessage html = new NpcHtmlMessage(1);
  2519. +       final StringBuilder strBuffer = StringUtil.startAppend(3500, "<html><title>Faction Maps</title><body><center>");
  2520. +       strBuffer.append("<img src=\"L2UI_CH3.onscrmsg_pattern01_1\" width=300 height=32 align=left><br>");
  2521. +       Connection con = null;
  2522. +       try
  2523. +       {
  2524. +           con = L2DatabaseFactory.getInstance().getConnection();
  2525. +           PreparedStatement statement = con.prepareStatement("SELECT * FROM faction_maps");
  2526. +           ResultSet rset = statement.executeQuery();
  2527. +           for (int r = 0; r < _mapVotes.length; r++)
  2528. +               _mapVotes[r] = 0;
  2529. +           while (rset.next())
  2530. +           {
  2531. +               strBuffer.append("<button value=\"" + rset.getString("map_name") + "\" action=\"bypass -h voteformap " + rset.getInt("mapId") + "\" width=170 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  2532. +               _mapNames[rset.getInt("mapId")] = rset.getString("map_name");
  2533. +           }
  2534. +
  2535. +           rset.close();
  2536. +           statement.close();
  2537. +       }
  2538. +       catch (Exception e)
  2539. +       {
  2540. +           e.printStackTrace();
  2541. +       }
  2542. +       finally
  2543. +       {
  2544. +           try {con.close();} catch (Exception e){}
  2545. +       }
  2546. +       strBuffer.append("<img src=\"L2UI_CH3.onscrmsg_pattern01_2\" width=300 height=32 align=left></center></body></html>");
  2547. +       html.setHtml(strBuffer.toString());
  2548. +       for (L2PcInstance plajer : L2World.getInstance().getAllPlayers().values())
  2549. +           plajer.sendPacket(html);
  2550. +       try{Thread.sleep(60000);}catch (Exception e){}
  2551. +       endVoting(false);
  2552. +   }
  2553. +  
  2554. +   public static void endVoting(boolean onLoad)
  2555. +   {
  2556. +       int team1 = 0;
  2557. +       for (L2PcInstance zaidejas1 : L2World.getInstance().getAllteam1Players())
  2558. +           team1 = zaidejas1.getFactionPoints();
  2559. +       int team2 = 0;
  2560. +       for (L2PcInstance zaidejas2 : L2World.getInstance().getAllteam2Players())
  2561. +           team2 = zaidejas2.getFactionPoints();
  2562. +       int team3 = 0;
  2563. +       for (L2PcInstance zaidejas3 : L2World.getInstance().getAllteam3Players())
  2564. +           team3 = zaidejas3.getFactionPoints();
  2565. +       int bestteam = 0;
  2566. +       if (team1 > team2 && team1 > team3)
  2567. +           bestteam = 1;
  2568. +       else if (team2 > team1 && team2 > team3)
  2569. +           bestteam = 2;
  2570. +       else if (team3 > team1 && team3 > team2)
  2571. +           bestteam = 3;
  2572. +       else if (team1 == team2)
  2573. +           bestteam = 4;
  2574. +       else if (team1 == team3)
  2575. +           bestteam = 5;
  2576. +       else if (team2 == team3)
  2577. +           bestteam = 6;
  2578. +       else if (team1 == team2 && team1 == team3 && team2 == team3 && team1 > 0 && team2 > 0 && team3 > 0)
  2579. +           bestteam = 7;
  2580. +
  2581. +       _nextMapIn = Calendar.getInstance().getTimeInMillis() + 7200000;
  2582. +       if (!onLoad)
  2583. +       {
  2584. +           _voting = false;
  2585. +           int mostVotes = 0;
  2586. +           int mostMapId = 0;
  2587. +           for (int i = 0; i < _mapVotes.length; i++)
  2588. +           {
  2589. +               if (_mapVotes[i] > mostVotes)
  2590. +               {
  2591. +                   mostVotes = _mapVotes[i];
  2592. +                   mostMapId = i;
  2593. +               }
  2594. +           }
  2595. +           _mapName = _mapNames[mostMapId];
  2596. +           _mapId = mostMapId;
  2597. +           Announcements.getInstance().announceToAll("Voting for faction maps has ended.");
  2598. +           Announcements.getInstance().announceToAll("The next map will be: " + _mapName);
  2599. +          
  2600. +            Broadcast.sendMessToAllFactionPlayers("Points, collected during this round:");
  2601. +            Broadcast.sendMessToAllFactionPlayers("[" + Config.FACTION_TEAM1_NAME + "] collected - " + team1 + " points");
  2602. +            Broadcast.sendMessToAllFactionPlayers("[" + Config.FACTION_TEAM2_NAME + "] collected - " + team2 + " points");
  2603. +            Broadcast.sendMessToAllFactionPlayers("[" + Config.FACTION_TEAM3_NAME + "] collected - " + team3 + " points");
  2604. +          
  2605. +           if (bestteam == 1)
  2606. +               for (L2PcInstance _players : L2World.getInstance().getAllteam1Players())
  2607. +               {
  2608. +                   Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM1_NAME + " faction won, all faction members got rewarded!");
  2609. +                   _players.addItem("Admin", 57, 20, _players, true);
  2610. +               }
  2611. +           else if (bestteam == 2)
  2612. +               for (L2PcInstance _players : L2World.getInstance().getAllteam2Players())
  2613. +               {
  2614. +                   Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM2_NAME + " faction won, all faction members got rewarded!");
  2615. +                   _players.addItem("Admin", 57, 20, _players, true);
  2616. +               }
  2617. +           else if (bestteam == 3)
  2618. +               for (L2PcInstance _players : L2World.getInstance().getAllteam3Players())
  2619. +               {
  2620. +                   Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM3_NAME + " faction won, all faction members got rewarded!");
  2621. +                   _players.addItem("Admin", 57, 20, _players, true);
  2622. +               }
  2623. +           else if (bestteam == 4)
  2624. +           {
  2625. +               Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM1_NAME + " and " + Config.FACTION_TEAM2_NAME + " factions won, all faction members got rewarded!");
  2626. +               for (L2PcInstance _players : L2World.getInstance().getAllteam1Players())
  2627. +                   _players.addItem("Admin", 57, 20, _players, true);
  2628. +               for (L2PcInstance _players : L2World.getInstance().getAllteam2Players())
  2629. +                   _players.addItem("Admin", 57, 20, _players, true);
  2630. +           }
  2631. +           else if (bestteam == 5)
  2632. +           {
  2633. +               Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM1_NAME + " and " + Config.FACTION_TEAM3_NAME + " factions won, all faction members got rewarded!");
  2634. +               for (L2PcInstance _players : L2World.getInstance().getAllteam1Players())
  2635. +                   _players.addItem("Admin", 57, 20, _players, true);
  2636. +               for (L2PcInstance _players : L2World.getInstance().getAllteam3Players())
  2637. +                   _players.addItem("Admin", 57, 20, _players, true);
  2638. +           }
  2639. +           else if (bestteam == 6)
  2640. +           {
  2641. +               Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM2_NAME + " and " + Config.FACTION_TEAM3_NAME + " factions won, all faction members got rewarded!");
  2642. +               for (L2PcInstance _players : L2World.getInstance().getAllteam2Players())
  2643. +                   _players.addItem("Admin", 57, 20, _players, true);
  2644. +               for (L2PcInstance _players : L2World.getInstance().getAllteam3Players())
  2645. +                   _players.addItem("Admin", 57, 20, _players, true);
  2646. +           }
  2647. +           else if (bestteam == 7)
  2648. +           {
  2649. +               Broadcast.sendMessToAllFactionPlayers("All factions won, all faction members got rewarded!");
  2650. +               for (L2PcInstance _players : L2World.getInstance().getAllteam1Players())
  2651. +                   _players.addItem("Admin", 57, 20, _players, true);
  2652. +               for (L2PcInstance _players : L2World.getInstance().getAllteam2Players())
  2653. +                   _players.addItem("Admin", 57, 20, _players, true);
  2654. +               for (L2PcInstance _players : L2World.getInstance().getAllteam3Players())
  2655. +                   _players.addItem("Admin", 57, 20, _players, true);
  2656. +           }
  2657. +           else
  2658. +               Broadcast.sendMessToAllFactionPlayers("Round ended in tie!");
  2659. +
  2660. +           for (L2PcInstance zaid : L2World.getInstance().getAllPlayers().values())
  2661. +               zaid.setFactionPoints(0);
  2662. +          
  2663. +           L2TpFlagInstance.spawnFlags();
  2664. +          
  2665. +           Connection con = null;
  2666. +           try
  2667. +           {
  2668. +               con = L2DatabaseFactory.getInstance().getConnection();
  2669. +               PreparedStatement statement = null;
  2670. +               statement = con.prepareStatement("UPDATE faction_maps SET current=0");
  2671. +               statement.execute();
  2672. +               statement = con.prepareStatement("UPDATE faction_maps SET current=1 WHERE mapId=?");
  2673. +               statement.setInt(1, _mapId);
  2674. +               statement.execute();
  2675. +               statement.close();
  2676. +           }
  2677. +           catch (Exception e) { _log.warning("End voting: "+ e); }
  2678. +           finally { try { con.close(); } catch (Exception e) {} }
  2679. +       }
  2680. +       int time = 0;
  2681. +       String left = "";
  2682. +       for (int a = 4; a > 0;a-=1)
  2683. +       {
  2684. +           switch(a)
  2685. +           {
  2686. +               case 4:
  2687. +                   time = 3600000;
  2688. +                   left = "1 hour";
  2689. +                   break;
  2690. +               case 3:
  2691. +                   time = 1800000;
  2692. +                   left = "30 minutes";
  2693. +                   break;
  2694. +               case 2:
  2695. +                   time = 1500000;
  2696. +                   left = "5 minutes";
  2697. +                   break;
  2698. +               case 1:
  2699. +                   time = 240000;
  2700. +                   left = "1 minute";
  2701. +                   break;
  2702. +           }
  2703. +           try{Thread.sleep(time);}catch (Exception e){}
  2704. +           ExShowScreenMessage exshowscrn = new ExShowScreenMessage("Voting for faction maps will begin in " + left,4500);
  2705. +           Broadcast.toAllOnlinePlayers(exshowscrn);
  2706. +       }
  2707. +       beginVoting();
  2708. +   }
  2709. +  
  2710. +   public static void voteForMap(int mapId)
  2711. +   {
  2712. +       _mapVotes[mapId] +=1;
  2713. +   }
  2714. +}
  2715. \ No newline at end of file
  2716. Index: java/net/sf/l2j/gameserver/model/L2Skill.java
  2717. ===================================================================
  2718. --- java/net/sf/l2j/gameserver/model/L2Skill.java   (revision 128)
  2719. +++ java/net/sf/l2j/gameserver/model/L2Skill.java   (working copy)
  2720. @@ -2139,6 +2139,26 @@
  2721.             {
  2722.                 if (targetPlayer == caster || targetPlayer == player)
  2723.                     return false;
  2724. +                  
  2725. +               boolean cond = true;
  2726. +               L2PcInstance trgtF = null;
  2727. +               if (target instanceof L2PcInstance)
  2728. +                   trgtF = (L2PcInstance)target;
  2729. +               else if (target instanceof L2SummonInstance)
  2730. +                   trgtF = ((L2SummonInstance)target).getOwner();
  2731. +               if (trgtF != null && Config.FACTION_ENGINE_ENABLED)
  2732. +               {
  2733. +                   if (trgtF.getFactionId() == player.getFactionId())
  2734. +                       cond = false;
  2735. +                   if (trgtF.getFactionId() == 0 || player.getFactionId() == 0)
  2736. +                       cond = false;
  2737. +//                 if (trgtF.isInsideZone(L2Character.ZONE_PEACE))
  2738. +//                     cond = false;
  2739. +                   if (trgtF.isInOlympiadMode() && player.isInOlympiadMode())
  2740. +                       cond = true;
  2741. +               }
  2742. +               if (!cond)
  2743. +                   return false;
  2744.                
  2745.                 if (targetPlayer.inObserverMode())
  2746.                     return false;
  2747. Index: java/net/sf/l2j/gameserver/model/L2World.java
  2748. ===================================================================
  2749. --- java/net/sf/l2j/gameserver/model/L2World.java   (revision 128)
  2750. +++ java/net/sf/l2j/gameserver/model/L2World.java   (working copy)
  2751. @@ -64,6 +64,9 @@
  2752.     private Map<Integer, L2PcInstance> _allPlayers;
  2753.     private Map<Integer, L2Object> _allObjects;
  2754.     private Map<Integer, L2PetInstance> _petsInstance;
  2755. +    private Map<String, L2PcInstance> _allteam1Players;
  2756. +    private Map<String, L2PcInstance> _allteam2Players;
  2757. +    private Map<String, L2PcInstance> _allteam3Players;
  2758.  
  2759.      private L2WorldRegion[][] _worldRegions;
  2760.      private static final L2World _instance = new L2World();
  2761. @@ -76,6 +79,9 @@
  2762.         _allPlayers = new FastMap<Integer, L2PcInstance>().shared();
  2763.         _petsInstance = new FastMap<Integer, L2PetInstance>().shared();
  2764.         _allObjects = new FastMap<Integer, L2Object>().shared();
  2765. +        _allteam1Players = new FastMap<String, L2PcInstance>().shared();
  2766. +        _allteam2Players = new FastMap<String, L2PcInstance>().shared();
  2767. +        _allteam3Players = new FastMap<String, L2PcInstance>().shared();
  2768.  
  2769.          initRegions();
  2770.      }
  2771. @@ -202,6 +208,36 @@
  2772.     {
  2773.         return _allPlayers;
  2774.     }
  2775. +  
  2776. +   public Map<String, L2PcInstance> getAllTeam1()
  2777. +   {
  2778. +       return _allteam1Players;
  2779. +   }
  2780. +  
  2781. +   public Map<String, L2PcInstance> getAllTeam2()
  2782. +   {
  2783. +       return _allteam2Players;
  2784. +   }
  2785. +  
  2786. +   public Map<String, L2PcInstance> getAllTeam3()
  2787. +   {
  2788. +       return _allteam3Players;
  2789. +   }
  2790. +  
  2791. +    public Collection<L2PcInstance> getAllteam1Players()
  2792. +    {
  2793. +       return _allteam1Players.values();
  2794. +    }
  2795. +    
  2796. +    public Collection<L2PcInstance> getAllteam2Players()
  2797. +    {
  2798. +       return _allteam2Players.values();
  2799. +    }
  2800. +  
  2801. +    public Collection<L2PcInstance> getAllteam3Players()
  2802. +    {
  2803. +       return _allteam3Players.values();
  2804. +    }
  2805.  
  2806.      /**
  2807.       * Return how many players are online.<BR><BR>
  2808. @@ -325,6 +361,12 @@
  2809.                 }
  2810.                 _allPlayers.put(player.getObjectId(), player);
  2811.             }
  2812. +           if (player.getFactionId() == 1)
  2813. +               _allteam1Players.put(player.getName().toLowerCase(),player);
  2814. +           else if (player.getFactionId() == 2)
  2815. +               _allteam2Players.put(player.getName().toLowerCase(),player);
  2816. +           else if (player.getFactionId() == 3)
  2817. +              _allteam3Players.put(player.getName().toLowerCase(),player);
  2818.          }
  2819.          
  2820.         if (!newRegion.isActive())
  2821. @@ -437,8 +479,15 @@
  2822.              // If selected L2Object is a L2PcIntance, remove it from L2ObjectHashSet(L2PcInstance) _allPlayers of L2World
  2823.              if (object instanceof L2PcInstance)
  2824.              {
  2825. -                if (!((L2PcInstance)object).isTeleporting())
  2826. -                   removeFromAllPlayers((L2PcInstance)object);
  2827. +               L2PcInstance player = (L2PcInstance) object;
  2828. +               if (!player.isTeleporting())
  2829. +                   removeFromAllPlayers(player);
  2830. +               if (player.getFactionId() == 1)
  2831. +                   _allteam1Players.remove(player.getName().toLowerCase());
  2832. +               else if (player.getFactionId() == 2)
  2833. +                  _allteam2Players.remove(player.getName().toLowerCase());
  2834. +               else if (player.getFactionId() == 3)
  2835. +                   _allteam3Players.remove(player.getName().toLowerCase());
  2836.              }
  2837.          }
  2838.      }
  2839. Index: java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java
  2840. ===================================================================
  2841. --- java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java   (revision 128)
  2842. +++ java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java   (working copy)
  2843. @@ -196,7 +196,10 @@
  2844.         L2PcTemplate template = newChar.getTemplate();
  2845.  
  2846.         newChar.addAdena("Init", Config.STARTING_ADENA, null, false);
  2847. -       newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
  2848. +       if (!Config.FACTION_ENGINE_ENABLED)
  2849. +           newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
  2850. +       else
  2851. +           newChar.setXYZInvisible(Config.FACTION_CUSTOM_SPAWN_X, Config.FACTION_CUSTOM_SPAWN_Y, Config.FACTION_CUSTOM_SPAWN_Z);
  2852.         newChar.setTitle("");
  2853.        
  2854.         newChar.registerShortCut(new L2ShortCut(0,0,3,2,-1,1));     // attack shortcut
  2855. Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
  2856. ===================================================================
  2857. --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (revision 128)
  2858. +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java    (working copy)
  2859. @@ -1,4 +1,5 @@
  2860.  /*
  2861. +/*
  2862.   * This program is free software; you can redistribute it and/or modify
  2863.   * it under the terms of the GNU General Public License as published by
  2864.   * the Free Software Foundation; either version 2, or (at your option)
  2865. @@ -148,6 +149,39 @@
  2866.             sendPacket(new PledgeShowMemberListAll(activeChar.getClan(), activeChar));
  2867.             sendPacket(new PledgeStatusChanged(activeChar.getClan()));
  2868.         }
  2869. +      
  2870. +       if (Config.FACTION_ENGINE_ENABLED)
  2871. +       {
  2872. +           if (activeChar.getFactionId() == 1)
  2873. +           {
  2874. +               activeChar.getAppearance().setNameColor(Config.FACTION_TEAM1_COLOR);
  2875. +               activeChar.getAppearance().setTitleColor(Config.FACTION_TEAM1_COLOR);
  2876. +               activeChar.sendMessage("You are fighting for " + Config.FACTION_TEAM1_NAME + " Faction");
  2877. +           }
  2878. +           else if (activeChar.getFactionId() == 2)
  2879. +           {
  2880. +               activeChar.getAppearance().setNameColor(Config.FACTION_TEAM2_COLOR);
  2881. +               activeChar.getAppearance().setTitleColor(Config.FACTION_TEAM2_COLOR);
  2882. +               activeChar.sendMessage("You are fighting for " + Config.FACTION_TEAM2_NAME + " Faction");
  2883. +           }
  2884. +           else if (activeChar.getFactionId() == 3)
  2885. +           {
  2886. +               activeChar.getAppearance().setNameColor(Config.FACTION_TEAM3_COLOR);
  2887. +               activeChar.getAppearance().setTitleColor(Config.FACTION_TEAM3_COLOR);
  2888. +               activeChar.sendMessage("You are fighting for " + Config.FACTION_TEAM3_NAME + " Faction");
  2889. +           }
  2890. +                  
  2891. +           activeChar.setIP((activeChar.getClient().getConnection().getInetAddress().getHostAddress()).toString());           
  2892. +           if (Config.ENABLE_ONLINE_PLAYERS_ON_ENTERWORLD)
  2893. +           {
  2894. +               activeChar.sendMessage("--------------------------------------------------------------");
  2895. +               activeChar.sendMessage(Config.FACTION_TEAM1_NAME + ": " + L2World.getInstance().getAllteam1Players().size());
  2896. +               activeChar.sendMessage(Config.FACTION_TEAM2_NAME + ": " + L2World.getInstance().getAllteam2Players().size());
  2897. +               activeChar.sendMessage(Config.FACTION_TEAM3_NAME + ": " + L2World.getInstance().getAllteam3Players().size());
  2898. +               activeChar.sendMessage("Total: " + L2World.getInstance().getAllPlayersCount() + " online.");
  2899. +               activeChar.sendMessage("--------------------------------------------------------------");
  2900. +           }
  2901. +       }
  2902.          
  2903.         // Updating Seal of Strife Buff/Debuff
  2904.         if (SevenSigns.getInstance().isSealValidationPeriod() && SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) != SevenSigns.CABAL_NULL)
  2905. @@ -182,7 +216,8 @@
  2906.          
  2907.          // Announcements, welcome & Seven signs period messages
  2908.          sendPacket(new SystemMessage(SystemMessageId.WELCOME_TO_LINEAGE));
  2909. -        SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
  2910. +       if (!Config.FACTION_ENGINE_ENABLED)
  2911. +           SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
  2912.          Announcements.getInstance().showAnnouncements(activeChar);
  2913.          
  2914.         // if player is DE, add shadow sense skill at night
  2915. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java
  2916. ===================================================================
  2917. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java  (revision 128)
  2918. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java  (working copy)
  2919. @@ -169,6 +169,23 @@
  2920.                         return;
  2921.                     }
  2922.                    
  2923. +                   boolean cond = true;
  2924. +                   L2PcInstance player = null;
  2925. +                   if (target instanceof L2PcInstance)
  2926. +                       player = (L2PcInstance) target;
  2927. +                   else if (target instanceof L2SummonInstance)
  2928. +                       player = ((L2SummonInstance) target).getOwner();
  2929. +                   if (player != null && Config.FACTION_ENGINE_ENABLED)
  2930. +                   {
  2931. +                       if (activeChar.getFactionId() == player.getFactionId())
  2932. +                           cond = false;
  2933. +                       if (activeChar.getFactionId() == 0 || player.getFactionId() == 0)
  2934. +                           cond = false;
  2935. +                       //pataisyti del peace zonos
  2936. +                   }
  2937. +               if (!cond)
  2938. +                   return;
  2939. +                  
  2940.                     pet.setTarget(target);
  2941.                     if (target.isAutoAttackable(activeChar) || _ctrlPressed)
  2942.                     {
  2943. @@ -386,6 +403,31 @@
  2944.             return;
  2945.         }
  2946.        
  2947. +       boolean cond = true;
  2948. +       L2PcInstance player = null;
  2949. +       if (target instanceof L2PcInstance)
  2950. +           player = (L2PcInstance) target;
  2951. +       else if (target instanceof L2SummonInstance)
  2952. +           player = ((L2SummonInstance) target).getOwner();
  2953. +       if (player != null && Config.FACTION_ENGINE_ENABLED)
  2954. +       {
  2955. +           if (activeChar.getFactionId() == player.getFactionId())
  2956. +           {
  2957. +               activeChar.sendMessage("RequestActionUse 516 line: target faction = player");
  2958. +               cond = false;
  2959. +           }
  2960. +           if (activeChar.getFactionId() == 0 || player.getFactionId() == 0)
  2961. +           {
  2962. +               activeChar.sendMessage("RequestActionUse 521 line: target faction = 0 or player faction = 0");
  2963. +               cond = false;
  2964. +           }
  2965. +       }
  2966. +       if (!cond)
  2967. +       {
  2968. +           activeChar.sendMessage("RequestActionUse line 527 cond = false");
  2969. +           return;
  2970. +       }
  2971. +      
  2972.         L2Summon activeSummon = activeChar.getPet();
  2973.         if (activeSummon != null && !activeSummon.isBetrayed())
  2974.         {
  2975. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
  2976. ===================================================================
  2977. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java  (revision 128)
  2978. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java  (working copy)
  2979. @@ -80,6 +80,18 @@
  2980.             return;
  2981.         }
  2982.        
  2983. +       if (requestor.getFactionId() != target.getFactionId() && Config.FACTION_ENGINE_ENABLED)
  2984. +       {
  2985. +           requestor.sendMessage("You cannot invite players from another faction.");
  2986. +           return;
  2987. +       }
  2988. +
  2989. +       if (requestor.getFactionId() == 0 || target.getFactionId() == 0 && Config.FACTION_ENGINE_ENABLED)
  2990. +       {
  2991. +           requestor.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
  2992. +           return;
  2993. +       }
  2994. +
  2995.         if (target.isInParty())
  2996.          {
  2997.             SystemMessage msg = new SystemMessage(SystemMessageId.S1_IS_ALREADY_IN_PARTY).addPcName(target);
  2998. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
  2999. ===================================================================
  3000. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java   (revision 128)
  3001. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java   (working copy)
  3002. @@ -30,6 +30,8 @@
  3003.  import net.sf.l2j.gameserver.model.entity.Castle;
  3004.  import net.sf.l2j.gameserver.model.entity.ClanHall;
  3005.  
  3006. +import net.sf.l2j.Config;
  3007. +
  3008.  public final class RequestRestartPoint extends L2GameClientPacket
  3009.  {
  3010.     private static final String C_6d_REQUESTRESTARTPOINT = "[C] 6d RequestRestartPoint";
  3011. @@ -63,6 +65,8 @@
  3012.                 _requestedPointType = 27;
  3013.             else if (activeChar.isFestivalParticipant())
  3014.                 _requestedPointType = 4;
  3015. +           else if (activeChar.getFactionId() >= 0)
  3016. +               _requestedPointType = 99;
  3017.  
  3018.             switch (_requestedPointType)
  3019.             {
  3020. @@ -137,6 +141,19 @@
  3021.                         return;
  3022.                     loc = new Location(-114356, -249645, -2984);
  3023.                     break;
  3024. +                  
  3025. +               case 99: //faction base
  3026. +                   if (activeChar.isGM())
  3027. +                       loc = new Location(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  3028. +                   else if (activeChar.getFactionId() == 1)
  3029. +                       loc = new Location(Config.FACTION_TEAM1_BASE_X, Config.FACTION_TEAM1_BASE_Y, Config.FACTION_TEAM1_BASE_Z);
  3030. +                   else if (activeChar.getFactionId() == 2)
  3031. +                       loc = new Location(Config.FACTION_TEAM2_BASE_X, Config.FACTION_TEAM2_BASE_Y, Config.FACTION_TEAM2_BASE_Z);
  3032. +                   else if (activeChar.getFactionId() == 3)
  3033. +                       loc = new Location(Config.FACTION_TEAM3_BASE_X, Config.FACTION_TEAM3_BASE_Y, Config.FACTION_TEAM3_BASE_Z);
  3034. +                   else
  3035. +                       loc = new Location(Config.FACTION_CUSTOM_SPAWN_X, Config.FACTION_CUSTOM_SPAWN_Y, Config.FACTION_CUSTOM_SPAWN_Z);
  3036. +                   break;
  3037.  
  3038.                 default:
  3039.                     loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Town);
  3040. Index: java/net/sf/l2j/gameserver/util/Broadcast.java
  3041. ===================================================================
  3042. --- java/net/sf/l2j/gameserver/util/Broadcast.java  (revision 128)
  3043. +++ java/net/sf/l2j/gameserver/util/Broadcast.java  (working copy)
  3044. @@ -197,6 +197,38 @@
  3045.                 onlinePlayer.sendPacket(mov);
  3046.      }
  3047.    
  3048. +   public static void sendMessToAllFactionPlayers(String text)
  3049. +   {
  3050. +       Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
  3051. +           for (L2PcInstance onlinePlayer : pls)
  3052. +               if (onlinePlayer.isOnline() == true)
  3053. +                   onlinePlayer.sendMessage(text);
  3054. +   }
  3055. +  
  3056. +   public static void sendMessToAllTeam1Players(String text)
  3057. +   {
  3058. +       Collection<L2PcInstance> pls = L2World.getInstance().getAllTeam1().values();
  3059. +           for (L2PcInstance onlinePlayer : pls)
  3060. +               if (onlinePlayer.isOnline() == true)
  3061. +                   onlinePlayer.sendMessage(text);
  3062. +   }
  3063. +  
  3064. +   public static void sendMessToAllTeam2Players(String text)
  3065. +   {
  3066. +       Collection<L2PcInstance> pls = L2World.getInstance().getAllTeam2().values();
  3067. +           for (L2PcInstance onlinePlayer : pls)
  3068. +               if (onlinePlayer.isOnline() == true)
  3069. +                   onlinePlayer.sendMessage(text);
  3070. +   }
  3071. +  
  3072. +   public static void sendMessToAllTeam3Players(String text)
  3073. +   {
  3074. +       Collection<L2PcInstance> pls = L2World.getInstance().getAllTeam3().values();
  3075. +           for (L2PcInstance onlinePlayer : pls)
  3076. +               if (onlinePlayer.isOnline() == true)
  3077. +                   onlinePlayer.sendMessage(text);
  3078. +   }
  3079. +  
  3080.     public static void announceToOnlinePlayers(String text)
  3081.     {
  3082.         CreatureSay cs = new CreatureSay(0, Say2.ANNOUNCEMENT, "", text);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement