Anti Farm PvP

Iniciado por Swarlog, Jun 25, 2025, 08:58 PM

Tema anterior - Siguiente tema

Swarlog

Esta implementación es para:

1 - If players have same clan don't give Item.
2 - If players have some ally don't give Item.
3 - If players are in party don't give item.
4 - If player kills player with level < 40 don't give Item.
5 - If player kills player with same Ip don't give Item.
6 - If target have Pdef < 300 don't give Item.
7 - If target have Patk < 300 don't give item.

CitarL2PcIstance:

- Incrementa las muertes pvp y envia informacion al jugador:

Código (text) [Seleccionar]
//Anti FARM Clan - Ally
         if((getClanId() > 0 && target.getClanId() > 0 && getClanId() == target.getClanId()) || (getAllyId() > 0 && target.getAllyId() > 0 && getAllyId() == target.getAllyId()))
         {
         this.sendMessage("Farm is punishable with Ban! Gm informed.");
          _log.warning("PVP POINT FARM ATTEMPT: " + this.getName() + " and" + target.getName() +". CLAN or ALLY.");
         return;
         }
       
         //Anti FARM level player < 40
         if(target.getLevel() < 40)
         {
         this.sendMessage("Farm is punishable with Ban! Don't kill new players! Gm informed.");
         _log.warning("PVP POINT FARM ATTEMPT: " + this.getName() + " and" + target.getName() +". NEWBIE PG.");
         return;
         }
         
         //Anti FARM pdef < 300
         if(target.getPDef(getLockedTarget()) < 300)
         {
         this.sendMessage("Farm is punishable with Ban! Gm informed.");
         _log.warning("PVP POINT FARM ATTEMPT: " + this.getName() + " and" + target.getName() +". P DEF Lower.");
         return;
         }
         
         //Anti FARM p atk < 300
         if(target.getPAtk(getLockedTarget()) < 300)
         {
         this.sendMessage("Farm is punishable with Ban! Gm informed.");
         _log.warning("PVP POINT FARM ATTEMPT: " + this.getName() + " and" + target.getName() +". P Atk Lower.");
         return;
         }
         
     
   
   
         //Anti FARM Party   
         if(this.getParty() != null && target.getParty() != null)
         {
           if(this.getParty().equals(target.getParty()))
           {
            this.sendMessage("Farm is punishable with Ban! Gm informed.");   
            _log.warning("PVP POINT FARM ATTEMPT: " + this.getName() + " and" + target.getName() +". PARTY.");
            return;
           }
         
         }
           
         //Anti FARM same Ip
         String ip1 = this.getClient().getConnection().getSocket().getInetAddress().getHostAddress();
         String ip2 = target.getClient().getConnection().getSocket().getInetAddress().getHostAddress();
 
         if (ip1.equals(ip2))
         {
         this.sendMessage("Farm is punishable with Ban! Gm informed.");
         _log.warning("PVP POINT FARM ATTEMPT: " + this.getName() + " and " + target.getName() +". SAME IP.");
         return;
         }

To Give item for PvP add this in L2PcIstance:

Código (text) [Seleccionar]
+       [b]//Reward every PvP point with 1 Medal[/b]
 +      addItem("Loot", 4037, 1, this, true);
 +       sendMessage("You have earned 1 Medal for a sucessful PvP!!");
 
       
        // Send a Server->Client UserInfo packet to attacker with its Karma and PK Counter
        sendPacket(new UserInfo(this));
        sendPacket(new ExBrExtraUserInfo(this));
    }
 
    /**
     * Increase pk count, karma and send the info to the player

If you have an herror of "target", use this patch:

Código (text) [Seleccionar]
# Index: N:/workspace/L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
# ===================================================================
# --- N:/workspace/L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java    (revision 2684)
# +++ N:/workspace/L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
# @@ -32,6 +32,7 @@
#  import javolution.util.FastMap;
#  import net.sf.l2j.Config;
#  import net.sf.l2j.L2DatabaseFactory;
# +import net.sf.l2j.gameserver.Announcements;
#  import net.sf.l2j.gameserver.GameTimeController;
#  import net.sf.l2j.gameserver.GeoData;
#  import net.sf.l2j.gameserver.GmListTable;
# @@ -5123,8 +5124,8 @@

#         L2PcInstance targetPlayer = target.getActingPlayer();

# -       if (targetPlayer == null) return;                                          // Target player is null
# -       if (targetPlayer == this) return;                                          // Target player is self
# +       if (targetPlayer == null) return;
# +       if (targetPlayer == this) return;

#         if (isCursedWeaponEquipped())
#         {
# @@ -5158,7 +5159,7 @@
#                 )
#         )
#         {
# -            increasePvpKills();
# +            increasePvpKills(targetPlayer);
#         }
#         else                                                                        // Target player doesn't have pvp flag set
#         {
# @@ -5170,7 +5171,7 @@
#                      if (targetPlayer.getClan().isAtWarWith(getClanId()))
#                      {
#                          // 'Both way war' -> 'PvP Kill'
# -                        increasePvpKills();
# +                        increasePvpKills(targetPlayer);
#                          return;
#                      }
#                  }
# @@ -5181,7 +5182,7 @@
#             {
#                 if ( Config.KARMA_AWARD_PK_KILL )
#                 {
# -                    increasePvpKills();
# +                    increasePvpKills(targetPlayer);
#                 }
#             }
#             else if (targetPlayer.getPvpFlag() == 0)                                                                    // Target player doesn't have karma
# @@ -5210,15 +5211,32 @@
#       * Increase the pvp kills count and send the info to the player
#       *
#       */
# -    public void increasePvpKills()
# +public void increasePvpKills(L2PcInstance target)