Advertisement
BossForever

[aCis] No Attack NPC

Jul 22nd, 2017
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.61 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: config/npcs.properties
  4. ===================================================================
  5. --- config/npcs.properties  (revision 48)
  6. +++ config/npcs.properties  (working copy)
  7. @@ -89,6 +89,13 @@
  8.  # Show clan && alliance crests on summons, default: False
  9.  ShowSummonCrest = False
  10.  
  11. +# If True ActiveChar will not be able to Attack the Listed Npc Types.
  12. +DisableAttackToNpcs = True
  13. +
  14. +# List of NPC's that allow casting skills on them
  15. +# Any other type will not allow casting
  16. +AllowedNPCTypes = GrandBoss,Chest,FestivalMonster,Minion,Monster,Pet,RaidBoss,SiegeGuard,SiegeNpc,ControlTower,Artefact,PenaltyMonster,FeedableBeast,SiegeFlag,RiftInvader,Guard,GuardNoHTML
  17. +
  18.  #=============================================================
  19.  #                        Wyvern Manager
  20.  #=============================================================
  21. Index: java/net/sf/l2j/Config.java
  22. ===================================================================
  23. --- java/net/sf/l2j/Config.java (revision 48)
  24. +++ java/net/sf/l2j/Config.java (working copy)
  25. @@ -402,6 +402,10 @@
  26.     public static boolean SHOW_NPC_LVL;
  27.     public static boolean SHOW_NPC_CREST;
  28.     public static boolean SHOW_SUMMON_CREST;
  29. +   public static boolean NPC_ATTACKABLE;
  30. +   public static boolean DISABLE_ATTACK_NPC_TYPE;
  31. +   public static String ALLOWED_NPC_TYPES;
  32. +   public static List<String> LIST_ALLOWED_NPC_TYPES;
  33.    
  34.     /** Wyvern Manager */
  35.     public static boolean WYVERN_ALLOW_UPGRADER;
  36. @@ -1784,6 +1788,12 @@
  37.         SHOW_NPC_LVL = npcs.getProperty("ShowNpcLevel", false);
  38.         SHOW_NPC_CREST = npcs.getProperty("ShowNpcCrest", false);
  39.         SHOW_SUMMON_CREST = npcs.getProperty("ShowSummonCrest", false);
  40. +       DISABLE_ATTACK_NPC_TYPE = npcs.getProperty("DisableAttackToNpcs", false);
  41. +       ALLOWED_NPC_TYPES = npcs.getProperty("AllowedNPCTypes");
  42. +       LIST_ALLOWED_NPC_TYPES = new ArrayList<>();
  43. +       for (String npc_type : ALLOWED_NPC_TYPES.split(","))
  44. +       LIST_ALLOWED_NPC_TYPES.add(npc_type);
  45. +       NPC_ATTACKABLE = npcs.getProperty("NpcAttackable", false);
  46.        
  47.         WYVERN_ALLOW_UPGRADER = npcs.getProperty("AllowWyvernUpgrader", true);
  48.         WYVERN_REQUIRED_LEVEL = npcs.getProperty("RequiredStriderLevel", 55);
  49. Index: java/net/sf/l2j/gameserver/model/actor/Creature.java
  50. ===================================================================
  51. --- java/net/sf/l2j/gameserver/model/actor/Creature.java    (revision 49)
  52. +++ java/net/sf/l2j/gameserver/model/actor/Creature.java    (working copy)
  53. @@ -542,6 +542,19 @@
  54.             sendPacket(ActionFailed.STATIC_PACKET);
  55.             return;
  56.         }
  57. +        
  58. +           if (target instanceof Npc && Config.DISABLE_ATTACK_NPC_TYPE)
  59. +           {
  60. +               String mobtype = ((Npc) target).getTemplate().getType();
  61. +               if (!Config.LIST_ALLOWED_NPC_TYPES.contains(mobtype))
  62. +               {
  63. +                   SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2);
  64. +                   sm.addString("Npc Type " + mobtype + " has Protection - No Attack Allowed!");
  65. +                   ((Player) this).sendPacket(sm);
  66. +                   ((Player) this).sendPacket(ActionFailed.STATIC_PACKET);
  67. +                   return;
  68. +               }
  69. +           }
  70.        
  71.         stopEffectsOnAction();
  72.        
  73. @@ -1123,7 +1136,19 @@
  74.             }
  75.             return;
  76.         }
  77. -      
  78. +        
  79. +       if (target instanceof Player && target instanceof Npc && Config.DISABLE_ATTACK_NPC_TYPE)
  80. +       {
  81. +           final String mobtype = ((Npc) target).getTemplate().getType();
  82. +           if (!Config.LIST_ALLOWED_NPC_TYPES.contains(mobtype))
  83. +           {
  84. +               SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_S2);
  85. +               sm.addString("Npc Type " + mobtype + " has Protection - No Attack Allowed!");
  86. +               ((Player) target).sendPacket(sm);
  87. +               ((Player) target).sendPacket(ActionFailed.STATIC_PACKET);
  88. +               return;
  89. +           }
  90. +       }
  91.         // Get the casting time of the skill (base)
  92.         int hitTime = skill.getHitTime();
  93.         int coolTime = skill.getCoolTime();
  94. @@ -3982,7 +4007,14 @@
  95.     {
  96.         if (target == null)
  97.             return false;
  98. -      
  99. +  
  100. +       if (target instanceof Npc && Config.DISABLE_ATTACK_NPC_TYPE)
  101. +       {
  102. +           String mobtype = ((Npc) target).getTemplate().getType();
  103. +           if (Config.LIST_ALLOWED_NPC_TYPES.contains(mobtype))
  104. +               return false;
  105. +       }
  106. +  
  107.         if (target instanceof Npc || attacker instanceof Npc)
  108.             return false;
  109.        
  110. Index: java/net/sf/l2j/gameserver/model/actor/Npc.java
  111. ===================================================================
  112. --- java/net/sf/l2j/gameserver/model/actor/Npc.java (revision 49)
  113. +++ java/net/sf/l2j/gameserver/model/actor/Npc.java (working copy)
  114. @@ -210,7 +210,10 @@
  115.     @Override
  116.     public boolean isAttackable()
  117.     {
  118. -       return true;
  119. +       if (Config.NPC_ATTACKABLE || this instanceof Attackable)
  120. +           return true;
  121. +      
  122. +      return false;
  123.     }
  124.    
  125.     /**
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement