|
Работа со скриптами Помощь в редактировании и написании квестов к Java серверам, а так же эвентов.
Описание темы:Подсветка фракции |
Ссылки сообщества |
Изображения и альбомы |
Пользователи |
К странице... |
Опции темы |
12.01.2015, 23:55 | #1 |
Пользователь
|
GvE
Добрый вечер уважаемые пользователи. Вписал код для Войны между фракциями (Добро и Зло) У каждой команды своя подсветка (Синяя/Красная, как на ТВТ евенте) Все работает. Как мне убрать подсветку у 2-ух фракций что за это отвечает. Исходники L2jServer client-Gracia Final. Вот diff:
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.L2Cubic Instance; import net.sf.l2j.gameserver.model.actor.instance.L2PcIns tance; import net.sf.l2j.gameserver.model.actor.instance.L2PetIn stance; +import net.sf.l2j.gameserver.model.itemcontainer.Inventor y; 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.System Message; import net.sf.l2j.gameserver.templates.StatsSet; import net.sf.l2j.gameserver.templates.chars.L2NpcTemplat e; +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_YOURSE LF)); 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_PAR TY); 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.getObjec tId()) && 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.getObje ctId()) && 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.L2Class MasterInstance; import net.sf.l2j.gameserver.model.actor.instance.L2PcIns tance; +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().getConnec tion().getInetAddress().getHostAddress()).toString ()); + // Set Hero status if it applies if (Hero.getInstance().getHeroes() != null && Hero.getInstance().getHeroes().containsKey(activeC har.getObjectId())) activeChar.setHero(true); @@ -361,7 +364,16 @@ SevenSigns.getInstance().sendCurrentPeriodMsg(acti veChar); Announcements.getInstance().showAnnouncements(acti veChar); - + + 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.TeleportW hereType.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.Creatu reSay; +import net.sf.l2j.gameserver.network.serverpackets.Action Failed; +import net.sf.l2j.gameserver.network.serverpackets.MyTarg etSelected; +import net.sf.l2j.gameserver.network.serverpackets.NpcHtm lMessage; +import net.sf.l2j.gameserver.network.serverpackets.Social Action; +import net.sf.l2j.gameserver.network.serverpackets.Valida teLocation; +import net.sf.l2j.gameserver.network.serverpackets.MagicS killUse; +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplat e; +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.getN ame().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.getN ame().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(ne w Runnable() + {public void run() + { + player.setTeam(player.getFactionId()); + player.teleToLocation(MapRegionTable.TeleportWhere Type.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().tryPerf ormAction("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.getN ame().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.getN ame().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(ne w 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().tryPerf ormAction("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.g etName().toLowerCase()); + else + L2World.getInstance().getAllEvil().remove(player.g etName().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(ne w 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_INTEN TION_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.L2Siege SummonInstance; import net.sf.l2j.gameserver.model.actor.instance.L2Stati cObjectInstance; import net.sf.l2j.gameserver.model.actor.instance.L2Summo nInstance; +import net.sf.l2j.gameserver.model.entity.TvTEvent; import net.sf.l2j.gameserver.network.SystemMessageId; import net.sf.l2j.gameserver.network.serverpackets.Action Failed; import net.sf.l2j.gameserver.network.serverpackets.ChairS it; @@ -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.getObjectI d()) && 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.getObjectI d()) && 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.Action Failed; +import net.sf.l2j.gameserver.network.serverpackets.MyTarg etSelected; +import net.sf.l2j.gameserver.network.serverpackets.NpcHtm lMessage; +import net.sf.l2j.gameserver.network.serverpackets.Social Action; +import net.sf.l2j.gameserver.network.serverpackets.Valida teLocation; +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplat e; +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.ge tName()); + + 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_INTEN TION_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_POIN TS, 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.L2FactT eleporterInstance; +import net.sf.l2j.gameserver.model.actor.instance.L2PcIns tance; +import net.sf.l2j.gameserver.model.actor.instance.L2TpFla gInstance; +import net.sf.l2j.gameserver.network.serverpackets.ExShow ScreenMessage; +import net.sf.l2j.gameserver.network.serverpackets.NpcHtm lMessage; +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(ne w 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.TeleportWhere Type.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.L2PetIn stance; import net.sf.l2j.gameserver.model.actor.instance.L2RiftI nvaderInstance; import net.sf.l2j.gameserver.model.actor.instance.L2PcIns tance.SkillDat; +import net.sf.l2j.gameserver.model.actor.instance.L2TpFla gInstance; +import net.sf.l2j.gameserver.model.actor.instance.L2Summo nInstance; import net.sf.l2j.gameserver.model.actor.knownlist.CharKn ownList; import net.sf.l2j.gameserver.model.actor.position.CharPos ition; import net.sf.l2j.gameserver.model.actor.stat.CharStat; import net.sf.l2j.gameserver.model.actor.status.CharStatu s; +import net.sf.l2j.gameserver.model.entity.TvTEvent; import net.sf.l2j.gameserver.model.itemcontainer.Inventor y; 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().toLowerCas e()); + else if (player.getFactionId() == 2) + _allevilPlayers.remove(player.getName().toLowerCas e()); // 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.L2FactT eleporterInstance; import net.sf.l2j.gameserver.model.actor.appearance.PcApp earance; import net.sf.l2j.gameserver.model.actor.knownlist.PcKnow nList; import net.sf.l2j.gameserver.model.actor.position.PcPosit ion; @@ -165,6 +166,7 @@ import net.sf.l2j.gameserver.network.serverpackets.ExOlym piadUserInfo; import net.sf.l2j.gameserver.network.serverpackets.ExPriv ateStoreSetWholeMsg; import net.sf.l2j.gameserver.network.serverpackets.ExSetC ompassZoneCode; +import net.sf.l2j.gameserver.network.serverpackets.ExShow ScreenMessage; import net.sf.l2j.gameserver.network.serverpackets.ExSpaw nEmitter; import net.sf.l2j.gameserver.network.serverpackets.ExStor ageMaxCount; import net.sf.l2j.gameserver.network.serverpackets.ExVita lityPointInfo; @@ -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,m axCp,curCp,maxMp,curMp,face,hairStyle,hairColor,se x,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,c lassid,deletetime,cancraft,title,accesslevel,onlin e,isin7sdungeon,clan_privs,wantspeace,base_class,n ewbie,nobless,power_grade,last_recom_date) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? ,?,?,?,?,?,?,?,?,?,?,?)"; - private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,cu rMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading =?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=? ,fame=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=? ,clanid=?,race=?,classid=?,deletetime=?,title=?,ac cesslevel=?,online=?,isin7sdungeon=?,clan_privs=?, wantspeace=?,base_class=?,onlinetime=?,punish_leve l=?,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=?,vitali ty_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,vita lity_points FROM characters WHERE charId=?"; + private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,cu rMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading =?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=? ,fame=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=? ,clanid=?,race=?,classid=?,deletetime=?,title=?,ac cesslevel=?,online=?,isin7sdungeon=?,clan_privs=?, wantspeace=?,base_class=?,onlinetime=?,punish_leve l=?,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=?,vitali ty_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,vita lity_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().getP aperdollItemId(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_EQ UIP_THIS_ITEM_WHEN_YOUR_PK_COUNT_IS_GREATER_THAN_O R_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_jo in_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).getOwner(); + + if (player != null) + if (getFactionId() != player.getFactionId()) + return true; + // TODO: check for friendly mobs // Check if the attacker is a L2MonsterInstance if (attacker instanceof L2MonsterInstance) @@ -8793,6 +8823,25 @@ // Check if this is offensive magic skill if (skill.isOffensive()) { + boolean cond = true; + L2PcInstance trgtF = null; + if (target instanceof L2PcInstance) + trgtF = (L2PcInstance)target; + else if (target instanceof L2SummonInstance) + trgtF = ((L2SummonInstance)target).getOwner(); + if (trgtF != null) + { + if (trgtF.getFactionId() == getFactionId()) + cond = false; + if (trgtF.isInOlympiadMode() && isInOlympiadMode()) + cond = true; + if (TvTEvent.isStarted() && TvTEvent.isPlayerParticipant(trgtF.getObjectId()) && TvTEvent.isPlayerParticipant(getObjectId())) + cond = true; + } + + if (!cond) + return false; + if ((isInsidePeaceZone(this, target)) && !getAccessLevel().allowPeaceAttack()) { // If L2Character or target is in a peace zone, send a system message TARGET_IN_PEACEZONE a Server->Client packet ActionFailed @@ -9938,7 +9987,7 @@ public void setHero(boolean hero) { - if (hero && _baseClass == _activeClass) + if (hero) { for (L2Skill s : HeroSkillTable.getHeroSkills()) addSkill(s, false); //Dont Save Hero skills to database Index: java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java ================================================== ================= --- java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java (revision 3695) +++ java/net/sf/l2j/gameserver/network/clientpackets/UseItem.java (working copy) @@ -23,6 +23,7 @@ import net.sf.l2j.gameserver.handler.ItemHandler; import net.sf.l2j.gameserver.instancemanager.FortSiegeMan ager; import net.sf.l2j.gameserver.model.L2ItemInstance; +import net.sf.l2j.gameserver.model.L2Skill; import net.sf.l2j.gameserver.model.actor.instance.L2PcIns tance; import net.sf.l2j.gameserver.model.base.Race; import net.sf.l2j.gameserver.model.itemcontainer.Inventor y; @@ -31,6 +32,7 @@ import net.sf.l2j.gameserver.network.serverpackets.ItemLi st; import net.sf.l2j.gameserver.network.serverpackets.ShowCa lculator; import net.sf.l2j.gameserver.network.serverpackets.System Message; +import net.sf.l2j.gameserver.network.serverpackets.SkillC oolTime; import net.sf.l2j.gameserver.templates.item.L2Armor; import net.sf.l2j.gameserver.templates.item.L2ArmorType; import net.sf.l2j.gameserver.templates.item.L2Item; @@ -172,6 +174,23 @@ if (itemId >= 7117 && itemId <= 7135) return; } + + if (item.isAugmented() && !item.isEquipped() && activeChar.isInOlympiadMode()) + { + if (item.getAugmentation().getSkill() != null) + { + L2Skill skill = item.getAugmentation().getSkill(); + if (skill.isActive()) + { + if (!activeChar.getReuseTimeStamp().containsKey(skill .getId())) + { + activeChar.addTimeStamp(skill.getId(), 30000); + activeChar.disableSkill(skill.getId(), 30000); + } + activeChar.sendPacket(new SkillCoolTime(activeChar)); + } + } + } // Items that cannot be used if (itemId == 57) Index: java/net/sf/l2j/gameserver/GameServer.java ================================================== ================= --- java/net/sf/l2j/gameserver/GameServer.java (revision 3695) +++ java/net/sf/l2j/gameserver/GameServer.java (working copy) @@ -106,7 +106,9 @@ import net.sf.l2j.gameserver.model.L2World; import net.sf.l2j.gameserver.model.entity.Hero; import net.sf.l2j.gameserver.model.entity.TvTManager; +import net.sf.l2j.gameserver.model.entity.FactionMaps; import net.sf.l2j.gameserver.model.olympiad.Olympiad; +import net.sf.l2j.gameserver.model.actor.instance.L2TpFla gInstance; import net.sf.l2j.gameserver.network.L2GameClient; import net.sf.l2j.gameserver.network.L2GamePacketHandler; import net.sf.l2j.gameserver.pathfinding.PathFinding; @@ -404,6 +406,8 @@ TvTManager.getInstance(); KnownListUpdateTaskManager.getInstance(); + FactionMaps.loadCurrentMap(); + L2TpFlagInstance.spawnFlags(); if (Config.DEADLOCK_DETECTOR) { _deadDetectThread = new DeadLockDetector(); Index: java/net/sf/l2j/gameserver/model/actor/instance/L2TpFlagInstance.java ================================================== ================= --- java/net/sf/l2j/gameserver/model/actor/instance/L2TpFlagInstance.java (revision 0) +++ java/net/sf/l2j/gameserver/model/actor/instance/L2TpFlagInstance.java (revision 0) @@ -0,0 +1,252 @@ +/* + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <http://www.gnu.org/licenses/>. + */ +package net.sf.l2j.gameserver.model.actor.instance; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.logging.Logger; + +import net.sf.l2j.L2DatabaseFactory; +import net.sf.l2j.gameserver.Announcements; +import net.sf.l2j.gameserver.ai.CtrlIntention; +import net.sf.l2j.gameserver.datatables.NpcTable; +import net.sf.l2j.gameserver.idfactory.IdFactory; +import net.sf.l2j.gameserver.model.L2Skill; +import net.sf.l2j.gameserver.model.actor.L2Character; +import net.sf.l2j.gameserver.model.actor.L2Npc; +import net.sf.l2j.gameserver.model.entity.FactionMaps; +import net.sf.l2j.gameserver.network.serverpackets.Action Failed; +import net.sf.l2j.gameserver.network.serverpackets.MyTarg etSelected; +import net.sf.l2j.gameserver.network.serverpackets.Status Update; +import net.sf.l2j.gameserver.network.serverpackets.Valida teLocation; +import net.sf.l2j.gameserver.templates.chars.L2NpcTemplat e; +import net.sf.l2j.gameserver.util.Broadcast; + +public class L2TpFlagInstance extends L2Npc +{ + private final static Logger _log = Logger.getLogger(L2FactTeleporterInstance.class.ge tName()); + + private int _faction=0; + private int _occupayable=0; + private String _title = ""; + private String _flagPlace = ""; + + public L2TpFlagInstance(int objectId, L2NpcTemplate template) + { + super(objectId, template); + } + + public static void spawnFlags() + { + Connection con = null; + + try + { + con = L2DatabaseFactory.getInstance().getConnection(); + PreparedStatement statement = con.prepareStatement("SELECT * FROM faction_crystals WHERE mapId=?"); + statement.setInt(1, FactionMaps.getMapId()); + ResultSet rset = statement.executeQuery(); + + while (rset.next()) + { + String _titlea = ""; + if (rset.getInt("factionId") == 1) + _titlea = "Blue"; + else if (rset.getInt("factionId") == 2) + _titlea = "Red"; + + L2TpFlagInstance flag = new L2TpFlagInstance(IdFactory.getInstance().getNextId (),NpcTable.getInstance().getTemplate(31217)); + flag.setTitle(_titlea); + flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp()); + flag.setHeading(0); + flag.setName(rset.getString("flagName")); + flag.setFlagName(rset.getString("flagName")); + flag.setFlagFactionId(rset.getInt("factionId")); + flag.spawnMe(rset.getInt("x"),rset.getInt("y"),rse t.getInt("z") + 50); + if (rset.getInt("factionId") != 0) + { + if (rset.getInt("factionId") == 1) + L2FactTeleporterInstance._tpBlueFlags.add(flag); + else + L2FactTeleporterInstance._tpRedFlags.add(flag); + flag.setIsInvul(true); + flag.setIsUnoccupayable(1); + } + _log.info("Spawned crystal: " + rset.getString("flagName")); + } + + rset.close(); + statement.close(); + } + catch (Exception e) + { + _log.warning("Kazkas blogai su kristalais faction:" + e); + } + finally + { + try {con.close();} catch (Exception e){} + } + Announcements.getInstance().announceToAll("Spawned faction map: " + FactionMaps.getMapName()); + } + + public void setFlagName(String a) + { + _flagPlace = a; + } + + public String getFlagName() + { + return _flagPlace; + } + + @Override + public boolean isAttackable() + { + return true; + } + + @Override + public boolean isAutoAttackable(L2Character attacker) + { + return true; + } + + @Override + public boolean doDie(L2Character killer) + { + if (!super.doDie(killer)) + return false; + if (getFlagFactionId() == 1) + L2FactTeleporterInstance._tpBlueFlags.remove(this) ; + else if (getFlagFactionId() == 2) + L2FactTeleporterInstance._tpRedFlags.remove(this); + + L2PcInstance player = null; + int _faktjon = 0; + String _name = ""; + + if (killer instanceof L2PcInstance) + player = (L2PcInstance) killer; + else if (killer instanceof L2SummonInstance) + player = ((L2SummonInstance) killer).getOwner(); + + _faktjon = player.getFactionId(); + if (_faktjon == 1) + _title = "Blue"; + else + _title = "Red"; + + L2TpFlagInstance flag = new L2TpFlagInstance(IdFactory.getInstance().getNextId (),NpcTable.getInstance().getTemplate(31217)); + _name = this.getName(); + flag.setTitle(_title); + flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp()); + flag.setHeading(0); + flag.setName(_name); + flag.setFlagName(_name); + flag.setIsUnoccupayable(0); + flag.setFlagFactionId(_faktjon); + flag.spawnMe(this.getX(), this.getY(), this.getZ()); + deleteMe(); + + if (_faktjon == 1) + L2FactTeleporterInstance._tpBlueFlags.add(flag); + else + L2FactTeleporterInstance._tpRedFlags.add(flag); + + Broadcast.sendMessToAllFactionPlayers(_title + " faction member " + player.getName() + " has occupied " + _flagPlace + " crystal."); + return true; + } + + @Override + public void onForcedAttack(L2PcInstance player) + { + onAction(player); + } + + public void setIsUnoccupayable(int a) + { + _occupayable = a; + } + + public int isUnoccupayable() + { + return _occupayable; + } + + @Override + public void onAction(L2PcInstance player) + { + if (player == null || !canTarget(player)) + return; + + // Check if the L2PcInstance already target the L2NpcInstance + if (this != player.getTarget()/* && player.inWorld() == 1*/) + { + // Set the target of the L2PcInstance player + player.setTarget(this); + + // Send a Server->Client packet MyTargetSelected to the L2PcInstance player + MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel()); + player.sendPacket(my); + + // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar + StatusUpdate su = new StatusUpdate(getObjectId()); + su.addAttribute(StatusUpdate.CUR_HP, (int)getStatus().getCurrentHp() ); + su.addAttribute(StatusUpdate.MAX_HP, getMaxHp() ); + player.sendPacket(su); + + // Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client + player.sendPacket(new ValidateLocation(this)); + } + else + { + if (isAutoAttackable(player) && Math.abs(player.getZ() - getZ()) < 100) + player.getAI().setIntention(CtrlIntention.AI_INTEN TION_ATTACK, this); + else + { + // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet + player.sendPacket(ActionFailed.STATIC_PACKET); + } + } + } + + public int getFlagFactionId() + { + return _faction; + } + + public void setFlagFactionId(int i) + { + _faction = i; + } + + @Override + public void reduceCurrentHp(double damage, L2Character attacker, L2Skill skill) + { + L2PcInstance plajor = null; + boolean cord = false; + if (attacker instanceof L2PcInstance) + plajor = (L2PcInstance) attacker; + else if (attacker instanceof L2SummonInstance) + plajor = ((L2SummonInstance) attacker).getOwner(); + + if (/*plajor.inWorld() == 1 && */plajor.getFactionId() != getFlagFactionId()) + cord = true; + + if (cord) + super.reduceCurrentHp(damage, attacker, skill); + } +} \ No newline at end of file Index: java/net/sf/l2j/gameserver/datatables/MapRegionTable.java ================================================== ================= --- java/net/sf/l2j/gameserver/datatables/MapRegionTable.java (revision 3695) +++ java/net/sf/l2j/gameserver/datatables/MapRegionTable.java (working copy) @@ -562,24 +562,19 @@ } } - // Checking if in an instance - if (player.getInstanceId() > 0) - { - Instance inst = InstanceManager.getInstance().getInstance(player.g etInstanceId()); - if (inst != null) - { - coord = inst.getSpawnLoc(); - if (coord[0] != 0 && coord[1] != 0 && coord[2] != 0) - return new Location(coord[0], coord[1], coord[2]); - } - } + if (player.getFactionId() == 1) + return new Location(185081,-12601,-5492); + else if (player.getFactionId() == 2) + return new Location(185060,-9615,-5492); + else + return new Location(147308,142827,-15872); } // Get the nearest town // TODO: Micht: Maybe we should add some checks to prevent exception here. coord = TownManager.getClosestTown(activeChar).getSpawnLoc (); - - return new Location(coord[0], coord[1], coord[2]); + + return new Location(147308,142827,-15872); } @SuppressWarnings("synthetic-access") Index: java/net/sf/l2j/gameserver/model/entity/Duel.java ================================================== ================= --- java/net/sf/l2j/gameserver/model/entity/Duel.java (revision 3695) +++ java/net/sf/l2j/gameserver/model/entity/Duel.java (working copy) @@ -461,23 +461,23 @@ for (L2PcInstance temp : _playerA.getParty().getPartyMembers()) { temp.setIsInDuel(0); - temp.setTeam(0); + temp.setTeam(temp.getFactionId()); temp.broadcastUserInfo(); } for (L2PcInstance temp : _playerB.getParty().getPartyMembers()) { temp.setIsInDuel(0); - temp.setTeam(0); + temp.setTeam(temp.getFactionId()); temp.broadcastUserInfo(); } } else { _playerA.setIsInDuel(0); - _playerA.setTeam(0); + _playerA.setTeam(_playerA.getFactionId()); _playerA.broadcastUserInfo(); _playerB.setIsInDuel(0); - _playerB.setTeam(0); + _playerB.setTeam(_playerB.getFactionId()); _playerB.broadcastUserInfo(); } Буду благодарен за помощь. |
13.01.2015, 00:03 | #2 |
Antihero
Регистрация: 03.04.2010
Адрес: Virtual Reality
Сообщений: 2,455
Отблагодарили 1,098 раз(а)
Рейтинг мнений:
918
|
Re: GvE
:Свернуть ↑
Свернуть ↑Развернуть ↓
Не думаю, что тут Вам помогут с таким отношением. Для начала оформите код, как код, что бы форматирование не разьезжалось. На форуме есть специальная кнопка для этого. Смотрите что отсылается в пакетах CharInfo & UserInfo. |
Сказали спасибо: |
13.01.2015, 00:15 | #3 |
Пользователь
Регистрация: 12.01.2015
Адрес: Пермь
Возраст: 38
Сообщений: 69
Отблагодарили 5 раз(а)
Рейтинг мнений:
37
|
Re: GvE
Нафиг там вообще оформление диффки? Глазами это читать - с ума сойти.
Проще было бы выложить дифф-файл, а кто захочет помочь - клипсой загрузит его и поглядит. А вообще, красная и синяя подсветки задаются player.setTeam(1) и player.setTeam(2) (или наоборот, не помню уже). Ищи, где задается тима и убирай. Johnson получился в результате деления на null. Помогаю с джавой только за булочки с маком. |
13.01.2015, 00:15 | #4 | |
Пользователь
|
Re: GvE
Цитата:
Вот то что выделил зеленым цветом, по идее и дает ауру |
|
13.01.2015, 01:25 | #5 |
Пользователь
|
Re: GvE
Спасибо ребята, сейчас буду шайтанить=)
Добавлено через 1 час 7 минут Проблема решена, все изменил подвог был в "setTeam" еще раз спасибо ребята. Последний раз редактировалось Phantomas; 13.01.2015 в 02:33. Причина: Добавлено сообщение |
Здесь присутствуют: 1 (пользователей: 0 , гостей: 1) | |
|
|