Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: config/factions.properties
- ===================================================================
- --- config/factions.properties (revision 0)
- +++ config/factions.properties (revision 0)
- @@ -0,0 +1,110 @@
- +#=============================================================
- +# Faction Engine
- +#=============================================================
- +#Enable Triple Faction Engine by Kic2Ass
- +FactionEngineEnabled = True
- +
- +#Faction Names
- +Team1Name = Angels
- +Team2Name = Demons
- +Team3Name = Fallens
- +#Team Name Colors in RGB format.
- +Team1ColorName = 00FFFF
- +Team2ColorName = 00FF00
- +Team3ColorName = 00FF00
- +
- +#Custom levels at start and for subclass.
- +StartingLevel = 75
- +StartingLevelSubClass = 75
- +
- +#Enable or Disable Item Rewards in Pvp and Pk
- +FactionPlayerGetItemByPvP = True
- +#Item Amount (Player will receive - (FactionEngineAmmountItemRewardPvp * Faction Flags Number))
- +FactionEngineAmmountItemRewardPvp = 1
- +#Item ID, which player will receive in PVP
- +FactionPvPItemRewardID = 57
- +
- +#Enable or Disable Item Rewards in Pvp and Pk for Party members
- +FactionPlayerGetItemByPvPInParty = True
- +#Party Reward only for support classes
- +PartyRewardOnlySupportClass = True
- +#Default 100%
- +Chance = 100
- +#Reward item ids
- +PartyReward1 = 57
- +PartyReward2 = 57
- +PartyReward3 = 57
- +PartyReward4 = 57
- +PartyReward5 = 57
- +PartyReward6 = 57
- +PartyReward7 = 57
- +PartyReward8 = 57
- +PartyReward9 = 57
- +PartyReward10 = 57
- +#Reward amounts
- +PartyAmount1 = 1
- +PartyAmount2 = 2
- +PartyAmount3 = 3
- +PartyAmount4 = 5
- +PartyAmount5 = 4
- +PartyAmount6 = 6
- +PartyAmount7 = 8
- +PartyAmount8 = 7
- +PartyAmount9 = 9
- +PartyAmount10 = 10
- +
- +#Enable or Disable skill points and ancient adena reward by capturing enemy flag
- +FactionPlayerGetSpAAFlag = True
- +#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)
- +FactionEngineAmmountSpFirstFlag = 1000
- +FactionEngineAmmountSpSecondFlag = 500
- +FactionEngineAmmountSpThirdFlag = 250
- +#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)
- +FactionEngineAmmountAAFirstFlag = 15
- +FactionEngineAmmountAASecondFlag = 10
- +FactionEngineAmmountAAThirdFlag = 5
- +
- +#Enable or Disable experience gain in PVP
- +FactionPlayerGetExp = True
- +#Experience reward in PVP (first - lvl75-76)(second - lvl76-78)(third - lvl 78-80)
- +FactionExpRewardInPvpFirst = 1000000
- +FactionExpRewardInPvpSecond = 500000
- +FactionExpRewardInPvpThird = 250000
- +#Faction points reward by capturing enemy base
- +FactionPointsRewardFlag = 5
- +#Faction points reward by killing enemy faction member
- +FactionPointsRewardPvp = 3
- +
- +#Team1 Faction Base location
- +FactionTeam1BaseX = 147453
- +FactionTeam1BaseY = 27502
- +FactionTeam1BaseZ = -2204
- +#Team2 Faction Base location
- +FactionTeam2BaseX = 147741
- +FactionTeam2BaseY = -55566
- +FactionTeam2BaseZ = -2734
- +#Team3 Faction Base location
- +FactionTeam3BaseX = 147741
- +FactionTeam3BaseY = -55566
- +FactionTeam3BaseZ = -2734
- +#Spawn location for newbies (Faction engine must be enabled)
- +FactionCustomSpawnX = 147453
- +FactionCustomSpawnY = 27502
- +FactionCustomSpawnZ = -2204
- +
- +#Enable or Disable .online command to see online status of all factions
- +EnableOnlinePlayersVC = True
- +#Show online status of all factions on login
- +EnableOnlinePlayersEnterworld = True
- +
- +#Enable or Disable anti pvp farm by IP protection
- +EnableProtectionIP = True
- +#Enable or Disable anti pvp farm on same clan
- +EnableProtectionClan = True
- +#Enable or Disable anti pvp farm on same ally
- +EnableProtectionAlly = True
- +#Enable or Disable anti pvp farm by PDef protection (If target Pdef is less than "ProtectionArmourAmount" , player won't be rewarded)
- +EnableProtectionArmour = True
- +ProtectionArmourAmount = 300
- \ No newline at end of file
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 128)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ -60,10 +60,83 @@
- public static final String SERVER_FILE = "./config/server.properties";
- public static final String SIEGE_FILE = "./config/siege.properties";
- public static final String TELNET_FILE = "./config/telnet.properties";
- + public static final String FACTION_ENGINE_FILE = "./config/factions.properties";
- /**--------------------------------------------------
- // Variable Definitions
- //-------------------------------------------------*/
- +
- + //--------------------------------------------------
- + // Faction Engine Configurations
- + //--------------------------------------------------
- + public static boolean FACTION_ONLYSUPPORTS;
- + public static boolean FACTION_ENGINE_ENABLED;
- + public static boolean FACTION_ALLOW_ITEM_REWARD_PARTY;
- + public static boolean FACTION_ALLOW_ITEM_REWARD;
- + public static boolean FACTION_ALLOW_EXP_REWARD;
- + public static boolean FACTION_ALLOW_SP_REWARD_FLAG;
- + public static int FACTION_ITEM_NUMBER_REWARD_ON_PVP;
- + public static int FACTION_TEAM1_COLOR;
- + public static int FACTION_TEAM2_COLOR;
- + public static int FACTION_TEAM3_COLOR;
- + public static int FACTION_START_LVL;
- + public static int FACTION_START_LVL_SUB;
- + public static int FACTION_CHANCE;
- + public static int FACTION_PARTY_REWARD1;
- + public static int FACTION_PARTY_REWARD2;
- + public static int FACTION_PARTY_REWARD3;
- + public static int FACTION_PARTY_REWARD4;
- + public static int FACTION_PARTY_REWARD5;
- + public static int FACTION_PARTY_REWARD6;
- + public static int FACTION_PARTY_REWARD7;
- + public static int FACTION_PARTY_REWARD8;
- + public static int FACTION_PARTY_REWARD9;
- + public static int FACTION_PARTY_REWARD10;
- + public static int FACTION_PARTY_REWARD_AMMOUNT1;
- + public static int FACTION_PARTY_REWARD_AMMOUNT2;
- + public static int FACTION_PARTY_REWARD_AMMOUNT3;
- + public static int FACTION_PARTY_REWARD_AMMOUNT4;
- + public static int FACTION_PARTY_REWARD_AMMOUNT5;
- + public static int FACTION_PARTY_REWARD_AMMOUNT6;
- + public static int FACTION_PARTY_REWARD_AMMOUNT7;
- + public static int FACTION_PARTY_REWARD_AMMOUNT8;
- + public static int FACTION_PARTY_REWARD_AMMOUNT9;
- + public static int FACTION_PARTY_REWARD_AMMOUNT10;
- + public static String FACTION_TEAM1_NAME;
- + public static String FACTION_TEAM2_NAME;
- + public static String FACTION_TEAM3_NAME;
- + public static int FACTION_TEAM1_BASE_X;
- + public static int FACTION_TEAM1_BASE_Y;
- + public static int FACTION_TEAM1_BASE_Z;
- + public static int FACTION_TEAM2_BASE_X;
- + public static int FACTION_TEAM2_BASE_Y;
- + public static int FACTION_TEAM2_BASE_Z;
- + public static int FACTION_TEAM3_BASE_X;
- + public static int FACTION_TEAM3_BASE_Y;
- + public static int FACTION_TEAM3_BASE_Z;
- + public static int FACTION_CUSTOM_SPAWN_X;
- + public static int FACTION_CUSTOM_SPAWN_Y;
- + public static int FACTION_CUSTOM_SPAWN_Z;
- + public static int FACTION_ITEM_REWARD_ID_PVP;
- + public static int FACTION_SP_REWARD_FIRST_FLAG;
- + public static int FACTION_SP_REWARD_SECOND_FLAG;
- + public static int FACTION_SP_REWARD_THIRD_FLAG;
- + public static int FACTION_AA_REWARD_FIRST_FLAG;
- + public static int FACTION_AA_REWARD_SECOND_FLAG;
- + public static int FACTION_AA_REWARD_THIRD_FLAG;
- + public static int FACTION_EXP_REWARD_PVP_FIRST;
- + public static int FACTION_EXP_REWARD_PVP_SECOND;
- + public static int FACTION_EXP_REWARD_PVP_THIRD;
- + public static int FACTION_POINTS_PVP;
- + public static int FACTION_POINTS_FLAG;
- + public static boolean ENABLE_ONLINE_VC;
- + public static boolean ENABLE_ONLINE_PLAYERS_ON_ENTERWORLD;
- + public static boolean ENABLE_DUALBOX_PROTECTION_IP;
- + public static boolean ENABLE_DUALBOX_PROTECTION_CLAN;
- + public static boolean ENABLE_DUALBOX_PROTECTION_ALLY;
- + public static boolean ENABLE_DUALBOX_PROTECTION_ARM;
- + public static int PROTECTION_ARMOUR_AMOUNT;
- //--------------------------------------------------
- // Clans settings
- @@ -690,7 +763,91 @@
- if (Server.serverMode == Server.MODE_GAMESERVER)
- {
- _log.info("Loading gameserver configuration files.");
- +
- +
- + // Load Faction Engine Config File
- + try
- + {
- + Properties factionEngine = new Properties();
- + InputStream is = new FileInputStream(new File(FACTION_ENGINE_FILE));
- + factionEngine.load(is);
- + is.close();
- + FACTION_ENGINE_ENABLED = Boolean.parseBoolean(factionEngine.getProperty("FactionEngineEnabled", "False"));
- + FACTION_TEAM1_NAME = factionEngine.getProperty("Team1Name", "Angels");
- + FACTION_TEAM2_NAME = factionEngine.getProperty("Team2Name", "Demons");
- + FACTION_TEAM3_NAME = factionEngine.getProperty("Team3Name", "Fallens");
- + FACTION_TEAM1_COLOR = Integer.decode("0x" + factionEngine.getProperty("Team1ColorName", "000000"));
- + FACTION_TEAM2_COLOR = Integer.decode("0x" + factionEngine.getProperty("Team2ColorName", "000000"));
- + FACTION_TEAM3_COLOR = Integer.decode("0x" + factionEngine.getProperty("Team3ColorName", "000000"));
- + FACTION_START_LVL = Integer.parseInt(factionEngine.getProperty("StartingLevel", "1"));
- + FACTION_START_LVL_SUB = Integer.parseInt(factionEngine.getProperty("StartingLevelSubClass", "40"));
- + FACTION_ALLOW_ITEM_REWARD = Boolean.parseBoolean(factionEngine.getProperty("FactionPlayerGetItemByPvP", "False"));
- + FACTION_ITEM_NUMBER_REWARD_ON_PVP = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountItemRewardPvp", "3"));
- + FACTION_ITEM_REWARD_ID_PVP = Integer.parseInt(factionEngine.getProperty("FactionPvPItemRewardID", "57"));
- + FACTION_ALLOW_ITEM_REWARD_PARTY = Boolean.parseBoolean(factionEngine.getProperty("FactionPlayerGetItemByPvPInParty", "False"));
- + FACTION_ONLYSUPPORTS = Boolean.parseBoolean(factionEngine.getProperty("PartyRewardOnlySupportClass", "False"));
- + FACTION_CHANCE = Integer.parseInt(factionEngine.getProperty("Chance", "100"));
- + FACTION_PARTY_REWARD1 = Integer.parseInt(factionEngine.getProperty("PartyReward1", "57"));
- + FACTION_PARTY_REWARD2 = Integer.parseInt(factionEngine.getProperty("PartyReward2", "57"));
- + FACTION_PARTY_REWARD3 = Integer.parseInt(factionEngine.getProperty("PartyReward3", "57"));
- + FACTION_PARTY_REWARD4 = Integer.parseInt(factionEngine.getProperty("PartyReward4", "57"));
- + FACTION_PARTY_REWARD5 = Integer.parseInt(factionEngine.getProperty("PartyReward5", "57"));
- + FACTION_PARTY_REWARD6 = Integer.parseInt(factionEngine.getProperty("PartyReward6", "57"));
- + FACTION_PARTY_REWARD7 = Integer.parseInt(factionEngine.getProperty("PartyReward7", "57"));
- + FACTION_PARTY_REWARD8 = Integer.parseInt(factionEngine.getProperty("PartyReward8", "57"));
- + FACTION_PARTY_REWARD9 = Integer.parseInt(factionEngine.getProperty("PartyReward9", "57"));
- + FACTION_PARTY_REWARD10 = Integer.parseInt(factionEngine.getProperty("PartyReward10", "57"));
- + FACTION_PARTY_REWARD_AMMOUNT1 = Integer.parseInt(factionEngine.getProperty("PartyAmount1", "1"));
- + FACTION_PARTY_REWARD_AMMOUNT2 = Integer.parseInt(factionEngine.getProperty("PartyAmount2", "1"));
- + FACTION_PARTY_REWARD_AMMOUNT3 = Integer.parseInt(factionEngine.getProperty("PartyAmount3", "1"));
- + FACTION_PARTY_REWARD_AMMOUNT4 = Integer.parseInt(factionEngine.getProperty("PartyAmount4", "1"));
- + FACTION_PARTY_REWARD_AMMOUNT5 = Integer.parseInt(factionEngine.getProperty("PartyAmount5", "1"));
- + FACTION_PARTY_REWARD_AMMOUNT6 = Integer.parseInt(factionEngine.getProperty("PartyAmount6", "1"));
- + FACTION_PARTY_REWARD_AMMOUNT7 = Integer.parseInt(factionEngine.getProperty("PartyAmount7", "1"));
- + FACTION_PARTY_REWARD_AMMOUNT8 = Integer.parseInt(factionEngine.getProperty("PartyAmount8", "1"));
- + FACTION_PARTY_REWARD_AMMOUNT9 = Integer.parseInt(factionEngine.getProperty("PartyAmount9", "1"));
- + FACTION_PARTY_REWARD_AMMOUNT10 = Integer.parseInt(factionEngine.getProperty("PartyAmount10", "1"));
- + FACTION_ALLOW_SP_REWARD_FLAG = Boolean.parseBoolean(factionEngine.getProperty("FactionPlayerGetSpAAFlag", "False"));
- + FACTION_SP_REWARD_FIRST_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountSpFirstFlag", "1000"));
- + FACTION_SP_REWARD_SECOND_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountSpSecondFlag", "500"));
- + FACTION_SP_REWARD_THIRD_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountSpThirdFlag", "250"));
- + FACTION_AA_REWARD_FIRST_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountAAFirstFlag", "1000"));
- + FACTION_AA_REWARD_SECOND_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountAASecondFlag", "500"));
- + FACTION_AA_REWARD_THIRD_FLAG = Integer.parseInt(factionEngine.getProperty("FactionEngineAmmountAAThirdFlag", "250"));
- + FACTION_ALLOW_EXP_REWARD = Boolean.parseBoolean(factionEngine.getProperty("FactionPlayerGetExp", "False"));
- + FACTION_EXP_REWARD_PVP_FIRST = Integer.parseInt(factionEngine.getProperty("FactionExpRewardInPvpFirst", "1000000"));
- + FACTION_EXP_REWARD_PVP_SECOND = Integer.parseInt(factionEngine.getProperty("FactionExpRewardInPvpSecond", "500000"));
- + FACTION_EXP_REWARD_PVP_THIRD = Integer.parseInt(factionEngine.getProperty("FactionExpRewardInPvpThird", "250000"));
- + FACTION_POINTS_FLAG = Integer.parseInt(factionEngine.getProperty("FactionPointsRewardFlag", "5"));
- + FACTION_POINTS_PVP = Integer.parseInt(factionEngine.getProperty("FactionPointsRewardPvp", "3"));
- + FACTION_TEAM1_BASE_X = Integer.parseInt(factionEngine.getProperty("FactionTeam1BaseX", "0"));
- + FACTION_TEAM1_BASE_Y = Integer.parseInt(factionEngine.getProperty("FactionTeam1BaseY", "0"));
- + FACTION_TEAM1_BASE_Z = Integer.parseInt(factionEngine.getProperty("FactionTeam1BaseZ", "0"));
- + FACTION_TEAM2_BASE_X = Integer.parseInt(factionEngine.getProperty("FactionTeam2BaseX", "0"));
- + FACTION_TEAM2_BASE_Y = Integer.parseInt(factionEngine.getProperty("FactionTeam2BaseY", "0"));
- + FACTION_TEAM2_BASE_Z = Integer.parseInt(factionEngine.getProperty("FactionTeam2BaseZ", "0"));
- + FACTION_TEAM3_BASE_X = Integer.parseInt(factionEngine.getProperty("FactionTeam3BaseX", "0"));
- + FACTION_TEAM3_BASE_Y = Integer.parseInt(factionEngine.getProperty("FactionTeam3BaseY", "0"));
- + FACTION_TEAM3_BASE_Z = Integer.parseInt(factionEngine.getProperty("FactionTeam3BaseZ", "0"));
- + FACTION_CUSTOM_SPAWN_X = Integer.parseInt(factionEngine.getProperty("FactionCustomSpawnX", "0"));
- + FACTION_CUSTOM_SPAWN_Y = Integer.parseInt(factionEngine.getProperty("FactionCustomSpawnY", "0"));
- + FACTION_CUSTOM_SPAWN_Z = Integer.parseInt(factionEngine.getProperty("FactionCustomSpawnZ", "0"));
- + ENABLE_ONLINE_VC = Boolean.parseBoolean(factionEngine.getProperty("EnableOnlinePlayersVC", "False"));
- + ENABLE_ONLINE_PLAYERS_ON_ENTERWORLD = Boolean.parseBoolean(factionEngine.getProperty("EnableOnlinePlayersEnterworld", "False"));
- + ENABLE_DUALBOX_PROTECTION_IP = Boolean.parseBoolean(factionEngine.getProperty("EnableProtectionIP", "False"));
- + ENABLE_DUALBOX_PROTECTION_CLAN = Boolean.parseBoolean(factionEngine.getProperty("EnableProtectionClan", "False"));
- + ENABLE_DUALBOX_PROTECTION_ALLY = Boolean.parseBoolean(factionEngine.getProperty("EnableProtectionAlly", "False"));
- + ENABLE_DUALBOX_PROTECTION_ARM = Boolean.parseBoolean(factionEngine.getProperty("EnableProtectionArmour", "False"));
- + PROTECTION_ARMOUR_AMOUNT = Integer.parseInt(factionEngine.getProperty("ProtectionArmourAmount", "0"));
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + throw new Error("Server failed to load "+FACTION_ENGINE_FILE+" file.");
- + }
- +
- // Clans settings
- try
- {
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 128)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -68,6 +68,7 @@
- import net.sf.l2j.gameserver.handler.ItemHandler;
- import net.sf.l2j.gameserver.handler.SkillHandler;
- import net.sf.l2j.gameserver.handler.UserCommandHandler;
- +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
- import net.sf.l2j.gameserver.idfactory.IdFactory;
- import net.sf.l2j.gameserver.instancemanager.AuctionManager;
- import net.sf.l2j.gameserver.instancemanager.BoatManager;
- @@ -102,6 +103,9 @@
- import net.sf.l2j.status.Status;
- import net.sf.l2j.util.IPv4Filter;
- +import net.sf.l2j.gameserver.model.entity.FactionMaps;
- +import net.sf.l2j.gameserver.model.actor.instance.L2TpFlagInstance;
- +
- import org.mmocore.network.SelectorConfig;
- import org.mmocore.network.SelectorThread;
- @@ -209,6 +213,15 @@
- printSection("Olympiad");
- Olympiad.getInstance();
- Hero.getInstance();
- +
- + printSection("Faction Engine");
- + if (Config.FACTION_ENGINE_ENABLED)
- + {
- + FactionMaps.loadCurrentMap();
- + L2TpFlagInstance.spawnFlags();
- + }
- + else
- + System.out.println("Faction Engine is currently disabled.");
- printSection("Cache");
- HtmCache.getInstance();
- @@ -255,6 +268,7 @@
- _log.config("ItemHandler: Loaded " + ItemHandler.getInstance().size() + " handlers.");
- _log.config("SkillHandler: Loaded " + SkillHandler.getInstance().size() + " handlers.");
- _log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
- + _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
- if (Config.ALLOW_WEDDING)
- CoupleManager.getInstance();
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 128)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
- @@ -15,8 +15,13 @@
- package net.sf.l2j.gameserver.handler.chathandlers;
- import java.util.Collection;
- +import java.util.StringTokenizer;
- +import java.util.logging.Logger;
- +import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
- import net.sf.l2j.gameserver.model.BlockList;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- @@ -29,6 +34,7 @@
- public class ChatAll implements IChatHandler
- {
- private static final int[] COMMAND_IDS = { 0 };
- + private static Logger _log = Logger.getLogger(ChatAll.class.getName());
- /**
- * Handle chat type 'all'
- @@ -36,16 +42,53 @@
- */
- public void handleChat(int type, L2PcInstance activeChar, String params, String text)
- {
- - CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- - Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
- -
- - for (L2PcInstance player : plrs)
- + boolean vcd_used = false;
- + if (text.startsWith("."))
- {
- - if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
- - player.sendPacket(cs);
- + StringTokenizer st = new StringTokenizer(text);
- + IVoicedCommandHandler vch;
- + String command = "";
- +
- + if (st.countTokens() > 1)
- + {
- + command = st.nextToken().substring(1);
- + params = text.substring(command.length() + 2);
- + vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
- + }
- + else
- + {
- + command = text.substring(1);
- + if (Config.DEBUG)
- + _log.info("Command: " + command);
- + vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
- + }
- +
- + if (vch != null)
- + {
- + vch.useVoicedCommand(command, activeChar, params);
- + vcd_used = true;
- + }
- + else
- + {
- + if (Config.DEBUG)
- + _log.warning("No handler registered for bypass '" + command + "'");
- + vcd_used = false;
- + }
- }
- +
- + if (!vcd_used)
- + {
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- + Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
- +
- + for (L2PcInstance player : plrs)
- + {
- + if (player != null && activeChar.isInsideRadius(player, 1250, false, true) && !BlockList.isBlocked(player, activeChar))
- + player.sendPacket(cs);
- + }
- - activeChar.sendPacket(cs);
- + activeChar.sendPacket(cs);
- + }
- }
- /**
- Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (revision 0)
- @@ -0,0 +1,43 @@
- +/*
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * http://www.gnu.org/copyleft/gpl.html
- + */
- +package net.sf.l2j.gameserver.handler;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + * This class ...
- + *
- + * @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:09 $
- + */
- +public interface IVoicedCommandHandler
- +{
- + /**
- + * this is the worker method that is called when someone uses an admin command.
- + * @param activeChar
- + * @param command
- + * @return command success
- + */
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target);
- +
- + /**
- + * this method is called at initialization to register all the item ids automatically
- + * @return all known itemIds
- + */
- + public String[] getVoicedCommandList();
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
- @@ -0,0 +1,83 @@
- +/*
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * http://www.gnu.org/copyleft/gpl.html
- + */
- +package net.sf.l2j.gameserver.handler;
- +
- +import java.util.Map;
- +import java.util.logging.Logger;
- +
- +import javolution.util.FastMap;
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.OnlinePlayers;
- +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Points;
- +
- +public class VoicedCommandHandler
- +{
- + private static Logger _log = Logger.getLogger(ItemHandler.class.getName());
- +
- + private static VoicedCommandHandler _instance;
- + private Map<String, IVoicedCommandHandler> _datatable;
- +
- + public static VoicedCommandHandler getInstance()
- + {
- + if (_instance == null)
- + _instance = new VoicedCommandHandler();
- +
- + return _instance;
- + }
- +
- + private VoicedCommandHandler()
- + {
- + _datatable = new FastMap<String, IVoicedCommandHandler>();
- +
- + if (Config.FACTION_ENGINE_ENABLED)
- + {
- + if (Config.ENABLE_ONLINE_VC)
- + registerVoicedCommandHandler(new OnlinePlayers());
- + registerVoicedCommandHandler(new Points());
- + }
- + }
- +
- + public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
- + {
- + String[] ids = handler.getVoicedCommandList();
- + for (int i = 0; i < ids.length; i++)
- + {
- + if (Config.DEBUG) _log.fine("Adding handler for command "+ids[i]);
- + _datatable.put(ids[i], handler);
- + }
- + }
- +
- + public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
- + {
- + String command = voicedCommand;
- +
- + if (voicedCommand.indexOf(" ") != -1)
- + command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
- +
- + if (Config.DEBUG)
- + _log.fine("getting handler for command: "+command+" -> "+(_datatable.get(command) != null));
- +
- + return _datatable.get(command);
- + }
- +
- + public int size()
- + {
- + return _datatable.size();
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/OnlinePlayers.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/OnlinePlayers.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/OnlinePlayers.java (revision 0)
- @@ -0,0 +1,44 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.model.L2World;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class OnlinePlayers implements IVoicedCommandHandler
- +{
- + private static final String[] _voicedCommands = { "online" };
- +
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
- + {
- + if (command.equalsIgnoreCase("online"))
- + {
- + activeChar.sendMessage("--------------------------------------------------------------");
- + activeChar.sendMessage(Config.FACTION_TEAM1_NAME + ": " + L2World.getInstance().getAllteam1Players().size());
- + activeChar.sendMessage(Config.FACTION_TEAM2_NAME + ": " + L2World.getInstance().getAllteam2Players().size());
- + activeChar.sendMessage(Config.FACTION_TEAM3_NAME + ": " + L2World.getInstance().getAllteam3Players().size());
- + activeChar.sendMessage("Total: " + L2World.getInstance().getAllPlayersCount() + " online.");
- + activeChar.sendMessage("--------------------------------------------------------------");
- + }
- + return false;
- + }
- +
- + public String[] getVoicedCommandList()
- + {
- + return _voicedCommands;
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Points.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Points.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Points.java (revision 0)
- @@ -0,0 +1,69 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.model.L2World;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
- +
- +public class Points implements IVoicedCommandHandler
- +{
- + private static final String[] _voicedCommands = { "points" };
- +
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
- + {
- + if (command.equalsIgnoreCase("points"))
- + {
- + int team1 = 0;
- + int team2 = 0;
- + int team3 = 0;
- + for (L2PcInstance zaidejas1 : L2World.getInstance().getAllteam1Players())
- + team1 = zaidejas1.getFactionPoints();
- + for (L2PcInstance zaidejas2 : L2World.getInstance().getAllteam2Players())
- + team2 = zaidejas2.getFactionPoints();
- + for (L2PcInstance zaidejas3 : L2World.getInstance().getAllteam3Players())
- + team3 = zaidejas3.getFactionPoints();
- +
- + int taskai = 0;
- + if (activeChar.getFactionId() == 1)
- + taskai = team1;
- + if (activeChar.getFactionId() == 2)
- + taskai = team2;
- + if (activeChar.getFactionId() == 3)
- + taskai = team3;
- + if (activeChar.getFactionId() > 0)
- + {
- + activeChar.sendMessage("--------------------------------------------------------------");
- + activeChar.sendMessage("Your points: " + activeChar.getFactionPoints());
- + activeChar.sendMessage("Your faction points: " + taskai);
- + activeChar.sendMessage("Winning Faction members will get special reward!");
- + activeChar.sendMessage("--------------------------------------------------------------");
- + }
- + else
- + {
- + activeChar.sendPacket(new PlaySound("monsound5.frintessa_shout2"));
- + activeChar.sendMessage("Please chose your faction at Faction manager!");
- + }
- + }
- + return false;
- + }
- +
- + public String[] getVoicedCommandList()
- + {
- + return _voicedCommands;
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2FactionInstance.java (revision 0)
- @@ -0,0 +1,309 @@
- +/*
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * http://www.gnu.org/copyleft/gpl.html
- + */
- +package net.sf.l2j.gameserver.model.actor.instance;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.StringTokenizer;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.gameserver.ThreadPoolManager;
- +import net.sf.l2j.gameserver.ai.CtrlIntention;
- +import net.sf.l2j.gameserver.datatables.MapRegionTable;
- +import net.sf.l2j.gameserver.model.L2World;
- +import net.sf.l2j.gameserver.model.base.Experience;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
- +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
- +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
- +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
- +import net.sf.l2j.util.StringUtil;
- +import net.sf.l2j.util.Rnd;
- +
- +public final class L2FactionInstance extends L2NpcInstance
- +{
- + public L2FactionInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- +
- + private final static Logger _log = Logger.getLogger(L2FactionInstance.class.getName());
- +
- + int team1Count = L2World.getInstance().getAllteam1Players().size();
- + int team2Count = L2World.getInstance().getAllteam2Players().size();
- + int team3Count = L2World.getInstance().getAllteam3Players().size();
- +
- + @Override
- + public void onBypassFeedback(final L2PcInstance player, String command)
- + {
- + StringTokenizer st = new StringTokenizer(command, " ");
- + String actualCommand = st.nextToken();
- + int val = 0;
- + if (st.countTokens() >= 1)
- + val = Integer.valueOf(st.nextToken());
- +
- + if (actualCommand.equalsIgnoreCase("setfaction"))
- + {
- + if (val < 1)
- + return;
- +
- + if (val == 1)
- + {
- + if (player.getFactionId() == 2 && (team1Count - team2Count > 3))
- + {
- + player.sendMessage("Too many players in " + Config.FACTION_TEAM1_NAME + " faction. Come back later.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (player.getFactionId() == 3 && (team1Count - team3Count > 3))
- + {
- + player.sendMessage("Too many players in " + Config.FACTION_TEAM1_NAME + " faction. Come back later.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (val == player.getFactionId())
- + {
- + player.sendMessage("You already belong to " + Config.FACTION_TEAM1_NAME + " faction.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- + if (player.getFactionId() == 2)
- + {
- + L2World.getInstance().getAllTeam2().remove(player.getName().toLowerCase());
- + L2World.getInstance().getAllTeam1().put(player.getName().toLowerCase(),player);
- + player.sendMessage("[" + Config.FACTION_TEAM2_NAME + "] Goodbye!");
- + player.sendMessage("[" + Config.FACTION_TEAM1_NAME + "] For Faction Glory!");
- + }
- + else if (player.getFactionId() == 3)
- + {
- + L2World.getInstance().getAllTeam3().remove(player.getName().toLowerCase());
- + L2World.getInstance().getAllTeam1().put(player.getName().toLowerCase(),player);
- + player.sendMessage("[" + Config.FACTION_TEAM3_NAME + "] Goodbye!");
- + player.sendMessage("[" + Config.FACTION_TEAM1_NAME + "] For Faction Glory!");
- + }
- + else if (player.getFactionId() == 0)
- + {
- + L2World.getInstance().getAllTeam1().put(player.getName().toLowerCase(),player);
- + player.sendMessage("[" + Config.FACTION_TEAM1_NAME + "] For Faction Glory!");
- + }
- + player.getParty().removePartyMember(player);
- + player.getAppearance().setNameColor(Config.FACTION_TEAM1_COLOR);
- + player.getAppearance().setTitleColor(Config.FACTION_TEAM1_COLOR);
- + player.broadcastUserInfo();
- + }
- + else if (val == 2)
- + {
- + if (player.getFactionId() == 1 && (team2Count - team1Count > 3))
- + {
- + player.sendMessage("Too many players in " + Config.FACTION_TEAM2_NAME + " faction. Come back later.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (player.getFactionId() == 3 && (team2Count - team3Count > 3))
- + {
- + player.sendMessage("Too many players in " + Config.FACTION_TEAM2_NAME + " faction. Come back later.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (val == player.getFactionId())
- + {
- + player.sendMessage("You already belong to " + Config.FACTION_TEAM2_NAME + " faction.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- + if (player.getFactionId() == 1)
- + {
- + L2World.getInstance().getAllTeam1().remove(player.getName().toLowerCase());
- + L2World.getInstance().getAllTeam2().put(player.getName().toLowerCase(),player);
- + player.sendMessage("[" + Config.FACTION_TEAM1_NAME + "] Goodbye!");
- + player.sendMessage("[" + Config.FACTION_TEAM2_NAME + "] For Faction Glory!");
- + }
- + else if (player.getFactionId() == 3)
- + {
- + L2World.getInstance().getAllTeam3().remove(player.getName().toLowerCase());
- + L2World.getInstance().getAllTeam2().put(player.getName().toLowerCase(),player);
- + player.sendMessage("[" + Config.FACTION_TEAM3_NAME + "] Goodbye!");
- + player.sendMessage("[" + Config.FACTION_TEAM2_NAME + "] For Faction Glory!");
- + }
- + else if (player.getFactionId() == 0)
- + {
- + L2World.getInstance().getAllTeam2().put(player.getName().toLowerCase(),player);
- + player.sendMessage("[" + Config.FACTION_TEAM2_NAME + "] For Faction Glory!");
- + }
- + player.getParty().removePartyMember(player);
- + player.getAppearance().setNameColor(Config.FACTION_TEAM2_COLOR);
- + player.getAppearance().setTitleColor(Config.FACTION_TEAM2_COLOR);
- + player.broadcastUserInfo();
- + }
- + else
- + {
- + if (player.getFactionId() == 1 && (team3Count - team1Count > 3))
- + {
- + player.sendMessage("Too many players in " + Config.FACTION_TEAM3_NAME + " faction. Come back later.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (player.getFactionId() == 2 && (team3Count - team2Count > 3))
- + {
- + player.sendMessage("Too many players in " + Config.FACTION_TEAM3_NAME + " faction. Come back later.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (val == player.getFactionId())
- + {
- + player.sendMessage("You already belong to " + Config.FACTION_TEAM3_NAME + " faction.");
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- +
- + if (player.getFactionId() == 1)
- + {
- + L2World.getInstance().getAllTeam1().remove(player.getName().toLowerCase());
- + L2World.getInstance().getAllTeam3().put(player.getName().toLowerCase(),player);
- + player.sendMessage("[" + Config.FACTION_TEAM1_NAME + "] Goodbye!");
- + player.sendMessage("[" + Config.FACTION_TEAM3_NAME + "] For Faction Glory!");
- + }
- + else if (player.getFactionId() == 2)
- + {
- + L2World.getInstance().getAllTeam2().remove(player.getName().toLowerCase());
- + L2World.getInstance().getAllTeam3().put(player.getName().toLowerCase(),player);
- + player.sendMessage("[" + Config.FACTION_TEAM2_NAME + "] Goodbye!");
- + player.sendMessage("[" + Config.FACTION_TEAM3_NAME + "] For Faction Glory!");
- + }
- + else if (player.getFactionId() == 0)
- + {
- + L2World.getInstance().getAllTeam3().put(player.getName().toLowerCase(),player);
- + player.sendMessage("[" + Config.FACTION_TEAM3_NAME + "] For Faction Glory!");
- + }
- + player.getParty().removePartyMember(player);
- + player.getAppearance().setNameColor(Config.FACTION_TEAM3_COLOR);
- + player.getAppearance().setTitleColor(Config.FACTION_TEAM3_COLOR);
- + player.broadcastUserInfo();
- + }
- +
- + Connection connection = null;
- + try
- + {
- + connection = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement statement = connection.prepareStatement("UPDATE characters SET factionId=? WHERE char_name=?");
- + statement.setInt(1, val);
- + statement.setString(2, player.getName());
- + statement.execute();
- + statement.close();
- + connection.close();
- + }
- + catch (Exception e)
- + {
- + _log.info("Couldn't set player faction:" + val + " " + e);
- + }
- + finally{try{connection.close();}catch (Exception e){}}
- +
- + player.setFactionId(val);
- + player.broadcastUserInfo();
- + if (player.getLevel() < 5)
- + player.addExpAndSp(Experience.LEVEL[Config.FACTION_START_LVL], 0);
- + }
- + else
- + super.onBypassFeedback(player, command);
- + }
- +
- + @Override
- + public void onAction(L2PcInstance player)
- + {
- + if (this != player.getTarget())
- + {
- + player.setTarget(this);
- + player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
- + player.sendPacket(new ValidateLocation(this));
- + }
- + else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false))
- + {
- + SocialAction sa = new SocialAction(getObjectId(), Rnd.get(8));
- + broadcastPacket(sa);
- + player.setLastFolkNPC(this);
- + showMessageWindow(player);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- + else
- + {
- + player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- + }
- +
- + private void showMessageWindow(L2PcInstance player)
- + {
- + NpcHtmlMessage html = new NpcHtmlMessage(1);
- + final StringBuilder strBuffer = StringUtil.startAppend(3500, "<html><title>Faction Manager</title><body><center>");
- + if (player.getFactionId() != 0)
- + {
- + strBuffer.append("You belong to: <font color=\"LEVEL\">%faction%</font> faction.<br>");
- + strBuffer.append("Currently avaible factions:<br>");
- + strBuffer.append("<img src=\"L2UI_CH3.onscrmsg_pattern01_2\" width=300 height=32 align=left>");
- + }
- + else
- + {
- + strBuffer.append("</center>");
- + strBuffer.append("Welcome to L2CLAW Faction game, <font color=\"LEVEL\">%charname%</font>.<br>");
- + 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>");
- + strBuffer.append("<img src=\"L2UI_CH3.onscrmsg_pattern01_2\" width=300 height=32 align=left>");
- + }
- + if (player.getFactionId() == 1)
- + {
- + 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\">");
- + 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\">");
- + }
- + else if (player.getFactionId() == 2)
- + {
- + 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\">");
- + 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\">");
- + }
- + else if (player.getFactionId() == 3)
- + {
- + 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\">");
- + 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\">");
- + }
- + else
- + {
- + 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\">");
- + 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\">");
- + 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\">");
- + }
- + strBuffer.append("<img src=\"L2UI_CH3.onscrmsg_pattern01_2\" width=300 height=32 align=left>");
- + strBuffer.append("</center></body></html>");
- + html.setHtml(strBuffer.toString());
- + html.replace("%objectId%", String.valueOf(getObjectId()));
- + html.replace("%npcname%", getName());
- + html.replace("%charname%", player.getName());
- + if (player.getFactionId() == 1)
- + html.replace("%faction%", Config.FACTION_TEAM1_NAME);
- + else if (player.getFactionId() == 2)
- + html.replace("%faction%", Config.FACTION_TEAM2_NAME);
- + else if (player.getFactionId() == 3)
- + html.replace("%faction%", Config.FACTION_TEAM3_NAME);
- + player.sendPacket(html);
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2FactTeleporterInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2FactTeleporterInstance.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2FactTeleporterInstance.java (revision 0)
- @@ -0,0 +1,178 @@
- +/*
- + * This program is free software; you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation; either version 2, or (at your option)
- + * any later version.
- + *
- + * This program is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- + * GNU General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + *
- + * http://www.gnu.org/copyleft/gpl.html
- + */
- +package net.sf.l2j.gameserver.model.actor.instance;
- +
- +import java.util.StringTokenizer;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.Config;
- +import javolution.util.FastSet;
- +import net.sf.l2j.gameserver.ai.CtrlIntention;
- +import net.sf.l2j.gameserver.model.L2Object;
- +import net.sf.l2j.gameserver.model.L2World;
- +import net.sf.l2j.gameserver.model.entity.FactionMaps;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
- +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
- +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
- +import net.sf.l2j.util.StringUtil;
- +import net.sf.l2j.util.Rnd;
- +
- +/**
- + *
- + * @author Mindee
- + *
- + */
- +
- +public class L2FactTeleporterInstance extends L2NpcInstance
- +{
- + public L2FactTeleporterInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- +
- + private final static Logger _log = Logger.getLogger(L2FactTeleporterInstance.class.getName());
- +
- + public static FastSet<L2TpFlagInstance> _tpTeam1Flags = new FastSet<L2TpFlagInstance>();
- + public static FastSet<L2TpFlagInstance> _tpTeam2Flags = new FastSet<L2TpFlagInstance>();
- + public static FastSet<L2TpFlagInstance> _tpTeam3Flags = new FastSet<L2TpFlagInstance>();
- +
- + @Override
- + public void onBypassFeedback(final L2PcInstance player, String command)
- + {
- + StringTokenizer st = new StringTokenizer(command, " ");
- + String actualCommand = st.nextToken();
- + int val = 0;
- + if (st.countTokens() >= 1)
- + val = Integer.valueOf(st.nextToken());
- +
- + if (actualCommand.equalsIgnoreCase("teletoflag"))
- + {
- + teleToFlag(val,player);
- + }
- + else
- + super.onBypassFeedback(player, command);
- + }
- +
- + public void teleToFlag(int objId, L2PcInstance plajer)
- + {
- + L2Object object = L2World.getInstance().findObject(objId);
- + if (object != null && object instanceof L2TpFlagInstance)
- + {
- + L2TpFlagInstance kristalas = (L2TpFlagInstance) object;
- + if (plajer.getFactionId() == kristalas.getFlagFactionId())
- + plajer.teleToLocation(kristalas.getX() + 50,kristalas.getY(),kristalas.getZ() + 50);
- + }
- + else
- + {
- + plajer.sendMessage("Can't communicate with flag location. It doesn't exist or it was occupied.");
- + return;
- + }
- + }
- +
- + @Override
- + public void onAction(L2PcInstance player)
- + {
- + if (this != player.getTarget())
- + {
- + player.setTarget(this);
- + player.sendPacket(new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()));
- + player.sendPacket(new ValidateLocation(this));
- + }
- + else if (isInsideRadius(player, INTERACTION_DISTANCE, false, false))
- + {
- + SocialAction sa = new SocialAction(getObjectId(), Rnd.get(8));
- + broadcastPacket(sa);
- + player.setLastFolkNPC(this);
- + showMessageWindow(player);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- + else
- + {
- + player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- + }
- +
- + private void showMessageWindow(L2PcInstance player)
- + {
- + NpcHtmlMessage html = new NpcHtmlMessage(1);
- + final StringBuilder strBuffer = StringUtil.startAppend(3500, "<html><title>Faction Teleporter</title><body><center>");
- + if (player.getFactionId() == 0)
- + strBuffer.append("Please chose your faction and then come back!<br>");
- + else if (FactionMaps.isVoting() && player.getFactionId() != 0)
- + strBuffer.append("Map voting is in progress.<br>");
- + else
- + {
- + strBuffer.append("Current map is: <font color=\"LEVEL\">" + FactionMaps.getMapName() + "</font><br>");
- + strBuffer.append("Voting for next map will begin in: " + FactionMaps.getDelayUntilVoting() + "<br>");
- + strBuffer.append("Unoccupyable flags belonging to <font color=\"LEVEL\">%faction%</font> faction:<br>");
- + if (player.getFactionId() == 1)
- + for (L2TpFlagInstance unFlag : _tpTeam1Flags)
- + {
- + if (unFlag.isUnoccupayable() == 1)
- + 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\">");
- + }
- + else if (player.getFactionId() == 2)
- + for (L2TpFlagInstance unFlag : _tpTeam2Flags)
- + {
- + if (unFlag.isUnoccupayable() == 1)
- + 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\">");
- + }
- + else if (player.getFactionId() == 3)
- + for (L2TpFlagInstance unFlag : _tpTeam3Flags)
- + {
- + if (unFlag.isUnoccupayable() == 1)
- + 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\">");
- + }
- + strBuffer.append("Flags occupied by <font color=\"LEVEL\">%faction%</font> faction:<br>");
- + if (player.getFactionId() == 1)
- + for (L2TpFlagInstance unFlag : _tpTeam1Flags)
- + {
- + if (unFlag.isUnoccupayable() == 0)
- + 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\">");
- + }
- + else if (player.getFactionId() == 2)
- + for (L2TpFlagInstance unFlag : _tpTeam2Flags)
- + {
- + if (unFlag.isUnoccupayable() == 0)
- + 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\">");
- + }
- + else if (player.getFactionId() == 3)
- + for (L2TpFlagInstance unFlag : _tpTeam3Flags)
- + {
- + if (unFlag.isUnoccupayable() == 0)
- + 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\">");
- + }
- + }
- + strBuffer.append("</center></body></html>");
- + html.setHtml(strBuffer.toString());
- + html.replace("%objectId%", String.valueOf(getObjectId()));
- + html.replace("%npcname%", getName());
- + if (player.getFactionId() == 1)
- + html.replace("%faction%", Config.FACTION_TEAM1_NAME);
- + else if (player.getFactionId() == 2)
- + html.replace("%faction%", Config.FACTION_TEAM2_NAME);
- + else if (player.getFactionId() == 3)
- + html.replace("%faction%", Config.FACTION_TEAM3_NAME);
- + player.sendPacket(html);
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 128)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- @@ -220,6 +220,10 @@
- import net.sf.l2j.util.Point3D;
- import net.sf.l2j.util.Rnd;
- +import net.sf.l2j.gameserver.model.actor.instance.L2FactTeleporterInstance;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +
- /**
- * This class represents all player characters in the world.
- * There is always a client-thread connected to this (except if a player-store is activated upon logout).<BR><BR>
- @@ -240,8 +244,8 @@
- // Character SQL String Definitions:
- 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 (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- - 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=?";
- - 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=?";
- + 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=?";
- + 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=?";
- // Character Subclass SQL String Definitions:
- 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";
- @@ -344,6 +348,10 @@
- private int _karma;
- private int _pvpKills;
- private int _pkKills;
- +
- + private int _factionPoints;
- + private int uberKills = 0;
- +
- private byte _pvpFlag;
- private byte _siegeState = 0;
- private int _curWeightPenalty = 0;
- @@ -424,6 +432,31 @@
- private int _obsZ;
- private boolean _observerMode = false;
- + public boolean _votedForMap = false;
- + public void setVotedForMap(boolean a)
- + {
- + _votedForMap = a;
- + }
- +
- + public void setFactionPoints(int factionPoints)
- + {
- + _factionPoints = factionPoints;
- + }
- +
- + public int getFactionPoints()
- + {
- + return _factionPoints;
- + }
- +
- + public boolean votedForMap()
- + {
- + return _votedForMap;
- + }
- +
- + public int _oldX = 0;
- + public int _oldY = 0;
- + public int _oldZ = 0;
- +
- /** Stored from last ValidatePosition **/
- private Point3D _lastServerPosition = new Point3D(0, 0, 0);
- @@ -455,6 +488,13 @@
- /** Last NPC Id talked on a quest */
- private int _questNpcObject = 0;
- +
- + public void setIP(String ip)
- + {
- + IP = ip;
- + }
- +
- + public String IP;
- /** The table containing all Quests began by the L2PcInstance */
- private Map<String, QuestState> _quests = new FastMap<String, QuestState>();
- @@ -552,6 +592,32 @@
- private long _recentFakeDeathEndTime = 0;
- private boolean _isFakeDeath;
- + public int ArNePk = 0;
- +
- + public int getArNePk()
- + {
- + return this.ArNePk;
- + }
- + public void setArNePk(int i)
- + {
- + ArNePk=i;
- + }
- +
- + public int factionId = 0;
- + public int getFactionId()
- + {
- + return this.factionId;
- + }
- + public void setFactionId(int i)
- + {
- + factionId=i;
- + }
- + public int isInFaction = 0;
- + public int inWorld()
- + {
- + return isInFaction;
- + }
- +
- /** The fists L2Weapon of the L2PcInstance (used when no weapon is equipped) */
- private L2Weapon _fistsWeaponItem;
- @@ -562,6 +628,21 @@
- private int _expertisePenalty = 0;
- private L2ItemInstance _activeEnchantItem = null;
- +
- + public boolean checkPvpCond(L2Character target)
- + {
- + L2PcInstance target1 = (L2PcInstance)target;
- + if (target1.IP.equals(IP) && Config.ENABLE_DUALBOX_PROTECTION_IP && Config.FACTION_ENGINE_ENABLED)
- + return false;
- + if((getClanId() > 0 && target1.getClanId() > 0 && getClanId() == target1.getClanId()) && Config.ENABLE_DUALBOX_PROTECTION_CLAN && Config.FACTION_ENGINE_ENABLED)
- + return false;
- + if((getAllyId() > 0 && target1.getAllyId() > 0 && getAllyId() == target1.getAllyId()) && Config.ENABLE_DUALBOX_PROTECTION_ALLY && Config.FACTION_ENGINE_ENABLED)
- + return false;
- + if(target.getStat().getPDef(target) < Config.PROTECTION_ARMOUR_AMOUNT && Config.ENABLE_DUALBOX_PROTECTION_ARM && Config.FACTION_ENGINE_ENABLED)
- + return false;
- +
- + return true;
- + }
- protected boolean _inventoryDisable = false;
- @@ -1627,15 +1708,20 @@
- public void updatePvPFlag(int value)
- {
- - if (getPvpFlag() == value)
- - return;
- -
- - setPvpFlag(value);
- - sendPacket(new UserInfo(this));
- -
- - Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
- - for (L2PcInstance target : plrs)
- - target.sendPacket(new RelationChanged(this, getRelation(target), isAutoAttackable(target)));
- + if(!Config.FACTION_ENGINE_ENABLED)
- + {
- + if (getPvpFlag() == value)
- + return;
- +
- + setPvpFlag(value);
- + sendPacket(new UserInfo(this));
- +
- + Collection<L2PcInstance> plrs = getKnownList().getKnownPlayers().values();
- + for (L2PcInstance target : plrs)
- + target.sendPacket(new RelationChanged(this, getRelation(target), isAutoAttackable(target)));
- + }
- + else
- + setArNePk(1);
- }
- @Override
- @@ -3087,7 +3173,7 @@
- if (!isGM() && !_inventory.validateCapacity(0, item.isQuestItem()) && createdItem.isDropable() && (!createdItem.isStackable() || createdItem.getLastChange() != L2ItemInstance.MODIFIED))
- dropItem("InvDrop", createdItem, null, true);
- // Cursed Weapon
- - else if(CursedWeaponsManager.getInstance().isCursed(createdItem.getItemId()))
- + else if (CursedWeaponsManager.getInstance().isCursed(createdItem.getItemId()))
- CursedWeaponsManager.getInstance().activate(this, createdItem);
- return createdItem;
- @@ -3754,7 +3840,7 @@
- if (Config.GEODATA > 0)
- {
- - if(GeoData.getInstance().canSeeTarget(player, this))
- + if (GeoData.getInstance().canSeeTarget(player, this))
- player.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, this);
- }
- else
- @@ -4212,14 +4298,14 @@
- ItemTable.getInstance().destroyItem("Consume", target, this, null);
- }
- // Cursed Weapons are not distributed
- - else if(CursedWeaponsManager.getInstance().isCursed(target.getItemId()))
- + else if (CursedWeaponsManager.getInstance().isCursed(target.getItemId()))
- {
- addItem("Pickup", target, null, true);
- }
- else
- {
- // if item is instance of L2ArmorType or L2WeaponType broadcast an "Attention" system message
- - if(target.getItemType() instanceof L2ArmorType || target.getItemType() instanceof L2WeaponType)
- + if (target.getItemType() instanceof L2ArmorType || target.getItemType() instanceof L2WeaponType)
- {
- if (target.getEnchantLevel() > 0)
- {
- @@ -4635,6 +4721,7 @@
- // Clear the pvp flag
- setPvpFlag(0);
- + uberKills = 0;
- // Unsummon Cubics
- if (!_cubics.isEmpty())
- @@ -4800,33 +4887,177 @@
- if (isInsideZone(ZONE_PVP) || targetPlayer.isInsideZone(ZONE_PVP))
- return;
- - // Check if it's pvp
- - if ((checkIfPvP(target) && targetPlayer.getPvpFlag() != 0)
- - || (isInsideZone(ZONE_PVP) && targetPlayer.isInsideZone(ZONE_PVP)))
- - increasePvpKills();
- - // Target player doesn't have pvp flag set
- + if (!Config.FACTION_ENGINE_ENABLED)
- + {
- + // Check if it's pvp
- + if ((checkIfPvP(target) && targetPlayer.getPvpFlag() != 0)
- + || (isInsideZone(ZONE_PVP) && targetPlayer.isInsideZone(ZONE_PVP)))
- + increasePvpKills();
- + // Target player doesn't have pvp flag set
- + else
- + {
- + // check about wars
- + if (targetPlayer.getClan() != null && getClan() != null
- + && getClan().isAtWarWith(targetPlayer.getClanId())
- + && targetPlayer.getClan().isAtWarWith(getClanId())
- + && targetPlayer.getPledgeType() != L2Clan.SUBUNIT_ACADEMY
- + && getPledgeType() != L2Clan.SUBUNIT_ACADEMY)
- + {
- + // 'Both way war' -> 'PvP Kill'
- + increasePvpKills();
- + return;
- + }
- +
- + // 'No war' or 'One way war' -> 'Normal PK'
- + if (targetPlayer.getKarma() > 0)
- + {
- + if (Config.KARMA_AWARD_PK_KILL)
- + increasePvpKills();
- + }
- + else if (targetPlayer.getPvpFlag() == 0)
- + increasePkKillsAndKarma(targetPlayer.getLevel());
- + }
- + }
- else
- {
- - // check about wars
- - if (targetPlayer.getClan() != null && getClan() != null
- - && getClan().isAtWarWith(targetPlayer.getClanId())
- - && targetPlayer.getClan().isAtWarWith(getClanId())
- - && targetPlayer.getPledgeType() != L2Clan.SUBUNIT_ACADEMY
- - && getPledgeType() != L2Clan.SUBUNIT_ACADEMY)
- + if (Config.FACTION_ALLOW_ITEM_REWARD)
- {
- - // 'Both way war' -> 'PvP Kill'
- - increasePvpKills();
- - return;
- + if (getFactionId() == targetPlayer.getFactionId())
- + {
- + sendMessage("You can't get the item reward from the same faction!");
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (targetPlayer.getFactionId() == 0)
- + {
- + sendMessage("You can't get the item reward from player, who doesn't belong to any faction!");
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (getFactionId() == 0)
- + {
- + sendMessage("There is no rewards for non-faction players.");
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (!checkPvpCond(target) && (target instanceof L2PcInstance))
- + {
- + GmListTable.broadcastMessageToGMs(getName() + " - tried to cheat in pvp!");
- + sendMessage("You didn't meet the pvp conditions or you tried to cheat!");
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else
- + {
- + int points = getFactionPoints();
- + int count = Config.FACTION_ITEM_NUMBER_REWARD_ON_PVP;
- + if (getFactionId() == 1)
- + count *= L2FactTeleporterInstance._tpTeam1Flags.size();
- + else if (getFactionId() == 2)
- + count *= L2FactTeleporterInstance._tpTeam2Flags.size();
- + else if (getFactionId() == 3)
- + count *= L2FactTeleporterInstance._tpTeam3Flags.size();
- +
- + addItem("Loot", Config.FACTION_ITEM_REWARD_ID_PVP, count, this, true);
- + setFactionPoints(points + 1);
- + }
- }
- +
- + if (Config.FACTION_ALLOW_ITEM_REWARD_PARTY && (Rnd.get(100) < Config.FACTION_CHANCE) && getParty() != null)
- + {
- + if (getFactionId() == targetPlayer.getFactionId())
- + {
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (targetPlayer.getFactionId() == 0)
- + {
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (getFactionId() == 0)
- + {
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (!checkPvpCond(target) && (target instanceof L2PcInstance))
- + {
- + GmListTable.broadcastMessageToGMs(getName() + " - tried to cheat in pvp!");
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else
- + {
- + for (L2PcInstance member : getParty().getPartyMembers())
- + {
- + 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} };
- + int[] ar = items[Rnd.get(10)];
- - // 'No war' or 'One way war' -> 'Normal PK'
- - if (targetPlayer.getKarma() > 0)
- + 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)
- + {
- + member.addItem("Loot", ar[0], ar[1], this, true);
- + member.sendMessage("You have earned a support class party reward!");
- + }
- + else
- + {
- + member.addItem("Loot", ar[0], ar[1], this, true);
- + member.sendMessage("You have earned a party reward!");
- + }
- + }
- + }
- + }
- +
- + if (Config.FACTION_ALLOW_EXP_REWARD)
- {
- - if (Config.KARMA_AWARD_PK_KILL)
- - increasePvpKills();
- + if (getFactionId() == targetPlayer.getFactionId())
- + {
- + sendMessage("You can't earn experience from the same faction!");
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (targetPlayer.getFactionId() == 0)
- + {
- + sendMessage("You can't earn experience from player, who doesn't belong to any faction!");
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (getFactionId() == 0)
- + {
- + sendMessage("You can't earn experience from other players, while you're member of non-faction.");
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else if (!checkPvpCond(target) && (target instanceof L2PcInstance))
- + {
- + GmListTable.broadcastMessageToGMs(getName() + " - tried to cheat in pvp!");
- + sendMessage("You didn't meet the pvp conditions or you tried to cheat!");
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return;
- + }
- + else
- + {
- + if (getLevel() < 76)
- + addExpAndSp(Config.FACTION_EXP_REWARD_PVP_FIRST, 0);
- + else if (getLevel() >= 76 && getLevel() < 78)
- + addExpAndSp(Config.FACTION_EXP_REWARD_PVP_SECOND, 0);
- + else
- + addExpAndSp(Config.FACTION_EXP_REWARD_PVP_THIRD, 0);
- + }
- }
- - else if (targetPlayer.getPvpFlag() == 0)
- - increasePkKillsAndKarma(targetPlayer.getLevel());
- +
- + if (checkPvpCond(target) && (target instanceof L2PcInstance))
- + {
- + int points = getFactionPoints();
- + setFactionPoints(points + Config.FACTION_POINTS_PVP);
- + sendMessage("You received " + Config.FACTION_POINTS_PVP + " points for killing an member of enemy Faction!");
- + if (targetPlayer.getArNePk() > 0)
- + {
- + increasePvpKills();
- + targetPlayer.setArNePk(0);
- + }
- + else
- + increasePkKillsAndKarma(targetPlayer.getLevel());
- + }
- }
- }
- @@ -4836,11 +5067,102 @@
- */
- public void increasePvpKills()
- {
- - // Add karma to attacker and increase its PK counter
- - setPvpKills(getPvpKills() + 1);
- -
- - // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
- - sendPacket(new UserInfo(this));
- + if (!Config.FACTION_ENGINE_ENABLED)
- + // Add karma to attacker and increase its PK counter
- + setPvpKills(getPvpKills() + 1);
- + else
- + {
- + uberKills++;
- + String text="";
- +
- + if (uberKills >= 4)
- + {
- + switch (uberKills)
- + {
- + case 4:
- + text=getName() + " : Rampage!";
- + break;
- + case 6:
- + text=getName() + " : Dominating!";
- + break;
- + case 8:
- + text=getName() + " : Killing Spree!";
- + break;
- + case 10:
- + text=getName() + " : Monsterrr Kill!";
- + if (getFactionId() == 1)
- + Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 10 kills without death!");
- + else if (getFactionId() == 2)
- + Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 10 kills without death!");
- + else
- + Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 10 kills without death!");
- + break;
- + case 12:
- + text=getName() + " : Unstoppable!";
- + if (getFactionId() == 1)
- + Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 12 kills without death!");
- + else if (getFactionId() == 2)
- + Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 12 kills without death!");
- + else
- + Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 12 kills without death!");
- + break;
- + case 14:
- + text=getName() + " : Ultra Kill!";
- + if (getFactionId() == 1)
- + Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 14 kills without death!");
- + else if (getFactionId() == 2)
- + Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 14 kills without death!");
- + else
- + Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 14 kills without death!");
- + break;
- + case 16:
- + text=getName() + " : GOD LIKE!";
- + if (getFactionId() == 1)
- + Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 16 kills without death!");
- + else if (getFactionId() == 2)
- + Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 16 kills without death!");
- + else
- + Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 16 kills without death!");
- + break;
- + case 18:
- + text=getName() + " : Wicked Sick!";
- + if (getFactionId() == 1)
- + Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 18 kills without death!");
- + else if (getFactionId() == 2)
- + Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 18 kills without death!");
- + else
- + Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 18 kills without death!");
- + break;
- + case 20:
- + text=getName() + " : Ludicrous Kill!";
- + if (getFactionId() == 1)
- + Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 20 kills without death!");
- + else if (getFactionId() == 2)
- + Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 20 kills without death!");
- + else
- + Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 20 kills without death!");
- + break;
- + case 25:
- + text=getName() + " : HOLY SHIT!";
- + if (getFactionId() == 1)
- + Broadcast.sendMessToAllTeam1Players("Our faction member " + getName() + " made 25 kills without death!");
- + else if (getFactionId() == 2)
- + Broadcast.sendMessToAllTeam2Players("Our faction member " + getName() + " made 25 kills without death!");
- + else
- + Broadcast.sendMessToAllTeam3Players("Our faction member " + getName() + " made 25 kills without death!");
- + break;
- + }
- + ExShowScreenMessage exshowscrn = new ExShowScreenMessage(text,4500);
- + Broadcast.toAllOnlinePlayers(exshowscrn);
- + }
- +
- + // Add karma to attacker and increase its PK counter
- + setPkKills(getPkKills() + 1);
- + setPvpKills(getPvpKills() + 1);
- + }
- +
- + // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
- + sendPacket(new UserInfo(this));
- }
- /**
- @@ -4850,52 +5172,57 @@
- */
- public void increasePkKillsAndKarma(int targLVL)
- {
- - int baseKarma = Config.KARMA_MIN_KARMA;
- - int newKarma = baseKarma;
- - int karmaLimit = Config.KARMA_MAX_KARMA;
- + if (!Config.FACTION_ENGINE_ENABLED)
- + {
- + int baseKarma = Config.KARMA_MIN_KARMA;
- + int newKarma = baseKarma;
- + int karmaLimit = Config.KARMA_MAX_KARMA;
- - int pkLVL = getLevel();
- - int pkPKCount = getPkKills();
- + int pkLVL = getLevel();
- + int pkPKCount = getPkKills();
- - int lvlDiffMulti = 0;
- - int pkCountMulti = 0;
- + int lvlDiffMulti = 0;
- + int pkCountMulti = 0;
- - // Check if the attacker has a PK counter greater than 0
- - if (pkPKCount > 0)
- - pkCountMulti = pkPKCount / 2;
- - else
- - pkCountMulti = 1;
- + // Check if the attacker has a PK counter greater than 0
- + if (pkPKCount > 0)
- + pkCountMulti = pkPKCount / 2;
- + else
- + pkCountMulti = 1;
- - if (pkCountMulti < 1)
- - pkCountMulti = 1;
- + if (pkCountMulti < 1)
- + pkCountMulti = 1;
- - // Calculate the level difference Multiplier between attacker and killed L2PcInstance
- - if (pkLVL > targLVL)
- - lvlDiffMulti = pkLVL / targLVL;
- - else
- - lvlDiffMulti = 1;
- + // Calculate the level difference Multiplier between attacker and killed L2PcInstance
- + if (pkLVL > targLVL)
- + lvlDiffMulti = pkLVL / targLVL;
- + else
- + lvlDiffMulti = 1;
- - if (lvlDiffMulti < 1)
- - lvlDiffMulti = 1;
- + if (lvlDiffMulti < 1)
- + lvlDiffMulti = 1;
- - // Calculate the new Karma of the attacker : newKarma = baseKarma*pkCountMulti*lvlDiffMulti
- - newKarma *= pkCountMulti;
- - newKarma *= lvlDiffMulti;
- + // Calculate the new Karma of the attacker : newKarma = baseKarma*pkCountMulti*lvlDiffMulti
- + newKarma *= pkCountMulti;
- + newKarma *= lvlDiffMulti;
- - // Make sure newKarma is less than karmaLimit and higher than baseKarma
- - if (newKarma < baseKarma)
- - newKarma = baseKarma;
- + // Make sure newKarma is less than karmaLimit and higher than baseKarma
- + if (newKarma < baseKarma)
- + newKarma = baseKarma;
- - if (newKarma > karmaLimit)
- - newKarma = karmaLimit;
- + if (newKarma > karmaLimit)
- + newKarma = karmaLimit;
- - // Fix to prevent overflow (=> karma has a max value of 2 147 483 647)
- - if (getKarma() > (Integer.MAX_VALUE - newKarma))
- - newKarma = Integer.MAX_VALUE - getKarma();
- + // Fix to prevent overflow (=> karma has a max value of 2 147 483 647)
- + if (getKarma() > (Integer.MAX_VALUE - newKarma))
- + newKarma = Integer.MAX_VALUE - getKarma();
- - // Add karma to attacker and increase its PK counter
- - setPkKills(getPkKills() + 1);
- - setKarma(getKarma() + newKarma);
- + // Add karma to attacker and increase its PK counter
- + setPkKills(getPkKills() + 1);
- + setKarma(getKarma() + newKarma);
- + }
- + else
- + setPkKills(getPkKills() + 1);
- // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
- sendPacket(new UserInfo(this));
- @@ -6098,6 +6425,7 @@
- player.setOnlineTime(rset.getLong("onlinetime"));
- player.setNewbie(rset.getInt("newbie")==1);
- player.setNoble(rset.getInt("nobless")==1);
- + player.setFactionId(rset.getInt("factionId"));
- player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
- if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
- @@ -6571,7 +6899,13 @@
- statement.setLong(47, getClanCreateExpiryTime());
- statement.setString(48, getName());
- statement.setLong(49, getDeathPenaltyBuffLevel());
- - statement.setInt(50, getObjectId());
- + if (Config.FACTION_ENGINE_ENABLED)
- + {
- + statement.setInt(50, getFactionId());
- + statement.setInt(51, getObjectId());
- + }
- + else
- + statement.setInt(50, getObjectId());
- statement.execute();
- statement.close();
- @@ -7329,6 +7663,23 @@
- // Check if the attacker isn't the L2PcInstance Pet
- if (attacker == this || attacker == getPet())
- return false;
- +
- + L2PcInstance player = null;
- + if (attacker instanceof L2PcInstance)
- + player = (L2PcInstance) attacker;
- + if (attacker instanceof L2SummonInstance)
- + player = ((L2SummonInstance) attacker).getOwner();
- +
- + if (player != null && Config.FACTION_ENGINE_ENABLED)
- + {
- + if (!isInsidePeaceZone(this, player))
- + {
- + if (getFactionId() == 0 || player.getFactionId() == 0)
- + return false;
- + if (getFactionId() != player.getFactionId())
- + return true;
- + }
- + }
- // TODO: check for friendly mobs
- // Check if the attacker is a L2MonsterInstance
- @@ -7352,7 +7703,7 @@
- if (getClan() != null && attacker != null && getClan().isMember(attacker.getObjectId()))
- return false;
- - if(attacker instanceof L2Playable && isInsideZone(ZONE_PEACE))
- + if (attacker instanceof L2Playable && isInsideZone(ZONE_PEACE))
- return false;
- // Check if the L2PcInstance has Karma
- @@ -7685,6 +8036,27 @@
- return false;
- }
- + boolean cond = true;
- + L2PcInstance trgtF = null;
- + if (target instanceof L2PcInstance)
- + trgtF = (L2PcInstance)target;
- + else if (target instanceof L2SummonInstance)
- + trgtF = ((L2SummonInstance)target).getOwner();
- + if (trgtF != null && Config.FACTION_ENGINE_ENABLED)
- + {
- + if (trgtF.getFactionId() == getFactionId())
- + cond = false;
- + if (trgtF.getFactionId() == 0 || getFactionId() == 0)
- + cond = false;
- + if (trgtF.isInOlympiadMode() && isInOlympiadMode())
- + cond = true;
- + }
- + if (!cond)
- + {
- + sendPacket(ActionFailed.STATIC_PACKET);
- + return false;
- + }
- +
- if (isInOlympiadMode() && !isOlympiadStart())
- {
- // if L2PcInstance is in Olympia and the match isn't already start, send a Server->Client packet ActionFailed
- @@ -8000,6 +8372,9 @@
- if (skill.isPvpSkill()) // pvp skill
- {
- + if (getFactionId() != ((L2PcInstance)target).getFactionId() && !isInsidePeaceZone(this, ((L2PcInstance)target)))
- + return true;
- +
- // in clan war player can attack whites even with sleep etc.
- if (getClan() != null && ((L2PcInstance)target).getClan() != null)
- {
- @@ -8008,12 +8383,15 @@
- }
- // target's pvp flag is not set and target has no karma
- - if (((L2PcInstance)target).getPvpFlag() == 0 && ((L2PcInstance)target).getKarma() == 0)
- + if (((L2PcInstance)target).getPvpFlag() == 0 && ((L2PcInstance)target).getKarma() == 0 && !Config.FACTION_ENGINE_ENABLED)
- return false;
- }
- else if ((skilldat != null && !skilldat.isCtrlPressed() && skill.isOffensive() && !srcIsSummon)
- || (skilldatpet != null && !skilldatpet.isCtrlPressed() && skill.isOffensive() && srcIsSummon))
- {
- + if (getFactionId() != ((L2PcInstance)target).getFactionId() && !isInsidePeaceZone(this, ((L2PcInstance)target)))
- + return true;
- +
- // in clan war player can attack whites even with sleep etc.
- if (getClan() != null && ((L2PcInstance)target).getClan() != null)
- {
- @@ -8022,7 +8400,7 @@
- }
- // target's pvp flag is not set and target has no karma
- - if (((L2PcInstance)target).getPvpFlag() == 0 && ((L2PcInstance)target).getKarma() == 0)
- + if (((L2PcInstance)target).getPvpFlag() == 0 && ((L2PcInstance)target).getKarma() == 0 && !Config.FACTION_ENGINE_ENABLED)
- return false;
- }
- }
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2TpFlagInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2TpFlagInstance.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2TpFlagInstance.java (revision 0)
- @@ -0,0 +1,330 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.model.actor.instance;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.gameserver.Announcements;
- +import net.sf.l2j.gameserver.ai.CtrlIntention;
- +import net.sf.l2j.gameserver.datatables.NpcTable;
- +import net.sf.l2j.gameserver.idfactory.IdFactory;
- +import net.sf.l2j.gameserver.model.L2Skill;
- +import net.sf.l2j.gameserver.model.actor.L2Character;
- +import net.sf.l2j.gameserver.model.actor.L2Npc;
- +import net.sf.l2j.gameserver.model.entity.FactionMaps;
- +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
- +import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
- +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
- +import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
- +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +
- +public final class L2TpFlagInstance extends L2Npc
- +{
- + private final static Logger _log = Logger.getLogger(L2FactTeleporterInstance.class.getName());
- +
- + private int _faction=0;
- + private int _occupayable=0;
- + private String _title = "";
- + private String _flagPlace = "";
- +
- + public L2TpFlagInstance(int objectId, L2NpcTemplate template)
- + {
- + super(objectId, template);
- + }
- +
- + public static void spawnFlags()
- + {
- + Connection con = null;
- +
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement statement = con.prepareStatement("SELECT * FROM faction_crystals WHERE mapId=?");
- + statement.setInt(1, FactionMaps.getMapId());
- + ResultSet rset = statement.executeQuery();
- +
- + while (rset.next())
- + {
- + String _titlea = "";
- + if (rset.getInt("factionId") == 1)
- + _titlea = Config.FACTION_TEAM1_NAME + " Faction";
- + else if (rset.getInt("factionId") == 2)
- + _titlea = Config.FACTION_TEAM2_NAME + " Faction";
- + else if (rset.getInt("factionId") == 3)
- + _titlea = Config.FACTION_TEAM3_NAME + " Faction";
- +
- + L2TpFlagInstance flag = new L2TpFlagInstance(IdFactory.getInstance().getNextId(),NpcTable.getInstance().getTemplate(31217));
- + flag.setTitle(_titlea);
- + flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp());
- + flag.setHeading(0);
- + flag.setName(rset.getString("flagName"));
- + flag.setFlagName(rset.getString("flagName"));
- + flag.setFlagFactionId(rset.getInt("factionId"));
- + flag.spawnMe(rset.getInt("x"),rset.getInt("y"),rset.getInt("z") + 50);
- + if (rset.getInt("factionId") != 0)
- + {
- + if (rset.getInt("factionId") == 1)
- + L2FactTeleporterInstance._tpTeam1Flags.add(flag);
- + else if (rset.getInt("factionId") == 2)
- + L2FactTeleporterInstance._tpTeam2Flags.add(flag);
- + else
- + L2FactTeleporterInstance._tpTeam3Flags.add(flag);
- + flag.setIsInvul(true);
- + flag.setIsUnoccupayable(1);
- + }
- + _log.info("Spawned flag: " + rset.getString("flagName"));
- + }
- +
- + rset.close();
- + statement.close();
- + }
- + catch (Exception e)
- + {
- + _log.warning("Something is wrong with flags:" + e);
- + }
- + finally
- + {
- + try {con.close();} catch (Exception e){}
- + }
- + Announcements.getInstance().announceToAll("Spawned faction map: " + FactionMaps.getMapName());
- + }
- +
- + public void setFlagName(String a)
- + {
- + _flagPlace = a;
- + }
- +
- + public String getFlagName()
- + {
- + return _flagPlace;
- + }
- +
- + @Override
- + public boolean isAttackable()
- + {
- + return true;
- + }
- +
- + @Override
- + public boolean isAutoAttackable(L2Character attacker)
- + {
- + return true;
- + }
- +
- + @Override
- + public boolean doDie(L2Character killer)
- + {
- + L2PcInstance player = null;
- + if (killer instanceof L2PcInstance)
- + player = (L2PcInstance) killer;
- + else if (killer instanceof L2SummonInstance)
- + player = ((L2SummonInstance) killer).getOwner();
- +
- + int _faktjon = 0;
- + String _name = "";
- +
- + _faktjon = player.getFactionId();
- + if (_faktjon == 1)
- + _title = Config.FACTION_TEAM1_NAME + " Faction";
- + else if (_faktjon == 2)
- + _title = Config.FACTION_TEAM2_NAME + " Faction";
- + else if (_faktjon == 3)
- + _title = Config.FACTION_TEAM3_NAME + " Faction";
- + else
- + _title = "No Faction";
- +
- + if (!super.doDie(killer))
- + return false;
- +
- + if (player != null)
- + player.sendPacket(new PlaySound("skillsound7.pig_skill"));
- +
- + if (getFlagFactionId() == 1)
- + {
- + L2FactTeleporterInstance._tpTeam1Flags.remove(this);
- + Broadcast.sendMessToAllTeam1Players("[" + Config.FACTION_TEAM1_NAME + "] We just lost " + _flagPlace + " flag on " + FactionMaps.getMapName() + ". Go defend it!");
- + if (_faktjon == 2)
- + Broadcast.sendMessToAllTeam2Players("[" + Config.FACTION_TEAM2_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
- + else if (_faktjon == 3)
- + Broadcast.sendMessToAllTeam3Players("[" + Config.FACTION_TEAM3_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
- + }
- + else if (getFlagFactionId() == 2)
- + {
- + L2FactTeleporterInstance._tpTeam2Flags.remove(this);
- + Broadcast.sendMessToAllTeam2Players("[" + Config.FACTION_TEAM2_NAME + "] We just lost " + _flagPlace + " flag on " + FactionMaps.getMapName() + ". Go defend it!");
- + if (_faktjon == 1)
- + Broadcast.sendMessToAllTeam1Players("[" + Config.FACTION_TEAM1_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
- + else if (_faktjon == 3)
- + Broadcast.sendMessToAllTeam3Players("[" + Config.FACTION_TEAM3_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
- + }
- + else if (getFlagFactionId() == 3)
- + {
- + L2FactTeleporterInstance._tpTeam3Flags.remove(this);
- + Broadcast.sendMessToAllTeam3Players("[" + Config.FACTION_TEAM3_NAME + "] We just lost " + _flagPlace + " flag on " + FactionMaps.getMapName() + ". Go defend it!");
- + if (_faktjon == 1)
- + Broadcast.sendMessToAllTeam1Players("[" + Config.FACTION_TEAM1_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
- + else if (_faktjon == 2)
- + Broadcast.sendMessToAllTeam2Players("[" + Config.FACTION_TEAM2_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
- + }
- + else if (getFlagFactionId() == 0)
- + {
- + if (_faktjon == 1)
- + Broadcast.sendMessToAllTeam1Players("[" + Config.FACTION_TEAM1_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
- + else if (_faktjon == 2)
- + Broadcast.sendMessToAllTeam2Players("[" + Config.FACTION_TEAM2_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
- + else if (_faktjon == 3)
- + Broadcast.sendMessToAllTeam3Players("[" + Config.FACTION_TEAM3_NAME + "] " + player.getName() + " has occupied " + _flagPlace + " flag on " + FactionMaps.getMapName());
- + }
- +
- + L2TpFlagInstance flag = new L2TpFlagInstance(IdFactory.getInstance().getNextId(),NpcTable.getInstance().getTemplate(31217));
- + _name = this.getName();
- + flag.setTitle(_title);
- + flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp());
- + flag.setHeading(0);
- + flag.setName(_name);
- + flag.setFlagName(_name);
- + flag.setIsUnoccupayable(0);
- + flag.setFlagFactionId(_faktjon);
- + flag.spawnMe(this.getX(), this.getY(), this.getZ());
- + deleteMe();
- +
- + if (_faktjon == 1)
- + L2FactTeleporterInstance._tpTeam1Flags.add(flag);
- + else if (_faktjon == 2)
- + L2FactTeleporterInstance._tpTeam2Flags.add(flag);
- + else if (_faktjon == 3)
- + L2FactTeleporterInstance._tpTeam3Flags.add(flag);
- +
- + if (Config.FACTION_ALLOW_SP_REWARD_FLAG)
- + {
- + if (player.getClan() != null)
- + {
- + if (player.getClan().getLevel() < 5)
- + {
- + player.addExpAndSp(0, Config.FACTION_SP_REWARD_FIRST_FLAG);
- + player.addItem("Loot", 5575, Config.FACTION_AA_REWARD_FIRST_FLAG, this, true);
- + }
- + else if (player.getClan().getLevel() >= 5 && player.getClan().getLevel() < 7)
- + {
- + player.addExpAndSp(0, Config.FACTION_SP_REWARD_SECOND_FLAG);
- + player.addItem("Loot", 5575, Config.FACTION_AA_REWARD_SECOND_FLAG, this, true);
- + }
- + else
- + {
- + player.addExpAndSp(0, Config.FACTION_SP_REWARD_THIRD_FLAG);
- + player.addItem("Loot", 5575, Config.FACTION_AA_REWARD_THIRD_FLAG, this, true);
- + }
- + }
- + else
- + {
- + player.addExpAndSp(0, Config.FACTION_SP_REWARD_THIRD_FLAG);
- + player.addItem("Loot", 5575, Config.FACTION_AA_REWARD_THIRD_FLAG, this, true);
- + }
- + int points = player.getFactionPoints();
- + player.setFactionPoints(points + Config.FACTION_POINTS_FLAG);
- + player.sendMessage("You received " + Config.FACTION_POINTS_FLAG + " points for capturing enemy flag!");
- +
- + }
- +
- + return true;
- + }
- +
- + @Override
- + public void onForcedAttack(L2PcInstance player)
- + {
- + onAction(player);
- + }
- +
- + public void setIsUnoccupayable(int a)
- + {
- + _occupayable = a;
- + }
- +
- + public int isUnoccupayable()
- + {
- + return _occupayable;
- + }
- +
- + @Override
- + public void onAction(L2PcInstance player)
- + {
- + if (player == null || !canTarget(player))
- + return;
- +
- + // Check if the L2PcInstance already target the L2NpcInstance
- + if (this != player.getTarget())
- + {
- + // Set the target of the L2PcInstance player
- + player.setTarget(this);
- +
- + // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
- + MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
- + player.sendPacket(my);
- +
- + // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
- + StatusUpdate su = new StatusUpdate(getObjectId());
- + su.addAttribute(StatusUpdate.CUR_HP, (int)getStatus().getCurrentHp() );
- + su.addAttribute(StatusUpdate.MAX_HP, getMaxHp() );
- + player.sendPacket(su);
- +
- + // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
- + player.sendPacket(new ValidateLocation(this));
- + }
- + else
- + {
- + if (isAutoAttackable(player) && Math.abs(player.getZ() - getZ()) < 100)
- + player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, this);
- + else
- + {
- + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
- + player.sendPacket(ActionFailed.STATIC_PACKET);
- + }
- + }
- + }
- +
- + public int getFlagFactionId()
- + {
- + return _faction;
- + }
- +
- + public void setFlagFactionId(int i)
- + {
- + _faction = i;
- + }
- +
- + @Override
- + public void reduceCurrentHp(double damage, L2Character attacker, L2Skill skill)
- + {
- + L2PcInstance plajor = null;
- + boolean cord = false;
- + if (attacker instanceof L2PcInstance)
- + plajor = (L2PcInstance) attacker;
- + else if (attacker instanceof L2SummonInstance)
- + plajor = ((L2SummonInstance) attacker).getOwner();
- +
- + if (plajor.getFactionId() != getFlagFactionId() && plajor.getFactionId() != 0)
- + cord = true;
- +
- + if (cord)
- + super.reduceCurrentHp(damage, attacker, skill);
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/actor/L2Character.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/L2Character.java (revision 128)
- +++ java/net/sf/l2j/gameserver/model/actor/L2Character.java (working copy)
- @@ -116,6 +116,9 @@
- import net.sf.l2j.util.Point3D;
- import net.sf.l2j.util.Rnd;
- +import net.sf.l2j.gameserver.model.actor.instance.L2TpFlagInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
- +
- /**
- * L2Character is the mother class of all character objects of the world (PC, NPC...) :<br><br>
- * <b><u> Instances using it </u> :</b>
- @@ -593,6 +596,29 @@
- if (this instanceof L2PcInstance)
- {
- + L2PcInstance player = (L2PcInstance) this;
- + L2PcInstance trgtF = null;
- + boolean cond = true;
- +
- + if (target instanceof L2PcInstance)
- + trgtF = (L2PcInstance) target;
- + else if (target instanceof L2SummonInstance)
- + trgtF = ((L2SummonInstance)target).getOwner();
- +
- + if (trgtF != null && Config.FACTION_ENGINE_ENABLED)
- + {
- + if (trgtF.getFactionId() == player.getFactionId())
- + cond = false;
- + if (trgtF.getFactionId() == 0 || player.getFactionId() == 0)
- + cond = false;
- + if (isInsidePeaceZone(this, trgtF))
- + cond = false;
- + if (trgtF.isInOlympiadMode() && player.isInOlympiadMode())
- + cond = true;
- + }
- + if (!cond)
- + return;
- +
- if (((L2PcInstance)this).inObserverMode())
- {
- sendPacket(new SystemMessage(SystemMessageId.OBSERVERS_CANNOT_PARTICIPATE));
- @@ -1730,7 +1756,8 @@
- // Stop Regeneration task, and removes all current effects
- getStatus().stopHpMpRegeneration();
- stopAllEffectsExceptThoseThatLastThroughDeath();
- +
- calculateRewards(killer);
- @@ -1803,12 +1830,16 @@
- {
- restorefull = true;
- ((L2Playable)this).stopPhoenixBlessing(null);
- - }
- + }
- + else if (this instanceof L2PcInstance && ((L2PcInstance) this).getFactionId() != 0 && Config.FACTION_ENGINE_ENABLED)
- + restorefull = true;
- if (restorefull)
- {
- _status.setCurrentHp(getMaxHp());
- _status.setCurrentMp(getMaxMp());
- + if (Config.FACTION_ENGINE_ENABLED)
- + _status.setCurrentCp(getMaxCp());
- }
- else
- _status.setCurrentHp(getMaxHp() * Config.RESPAWN_RESTORE_HP);
- Index: java/net/sf/l2j/gameserver/model/base/SubClass.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/base/SubClass.java (revision 128)
- +++ java/net/sf/l2j/gameserver/model/base/SubClass.java (working copy)
- @@ -18,6 +18,8 @@
- */
- package net.sf.l2j.gameserver.model.base;
- +import net.sf.l2j.Config;
- +
- /**
- * Character Sub-Class Definition
- * <BR>
- @@ -28,9 +30,9 @@
- public final class SubClass
- {
- private PlayerClass _class;
- - private long _exp = Experience.LEVEL[40];
- + private long _exp = Experience.LEVEL[Config.FACTION_START_LVL_SUB];
- private int _sp = 0;
- - private byte _level = 40;
- + private byte _level = (byte)Config.FACTION_START_LVL_SUB;
- private int _classIndex = 1;
- public SubClass(int classId, long exp, int sp, byte level, int classIndex)
- Index: java/net/sf/l2j/gameserver/model/CharEffectList.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/CharEffectList.java (revision 128)
- +++ java/net/sf/l2j/gameserver/model/CharEffectList.java (working copy)
- @@ -363,8 +363,16 @@
- // Exit them
- for (L2Effect e : effects)
- {
- - if (e != null)
- - e.exit(true);
- + if (!Config.FACTION_ENGINE_ENABLED)
- + {
- + if (e != null)
- + e.exit(true);
- + }
- + else
- + {
- + if (e != null && e.getSkill().isDebuff())
- + e.exit(true);
- + }
- }
- }
- Index: java/net/sf/l2j/gameserver/model/entity/FactionMaps.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/entity/FactionMaps.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/entity/FactionMaps.java (revision 0)
- @@ -0,0 +1,337 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.model.entity;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.Calendar;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.L2DatabaseFactory;
- +import net.sf.l2j.gameserver.Announcements;
- +import net.sf.l2j.gameserver.ThreadPoolManager;
- +import net.sf.l2j.gameserver.datatables.MapRegionTable;
- +import net.sf.l2j.gameserver.model.L2World;
- +import net.sf.l2j.gameserver.model.actor.instance.L2FactTeleporterInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.model.actor.instance.L2TpFlagInstance;
- +import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
- +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +import net.sf.l2j.util.StringUtil;
- +
- +/**
- + * @author DarthVader
- + */
- +public class FactionMaps
- +{
- + private final static Logger _log = Logger.getLogger(FactionMaps.class.getName());
- + public static int _mapId = 0;
- + public static String _mapName = "";
- + public static boolean _voting = false;
- + public static int[] _mapVotes = new int[10];
- + public static String[] _mapNames = new String[10];
- + private static long _nextMapIn = 0;
- +
- + public static boolean isVoting()
- + {
- + return _voting;
- + }
- +
- + public static int getMapId()
- + {
- + return _mapId;
- + }
- +
- + public static String getMapName()
- + {
- + return _mapName;
- + }
- +
- + public static String getDelayUntilVoting()
- + {
- + long trim = _nextMapIn - Calendar.getInstance().getTimeInMillis();
- + int h = 0;
- + int m = 0;
- + int s = 0;
- + int k = 1/2;
- + h = 0;
- + m = 0;
- + s = 0;
- +
- + if (trim/3600000 >= 1)
- + {
- + h = Math.round(trim/3600000-k);
- + trim -=h*3600000;
- + }
- + if (trim/60 >= 1)
- + {
- + m = Math.round(trim/60000-k);
- + trim -=m*60000;
- + }
- + if (trim/1000 >= 1)
- + {
- + s = Math.round(trim/1000-k);
- + }
- + return h + "h. " + m + "m. " + s + "s.";
- + }
- +
- + public static void loadCurrentMap()
- + {
- + Connection con = null;
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement stmt = con.prepareStatement("SELECT mapId,map_name FROM faction_maps WHERE current=1");
- + ResultSet rset = stmt.executeQuery();
- + while (rset.next())
- + {
- + _mapId = rset.getInt("mapId");
- + _mapName = rset.getString("map_name");
- + }
- + rset.close();
- + stmt.close();
- + }
- + catch (Exception e) { _log.warning("Load current map: "+ e); }
- + finally { try { con.close(); } catch (Exception e) {} }
- + ThreadPoolManager.getInstance().scheduleGeneral(new Runnable(){public void run(){endVoting(true);}}, 1000);
- + }
- +
- + public static void beginVoting()
- + {
- + for (L2TpFlagInstance flag : L2FactTeleporterInstance._tpTeam1Flags)
- + flag.deleteMe();
- + for (L2TpFlagInstance flag : L2FactTeleporterInstance._tpTeam2Flags)
- + flag.deleteMe();
- + for (L2TpFlagInstance flag : L2FactTeleporterInstance._tpTeam3Flags)
- + flag.deleteMe();
- + L2FactTeleporterInstance._tpTeam1Flags.clear();
- + L2FactTeleporterInstance._tpTeam2Flags.clear();
- + L2FactTeleporterInstance._tpTeam3Flags.clear();
- + for (L2PcInstance plajer : L2World.getInstance().getAllPlayers().values())
- + {
- + if (plajer.getFactionId() == 1)
- + plajer.teleToLocation(Config.FACTION_TEAM1_BASE_X, Config.FACTION_TEAM1_BASE_Y, Config.FACTION_TEAM1_BASE_Z);
- + else if (plajer.getFactionId() == 2)
- + plajer.teleToLocation(Config.FACTION_TEAM2_BASE_X, Config.FACTION_TEAM2_BASE_Y, Config.FACTION_TEAM2_BASE_Z);
- + else if (plajer.getFactionId() == 3)
- + plajer.teleToLocation(Config.FACTION_TEAM3_BASE_X, Config.FACTION_TEAM3_BASE_Y, Config.FACTION_TEAM3_BASE_Z);
- + else
- + plajer.teleToLocation(Config.FACTION_CUSTOM_SPAWN_X, Config.FACTION_CUSTOM_SPAWN_Y, Config.FACTION_CUSTOM_SPAWN_Z);
- +
- + plajer.setVotedForMap(false);
- + }
- + Announcements.getInstance().announceToAll("Round ended.");
- + Announcements.getInstance().announceToAll("Voting for next faction map has begun. It will end in 60 seconds.");
- + _voting = true;
- + NpcHtmlMessage html = new NpcHtmlMessage(1);
- + final StringBuilder strBuffer = StringUtil.startAppend(3500, "<html><title>Faction Maps</title><body><center>");
- + strBuffer.append("<img src=\"L2UI_CH3.onscrmsg_pattern01_1\" width=300 height=32 align=left><br>");
- + Connection con = null;
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement statement = con.prepareStatement("SELECT * FROM faction_maps");
- + ResultSet rset = statement.executeQuery();
- + for (int r = 0; r < _mapVotes.length; r++)
- + _mapVotes[r] = 0;
- + while (rset.next())
- + {
- + 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\">");
- + _mapNames[rset.getInt("mapId")] = rset.getString("map_name");
- + }
- +
- + rset.close();
- + statement.close();
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + }
- + finally
- + {
- + try {con.close();} catch (Exception e){}
- + }
- + strBuffer.append("<img src=\"L2UI_CH3.onscrmsg_pattern01_2\" width=300 height=32 align=left></center></body></html>");
- + html.setHtml(strBuffer.toString());
- + for (L2PcInstance plajer : L2World.getInstance().getAllPlayers().values())
- + plajer.sendPacket(html);
- + try{Thread.sleep(60000);}catch (Exception e){}
- + endVoting(false);
- + }
- +
- + public static void endVoting(boolean onLoad)
- + {
- + int team1 = 0;
- + for (L2PcInstance zaidejas1 : L2World.getInstance().getAllteam1Players())
- + team1 = zaidejas1.getFactionPoints();
- + int team2 = 0;
- + for (L2PcInstance zaidejas2 : L2World.getInstance().getAllteam2Players())
- + team2 = zaidejas2.getFactionPoints();
- + int team3 = 0;
- + for (L2PcInstance zaidejas3 : L2World.getInstance().getAllteam3Players())
- + team3 = zaidejas3.getFactionPoints();
- + int bestteam = 0;
- + if (team1 > team2 && team1 > team3)
- + bestteam = 1;
- + else if (team2 > team1 && team2 > team3)
- + bestteam = 2;
- + else if (team3 > team1 && team3 > team2)
- + bestteam = 3;
- + else if (team1 == team2)
- + bestteam = 4;
- + else if (team1 == team3)
- + bestteam = 5;
- + else if (team2 == team3)
- + bestteam = 6;
- + else if (team1 == team2 && team1 == team3 && team2 == team3 && team1 > 0 && team2 > 0 && team3 > 0)
- + bestteam = 7;
- +
- + _nextMapIn = Calendar.getInstance().getTimeInMillis() + 7200000;
- + if (!onLoad)
- + {
- + _voting = false;
- + int mostVotes = 0;
- + int mostMapId = 0;
- + for (int i = 0; i < _mapVotes.length; i++)
- + {
- + if (_mapVotes[i] > mostVotes)
- + {
- + mostVotes = _mapVotes[i];
- + mostMapId = i;
- + }
- + }
- + _mapName = _mapNames[mostMapId];
- + _mapId = mostMapId;
- + Announcements.getInstance().announceToAll("Voting for faction maps has ended.");
- + Announcements.getInstance().announceToAll("The next map will be: " + _mapName);
- +
- + Broadcast.sendMessToAllFactionPlayers("Points, collected during this round:");
- + Broadcast.sendMessToAllFactionPlayers("[" + Config.FACTION_TEAM1_NAME + "] collected - " + team1 + " points");
- + Broadcast.sendMessToAllFactionPlayers("[" + Config.FACTION_TEAM2_NAME + "] collected - " + team2 + " points");
- + Broadcast.sendMessToAllFactionPlayers("[" + Config.FACTION_TEAM3_NAME + "] collected - " + team3 + " points");
- +
- + if (bestteam == 1)
- + for (L2PcInstance _players : L2World.getInstance().getAllteam1Players())
- + {
- + Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM1_NAME + " faction won, all faction members got rewarded!");
- + _players.addItem("Admin", 57, 20, _players, true);
- + }
- + else if (bestteam == 2)
- + for (L2PcInstance _players : L2World.getInstance().getAllteam2Players())
- + {
- + Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM2_NAME + " faction won, all faction members got rewarded!");
- + _players.addItem("Admin", 57, 20, _players, true);
- + }
- + else if (bestteam == 3)
- + for (L2PcInstance _players : L2World.getInstance().getAllteam3Players())
- + {
- + Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM3_NAME + " faction won, all faction members got rewarded!");
- + _players.addItem("Admin", 57, 20, _players, true);
- + }
- + else if (bestteam == 4)
- + {
- + Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM1_NAME + " and " + Config.FACTION_TEAM2_NAME + " factions won, all faction members got rewarded!");
- + for (L2PcInstance _players : L2World.getInstance().getAllteam1Players())
- + _players.addItem("Admin", 57, 20, _players, true);
- + for (L2PcInstance _players : L2World.getInstance().getAllteam2Players())
- + _players.addItem("Admin", 57, 20, _players, true);
- + }
- + else if (bestteam == 5)
- + {
- + Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM1_NAME + " and " + Config.FACTION_TEAM3_NAME + " factions won, all faction members got rewarded!");
- + for (L2PcInstance _players : L2World.getInstance().getAllteam1Players())
- + _players.addItem("Admin", 57, 20, _players, true);
- + for (L2PcInstance _players : L2World.getInstance().getAllteam3Players())
- + _players.addItem("Admin", 57, 20, _players, true);
- + }
- + else if (bestteam == 6)
- + {
- + Broadcast.sendMessToAllFactionPlayers("" + Config.FACTION_TEAM2_NAME + " and " + Config.FACTION_TEAM3_NAME + " factions won, all faction members got rewarded!");
- + for (L2PcInstance _players : L2World.getInstance().getAllteam2Players())
- + _players.addItem("Admin", 57, 20, _players, true);
- + for (L2PcInstance _players : L2World.getInstance().getAllteam3Players())
- + _players.addItem("Admin", 57, 20, _players, true);
- + }
- + else if (bestteam == 7)
- + {
- + Broadcast.sendMessToAllFactionPlayers("All factions won, all faction members got rewarded!");
- + for (L2PcInstance _players : L2World.getInstance().getAllteam1Players())
- + _players.addItem("Admin", 57, 20, _players, true);
- + for (L2PcInstance _players : L2World.getInstance().getAllteam2Players())
- + _players.addItem("Admin", 57, 20, _players, true);
- + for (L2PcInstance _players : L2World.getInstance().getAllteam3Players())
- + _players.addItem("Admin", 57, 20, _players, true);
- + }
- + else
- + Broadcast.sendMessToAllFactionPlayers("Round ended in tie!");
- +
- + for (L2PcInstance zaid : L2World.getInstance().getAllPlayers().values())
- + zaid.setFactionPoints(0);
- +
- + L2TpFlagInstance.spawnFlags();
- +
- + Connection con = null;
- + try
- + {
- + con = L2DatabaseFactory.getInstance().getConnection();
- + PreparedStatement statement = null;
- + statement = con.prepareStatement("UPDATE faction_maps SET current=0");
- + statement.execute();
- + statement = con.prepareStatement("UPDATE faction_maps SET current=1 WHERE mapId=?");
- + statement.setInt(1, _mapId);
- + statement.execute();
- + statement.close();
- + }
- + catch (Exception e) { _log.warning("End voting: "+ e); }
- + finally { try { con.close(); } catch (Exception e) {} }
- + }
- + int time = 0;
- + String left = "";
- + for (int a = 4; a > 0;a-=1)
- + {
- + switch(a)
- + {
- + case 4:
- + time = 3600000;
- + left = "1 hour";
- + break;
- + case 3:
- + time = 1800000;
- + left = "30 minutes";
- + break;
- + case 2:
- + time = 1500000;
- + left = "5 minutes";
- + break;
- + case 1:
- + time = 240000;
- + left = "1 minute";
- + break;
- + }
- + try{Thread.sleep(time);}catch (Exception e){}
- + ExShowScreenMessage exshowscrn = new ExShowScreenMessage("Voting for faction maps will begin in " + left,4500);
- + Broadcast.toAllOnlinePlayers(exshowscrn);
- + }
- + beginVoting();
- + }
- +
- + public static void voteForMap(int mapId)
- + {
- + _mapVotes[mapId] +=1;
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/model/L2Skill.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/L2Skill.java (revision 128)
- +++ java/net/sf/l2j/gameserver/model/L2Skill.java (working copy)
- @@ -2139,6 +2139,26 @@
- {
- if (targetPlayer == caster || targetPlayer == player)
- return false;
- +
- + boolean cond = true;
- + L2PcInstance trgtF = null;
- + if (target instanceof L2PcInstance)
- + trgtF = (L2PcInstance)target;
- + else if (target instanceof L2SummonInstance)
- + trgtF = ((L2SummonInstance)target).getOwner();
- + if (trgtF != null && Config.FACTION_ENGINE_ENABLED)
- + {
- + if (trgtF.getFactionId() == player.getFactionId())
- + cond = false;
- + if (trgtF.getFactionId() == 0 || player.getFactionId() == 0)
- + cond = false;
- +// if (trgtF.isInsideZone(L2Character.ZONE_PEACE))
- +// cond = false;
- + if (trgtF.isInOlympiadMode() && player.isInOlympiadMode())
- + cond = true;
- + }
- + if (!cond)
- + return false;
- if (targetPlayer.inObserverMode())
- return false;
- Index: java/net/sf/l2j/gameserver/model/L2World.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/L2World.java (revision 128)
- +++ java/net/sf/l2j/gameserver/model/L2World.java (working copy)
- @@ -64,6 +64,9 @@
- private Map<Integer, L2PcInstance> _allPlayers;
- private Map<Integer, L2Object> _allObjects;
- private Map<Integer, L2PetInstance> _petsInstance;
- + private Map<String, L2PcInstance> _allteam1Players;
- + private Map<String, L2PcInstance> _allteam2Players;
- + private Map<String, L2PcInstance> _allteam3Players;
- private L2WorldRegion[][] _worldRegions;
- private static final L2World _instance = new L2World();
- @@ -76,6 +79,9 @@
- _allPlayers = new FastMap<Integer, L2PcInstance>().shared();
- _petsInstance = new FastMap<Integer, L2PetInstance>().shared();
- _allObjects = new FastMap<Integer, L2Object>().shared();
- + _allteam1Players = new FastMap<String, L2PcInstance>().shared();
- + _allteam2Players = new FastMap<String, L2PcInstance>().shared();
- + _allteam3Players = new FastMap<String, L2PcInstance>().shared();
- initRegions();
- }
- @@ -202,6 +208,36 @@
- {
- return _allPlayers;
- }
- +
- + public Map<String, L2PcInstance> getAllTeam1()
- + {
- + return _allteam1Players;
- + }
- +
- + public Map<String, L2PcInstance> getAllTeam2()
- + {
- + return _allteam2Players;
- + }
- +
- + public Map<String, L2PcInstance> getAllTeam3()
- + {
- + return _allteam3Players;
- + }
- +
- + public Collection<L2PcInstance> getAllteam1Players()
- + {
- + return _allteam1Players.values();
- + }
- +
- + public Collection<L2PcInstance> getAllteam2Players()
- + {
- + return _allteam2Players.values();
- + }
- +
- + public Collection<L2PcInstance> getAllteam3Players()
- + {
- + return _allteam3Players.values();
- + }
- /**
- * Return how many players are online.<BR><BR>
- @@ -325,6 +361,12 @@
- }
- _allPlayers.put(player.getObjectId(), player);
- }
- + if (player.getFactionId() == 1)
- + _allteam1Players.put(player.getName().toLowerCase(),player);
- + else if (player.getFactionId() == 2)
- + _allteam2Players.put(player.getName().toLowerCase(),player);
- + else if (player.getFactionId() == 3)
- + _allteam3Players.put(player.getName().toLowerCase(),player);
- }
- if (!newRegion.isActive())
- @@ -437,8 +479,15 @@
- // If selected L2Object is a L2PcIntance, remove it from L2ObjectHashSet(L2PcInstance) _allPlayers of L2World
- if (object instanceof L2PcInstance)
- {
- - if (!((L2PcInstance)object).isTeleporting())
- - removeFromAllPlayers((L2PcInstance)object);
- + L2PcInstance player = (L2PcInstance) object;
- + if (!player.isTeleporting())
- + removeFromAllPlayers(player);
- + if (player.getFactionId() == 1)
- + _allteam1Players.remove(player.getName().toLowerCase());
- + else if (player.getFactionId() == 2)
- + _allteam2Players.remove(player.getName().toLowerCase());
- + else if (player.getFactionId() == 3)
- + _allteam3Players.remove(player.getName().toLowerCase());
- }
- }
- }
- Index: java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java (revision 128)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java (working copy)
- @@ -196,7 +196,10 @@
- L2PcTemplate template = newChar.getTemplate();
- newChar.addAdena("Init", Config.STARTING_ADENA, null, false);
- - newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
- + if (!Config.FACTION_ENGINE_ENABLED)
- + newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
- + else
- + newChar.setXYZInvisible(Config.FACTION_CUSTOM_SPAWN_X, Config.FACTION_CUSTOM_SPAWN_Y, Config.FACTION_CUSTOM_SPAWN_Z);
- newChar.setTitle("");
- newChar.registerShortCut(new L2ShortCut(0,0,3,2,-1,1)); // attack shortcut
- Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 128)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
- @@ -1,4 +1,5 @@
- /*
- +/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- @@ -148,6 +149,39 @@
- sendPacket(new PledgeShowMemberListAll(activeChar.getClan(), activeChar));
- sendPacket(new PledgeStatusChanged(activeChar.getClan()));
- }
- +
- + if (Config.FACTION_ENGINE_ENABLED)
- + {
- + if (activeChar.getFactionId() == 1)
- + {
- + activeChar.getAppearance().setNameColor(Config.FACTION_TEAM1_COLOR);
- + activeChar.getAppearance().setTitleColor(Config.FACTION_TEAM1_COLOR);
- + activeChar.sendMessage("You are fighting for " + Config.FACTION_TEAM1_NAME + " Faction");
- + }
- + else if (activeChar.getFactionId() == 2)
- + {
- + activeChar.getAppearance().setNameColor(Config.FACTION_TEAM2_COLOR);
- + activeChar.getAppearance().setTitleColor(Config.FACTION_TEAM2_COLOR);
- + activeChar.sendMessage("You are fighting for " + Config.FACTION_TEAM2_NAME + " Faction");
- + }
- + else if (activeChar.getFactionId() == 3)
- + {
- + activeChar.getAppearance().setNameColor(Config.FACTION_TEAM3_COLOR);
- + activeChar.getAppearance().setTitleColor(Config.FACTION_TEAM3_COLOR);
- + activeChar.sendMessage("You are fighting for " + Config.FACTION_TEAM3_NAME + " Faction");
- + }
- +
- + activeChar.setIP((activeChar.getClient().getConnection().getInetAddress().getHostAddress()).toString());
- + if (Config.ENABLE_ONLINE_PLAYERS_ON_ENTERWORLD)
- + {
- + activeChar.sendMessage("--------------------------------------------------------------");
- + activeChar.sendMessage(Config.FACTION_TEAM1_NAME + ": " + L2World.getInstance().getAllteam1Players().size());
- + activeChar.sendMessage(Config.FACTION_TEAM2_NAME + ": " + L2World.getInstance().getAllteam2Players().size());
- + activeChar.sendMessage(Config.FACTION_TEAM3_NAME + ": " + L2World.getInstance().getAllteam3Players().size());
- + activeChar.sendMessage("Total: " + L2World.getInstance().getAllPlayersCount() + " online.");
- + activeChar.sendMessage("--------------------------------------------------------------");
- + }
- + }
- // Updating Seal of Strife Buff/Debuff
- if (SevenSigns.getInstance().isSealValidationPeriod() && SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) != SevenSigns.CABAL_NULL)
- @@ -182,7 +216,8 @@
- // Announcements, welcome & Seven signs period messages
- sendPacket(new SystemMessage(SystemMessageId.WELCOME_TO_LINEAGE));
- - SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
- + if (!Config.FACTION_ENGINE_ENABLED)
- + SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
- Announcements.getInstance().showAnnouncements(activeChar);
- // if player is DE, add shadow sense skill at night
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java (revision 128)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java (working copy)
- @@ -169,6 +169,23 @@
- return;
- }
- + boolean cond = true;
- + L2PcInstance player = null;
- + if (target instanceof L2PcInstance)
- + player = (L2PcInstance) target;
- + else if (target instanceof L2SummonInstance)
- + player = ((L2SummonInstance) target).getOwner();
- + if (player != null && Config.FACTION_ENGINE_ENABLED)
- + {
- + if (activeChar.getFactionId() == player.getFactionId())
- + cond = false;
- + if (activeChar.getFactionId() == 0 || player.getFactionId() == 0)
- + cond = false;
- + //pataisyti del peace zonos
- + }
- + if (!cond)
- + return;
- +
- pet.setTarget(target);
- if (target.isAutoAttackable(activeChar) || _ctrlPressed)
- {
- @@ -386,6 +403,31 @@
- return;
- }
- + boolean cond = true;
- + L2PcInstance player = null;
- + if (target instanceof L2PcInstance)
- + player = (L2PcInstance) target;
- + else if (target instanceof L2SummonInstance)
- + player = ((L2SummonInstance) target).getOwner();
- + if (player != null && Config.FACTION_ENGINE_ENABLED)
- + {
- + if (activeChar.getFactionId() == player.getFactionId())
- + {
- + activeChar.sendMessage("RequestActionUse 516 line: target faction = player");
- + cond = false;
- + }
- + if (activeChar.getFactionId() == 0 || player.getFactionId() == 0)
- + {
- + activeChar.sendMessage("RequestActionUse 521 line: target faction = 0 or player faction = 0");
- + cond = false;
- + }
- + }
- + if (!cond)
- + {
- + activeChar.sendMessage("RequestActionUse line 527 cond = false");
- + return;
- + }
- +
- L2Summon activeSummon = activeChar.getPet();
- if (activeSummon != null && !activeSummon.isBetrayed())
- {
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 128)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
- @@ -80,6 +80,18 @@
- return;
- }
- + if (requestor.getFactionId() != target.getFactionId() && Config.FACTION_ENGINE_ENABLED)
- + {
- + requestor.sendMessage("You cannot invite players from another faction.");
- + return;
- + }
- +
- + if (requestor.getFactionId() == 0 || target.getFactionId() == 0 && Config.FACTION_ENGINE_ENABLED)
- + {
- + requestor.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
- + return;
- + }
- +
- if (target.isInParty())
- {
- SystemMessage msg = new SystemMessage(SystemMessageId.S1_IS_ALREADY_IN_PARTY).addPcName(target);
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (revision 128)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
- @@ -30,6 +30,8 @@
- import net.sf.l2j.gameserver.model.entity.Castle;
- import net.sf.l2j.gameserver.model.entity.ClanHall;
- +import net.sf.l2j.Config;
- +
- public final class RequestRestartPoint extends L2GameClientPacket
- {
- private static final String C_6d_REQUESTRESTARTPOINT = "[C] 6d RequestRestartPoint";
- @@ -63,6 +65,8 @@
- _requestedPointType = 27;
- else if (activeChar.isFestivalParticipant())
- _requestedPointType = 4;
- + else if (activeChar.getFactionId() >= 0)
- + _requestedPointType = 99;
- switch (_requestedPointType)
- {
- @@ -137,6 +141,19 @@
- return;
- loc = new Location(-114356, -249645, -2984);
- break;
- +
- + case 99: //faction base
- + if (activeChar.isGM())
- + loc = new Location(activeChar.getX(), activeChar.getY(), activeChar.getZ());
- + else if (activeChar.getFactionId() == 1)
- + loc = new Location(Config.FACTION_TEAM1_BASE_X, Config.FACTION_TEAM1_BASE_Y, Config.FACTION_TEAM1_BASE_Z);
- + else if (activeChar.getFactionId() == 2)
- + loc = new Location(Config.FACTION_TEAM2_BASE_X, Config.FACTION_TEAM2_BASE_Y, Config.FACTION_TEAM2_BASE_Z);
- + else if (activeChar.getFactionId() == 3)
- + loc = new Location(Config.FACTION_TEAM3_BASE_X, Config.FACTION_TEAM3_BASE_Y, Config.FACTION_TEAM3_BASE_Z);
- + else
- + loc = new Location(Config.FACTION_CUSTOM_SPAWN_X, Config.FACTION_CUSTOM_SPAWN_Y, Config.FACTION_CUSTOM_SPAWN_Z);
- + break;
- default:
- loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Town);
- Index: java/net/sf/l2j/gameserver/util/Broadcast.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/util/Broadcast.java (revision 128)
- +++ java/net/sf/l2j/gameserver/util/Broadcast.java (working copy)
- @@ -197,6 +197,38 @@
- onlinePlayer.sendPacket(mov);
- }
- + public static void sendMessToAllFactionPlayers(String text)
- + {
- + Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
- + for (L2PcInstance onlinePlayer : pls)
- + if (onlinePlayer.isOnline() == true)
- + onlinePlayer.sendMessage(text);
- + }
- +
- + public static void sendMessToAllTeam1Players(String text)
- + {
- + Collection<L2PcInstance> pls = L2World.getInstance().getAllTeam1().values();
- + for (L2PcInstance onlinePlayer : pls)
- + if (onlinePlayer.isOnline() == true)
- + onlinePlayer.sendMessage(text);
- + }
- +
- + public static void sendMessToAllTeam2Players(String text)
- + {
- + Collection<L2PcInstance> pls = L2World.getInstance().getAllTeam2().values();
- + for (L2PcInstance onlinePlayer : pls)
- + if (onlinePlayer.isOnline() == true)
- + onlinePlayer.sendMessage(text);
- + }
- +
- + public static void sendMessToAllTeam3Players(String text)
- + {
- + Collection<L2PcInstance> pls = L2World.getInstance().getAllTeam3().values();
- + for (L2PcInstance onlinePlayer : pls)
- + if (onlinePlayer.isOnline() == true)
- + onlinePlayer.sendMessage(text);
- + }
- +
- public static void announceToOnlinePlayers(String text)
- {
- CreatureSay cs = new CreatureSay(0, Say2.ANNOUNCEMENT, "", text);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement