Axelut

DISABLE ATTACK TO NPC LIST

May 15th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: net.sf.l2j;Config.java
  2. ===================================================================
  3. --- net.sf.l2j;Config.java (revision 84)
  4. +++ net.sf.l2j;Config.java (working copy)
  5.  
  6. +   /** Disable attack Npcs */
  7. +   public static boolean DISABLE_ATTACK_NPC_TYPE;
  8. +   public static String ALLOWED_NPC_TYPES;
  9. +   public static ArrayList<String> LIST_ALLOWED_NPC_TYPES = new ArrayList<>();
  10.    
  11.  
  12. +       DISABLE_ATTACK_NPC_TYPE = npcs.getProperty("DisableAttackToNpcs", false);
  13. +       ALLOWED_NPC_TYPES = npcs.getProperty("AllowedNPCTypes");
  14. +       LIST_ALLOWED_NPC_TYPES = new ArrayList<>();
  15. +       for (String npc_type : ALLOWED_NPC_TYPES.split(","))
  16. +           LIST_ALLOWED_NPC_TYPES.add(npc_type);
  17.  
  18. Index: net.sf.l2j.gameserver.model.actor.instance;player.java
  19. ===================================================================
  20. --- net.sf.l2j.gameserver.model.actor.instance;player.java (revision 84)
  21. +++ net.sf.l2j.gameserver.model.actor.instance;player.java (working copy)
  22.  
  23.         if (target instanceof Door)
  24.             if (!((Door) target).isAutoAttackable(this) // Siege doors only hittable during siege
  25.                 || ((Door) target).isUnlockable() && skill.getSkillType() != L2SkillType.UNLOCK) // unlockable doors
  26.             {
  27.                 sendPacket(SystemMessageId.INCORRECT_TARGET);
  28.                 sendPacket(ActionFailed.STATIC_PACKET);
  29.                 return false;
  30.             }
  31.  
  32. +       if (target instanceof Npc && Config.DISABLE_ATTACK_NPC_TYPE)
  33. +       {
  34. +           String mobtype = ((Npc) target).getTemplate().getType();
  35. +           if (!Config.LIST_ALLOWED_NPC_TYPES.contains(mobtype) && skill.isOffensive())
  36. +           {
  37. +               sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  38. +               sendPacket(ActionFailed.STATIC_PACKET);
  39. +               return false;
  40. +           }
  41. +       }
  42.  
  43. Index: net.sf.l2j.gameserver.model.actor;Creature.java
  44. ===================================================================
  45. --- net.sf.l2j.gameserver.model.actor;Creature.java (revision 84)
  46. +++ net.sf.l2j.gameserver.model.actor;Creature.java (working copy)
  47.  
  48.         final Player player = getActingPlayer();
  49.        
  50.         if (player != null && player.inObserverMode())
  51.         {
  52.             sendPacket(SystemMessage.getSystemMessage(SystemMessageId.OBSERVERS_CANNOT_PARTICIPATE));
  53.             sendPacket(ActionFailed.STATIC_PACKET);
  54.             return;
  55.         }
  56.  
  57. +   if (target instanceof Npc && Config.DISABLE_ATTACK_NPC_TYPE)
  58. +   {
  59. +       String mobtype = ((Npc) target).getTemplate().getType();
  60. +       if (!Config.LIST_ALLOWED_NPC_TYPES.contains(mobtype))
  61. +           return;
  62. +   }
  63.  
  64. Index: net.sf.l2j.gameserver.model.actor;Summon.java
  65. ===================================================================
  66. --- net.sf.l2j.gameserver.model.actor;Summon.java (revision 84)
  67. +++ net.sf.l2j.gameserver.model.actor;Summon.java (working copy)
  68.  
  69.         // ************************************* Check Summon State *******************************************
  70.        
  71.         // Check if this is offensive magic skill
  72.         if (skill.isOffensive())
  73.         {
  74.             if (isInsidePeaceZone(this, target))
  75.             {
  76.                 // If summon or target is in a peace zone, send a system message TARGET_IN_PEACEZONE
  77.                 sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IN_PEACEZONE));
  78.                 return false;
  79.             }
  80.            
  81.             if (getOwner() != null && getOwner().isInOlympiadMode() && !getOwner().isOlympiadStart())
  82.             {
  83.                 // if Player is in Olympia and the match isn't already start, send ActionFailed
  84.                 sendPacket(ActionFailed.STATIC_PACKET);
  85.                 return false;
  86.             }
  87.  
  88. +           if (target instanceof Npc && Config.DISABLE_ATTACK_NPC_TYPE)
  89. +           {
  90. +               String mobtype = ((Npc) target).getTemplate().getType();
  91. +               if (!Config.LIST_ALLOWED_NPC_TYPES.contains(mobtype))
  92. +               {
  93. +                   sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
  94. +                   return false;
  95. +               }
  96. +           }
  97.  
  98. Index: config/npcs.propertis
  99. ===================================================================
  100. --- config/npcs.propertis (revision 84)
  101. +++ config/npcs.propertis (working copy)
  102.  
  103.  
  104. +   #=====================================================
  105. +   #           DISABLE ATTACK TO NPC LIST                
  106. +   #=====================================================
  107. +   # If True ActiveChar will not be able to Attack the Listed Npc Types.
  108. +   DisableAttackToNpcs = True
  109. +  
  110. +   # List of NPC's that allow casting skills on them
  111. +   # Any other type will not allow casting
  112. +   AllowedNPCTypes = GrandBoss,Chest,FestivalMonster,Monster,Pet,RaidBoss,SiegeGuard,SiegeNpc,ControlTower,FlameTower,Artefact,PenaltyMonster,FeedableBeast,RiftInvader,Guard,SiegeFlag
Add Comment
Please, Sign In to add comment