Cod3x Posted April 24, 2010 Posted April 24, 2010 Well, this is a patch will allow only the registered players or clans to fight in the siege, so noone else can come and fight. I made it for my server and also a friend helped me, I finished it today. Useful for PvP servers! Patch: Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeGuardInstance.java =================================================================== --- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeGuardInstance.java (revision 231) +++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeGuardInstance.java (revision 317) @@ -25,8 +25,13 @@ import net.sf.l2j.gameserver.ai.L2CharacterAI; import net.sf.l2j.gameserver.ai.L2SiegeGuardAI; +import net.sf.l2j.gameserver.datatables.ClanTable; +import net.sf.l2j.gameserver.instancemanager.SiegeManager; import net.sf.l2j.gameserver.model.L2Attackable; import net.sf.l2j.gameserver.model.L2CharPosition; import net.sf.l2j.gameserver.model.L2Character; +import net.sf.l2j.gameserver.model.L2Clan; +import net.sf.l2j.gameserver.model.L2SiegeClan; import net.sf.l2j.gameserver.model.actor.knownlist.SiegeGuardKnownList; +import net.sf.l2j.gameserver.model.entity.Siege; import net.sf.l2j.gameserver.network.serverpackets.ActionFailed; import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected; @@ -146,5 +151,34 @@ public void onAction(L2PcInstance player) { - if (!canTarget(player)) return; + if (!canTarget(player)) + return; + + boolean opp = false; + Siege siege = SiegeManager.getInstance().getSiege(player); + L2Clan oppClan = player.getClan(); + if (siege != null && siege.getIsInProgress() && oppClan != null) + { + for (L2SiegeClan clan : siege.getAttackerClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + + for (L2SiegeClan clan : siege.getDefenderClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + if(!opp) + return; + } // Check if the L2PcInstance already target the L2NpcInstance Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeFlagInstance.java =================================================================== --- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeFlagInstance.java (revision 231) +++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2SiegeFlagInstance.java (revision 317) @@ -96,6 +96,9 @@ if (player == null || !canTarget(player)) return; + + if(!_player.siegeonlyRegistered(player)) + return; - // Check if the L2PcInstance already target the L2NpcInstance + // Check if the L2PcInstance already target the L2NpcInstance if (this != player.getTarget()) { Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java =================================================================== --- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 314) +++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 317) @@ -106,4 +106,5 @@ import net.sf.l2j.gameserver.model.L2Request; import net.sf.l2j.gameserver.model.L2ShortCut; +import net.sf.l2j.gameserver.model.L2SiegeClan; import net.sf.l2j.gameserver.model.L2Skill; import net.sf.l2j.gameserver.model.L2SkillLearn; @@ -3419,4 +3420,11 @@ if (!TvTEvent.onAction(player.getName(), getName())) { + player.sendPacket(ActionFailed.STATIC_PACKET); + return; + } + + if (!siegeonlyRegistered(player)) + { + player.sendMessage("Player interaction disabled during sieges."); player.sendPacket(ActionFailed.STATIC_PACKET); return; @@ -10947,3 +10955,60 @@ _isAway = state; } + + public boolean siegeonlyRegistered(L2PcInstance player) + { + Siege siege = SiegeManager.getInstance().getSiege(this); + if (siege != null && siege.getIsInProgress()) + { + L2Clan selfClan = getClan(); + L2Clan oppClan = player.getClan(); + if (selfClan != null && oppClan != null) + { + boolean self = false; + for (L2SiegeClan clan : siege.getAttackerClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == selfClan || cl.getAllyId() == getAllyId()) + { + self = true; + break; + } + } + + for (L2SiegeClan clan : siege.getDefenderClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == selfClan || cl.getAllyId() == getAllyId()) + { + self = true; + break; + } + } + + boolean opp = false; + for (L2SiegeClan clan : siege.getAttackerClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + + for (L2SiegeClan clan : siege.getDefenderClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + return self && opp; + } + return false; + } + return true; + } } Index: /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2DoorInstance.java =================================================================== --- /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2DoorInstance.java (revision 231) +++ /trunk/GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2DoorInstance.java (revision 317) @@ -31,9 +31,13 @@ import net.sf.l2j.gameserver.ai.L2CharacterAI; import net.sf.l2j.gameserver.ai.L2DoorAI; +import net.sf.l2j.gameserver.datatables.ClanTable; import net.sf.l2j.gameserver.instancemanager.CastleManager; +import net.sf.l2j.gameserver.instancemanager.SiegeManager; import net.sf.l2j.gameserver.model.L2CharPosition; import net.sf.l2j.gameserver.model.L2Character; +import net.sf.l2j.gameserver.model.L2Clan; import net.sf.l2j.gameserver.model.L2ItemInstance; import net.sf.l2j.gameserver.model.L2Object; +import net.sf.l2j.gameserver.model.L2SiegeClan; import net.sf.l2j.gameserver.model.L2Skill; import net.sf.l2j.gameserver.model.actor.knownlist.DoorKnownList; @@ -42,4 +46,5 @@ import net.sf.l2j.gameserver.model.entity.Castle; import net.sf.l2j.gameserver.model.entity.ClanHall; +import net.sf.l2j.gameserver.model.entity.Siege; import net.sf.l2j.gameserver.network.L2GameClient; import net.sf.l2j.gameserver.network.serverpackets.ActionFailed; @@ -368,4 +373,38 @@ if (player == null) return; + + boolean opp = false; + Siege siege = SiegeManager.getInstance().getSiege(player); + L2Clan oppClan = player.getClan(); + if (siege != null && siege.getIsInProgress()) + { + if (oppClan != null) + { + for (L2SiegeClan clan : siege.getAttackerClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + + for (L2SiegeClan clan : siege.getDefenderClans()) + { + L2Clan cl = ClanTable.getInstance().getClan(clan.getClanId()); + if (cl == oppClan || cl.getAllyId() == player.getAllyId()) + { + opp = true; + break; + } + } + } + } + else + opp = true; + + if (!opp) + return; // Check if the L2PcInstance already target the L2NpcInstance Quote
livogro Posted April 24, 2010 Posted April 24, 2010 Thx! Useful share, keep up! I alredy did in my server :D Quote
NoSti* Posted April 24, 2010 Posted April 24, 2010 i cant understand you.. if one clan is not register to attack the castle can attack?? no .. and why you share it??? Quote
Dev Posted April 24, 2010 Posted April 24, 2010 i will test it and i will say u BTW what about ally if they cant register because they already own a castle? Quote
Cod3x Posted April 24, 2010 Author Posted April 24, 2010 i cant understand you.. if one clan is not register to attack the castle can attack?? no .. and why you share it??? If a clan is not registered he cannot attack the registered clans or participants during the event... Quote
Erol Posted April 26, 2010 Posted April 26, 2010 add a message to non attackers: "You cannot attack on siege area because your clan is not registered" Quote
~Greedy~ Posted April 26, 2010 Posted April 26, 2010 add a message to non attackers: "You cannot attack on siege area because your clan is not registered" /agree, cuz if someone wont knew that you are using thing like this, will spam youre server forum "why i cant attack... omg bug..." Quote
Coyote™ Posted April 26, 2010 Posted April 26, 2010 Gratz for destroying every retail feature left >_> Anw, I'd cut my head that I've seen this before. Anyway. PS: Fixed the Hide ammount, don't put so high values for such codes. Quote
Neo1993k Posted April 26, 2010 Posted April 26, 2010 Gratz for destroying every retail feature left >_> Anw, I'd cut my head that I've seen this before. Anyway. PS: Fixed the Hide ammount, don't put so high values for such codes. Yes it's right but it's very nice for fun server and pvp, work fine thanks for share it Quote
~Greedy~ Posted April 26, 2010 Posted April 26, 2010 Gratz for destroying every retail feature left >_> Anw, I'd cut my head that I've seen this before. Anyway. PS: Fixed the Hide ammount, don't put so high values for such codes. dude :D l2j isnt like retail already long long long time ago :D Quote
i˚Ozõ Posted April 26, 2010 Posted April 26, 2010 dude :D l2j isnt like retail already long long long time ago :D ye but this sux and if ally want to help then what ? -.- Quote
Cod3x Posted April 26, 2010 Author Posted April 26, 2010 ye but this sux and if ally want to help then what ? -.- Non-registered clans cannot attack the walls the guards the players registered in the siege... This is so so cool feature for PvP Servers. ! THE BEST WILL WIN. Quote
Coyote™ Posted April 26, 2010 Posted April 26, 2010 dude :D l2j isnt like retail already long long long time ago :D Ye, but the point is that no one's trying to create something similar to it. Quote
mikrosgiwrgakis.com Posted April 26, 2010 Posted April 26, 2010 this will reduce the pvp's! if is siege and there is only 2 clan attack and one defence the castle then if players without clan come to fight or others clan help the attackers then they will cant help cause of this and then no pvps...i dont want to see this in any server! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.