Рейтинг темы:
  • 0 Голос(ов) - 0 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
GvE
#1
Добрый вечер уважаемые пользователи. Вписал код для Войны между фракциями (Добро и Зло) У каждой команды своя подсветка (Синяя/Красная, как на ТВТ евенте) Все работает. Как мне убрать подсветку у 2-ух фракций что за это отвечает. Исходники L2jServer client-Gracia Final. Вот diff:

[SPOILER="faction core diff"]### Eclipse Workspace Patch 1.0
#P Faction patch test
Index: java/net/sf/l2j/gameserver/model/CharEffectList.java
===================================================================
--- java/net/sf/l2j/gameserver/model/CharEffectList.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/CharEffectList.java (working copy)
@@ -365,7 +365,7 @@
// Exit them
for (L2Effect e : effects)
{
- if (e != null)
+ if (e != null && e.getSkill().isDebuff())
e.exit(true);
}
}
Index: java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (working copy)
@@ -80,7 +80,13 @@
player.sendMessage("You or your target cant request trade in Olympiad mode");
return;
}
-
+
+ if (partner.getFactionId() != player.getFactionId())
+ {
+ player.sendMessage("Trading between factions is forbidden");
+ return;
+ }
+
// Alt game - Karma punishment
if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TRADE && (player.getKarma() > 0 || partner.getKarma() > 0))
{
Index: java/net/sf/l2j/gameserver/util/Broadcast.java
===================================================================
--- java/net/sf/l2j/gameserver/util/Broadcast.java (revision 3695)
+++ java/net/sf/l2j/gameserver/util/Broadcast.java (working copy)
@@ -221,6 +221,15 @@
}
}

+ public static void sendMessToAllFactionPlayers(String text)
+ {
+
+ Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
+ for (L2PcInstance onlinePlayer : pls)
+ if (onlinePlayer.isOnline() == 1/* && onlinePlayer.inWorld() == 1*/)
+ onlinePlayer.sendMessage(text);
+ }
+
public static void announceToOnlinePlayers(String text)
{
CreatureSay cs = new CreatureSay(0, Say2.ANNOUNCEMENT, "", text);
Index: java/net/sf/l2j/gameserver/network/clientpackets/SendWareHouseDepositList.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/SendWareHouseDepositList.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/SendWareHouseDepositList.java (working copy)
@@ -116,7 +116,7 @@
return;

// Freight price from config or normal price per item slot (30)
- final long fee = _items.length * 30;
+ final long fee = 0;
long currentAdena = player.getAdena();
int slots = 0;

Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadGame.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/OlympiadGame.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadGame.java (working copy)
@@ -34,6 +34,7 @@
import net.sf.l2j.gameserver.model.actor.instance.L2CubicInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
+import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
import net.sf.l2j.gameserver.model.olympiad.Olympiad.COMP_TYPE;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.clientpackets.Say2;
@@ -47,6 +48,7 @@
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.templates.StatsSet;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
+import net.sf.l2j.gameserver.templates.item.L2Item;
import net.sf.l2j.util.L2FastList;

/**
@@ -391,12 +393,14 @@
{
_playerOne.sendPacket(new ExOlympiadMatchEnd());
_playerOne.teleToLocation(x1, y1, z1, true);
+ _playerOne.setTeam(_playerOne.getFactionId());
}

if (_playerTwo != null)
{
_playerTwo.sendPacket(new ExOlympiadMatchEnd());
_playerTwo.teleToLocation(x2, y2, z2, true);
+ _playerTwo.setTeam(_playerTwo.getFactionId());
}
}

Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelAnswerStart.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelAnswerStart.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelAnswerStart.java (working copy)
@@ -50,7 +50,10 @@

L2PcInstance requestor = player.getActiveRequester();
if (requestor == null) return;
-
+
+ if (player.getFactionId() != requestor.getFactionId())
+ return;
+
if (_response == 1)
{
SystemMessage msg1 = null, msg2 = null;
Index: java/net/sf/l2j/gameserver/model/L2Clan.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Clan.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/L2Clan.java (working copy)
@@ -1984,6 +1984,12 @@
activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
return false;
}
+ if (activeChar.getFactionId() != target.getFactionId())
+ {
+ activeChar.sendMessage("Negalima imti kitos fakcijos zaideju i clana");
+ activeChar.sendMessage("You cannot invite anoher faction players");
+ return false;
+ }
if (activeChar.getObjectId() == target.getObjectId())
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_INVITE_YOURSELF));
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
@@ -71,7 +71,13 @@
requestor.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
return;
}
-
+
+ if (requestor.getFactionId() != target.getFactionId())
+ {
+ requestor.sendMessage("You cannot invite players from another faction.");
+ return;
+ }
+
if (target.isInParty())
{
SystemMessage msg = new SystemMessage(SystemMessageId.C1_IS_ALREADY_IN_PARTY);
Index: java/net/sf/l2j/gameserver/model/L2Skill.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Skill.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/L2Skill.java (working copy)
@@ -2131,7 +2131,30 @@
{
if (targetPlayer == caster || targetPlayer == player)
return false;
-
+
+ boolean cond = true;
+ if (target instanceof L2PcInstance)
+ {
+ if (targetPlayer.getFactionId() == player.getFactionId())
+ cond = false;
+ if (targetPlayer.isInOlympiadMode() && player.isInOlympiadMode())
+ cond = true;
+ if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(targetPlayer.getObjectId()) && TvTEvent.isPlayerParticipant(player.getObjectId()))
+ cond = true;
+ }
+ else if (target instanceof L2SummonInstance)
+ {
+ L2PcInstance targetPlayerR = ((L2SummonInstance)target).getOwner();
+ if (targetPlayerR.getFactionId() == player.getFactionId())
+ cond = false;
+ if (targetPlayerR.isInOlympiadMode() && player.isInOlympiadMode())
+ cond = true;
+ if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(targetPlayerR.getObjectId()) && TvTEvent.isPlayerParticipant(player.getObjectId()))
+ cond = true;
+ }
+ if (!cond)
+ return false;
+
if (targetPlayer.inObserverMode())
return false;

Index: java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java (working copy)
@@ -867,8 +867,10 @@
Announcements.getInstance().announceToAll(sm);

Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
+ //currentTime.add(Calendar.MONTH, 1);
+ currentTime.add(Calendar.HOUR, 168);
+ //currentTime.set(Calendar.DAY_OF_MONTH, 1);
+ currentTime.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
currentTime.set(Calendar.AM_PM, Calendar.AM);
currentTime.set(Calendar.HOUR, 12);
currentTime.set(Calendar.MINUTE, 0);
Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
@@ -50,6 +50,7 @@
import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2ClassMasterInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.base.Experience;
import net.sf.l2j.gameserver.model.entity.ClanHall;
import net.sf.l2j.gameserver.model.entity.Couple;
import net.sf.l2j.gameserver.model.entity.Fort;
@@ -190,6 +191,8 @@
if (activeChar.getCurrentHp() < 0.5)
activeChar.setIsDead(true);

+ activeChar.setIP((activeChar.getClient().getConnection().getInetAddress().getHostAddress()).toString());
+
// Set Hero status if it applies
if (Hero.getInstance().getHeroes() != null && Hero.getInstance().getHeroes().containsKey(activeChar.getObjectId()))
activeChar.setHero(true);
@@ -361,7 +364,16 @@

SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
Announcements.getInstance().showAnnouncements(activeChar);
-
+
+ if (activeChar.getLevel() > 85)
+ activeChar.addExpAndSp(Experience.LEVEL[86] - activeChar.getExp(), 0);
+ activeChar.setTeam(activeChar.getFactionId());
+ if (activeChar.getFactionId() == 1)
+ activeChar.sendMessage("Now you are playing for Blue faction.");
+ else if (activeChar.getFactionId() == 2)
+ activeChar.sendMessage("Now you are playing for Red faction.");
+ activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
+
if (showClanNotice)
{
NpcHtmlMessage notice = new NpcHtmlMessage(1);
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,273 @@
+/*
+ * 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.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.network.clientpackets.Say2;
+import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
+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.gameserver.util.Broadcast;
+import net.sf.l2j.util.Rnd;
+
+/**
+ *
+ * @author Laikeriz
+ *
+ */
+
+public class L2FactionInstance extends L2NpcInstance
+{
+ public L2FactionInstance(int objectId, L2NpcTemplate template)
+ {
+ super(objectId, template);
+ }
+
+ private final static Logger _log = Logger.getLogger(L2FactionInstance.class.getName());
+
+ @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;
+ String a = "";
+ CreatureSay cs;
+ if (player.getFactionId() != 0)
+ {
+ player.sendMessage("You have already chosen your faction faction");
+ player.sendMessage("Tu jau esi pasirinkes savo fakcija");
+ player.sendPacket(ActionFailed.STATIC_PACKET);
+ return;
+ }
+ else
+ {
+ int evilCount = L2World.getInstance().getAllevilPlayers().size();
+ int goodCount = L2World.getInstance().getAllgoodPlayers().size();
+ if (val == 1)
+ {
+ if (goodCount - evilCount > 3)
+ {
+ player.sendMessage("Too many players in this faction.");
+ player.sendMessage("Per daug zaideju sioje fakcijoje.");
+ return;
+ }
+ a="Blue";
+ L2World.getInstance().getAllGood().put(player.getName().toLowerCase(),player);
+ player.broadcastPacket(new MagicSkillUse(this, player, 4314, 1, 2000, 0));
+ cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "Welcome to Blue faction, " + player.getName() + "!");
+ }
+ else
+ {
+ if (evilCount - goodCount > 3)
+ {
+ player.sendMessage("Too many players in this faction.");
+ player.sendMessage("Per daug zaideju sioje fakcijoje.");
+ return;
+ }
+ a="Red";
+ L2World.getInstance().getAllEvil().put(player.getName().toLowerCase(),player);
+ player.broadcastPacket(new MagicSkillUse(this, player, 4316, 1, 2500, 0));
+ cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "Welcome to Red faction, " + player.getName() + "!");
+ }
+ 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.sendMessage("You have chosen " + a + " faction.");
+ Broadcast.toKnownPlayers(this, cs);
+ player.setFactionId(val);
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {public void run()
+ {
+ player.setTeam(player.getFactionId());
+ player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
+ }}, 5000);
+ player.broadcastUserInfo();
+ }
+ }
+/* else if (actualCommand.equalsIgnoreCase("chooseworld"))
+ {
+ CreatureSay cs;
+ final int[][] coords = {{185081,-12601,-5492},{185060,-9615,-5492},{115917,75345,-2599}};
+ if (val == 1)
+ {
+ if (player.inWorld() == 1)
+ {
+ player.sendMessage("You are already in Faction world.");
+ player.sendMessage("Tu jau esi Faction pasaulyje.");
+ return;
+ }
+ if (!player.getFloodProtectors().getFaction().tryPerformAction("change world"))
+ {
+ player.sendMessage("You can't change worlds so fast.");
+ player.sendMessage("Tu negali keisti pasauliu taip greitai.");
+ return;
+ }
+ if (player.getFactionId() == 1)
+ {
+ L2World.getInstance().getAllGood().put(player.getName().toLowerCase(),player);
+ player.broadcastPacket(new MagicSkillUse(this, player, 4314, 1, 2000, 0));
+ cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "Welcome to Blue faction, " + player.getName() + "!");
+ }
+ else
+ {
+ L2World.getInstance().getAllEvil().put(player.getName().toLowerCase(),player);
+ player.broadcastPacket(new MagicSkillUse(this, player, 4316, 1, 2500, 0));
+ cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "Welcome to Red faction, " + player.getName() + "!");
+ }
+ Broadcast.toKnownPlayers(this, cs);
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {public void run()
+ {
+ player.teleToLocation(coords[player.getFactionId()-1][0],coords[player.getFactionId()-1][1],coords[player.getFactionId()-1][2]);
+ player.setInWorld(1);
+ player.setTeam(player.getFactionId());
+ }}, 5000);
+ player.broadcastUserInfo();
+ }
+ else
+ {
+ if (player.inWorld() == 2)
+ {
+ player.sendMessage("You are already in PvP world.");
+ player.sendMessage("Tu jau esi PvP pasaulyje.");
+ return;
+ }
+ if (!player.getFloodProtectors().getFaction().tryPerformAction("change world"))
+ {
+ player.sendMessage("You can't change worlds so fast.");
+ player.sendMessage("Tu negali keisti pasauliu taip greitai.");
+ return;
+ }
+ if (player.getFactionId() == 1)
+ L2World.getInstance().getAllGood().remove(player.getName().toLowerCase());
+ else
+ L2World.getInstance().getAllEvil().remove(player.getName().toLowerCase());
+ cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "Welcome to PvP world, " + player.getName() + "!");
+ Broadcast.toKnownPlayers(this, cs);
+ player.broadcastPacket(new MagicSkillUse(player, 3157, 1, 0, 0));
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable(){public void run()
+ {
+ player.teleToLocation(coords[2][0],coords[2][1],coords[2][2]);
+ player.setTeam(0);
+ player.setInWorld(2);
+ }}, 5000);
+ if (player.getParty() != null)
+ player.leaveParty();
+ player.broadcastUserInfo();
+ }
+
+ Connection connection = null;
+ try
+ {
+ connection = L2DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = connection.prepareStatement("UPDATE characters SET faction=? 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){}}
+ }*/
+ 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);
+/* if (player.getFactionId() != 0)
+ html.setFile("data/html/mods/chooseworld.htm");
+ else*/
+ html.setFile("data/html/mods/AvD_faction.htm");
+ html.replace("%objectId%", String.valueOf(getObjectId()));
+ html.replace("%npcname%", getName());
+
+ player.sendPacket(html);
+ }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java (working copy)
@@ -34,6 +34,7 @@
import net.sf.l2j.gameserver.model.actor.instance.L2SiegeSummonInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2StaticObjectInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
+import net.sf.l2j.gameserver.model.entity.TvTEvent;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.ChairSit;
@@ -186,6 +187,24 @@
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)
+ {
+ if (activeChar.getFactionId() == player.getFactionId())
+ cond = false;
+ if (activeChar.isInOlympiadMode() && player.isInOlympiadMode())
+ cond = true;
+ if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(activeChar.getObjectId()) && TvTEvent.isPlayerParticipant(player.getObjectId()))
+ cond = true;
+ }
+ if (!cond)
+ return;
+
if (target.isAutoAttackable(activeChar) || _ctrlPressed)
{
if (target instanceof L2DoorInstance)
@@ -655,6 +674,24 @@
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)
+ {
+ if (activeChar.getFactionId() == player.getFactionId())
+ cond = false;
+ if (activeChar.isInOlympiadMode() && player.isInOlympiadMode())
+ cond = true;
+ if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(activeChar.getObjectId()) && TvTEvent.isPlayerParticipant(player.getObjectId()))
+ cond = true;
+ }
+ if (!cond)
+ return;
+
if (activeSummon != null && !activeSummon.isBetrayed())
{
if (activeSummon instanceof L2PetInstance && (activeSummon.getLevel() - activeChar.getLevel() > 20))
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,165 @@
+/*
+ * 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 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.gameserver.util.StringUtil;
+import net.sf.l2j.util.Rnd;
+
+/**
+ *
+ * @author Laikeriz
+ *
+ */
+
+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> _tpBlueFlags = new FastSet<L2TpFlagInstance>();
+ public static FastSet<L2TpFlagInstance> _tpRedFlags = 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 crystal. It doesn't exist or it was occupied.");
+ plajer.sendMessage("Nepavyksta susisiekti su kristalu. Arba jis buvo uzgrobtas arba jis neegzistuoja.");
+ 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>");
+// + "<img src=\"L2UI_CH3.onscrmsg_pattern01_1\" width=300 height=32 align=left><br>"
+ if (FactionMaps.isVoting())
+ 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 crystals belonging to <font color=\"LEVEL\">%faction%</font> faction:<br>");
+ if (player.getFactionId() == 1)
+ for (L2TpFlagInstance unFlag : _tpBlueFlags)
+ {
+ 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 : _tpRedFlags)
+ {
+ 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("Crystals occupied by <font color=\"LEVEL\">%faction%</font> faction:<br>");
+ if (player.getFactionId() == 1)
+ for (L2TpFlagInstance unFlag : _tpBlueFlags)
+ {
+ 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 : _tpRedFlags)
+ {
+ 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("<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());
+ if (player.getFactionId() == 1)
+ html.replace("%faction%", "Blue");
+ else if (player.getFactionId() == 2)
+ html.replace("%faction%", "Red");
+ player.sendPacket(html);
+ }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java (working copy)
@@ -57,6 +57,12 @@
activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
return;
}
+
+ if (activeChar.getFactionId() != ((L2PcInstance) ob).getFactionId())
+ {
+ activeChar.sendMessage("You cannot invite clan from another faction yo alliance");
+ return;
+ }

if(activeChar.getClan() == null)
{
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java (working copy)
@@ -31,6 +31,7 @@
import net.sf.l2j.gameserver.model.L2Clan.SubPledge;
import net.sf.l2j.gameserver.model.base.ClassId;
import net.sf.l2j.gameserver.model.base.ClassType;
+import net.sf.l2j.gameserver.model.base.Experience;
import net.sf.l2j.gameserver.model.base.PlayerClass;
import net.sf.l2j.gameserver.model.base.Race;
import net.sf.l2j.gameserver.model.base.SubClass;
@@ -428,6 +429,7 @@
html.setFile("data/html/villagemaster/SubClass_AddOk.htm");

player.sendPacket(new SystemMessage(SystemMessageId.CLASS_TRANSFER)); // Transfer to new class.
+ player.addExpAndSp(Experience.LEVEL[86] - player.getExp(), 0);
}
else
{
Index: java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java (working copy)
@@ -192,7 +192,7 @@

newChar.addAdena("Init", Config.STARTING_ADENA, null, false);

- newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
+ newChar.setXYZInvisible(147308,142827,-15872);
newChar.setTitle("");

newChar.setVitalityPoints(PcStat.MAX_VITALITY_POINTS, 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,235 @@
+/*
+ * 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.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.gameserver.util.StringUtil;
+
+/**
+ * @author Laikeriz
+ */
+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._tpBlueFlags)
+ flag.deleteMe();
+ for (L2TpFlagInstance flag : L2FactTeleporterInstance._tpRedFlags)
+ flag.deleteMe();
+ L2FactTeleporterInstance._tpBlueFlags.clear();
+ L2FactTeleporterInstance._tpRedFlags.clear();
+ for (L2PcInstance plajer : L2World.getInstance().getAllPlayers().values())
+ {
+ plajer.teleToLocation(MapRegionTable.TeleportWhereType.Town);
+ plajer.setVotedForMap(false);
+ }
+ 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)
+ {
+ _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);
+ 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/actor/L2Character.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/L2Character.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/actor/L2Character.java (working copy)
@@ -67,10 +67,13 @@
import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2RiftInvaderInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.SkillDat;
+import net.sf.l2j.gameserver.model.actor.instance.L2TpFlagInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
import net.sf.l2j.gameserver.model.actor.knownlist.CharKnownList;
import net.sf.l2j.gameserver.model.actor.position.CharPosition;
import net.sf.l2j.gameserver.model.actor.stat.CharStat;
import net.sf.l2j.gameserver.model.actor.status.CharStatus;
+import net.sf.l2j.gameserver.model.entity.TvTEvent;
import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.network.SystemMessageId;
@@ -716,7 +719,31 @@

if (isAttackingDisabled())
return;
-
+
+ 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)
+ {
+ if (trgtF.getFactionId() == player.getFactionId())
+ cond = false;
+ if (trgtF.isInOlympiadMode() && player.isInOlympiadMode())
+ cond = true;
+ if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(trgtF.getObjectId()) && TvTEvent.isPlayerParticipant(player.getObjectId()))
+ cond = true;
+ }
+ if (!cond)
+ return;
+ }
+
if (this instanceof L2PcInstance)
{
if (((L2PcInstance)this).inObserverMode())
Index: java/net/sf/l2j/gameserver/model/L2World.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2World.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/L2World.java (working copy)
@@ -63,7 +63,9 @@

/** HashMap(String Player name, L2PcInstance) containing all the players in game */
private Map<String, L2PcInstance> _allPlayers;
-
+ private Map<String, L2PcInstance> _allgoodPlayers;
+ private Map<String, L2PcInstance> _allevilPlayers;
+
/** L2ObjectHashMap(L2Object) containing all visible objects */
private Map<Integer, L2Object> _allObjects;

@@ -81,6 +83,8 @@
_allPlayers = new FastMap<String, L2PcInstance>().setShared(true);
_petsInstance = new FastMap<Integer, L2PetInstance>().setShared(true);
_allObjects = new FastMap<Integer, L2Object>().setShared(true);
+ _allgoodPlayers = new FastMap<String, L2PcInstance>().setShared(true);
+ _allevilPlayers = new FastMap<String, L2PcInstance>().setShared(true);

initRegions();
}
@@ -224,6 +228,26 @@
return _allPlayers;
}

+ public Map<String, L2PcInstance> getAllGood()
+ {
+ return _allgoodPlayers;
+ }
+
+ public Map<String, L2PcInstance> getAllEvil()
+ {
+ return _allevilPlayers;
+ }
+
+ public Collection<L2PcInstance> getAllgoodPlayers()
+ {
+ return _allgoodPlayers.values();
+ }
+
+ public Collection<L2PcInstance> getAllevilPlayers()
+ {
+ return _allevilPlayers.values();
+ }
+
/**
* Return how many players are online.<BR><BR>
*
@@ -337,6 +361,10 @@
}
_allPlayers.put(player.getName().toLowerCase(), player);
}
+ if (player.getFactionId() == 1)
+ _allgoodPlayers.put(player.getName().toLowerCase(),player);
+ else if (player.getFactionId() == 2)
+ _allevilPlayers.put(player.getName().toLowerCase(),player);
}

if (!newRegion.isActive())
@@ -453,8 +481,14 @@
// 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)
+ _allgoodPlayers.remove(player.getName().toLowerCase());
+ else if (player.getFactionId() == 2)
+ _allevilPlayers.remove(player.getName().toLowerCase());

// If selected L2Object is a GM L2PcInstance, remove it from Set(L2PcInstance) _gmList of GmListTable
//if (((L2PcInstance)object).isGM())
Index: java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (working copy)
@@ -205,7 +205,11 @@

public int getTitleColor()
{
- return _titleColor;
+ if (_owner.getFactionId() == 1)
+ return 0xFF0000;
+ else if (_owner.getFactionId() == 2)
+ return 0x0000FF;
+ return _titleColor;
}

public void setTitleColor(int titleColor)
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -119,6 +119,7 @@
import net.sf.l2j.gameserver.model.actor.L2Playable;
import net.sf.l2j.gameserver.model.actor.L2Summon;
import net.sf.l2j.gameserver.model.actor.L2Trap;
+import net.sf.l2j.gameserver.model.actor.instance.L2FactTeleporterInstance;
import net.sf.l2j.gameserver.model.actor.appearance.PcAppearance;
import net.sf.l2j.gameserver.model.actor.knownlist.PcKnownList;
import net.sf.l2j.gameserver.model.actor.position.PcPosition;
@@ -165,6 +166,7 @@
import net.sf.l2j.gameserver.network.serverpackets.ExOlympiadUserInfo;
import net.sf.l2j.gameserver.network.serverpackets.ExPrivateStoreSetWholeMsg;
import net.sf.l2j.gameserver.network.serverpackets.ExSetCompassZoneCode;
+import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.network.serverpackets.ExSpawnEmitter;
import net.sf.l2j.gameserver.network.serverpackets.ExStorageMaxCount;
import net.sf.l2j.gameserver.network.serverpackets.ExVitalityPointInfo;
@@ -229,6 +231,7 @@
import net.sf.l2j.gameserver.templates.skills.L2SkillType;
import net.sf.l2j.gameserver.util.FloodProtectors;
import net.sf.l2j.gameserver.util.Util;
+import net.sf.l2j.gameserver.util.Broadcast;
import net.sf.l2j.util.Point3D;
import net.sf.l2j.util.Rnd;

@@ -254,8 +257,8 @@

// Character Character SQL String Definitions:
private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,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=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,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=?,bookmarkslot=?,vitality_points=? WHERE charId=?";
- private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, 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,bookmarkslot,vitality_points FROM characters WHERE charId=?";
+ private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,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=?,bookmarkslot=?,vitality_points=?,factionId=? WHERE charId=?";
+ private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, 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,bookmarkslot,vitality_points,factionId FROM characters WHERE charId=?";

// Character Teleport Bookmark:
private static final String INSERT_TP_BOOKMARK = "INSERT INTO character_tpbookmark (charId,Id,x,y,z,icon,tag,name) values (?,?,?,?,?,?,?,?)";
@@ -393,7 +396,9 @@

/** The PK counter of the L2PcInstance (= Number of non PvP Flagged player killed) */
private int _pkKills;
-
+
+ private int uberKills=0;
+
/** The PvP Flag state of the L2PcInstance (0=White, 1=Purple) */
private byte _pvpFlag;

@@ -509,7 +514,22 @@
private int _obsY;
private int _obsZ;
private boolean _observerMode = false;
+
+ public boolean _votedForMap = false;
+ public void setVotedForMap(boolean a)
+ {
+ _votedForMap = a;
+ }

+ 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);

@@ -555,7 +575,14 @@

/** 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>();

@@ -667,7 +694,22 @@
// protects a char from agro mobs when getting up from fake death
private long _recentFakeDeathEndTime = 0;
private boolean _isFakeDeath;
-
+
+ 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 equiped) */
private L2Weapon _fistsWeaponItem;

@@ -684,7 +726,20 @@
private L2ItemInstance _activeEnchantSupportItem = null;
private L2ItemInstance _activeEnchantAttrItem = null;
private long _activeEnchantTimestamp = 0;
-
+
+ public boolean checkPvpCond(L2Character target)
+ {
+ L2PcInstance target1 = (L2PcInstance)target;
+ if (target1.IP.equals(IP))
+ return false;
+ if((getClanId() > 0 && target1.getClanId() > 0 && getClanId() == target1.getClanId()) || (getAllyId() > 0 && target1.getAllyId() > 0 && getAllyId() == target1.getAllyId()))
+ return false;
+ if(target.getStat().getPDef(target) < 300)
+ return false;
+
+ return true;
+ }
+
protected boolean _inventoryDisable = false;

protected Map<Integer, L2CubicInstance> _cubics = new FastMap<Integer, L2CubicInstance>().setShared(true);
@@ -1815,7 +1870,7 @@
@Override
public void updatePvPFlag(int value)
{
- if (getPvpFlag() == value)
+ /* if (getPvpFlag() == value)
return;
setPvpFlag(value);

@@ -1834,7 +1889,7 @@
if (getPet() != null)
target.sendPacket(new RelationChanged(getPet(), getRelation(this), isAutoAttackable(target)));
}
- }
+ }*/
}

@Override
@@ -5413,6 +5468,8 @@

setPvpFlag(0); // Clear the pvp flag

+ uberKills=0;
+
// Unsummon Cubics
if (!_cubics.isEmpty())
{
@@ -5572,87 +5629,9 @@

if (targetPlayer == null) return; // Target player is null
if (targetPlayer == this) return; // Target player is self
-
- if (isCursedWeaponEquipped())
- {
- CursedWeaponsManager.getInstance().increaseKills(_cursedWeaponEquippedId);
- // Custom message for time left
- // CursedWeapon cw = CursedWeaponsManager.getInstance().getCursedWeapon(_cursedWeaponEquipedId);
- // SystemMessage msg = new SystemMessage(SystemMessageId.THERE_IS_S1_HOUR_AND_S2_MINUTE_LEFT_OF_THE_FIXED_USAGE_TIME);
- // int timeLeftInHours = (int)(((cw.getTimeLeft()/60000)/60));
- // msg.addItemName(_cursedWeaponEquipedId);
- // msg.addNumber(timeLeftInHours);
- // sendPacket(msg);
- return;
- }
-
- // If in duel and you kill (only can kill l2summon), do nothing
- if (isInDuel() && targetPlayer.isInDuel()) return;
-
- // If in Arena, do nothing
- if (isInsideZone(ZONE_PVP) || targetPlayer.isInsideZone(ZONE_PVP))
- return;
-
- // Check if it's pvp
- if (
- (
- checkIfPvP(target) && // Can pvp and
- targetPlayer.getPvpFlag() != 0 // Target player has pvp flag set
- ) || // or
- (
- isInsideZone(ZONE_PVP) && // Player is inside pvp zone and
- targetPlayer.isInsideZone(ZONE_PVP) // Target player is inside pvp zone
- )
- )
- {
- if (target instanceof L2PcInstance)
- increasePvpKills();
- }
- else
- // Target player doesn't have pvp flag set
- {
- // 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'
- if (target instanceof L2PcInstance)
- increasePvpKills();
- return;
- }
-
- // 'No war' or 'One way war' -> 'Normal PK'
- if (targetPlayer.getKarma() > 0) // Target player has karma
- {
- if ( Config.KARMA_AWARD_PK_KILL )
- {
- if (target instanceof L2PcInstance)
- increasePvpKills();
- }
- }
- else if (targetPlayer.getPvpFlag() == 0) // Target player doesn't have karma
- {
- increasePkKillsAndKarma(targetPlayer.getLevel(), target instanceof L2PcInstance);
- //Unequip adventurer items
- if(getInventory().getPaperdollItemId(7) >= 7816 && getInventory().getPaperdollItemId(7) <= 7831)
- {
- L2ItemInstance invItem = getInventory().getItemByItemId(getInventory().getPaperdollItemId(7));
- if(invItem.isEquipped())
- {
- L2ItemInstance[] unequiped = getInventory().unEquipItemInSlotAndRecord(invItem.getLocationSlot());
- InventoryUpdate iu = new InventoryUpdate();
- for(L2ItemInstance itm: unequiped)
- iu.addModifiedItem(itm);
- sendPacket(iu);
- }
- refreshExpertisePenalty();
- sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_UNABLE_TO_EQUIP_THIS_ITEM_WHEN_YOUR_PK_COUNT_IS_GREATER_THAN_OR_EQUAL_TO_ONE));
- }
- }
- }
+
+ if(checkPvpCond(target) && (target instanceof L2PcInstance))
+ increasePvpKills();
}

/**
@@ -5661,9 +5640,46 @@
*/
public void increasePvpKills()
{
- // Add karma to attacker and increase its PK counter
+ uberKills++;
+ String text="";
+ int count = 1;
+ if (getFactionId() == 1)
+ count *= L2FactTeleporterInstance._tpBlueFlags.size();
+ else
+ count *= L2FactTeleporterInstance._tpRedFlags.size();
+ L2ItemInstance item = ItemTable.getInstance().createDummyItem(57);
+ item.setCount(count);
+ if (getParty() != null)
+ getParty().distributeItem(this, item);
+ else
+ addItem("Faction", item, this, true);
+
+ if (uberKills >= 3)
+ {
+ switch (uberKills)
+ {
+ case 3:
+ text=getName() + " : Multi-Kill!";
+ break;
+ case 6:
+ text=getName() + " : Dominating!";
+ break;
+ case 9:
+ text=getName() + " : Unstoppable!";
+ break;
+ case 12:
+ text=getName() + " : GOD LIKE!";
+ break;
+ }
+ ExShowScreenMessage exshowscrn = new ExShowScreenMessage(text,4500);
+ setPkKills(getPkKills() + 1);
+ Broadcast.toAllOnlinePlayers(exshowscrn);
+ }
setPvpKills(getPvpKills() + 1);
-
+
+ sendPacket(new UserInfo(this));
+ sendPacket(new ExBrExtraUserInfo(this));
+
// Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
sendPacket(new UserInfo(this));
sendPacket(new ExBrExtraUserInfo(this));
@@ -5677,6 +5693,7 @@
*/
public void increasePkKillsAndKarma(int targLVL, boolean increasePk)
{
+ increasePvpKills();/*
int baseKarma = Config.KARMA_MIN_KARMA;
int newKarma = baseKarma;
int karmaLimit = Config.KARMA_MAX_KARMA;
@@ -5720,7 +5737,7 @@

// Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
sendPacket(new UserInfo(this));
- sendPacket(new ExBrExtraUserInfo(this));
+ sendPacket(new ExBrExtraUserInfo(this));*/
}

public int calculateKarmaLost(long exp)
@@ -5758,7 +5775,7 @@

public void updatePvPStatus(L2Character target)
{
- L2PcInstance player_target = target.getActingPlayer();
+ /*L2PcInstance player_target = target.getActingPlayer();

if (player_target == null)
return;
@@ -5772,7 +5789,7 @@
setPvpFlagLasts(System.currentTimeMillis() + Config.PVP_NORMAL_TIME);
if (getPvpFlag() == 0)
startPvPFlag();
- }
+ }*/
}

/**
@@ -7140,7 +7157,9 @@
player.setOnlineTime(rset.getLong("onlinetime"));
player.setNewbie(rset.getInt("newbie"));
player.setNoble(rset.getInt("nobless")==1);
-
+
+ player.setFactionId(rset.getInt("factionId"));
+
player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
{
@@ -7581,7 +7600,8 @@
statement.setLong(51, getDeathPenaltyBuffLevel());
statement.setInt(52, getBookMarkSlot());
statement.setInt(53, getVitalityPoints());
- statement.setInt(54, getObjectId());
+ statement.setInt(54, getFactionId());
+ statement.setInt(55, getObjectId());

statement.execute();
statement.close();
@@ -8399,7 +8419,17 @@
// 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)...
Ответ
#2

Смотрите что отсылается в пакетах CharInfo & UserInfo.
m0nster.art - clear client patches, linkz to utils & code.
Гадаю по капче.
Ответ
#3
Нафиг там вообще оформление диффки? Глазами это читать - с ума сойти.
Проще было бы выложить дифф-файл, а кто захочет помочь - клипсой загрузит его и поглядит.

А вообще, красная и синяя подсветки задаются player.setTeam(1) и player.setTeam(2) (или наоборот, не помню уже). Ищи, где задается тима и убирай.
Johnson получился в результате деления на null. Помогаю с джавой только за булочки с маком.
Ответ
#4
[quote=Phantomas]Добрый вечер уважаемые пользователи. Вписал код для Войны между фракциями (Добро и Зло) У каждой команды своя подсветка (Синяя/Красная, как на ТВТ евенте) Все работает. Как мне убрать подсветку у 2-ух фракций что за это отвечает. Исходники L2jServer client-Gracia Final. Вот diff:

[SPOILER="faction core diff"]### Eclipse Workspace Patch 1.0
#P Faction patch test
Index: java/net/sf/l2j/gameserver/model/CharEffectList.java
===================================================================
--- java/net/sf/l2j/gameserver/model/CharEffectList.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/CharEffectList.java (working copy)
@@ -365,7 +365,7 @@
// Exit them
for (L2Effect e : effects)
{
- if (e != null)
+ if (e != null && e.getSkill().isDebuff())
e.exit(true);
}
}
Index: java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/TradeRequest.java (working copy)
@@ -80,7 +80,13 @@
player.sendMessage("You or your target cant request trade in Olympiad mode");
return;
}
-
+
+ if (partner.getFactionId() != player.getFactionId())
+ {
+ player.sendMessage("Trading between factions is forbidden");
+ return;
+ }
+
// Alt game - Karma punishment
if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TRADE && (player.getKarma() > 0 || partner.getKarma() > 0))
{
Index: java/net/sf/l2j/gameserver/util/Broadcast.java
===================================================================
--- java/net/sf/l2j/gameserver/util/Broadcast.java (revision 3695)
+++ java/net/sf/l2j/gameserver/util/Broadcast.java (working copy)
@@ -221,6 +221,15 @@
}
}

+ public static void sendMessToAllFactionPlayers(String text)
+ {
+
+ Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
+ for (L2PcInstance onlinePlayer : pls)
+ if (onlinePlayer.isOnline() == 1/* && onlinePlayer.inWorld() == 1*/)
+ onlinePlayer.sendMessage(text);
+ }
+
public static void announceToOnlinePlayers(String text)
{
CreatureSay cs = new CreatureSay(0, Say2.ANNOUNCEMENT, "", text);
Index: java/net/sf/l2j/gameserver/network/clientpackets/SendWareHouseDepositList.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/SendWareHouseDepositList.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/SendWareHouseDepositList.java (working copy)
@@ -116,7 +116,7 @@
return;

// Freight price from config or normal price per item slot (30)
- final long fee = _items.length * 30;
+ final long fee = 0;
long currentAdena = player.getAdena();
int slots = 0;

Index: java/net/sf/l2j/gameserver/model/olympiad/OlympiadGame.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/OlympiadGame.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/olympiad/OlympiadGame.java (working copy)
@@ -34,6 +34,7 @@
import net.sf.l2j.gameserver.model.actor.instance.L2CubicInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
+import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
import net.sf.l2j.gameserver.model.olympiad.Olympiad.COMP_TYPE;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.clientpackets.Say2;
@@ -47,6 +48,7 @@
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.templates.StatsSet;
import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
+import net.sf.l2j.gameserver.templates.item.L2Item;
import net.sf.l2j.util.L2FastList;

/**
@@ -391,12 +393,14 @@
{
_playerOne.sendPacket(new ExOlympiadMatchEnd());
_playerOne.teleToLocation(x1, y1, z1, true);
+ _playerOne.setTeam(_playerOne.getFactionId());
}

if (_playerTwo != null)
{
_playerTwo.sendPacket(new ExOlympiadMatchEnd());
_playerTwo.teleToLocation(x2, y2, z2, true);
+ _playerTwo.setTeam(_playerTwo.getFactionId());
}
}

Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelAnswerStart.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelAnswerStart.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestDuelAnswerStart.java (working copy)
@@ -50,7 +50,10 @@

L2PcInstance requestor = player.getActiveRequester();
if (requestor == null) return;
-
+
+ if (player.getFactionId() != requestor.getFactionId())
+ return;
+
if (_response == 1)
{
SystemMessage msg1 = null, msg2 = null;
Index: java/net/sf/l2j/gameserver/model/L2Clan.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Clan.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/L2Clan.java (working copy)
@@ -1984,6 +1984,12 @@
activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
return false;
}
+ if (activeChar.getFactionId() != target.getFactionId())
+ {
+ activeChar.sendMessage("Negalima imti kitos fakcijos zaideju i clana");
+ activeChar.sendMessage("You cannot invite anoher faction players");
+ return false;
+ }
if (activeChar.getObjectId() == target.getObjectId())
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_INVITE_YOURSELF));
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinParty.java (working copy)
@@ -71,7 +71,13 @@
requestor.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
return;
}
-
+
+ if (requestor.getFactionId() != target.getFactionId())
+ {
+ requestor.sendMessage("You cannot invite players from another faction.");
+ return;
+ }
+
if (target.isInParty())
{
SystemMessage msg = new SystemMessage(SystemMessageId.C1_IS_ALREADY_IN_PARTY);
Index: java/net/sf/l2j/gameserver/model/L2Skill.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2Skill.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/L2Skill.java (working copy)
@@ -2131,7 +2131,30 @@
{
if (targetPlayer == caster || targetPlayer == player)
return false;
-
+
+ boolean cond = true;
+ if (target instanceof L2PcInstance)
+ {
+ if (targetPlayer.getFactionId() == player.getFactionId())
+ cond = false;
+ if (targetPlayer.isInOlympiadMode() && player.isInOlympiadMode())
+ cond = true;
+ if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(targetPlayer.getObjectId()) && TvTEvent.isPlayerParticipant(player.getObjectId()))
+ cond = true;
+ }
+ else if (target instanceof L2SummonInstance)
+ {
+ L2PcInstance targetPlayerR = ((L2SummonInstance)target).getOwner();
+ if (targetPlayerR.getFactionId() == player.getFactionId())
+ cond = false;
+ if (targetPlayerR.isInOlympiadMode() && player.isInOlympiadMode())
+ cond = true;
+ if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(targetPlayerR.getObjectId()) && TvTEvent.isPlayerParticipant(player.getObjectId()))
+ cond = true;
+ }
+ if (!cond)
+ return false;
+
if (targetPlayer.inObserverMode())
return false;

Index: java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java
===================================================================
--- java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java (working copy)
@@ -867,8 +867,10 @@
Announcements.getInstance().announceToAll(sm);

Calendar currentTime = Calendar.getInstance();
- currentTime.add(Calendar.MONTH, 1);
- currentTime.set(Calendar.DAY_OF_MONTH, 1);
+ //currentTime.add(Calendar.MONTH, 1);
+ currentTime.add(Calendar.HOUR, 168);
+ //currentTime.set(Calendar.DAY_OF_MONTH, 1);
+ currentTime.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
currentTime.set(Calendar.AM_PM, Calendar.AM);
currentTime.set(Calendar.HOUR, 12);
currentTime.set(Calendar.MINUTE, 0);
Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
@@ -50,6 +50,7 @@
import net.sf.l2j.gameserver.model.actor.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2ClassMasterInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.base.Experience;
import net.sf.l2j.gameserver.model.entity.ClanHall;
import net.sf.l2j.gameserver.model.entity.Couple;
import net.sf.l2j.gameserver.model.entity.Fort;
@@ -190,6 +191,8 @@
if (activeChar.getCurrentHp() < 0.5)
activeChar.setIsDead(true);

+ activeChar.setIP((activeChar.getClient().getConnection().getInetAddress().getHostAddress()).toString());
+
// Set Hero status if it applies
if (Hero.getInstance().getHeroes() != null && Hero.getInstance().getHeroes().containsKey(activeChar.getObjectId()))
activeChar.setHero(true);
@@ -361,7 +364,16 @@

SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
Announcements.getInstance().showAnnouncements(activeChar);
-
+
+ if (activeChar.getLevel() > 85)
+ activeChar.addExpAndSp(Experience.LEVEL[86] - activeChar.getExp(), 0);
+ activeChar.setTeam(activeChar.getFactionId());
+ if (activeChar.getFactionId() == 1)
+ activeChar.sendMessage("Now you are playing for Blue faction.");
+ else if (activeChar.getFactionId() == 2)
+ activeChar.sendMessage("Now you are playing for Red faction.");
+ activeChar.teleToLocation(MapRegionTable.TeleportWhereType.Town);
+
if (showClanNotice)
{
NpcHtmlMessage notice = new NpcHtmlMessage(1);
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,273 @@
+/*
+ * 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.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.network.clientpackets.Say2;
+import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
+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.gameserver.util.Broadcast;
+import net.sf.l2j.util.Rnd;
+
+/**
+ *
+ * @author Laikeriz
+ *
+ */
+
+public class L2FactionInstance extends L2NpcInstance
+{
+ public L2FactionInstance(int objectId, L2NpcTemplate template)
+ {
+ super(objectId, template);
+ }
+
+ private final static Logger _log = Logger.getLogger(L2FactionInstance.class.getName());
+
+ @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;
+ String a = "";
+ CreatureSay cs;
+ if (player.getFactionId() != 0)
+ {
+ player.sendMessage("You have already chosen your faction faction");
+ player.sendMessage("Tu jau esi pasirinkes savo fakcija");
+ player.sendPacket(ActionFailed.STATIC_PACKET);
+ return;
+ }
+ else
+ {
+ int evilCount = L2World.getInstance().getAllevilPlayers().size();
+ int goodCount = L2World.getInstance().getAllgoodPlayers().size();
+ if (val == 1)
+ {
+ if (goodCount - evilCount > 3)
+ {
+ player.sendMessage("Too many players in this faction.");
+ player.sendMessage("Per daug zaideju sioje fakcijoje.");
+ return;
+ }
+ a="Blue";
+ L2World.getInstance().getAllGood().put(player.getName().toLowerCase(),player);
+ player.broadcastPacket(new MagicSkillUse(this, player, 4314, 1, 2000, 0));
+ cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "Welcome to Blue faction, " + player.getName() + "!");
+ }
+ else
+ {
+ if (evilCount - goodCount > 3)
+ {
+ player.sendMessage("Too many players in this faction.");
+ player.sendMessage("Per daug zaideju sioje fakcijoje.");
+ return;
+ }
+ a="Red";
+ L2World.getInstance().getAllEvil().put(player.getName().toLowerCase(),player);
+ player.broadcastPacket(new MagicSkillUse(this, player, 4316, 1, 2500, 0));
+ cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "Welcome to Red faction, " + player.getName() + "!");
+ }
+ 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.sendMessage("You have chosen " + a + " faction.");
+ Broadcast.toKnownPlayers(this, cs);
+ player.setFactionId(val);
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {public void run()
+ {
+ player.setTeam(player.getFactionId());
+ player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
+ }}, 5000);
+ player.broadcastUserInfo();
+ }
+ }
+/* else if (actualCommand.equalsIgnoreCase("chooseworld"))
+ {
+ CreatureSay cs;
+ final int[][] coords = {{185081,-12601,-5492},{185060,-9615,-5492},{115917,75345,-2599}};
+ if (val == 1)
+ {
+ if (player.inWorld() == 1)
+ {
+ player.sendMessage("You are already in Faction world.");
+ player.sendMessage("Tu jau esi Faction pasaulyje.");
+ return;
+ }
+ if (!player.getFloodProtectors().getFaction().tryPerformAction("change world"))
+ {
+ player.sendMessage("You can't change worlds so fast.");
+ player.sendMessage("Tu negali keisti pasauliu taip greitai.");
+ return;
+ }
+ if (player.getFactionId() == 1)
+ {
+ L2World.getInstance().getAllGood().put(player.getName().toLowerCase(),player);
+ player.broadcastPacket(new MagicSkillUse(this, player, 4314, 1, 2000, 0));
+ cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "Welcome to Blue faction, " + player.getName() + "!");
+ }
+ else
+ {
+ L2World.getInstance().getAllEvil().put(player.getName().toLowerCase(),player);
+ player.broadcastPacket(new MagicSkillUse(this, player, 4316, 1, 2500, 0));
+ cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "Welcome to Red faction, " + player.getName() + "!");
+ }
+ Broadcast.toKnownPlayers(this, cs);
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
+ {public void run()
+ {
+ player.teleToLocation(coords[player.getFactionId()-1][0],coords[player.getFactionId()-1][1],coords[player.getFactionId()-1][2]);
+ player.setInWorld(1);
+ player.setTeam(player.getFactionId());
+ }}, 5000);
+ player.broadcastUserInfo();
+ }
+ else
+ {
+ if (player.inWorld() == 2)
+ {
+ player.sendMessage("You are already in PvP world.");
+ player.sendMessage("Tu jau esi PvP pasaulyje.");
+ return;
+ }
+ if (!player.getFloodProtectors().getFaction().tryPerformAction("change world"))
+ {
+ player.sendMessage("You can't change worlds so fast.");
+ player.sendMessage("Tu negali keisti pasauliu taip greitai.");
+ return;
+ }
+ if (player.getFactionId() == 1)
+ L2World.getInstance().getAllGood().remove(player.getName().toLowerCase());
+ else
+ L2World.getInstance().getAllEvil().remove(player.getName().toLowerCase());
+ cs = new CreatureSay(getObjectId(), Say2.ALL, getName(), "Welcome to PvP world, " + player.getName() + "!");
+ Broadcast.toKnownPlayers(this, cs);
+ player.broadcastPacket(new MagicSkillUse(player, 3157, 1, 0, 0));
+ ThreadPoolManager.getInstance().scheduleGeneral(new Runnable(){public void run()
+ {
+ player.teleToLocation(coords[2][0],coords[2][1],coords[2][2]);
+ player.setTeam(0);
+ player.setInWorld(2);
+ }}, 5000);
+ if (player.getParty() != null)
+ player.leaveParty();
+ player.broadcastUserInfo();
+ }
+
+ Connection connection = null;
+ try
+ {
+ connection = L2DatabaseFactory.getInstance().getConnection();
+ PreparedStatement statement = connection.prepareStatement("UPDATE characters SET faction=? 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){}}
+ }*/
+ 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);
+/* if (player.getFactionId() != 0)
+ html.setFile("data/html/mods/chooseworld.htm");
+ else*/
+ html.setFile("data/html/mods/AvD_faction.htm");
+ html.replace("%objectId%", String.valueOf(getObjectId()));
+ html.replace("%npcname%", getName());
+
+ player.sendPacket(html);
+ }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestActionUse.java (working copy)
@@ -34,6 +34,7 @@
import net.sf.l2j.gameserver.model.actor.instance.L2SiegeSummonInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2StaticObjectInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
+import net.sf.l2j.gameserver.model.entity.TvTEvent;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.ChairSit;
@@ -186,6 +187,24 @@
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)
+ {
+ if (activeChar.getFactionId() == player.getFactionId())
+ cond = false;
+ if (activeChar.isInOlympiadMode() && player.isInOlympiadMode())
+ cond = true;
+ if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(activeChar.getObjectId()) && TvTEvent.isPlayerParticipant(player.getObjectId()))
+ cond = true;
+ }
+ if (!cond)
+ return;
+
if (target.isAutoAttackable(activeChar) || _ctrlPressed)
{
if (target instanceof L2DoorInstance)
@@ -655,6 +674,24 @@
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)
+ {
+ if (activeChar.getFactionId() == player.getFactionId())
+ cond = false;
+ if (activeChar.isInOlympiadMode() && player.isInOlympiadMode())
+ cond = true;
+ if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(activeChar.getObjectId()) && TvTEvent.isPlayerParticipant(player.getObjectId()))
+ cond = true;
+ }
+ if (!cond)
+ return;
+
if (activeSummon != null && !activeSummon.isBetrayed())
{
if (activeSummon instanceof L2PetInstance && (activeSummon.getLevel() - activeChar.getLevel() > 20))
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,165 @@
+/*
+ * 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 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.gameserver.util.StringUtil;
+import net.sf.l2j.util.Rnd;
+
+/**
+ *
+ * @author Laikeriz
+ *
+ */
+
+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> _tpBlueFlags = new FastSet<L2TpFlagInstance>();
+ public static FastSet<L2TpFlagInstance> _tpRedFlags = 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 crystal. It doesn't exist or it was occupied.");
+ plajer.sendMessage("Nepavyksta susisiekti su kristalu. Arba jis buvo uzgrobtas arba jis neegzistuoja.");
+ 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>");
+// + "<img src=\"L2UI_CH3.onscrmsg_pattern01_1\" width=300 height=32 align=left><br>"
+ if (FactionMaps.isVoting())
+ 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 crystals belonging to <font color=\"LEVEL\">%faction%</font> faction:<br>");
+ if (player.getFactionId() == 1)
+ for (L2TpFlagInstance unFlag : _tpBlueFlags)
+ {
+ 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 : _tpRedFlags)
+ {
+ 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("Crystals occupied by <font color=\"LEVEL\">%faction%</font> faction:<br>");
+ if (player.getFactionId() == 1)
+ for (L2TpFlagInstance unFlag : _tpBlueFlags)
+ {
+ 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 : _tpRedFlags)
+ {
+ 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("<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());
+ if (player.getFactionId() == 1)
+ html.replace("%faction%", "Blue");
+ else if (player.getFactionId() == 2)
+ html.replace("%faction%", "Red");
+ player.sendPacket(html);
+ }
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestJoinAlly.java (working copy)
@@ -57,6 +57,12 @@
activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_INVITED_THE_WRONG_TARGET));
return;
}
+
+ if (activeChar.getFactionId() != ((L2PcInstance) ob).getFactionId())
+ {
+ activeChar.sendMessage("You cannot invite clan from another faction yo alliance");
+ return;
+ }

if(activeChar.getClan() == null)
{
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2VillageMasterInstance.java (working copy)
@@ -31,6 +31,7 @@
import net.sf.l2j.gameserver.model.L2Clan.SubPledge;
import net.sf.l2j.gameserver.model.base.ClassId;
import net.sf.l2j.gameserver.model.base.ClassType;
+import net.sf.l2j.gameserver.model.base.Experience;
import net.sf.l2j.gameserver.model.base.PlayerClass;
import net.sf.l2j.gameserver.model.base.Race;
import net.sf.l2j.gameserver.model.base.SubClass;
@@ -428,6 +429,7 @@
html.setFile("data/html/villagemaster/SubClass_AddOk.htm");

player.sendPacket(new SystemMessage(SystemMessageId.CLASS_TRANSFER)); // Transfer to new class.
+ player.addExpAndSp(Experience.LEVEL[86] - player.getExp(), 0);
}
else
{
Index: java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java (revision 3695)
+++ java/net/sf/l2j/gameserver/network/clientpackets/CharacterCreate.java (working copy)
@@ -192,7 +192,7 @@

newChar.addAdena("Init", Config.STARTING_ADENA, null, false);

- newChar.setXYZInvisible(template.spawnX, template.spawnY, template.spawnZ);
+ newChar.setXYZInvisible(147308,142827,-15872);
newChar.setTitle("");

newChar.setVitalityPoints(PcStat.MAX_VITALITY_POINTS, 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,235 @@
+/*
+ * 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.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.gameserver.util.StringUtil;
+
+/**
+ * @author Laikeriz
+ */
+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._tpBlueFlags)
+ flag.deleteMe();
+ for (L2TpFlagInstance flag : L2FactTeleporterInstance._tpRedFlags)
+ flag.deleteMe();
+ L2FactTeleporterInstance._tpBlueFlags.clear();
+ L2FactTeleporterInstance._tpRedFlags.clear();
+ for (L2PcInstance plajer : L2World.getInstance().getAllPlayers().values())
+ {
+ plajer.teleToLocation(MapRegionTable.TeleportWhereType.Town);
+ plajer.setVotedForMap(false);
+ }
+ 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)
+ {
+ _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);
+ 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/actor/L2Character.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/L2Character.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/actor/L2Character.java (working copy)
@@ -67,10 +67,13 @@
import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2RiftInvaderInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance.SkillDat;
+import net.sf.l2j.gameserver.model.actor.instance.L2TpFlagInstance;
+import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;
import net.sf.l2j.gameserver.model.actor.knownlist.CharKnownList;
import net.sf.l2j.gameserver.model.actor.position.CharPosition;
import net.sf.l2j.gameserver.model.actor.stat.CharStat;
import net.sf.l2j.gameserver.model.actor.status.CharStatus;
+import net.sf.l2j.gameserver.model.entity.TvTEvent;
import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.network.SystemMessageId;
@@ -716,7 +719,31 @@

if (isAttackingDisabled())
return;
-
+
+ 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)
+ {
+ if (trgtF.getFactionId() == player.getFactionId())
+ cond = false;
+ if (trgtF.isInOlympiadMode() && player.isInOlympiadMode())
+ cond = true;
+ if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(trgtF.getObjectId()) && TvTEvent.isPlayerParticipant(player.getObjectId()))
+ cond = true;
+ }
+ if (!cond)
+ return;
+ }
+
if (this instanceof L2PcInstance)
{
if (((L2PcInstance)this).inObserverMode())
Index: java/net/sf/l2j/gameserver/model/L2World.java
===================================================================
--- java/net/sf/l2j/gameserver/model/L2World.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/L2World.java (working copy)
@@ -63,7 +63,9 @@

/** HashMap(String Player name, L2PcInstance) containing all the players in game */
private Map<String, L2PcInstance> _allPlayers;
-
+ private Map<String, L2PcInstance> _allgoodPlayers;
+ private Map<String, L2PcInstance> _allevilPlayers;
+
/** L2ObjectHashMap(L2Object) containing all visible objects */
private Map<Integer, L2Object> _allObjects;

@@ -81,6 +83,8 @@
_allPlayers = new FastMap<String, L2PcInstance>().setShared(true);
_petsInstance = new FastMap<Integer, L2PetInstance>().setShared(true);
_allObjects = new FastMap<Integer, L2Object>().setShared(true);
+ _allgoodPlayers = new FastMap<String, L2PcInstance>().setShared(true);
+ _allevilPlayers = new FastMap<String, L2PcInstance>().setShared(true);

initRegions();
}
@@ -224,6 +228,26 @@
return _allPlayers;
}

+ public Map<String, L2PcInstance> getAllGood()
+ {
+ return _allgoodPlayers;
+ }
+
+ public Map<String, L2PcInstance> getAllEvil()
+ {
+ return _allevilPlayers;
+ }
+
+ public Collection<L2PcInstance> getAllgoodPlayers()
+ {
+ return _allgoodPlayers.values();
+ }
+
+ public Collection<L2PcInstance> getAllevilPlayers()
+ {
+ return _allevilPlayers.values();
+ }
+
/**
* Return how many players are online.<BR><BR>
*
@@ -337,6 +361,10 @@
}
_allPlayers.put(player.getName().toLowerCase(), player);
}
+ if (player.getFactionId() == 1)
+ _allgoodPlayers.put(player.getName().toLowerCase(),player);
+ else if (player.getFactionId() == 2)
+ _allevilPlayers.put(player.getName().toLowerCase(),player);
}

if (!newRegion.isActive())
@@ -453,8 +481,14 @@
// 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)
+ _allgoodPlayers.remove(player.getName().toLowerCase());
+ else if (player.getFactionId() == 2)
+ _allevilPlayers.remove(player.getName().toLowerCase());

// If selected L2Object is a GM L2PcInstance, remove it from Set(L2PcInstance) _gmList of GmListTable
//if (((L2PcInstance)object).isGM())
Index: java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/actor/appearance/PcAppearance.java (working copy)
@@ -205,7 +205,11 @@

public int getTitleColor()
{
- return _titleColor;
+ if (_owner.getFactionId() == 1)
+ return 0xFF0000;
+ else if (_owner.getFactionId() == 2)
+ return 0x0000FF;
+ return _titleColor;
}

public void setTitleColor(int titleColor)
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 3695)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -119,6 +119,7 @@
import net.sf.l2j.gameserver.model.actor.L2Playable;
import net.sf.l2j.gameserver.model.actor.L2Summon;
import net.sf.l2j.gameserver.model.actor.L2Trap;
+import net.sf.l2j.gameserver.model.actor.instance.L2FactTeleporterInstance;
import net.sf.l2j.gameserver.model.actor.appearance.PcAppearance;
import net.sf.l2j.gameserver.model.actor.knownlist.PcKnownList;
import net.sf.l2j.gameserver.model.actor.position.PcPosition;
@@ -165,6 +166,7 @@
import net.sf.l2j.gameserver.network.serverpackets.ExOlympiadUserInfo;
import net.sf.l2j.gameserver.network.serverpackets.ExPrivateStoreSetWholeMsg;
import net.sf.l2j.gameserver.network.serverpackets.ExSetCompassZoneCode;
+import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.network.serverpackets.ExSpawnEmitter;
import net.sf.l2j.gameserver.network.serverpackets.ExStorageMaxCount;
import net.sf.l2j.gameserver.network.serverpackets.ExVitalityPointInfo;
@@ -229,6 +231,7 @@
import net.sf.l2j.gameserver.templates.skills.L2SkillType;
import net.sf.l2j.gameserver.util.FloodProtectors;
import net.sf.l2j.gameserver.util.Util;
+import net.sf.l2j.gameserver.util.Broadcast;
import net.sf.l2j.util.Point3D;
import net.sf.l2j.util.Rnd;

@@ -254,8 +257,8 @@

// Character Character SQL String Definitions:
private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,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=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,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=?,bookmarkslot=?,vitality_points=? WHERE charId=?";
- private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, 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,bookmarkslot,vitality_points FROM characters WHERE charId=?";
+ private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,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=?,bookmarkslot=?,vitality_points=?,factionId=? WHERE charId=?";
+ private static final String RESTORE_CHARACTER = "SELECT account_name, charId, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, fame, 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,bookmarkslot,vitality_points,factionId FROM characters WHERE charId=?";

// Character Teleport Bookmark:
private static final String INSERT_TP_BOOKMARK = "INSERT INTO character_tpbookmark (charId,Id,x,y,z,icon,tag,name) values (?,?,?,?,?,?,?,?)";
@@ -393,7 +396,9 @@

/** The PK counter of the L2PcInstance (= Number of non PvP Flagged player killed) */
private int _pkKills;
-
+
+ private int uberKills=0;
+
/** The PvP Flag state of the L2PcInstance (0=White, 1=Purple) */
private byte _pvpFlag;

@@ -509,7 +514,22 @@
private int _obsY;
private int _obsZ;
private boolean _observerMode = false;
+
+ public boolean _votedForMap = false;
+ public void setVotedForMap(boolean a)
+ {
+ _votedForMap = a;
+ }

+ 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);

@@ -555,7 +575,14 @@

/** 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>();

@@ -667,7 +694,22 @@
// protects a char from agro mobs when getting up from fake death
private long _recentFakeDeathEndTime = 0;
private boolean _isFakeDeath;
-
+
+ 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 equiped) */
private L2Weapon _fistsWeaponItem;

@@ -684,7 +726,20 @@
private L2ItemInstance _activeEnchantSupportItem = null;
private L2ItemInstance _activeEnchantAttrItem = null;
private long _activeEnchantTimestamp = 0;
-
+
+ public boolean checkPvpCond(L2Character target)
+ {
+ L2PcInstance target1 = (L2PcInstance)target;
+ if (target1.IP.equals(IP))
+ return false;
+ if((getClanId() > 0 && target1.getClanId() > 0 && getClanId() == target1.getClanId()) || (getAllyId() > 0 && target1.getAllyId() > 0 && getAllyId() == target1.getAllyId()))
+ return false;
+ if(target.getStat().getPDef(target) < 300)
+ return false;
+
+ return true;
+ }
+
protected boolean _inventoryDisable = false;

protected Map<Integer, L2CubicInstance> _cubics = new FastMap<Integer, L2CubicInstance>().setShared(true);
@@ -1815,7 +1870,7 @@
@Override
public void updatePvPFlag(int value)
{
- if (getPvpFlag() == value)
+ /* if (getPvpFlag() == value)
return;
setPvpFlag(value);

@@ -1834,7 +1889,7 @@
if (getPet() != null)
target.sendPacket(new RelationChanged(getPet(), getRelation(this), isAutoAttackable(target)));
}
- }
+ }*/
}

@Override
@@ -5413,6 +5468,8 @@

setPvpFlag(0); // Clear the pvp flag

+ uberKills=0;
+
// Unsummon Cubics
if (!_cubics.isEmpty())
{
@@ -5572,87 +5629,9 @@

if (targetPlayer == null) return; // Target player is null
if (targetPlayer == this) return; // Target player is self
-
- if (isCursedWeaponEquipped())
- {
- CursedWeaponsManager.getInstance().increaseKills(_cursedWeaponEquippedId);
- // Custom message for time left
- // CursedWeapon cw = CursedWeaponsManager.getInstance().getCursedWeapon(_cursedWeaponEquipedId);
- // SystemMessage msg = new SystemMessage(SystemMessageId.THERE_IS_S1_HOUR_AND_S2_MINUTE_LEFT_OF_THE_FIXED_USAGE_TIME);
- // int timeLeftInHours = (int)(((cw.getTimeLeft()/60000)/60));
- // msg.addItemName(_cursedWeaponEquipedId);
- // msg.addNumber(timeLeftInHours);
- // sendPacket(msg);
- return;
- }
-
- // If in duel and you kill (only can kill l2summon), do nothing
- if (isInDuel() && targetPlayer.isInDuel()) return;
-
- // If in Arena, do nothing
- if (isInsideZone(ZONE_PVP) || targetPlayer.isInsideZone(ZONE_PVP))
- return;
-
- // Check if it's pvp
- if (
- (
- checkIfPvP(target) && // Can pvp and
- targetPlayer.getPvpFlag() != 0 // Target player has pvp flag set
- ) || // or
- (
- isInsideZone(ZONE_PVP) && // Player is inside pvp zone and
- targetPlayer.isInsideZone(ZONE_PVP) // Target player is inside pvp zone
- )
- )
- {
- if (target instanceof L2PcInstance)
- increasePvpKills();
- }
- else
- // Target player doesn't have pvp flag set
- {
- // 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'
- if (target instanceof L2PcInstance)
- increasePvpKills();
- return;
- }
-
- // 'No war' or 'One way war' -> 'Normal PK'
- if (targetPlayer.getKarma() > 0) // Target player has karma
- {
- if ( Config.KARMA_AWARD_PK_KILL )
- {
- if (target instanceof L2PcInstance)
- increasePvpKills();
- }
- }
- else if (targetPlayer.getPvpFlag() == 0) // Target player doesn't have karma
- {
- increasePkKillsAndKarma(targetPlayer.getLevel(), target instanceof L2PcInstance);
- //Unequip adventurer items
- if(getInventory().getPaperdollItemId(7) >= 7816 && getInventory().getPaperdollItemId(7) <= 7831)
- {
- L2ItemInstance invItem = getInventory().getItemByItemId(getInventory().getPaperdollItemId(7));
- if(invItem.isEquipped())
- {
- L2ItemInstance[] unequiped = getInventory().unEquipItemInSlotAndRecord(invItem.getLocationSlot());
- InventoryUpdate iu = new InventoryUpdate();
- for(L2ItemInstance itm: unequiped)
- iu.addModifiedItem(itm);
- sendPacket(iu);
- }
- refreshExpertisePenalty();
- sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_UNABLE_TO_EQUIP_THIS_ITEM_WHEN_YOUR_PK_COUNT_IS_GREATER_THAN_OR_EQUAL_TO_ONE));
- }
- }
- }
+
+ if(checkPvpCond(target) && (target instanceof L2PcInstance))
+ increasePvpKills();
}

/**
@@ -5661,9 +5640,46 @@
*/
public void increasePvpKills()
{
- // Add karma to attacker and increase its PK counter
+ uberKills++;
+ String text="";
+ int count = 1;
+ if (getFactionId() == 1)
+ count *= L2FactTeleporterInstance._tpBlueFlags.size();
+ else
+ count *= L2FactTeleporterInstance._tpRedFlags.size();
+ L2ItemInstance item = ItemTable.getInstance().createDummyItem(57);
+ item.setCount(count);
+ if (getParty() != null)
+ getParty().distributeItem(this, item);
+ else
+ addItem("Faction", item, this, true);
+
+ if (uberKills >= 3)
+ {
+ switch (uberKills)
+ {
+ case 3:
+ text=getName() + " : Multi-Kill!";
+ break;
+ case 6:
+ text=getName() + " : Dominating!";
+ break;
+ case 9:
+ text=getName() + " : Unstoppable!";
+ break;
+ case 12:
+ text=getName() + " : GOD LIKE!";
+ break;
+ }
+ ExShowScreenMessage exshowscrn = new ExShowScreenMessage(text,4500);
+ setPkKills(getPkKills() + 1);
+ Broadcast.toAllOnlinePlayers(exshowscrn);
+ }
setPvpKills(getPvpKills() + 1);
-
+
+ sendPacket(new UserInfo(this));
+ sendPacket(new ExBrExtraUserInfo(this));
+
// Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
sendPacket(new UserInfo(this));
sendPacket(new ExBrExtraUserInfo(this));
@@ -5677,6 +5693,7 @@
*/
public void increasePkKillsAndKarma(int targLVL, boolean increasePk)
{
+ increasePvpKills();/*
int baseKarma = Config.KARMA_MIN_KARMA;
int newKarma = baseKarma;
int karmaLimit = Config.KARMA_MAX_KARMA;
@@ -5720,7 +5737,7 @@

// Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
sendPacket(new UserInfo(this));
- sendPacket(new ExBrExtraUserInfo(this));
+ sendPacket(new ExBrExtraUserInfo(this));*/
}

public int calculateKarmaLost(long exp)
@@ -5758,7 +5775,7 @@

public void updatePvPStatus(L2Character target)
{
- L2PcInstance player_target = target.getActingPlayer();
+ /*L2PcInstance player_target = target.getActingPlayer();

if (player_target == null)
return;
@@ -5772,7 +5789,7 @@
setPvpFlagLasts(System.currentTimeMillis() + Config.PVP_NORMAL_TIME);
if (getPvpFlag() == 0)
startPvPFlag();
- }
+ }*/
}

/**
@@ -7140,7 +7157,9 @@
player.setOnlineTime(rset.getLong("onlinetime"));
player.setNewbie(rset.getInt("newbie"));
player.setNoble(rset.getInt("nobless")==1);
-
+
+ player.setFactionId(rset.getInt("factionId"));
+
player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
if (player.getClanJoinExpiryTime() < System.currentTimeMillis())
{
@@ -7581,7 +7600,8 @@
statement.setLong(51, getDeathPenaltyBuffLevel());
statement.setInt(52, getBookMarkSlot());
statement.setInt(53, getVitalityPoints());
- statement.setInt(54, getObjectId());
+ statement.setInt(54, getFactionId());
+ statement.setInt(55, getObjectId());

statement.execute();
statement.close();
@@ -8399,7 +8419,17 @@
// 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 = ((L2SummonIn...
Ответ
#5
Спасибо ребята, сейчас буду шайтанить=)

Добавлено через 1 час 7 минут
Проблема решена, все изменил подвог был в "setTeam" еще раз спасибо ребята.
Ответ


Перейти к форуму:


Пользователи, просматривающие эту тему: 1 Гость(ей)