Advertisement
Giardev

FIX FESTIVAL SWEEPER L2JACIS

Jan 26th, 2022
1,290
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/skillhandlers/Sweep.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/skillhandlers/Sweep.java
  2. index a18f4de..38e83cf 100644
  3. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/skillhandlers/Sweep.java
  4. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/skillhandlers/Sweep.java
  5. @@ -49,6 +49,9 @@
  6.             // Reset variables.
  7.             monster.getSpoilState().clear();
  8.         }
  9. +      
  10. +       if (skill.hasSelfEffects())
  11. +           skill.getEffectsSelf(activeChar);
  12.     }
  13.    
  14.     @Override
  15. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/targethandlers/TargetAreaCorpseMob.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/targethandlers/TargetAreaCorpseMob.java
  16. index a88f6ba..5613cdb 100644
  17. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/targethandlers/TargetAreaCorpseMob.java
  18. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/targethandlers/TargetAreaCorpseMob.java
  19. @@ -4,13 +4,18 @@
  20.  import java.util.List;
  21.  
  22.  import net.sf.l2j.gameserver.enums.skills.SkillTargetType;
  23. +import net.sf.l2j.gameserver.enums.skills.SkillType;
  24.  import net.sf.l2j.gameserver.geoengine.GeoEngine;
  25.  import net.sf.l2j.gameserver.handler.ITargetHandler;
  26.  import net.sf.l2j.gameserver.model.actor.Attackable;
  27.  import net.sf.l2j.gameserver.model.actor.Creature;
  28.  import net.sf.l2j.gameserver.model.actor.Playable;
  29. +import net.sf.l2j.gameserver.model.actor.instance.Monster;
  30. +import net.sf.l2j.gameserver.model.actor.instance.Pet;
  31. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  32.  import net.sf.l2j.gameserver.network.SystemMessageId;
  33.  import net.sf.l2j.gameserver.skills.L2Skill;
  34. +import net.sf.l2j.gameserver.taskmanager.DecayTaskManager;
  35.  
  36.  public class TargetAreaCorpseMob implements ITargetHandler
  37.  {
  38. @@ -28,7 +33,17 @@
  39.        
  40.         for (Creature creature : target.getKnownTypeInRadius(Creature.class, skill.getSkillRadius()))
  41.         {
  42. -           if (creature == caster || creature.isDead() || !GeoEngine.getInstance().canSeeTarget(target, creature))
  43. +           if (creature == caster || !GeoEngine.getInstance().canSeeTarget(target, creature))
  44. +               continue;
  45. +          
  46. +           if (skill.getId() == 444)
  47. +           {
  48. +               if (creature instanceof Attackable && creature.isDead())
  49. +                   list.add(creature);
  50. +              
  51. +               continue;
  52. +           }
  53. +           else if (creature.isDead())
  54.                 continue;
  55.            
  56.             if (caster instanceof Playable && (creature instanceof Attackable || creature instanceof Playable))
  57. @@ -55,11 +70,44 @@
  58.     @Override
  59.     public boolean meetCastConditions(Playable caster, Creature target, L2Skill skill, boolean isCtrlPressed)
  60.     {
  61. -       if ((!(target instanceof Attackable)) || !target.isDead())
  62. +       // Verify if a corpse exists. Can't do anything on Pets.
  63. +       final Long time = DecayTaskManager.getInstance().get(target);
  64. +       if (time == null || target instanceof Pet)
  65.         {
  66.             caster.sendPacket(SystemMessageId.INVALID_TARGET);
  67.             return false;
  68.         }
  69. +      
  70. +       // Harvest can be done anytime.
  71. +       if (skill.getSkillType() == SkillType.HARVEST)
  72. +       {
  73. +           if (!(target instanceof Monster))
  74. +           {
  75. +               caster.sendPacket(SystemMessageId.THE_HARVEST_FAILED_BECAUSE_THE_SEED_WAS_NOT_SOWN);
  76. +               return false;
  77. +           }
  78. +          
  79. +           return true;
  80. +       }
  81. +      
  82. +       // Cast NpcTemplate over Creature template since only pets, servitors and NPCs are stored into DecayTaskManager, and all inherits from NpcTemplate.
  83. +       final NpcTemplate template = (NpcTemplate) target.getTemplate();
  84. +      
  85. +       // Check last corpse action time. That behavior exists whenever the target isn't seeded or spoiled.
  86. +       final boolean isSeededOrSpoiled = target instanceof Monster && (((Monster) target).getSeedState().isSeeded() || ((Monster) target).getSpoilState().isSpoiled());
  87. +       if (!isSeededOrSpoiled && System.currentTimeMillis() >= time - (template.getCorpseTime() * 1000 / 2))
  88. +       {
  89. +           caster.sendPacket(SystemMessageId.CORPSE_TOO_OLD_SKILL_NOT_USED);
  90. +           return false;
  91. +       }
  92. +      
  93. +       // Sweep always end as true if the target is a Monster ; otherwise, it's always false.
  94. +       if (skill.getSkillType() == SkillType.SWEEP && !(target instanceof Monster))
  95. +       {
  96. +           caster.sendPacket(SystemMessageId.SWEEPER_FAILED_TARGET_NOT_SPOILED);
  97. +           return false;
  98. +       }
  99. +      
  100.         return true;
  101.     }
  102.  }
  103. \ No newline at end of file
  104. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/targethandlers/TargetCorpseMob.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/targethandlers/TargetCorpseMob.java
  105. index 4fc5947..03b4055 100644
  106. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/targethandlers/TargetCorpseMob.java
  107. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/handler/targethandlers/TargetCorpseMob.java
  108. @@ -3,10 +3,11 @@
  109.  import net.sf.l2j.gameserver.enums.skills.SkillTargetType;
  110.  import net.sf.l2j.gameserver.enums.skills.SkillType;
  111.  import net.sf.l2j.gameserver.handler.ITargetHandler;
  112. -import net.sf.l2j.gameserver.model.actor.Attackable;
  113.  import net.sf.l2j.gameserver.model.actor.Creature;
  114.  import net.sf.l2j.gameserver.model.actor.Playable;
  115.  import net.sf.l2j.gameserver.model.actor.instance.Monster;
  116. +import net.sf.l2j.gameserver.model.actor.instance.Pet;
  117. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  118.  import net.sf.l2j.gameserver.network.SystemMessageId;
  119.  import net.sf.l2j.gameserver.skills.L2Skill;
  120.  import net.sf.l2j.gameserver.taskmanager.DecayTaskManager;
  121. @@ -37,18 +38,44 @@
  122.     @Override
  123.     public boolean meetCastConditions(Playable caster, Creature target, L2Skill skill, boolean isCtrlPressed)
  124.     {
  125. -       if (!(target instanceof Attackable) || !target.isDead())
  126. +       // Verify if a corpse exists. Can't do anything on Pets.
  127. +       final Long time = DecayTaskManager.getInstance().get(target);
  128. +       if (time == null || target instanceof Pet)
  129.         {
  130.             caster.sendPacket(SystemMessageId.INVALID_TARGET);
  131.             return false;
  132.         }
  133. +
  134. +       // Harvest can be done anytime.
  135. +       if (skill.getSkillType() == SkillType.HARVEST)
  136. +       {
  137. +           if (!(target instanceof Monster))
  138. +           {
  139. +               caster.sendPacket(SystemMessageId.THE_HARVEST_FAILED_BECAUSE_THE_SEED_WAS_NOT_SOWN);
  140. +               return false;
  141. +           }
  142. +          
  143. +           return true;
  144. +       }
  145. +
  146. +       // Cast NpcTemplate over Creature template since only pets, servitors and NPCs are stored into DecayTaskManager, and all inherits from NpcTemplate.
  147. +       final NpcTemplate template = (NpcTemplate) target.getTemplate();
  148.        
  149. -       if (target instanceof Monster && skill.getSkillType() == SkillType.DRAIN && !DecayTaskManager.getInstance().isCorpseActionAllowed((Monster) target))
  150. +       // Check last corpse action time. That behavior exists whenever the target isn't seeded or spoiled.
  151. +       final boolean isSeededOrSpoiled = target instanceof Monster && (((Monster) target).getSeedState().isSeeded() || ((Monster) target).getSpoilState().isSpoiled());
  152. +       if (!isSeededOrSpoiled && System.currentTimeMillis() >= time - (template.getCorpseTime() * 1000 / 2))
  153.         {
  154.             caster.sendPacket(SystemMessageId.CORPSE_TOO_OLD_SKILL_NOT_USED);
  155.             return false;
  156.         }
  157.        
  158. +       // Sweep always end as true if the target is a Monster ; otherwise, it's always false.
  159. +       if (skill.getSkillType() == SkillType.SWEEP && !(target instanceof Monster))
  160. +       {
  161. +           caster.sendPacket(SystemMessageId.SWEEPER_FAILED_TARGET_NOT_SPOILED);
  162. +           return false;
  163. +       }
  164. +      
  165.         return true;
  166.     }
  167.  }
  168. diff --git a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/taskmanager/DecayTaskManager.java b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/taskmanager/DecayTaskManager.java
  169. index 1b5bfb7..17dc930 100644
  170. --- a/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/taskmanager/DecayTaskManager.java
  171. +++ b/L2jOne_C6_Interlude/java/net/sf/l2j/gameserver/taskmanager/DecayTaskManager.java
  172. @@ -56,6 +56,11 @@
  173.         }
  174.     }
  175.    
  176. +   public final Long get(Creature creature)
  177. +   {
  178. +       return _creatures.get(creature);
  179. +   }
  180. +  
  181.     /**
  182.      * Adds a {@link Creature} to the {@link DecayTaskManager} with additional interval.
  183.      * @param creature : The {@link Creature} to be added.
  184. @@ -79,33 +84,11 @@
  185.     /**
  186.      * Removes the {@link Creature} passed as parameter from the {@link DecayTaskManager}.
  187.      * @param creature : The {@link Creature} to be removed.
  188. +    * @return True if an entry was successfully removed or false otherwise.
  189.      */
  190. -   public final void cancel(Creature creature)
  191. +   public final boolean cancel(Creature creature)
  192.     {
  193. -       _creatures.remove(creature);
  194. -   }
  195. -  
  196. -   /**
  197. -    * Removes the {@link Monster} passed as parameter from the {@link DecayTaskManager}.
  198. -    * @param monster : The {@link Monster} to be tested.
  199. -    * @return boolean : True, when action can be applied on a corpse.
  200. -    */
  201. -   public final boolean isCorpseActionAllowed(Monster monster)
  202. -   {
  203. -       // Verify if a corpse exists.
  204. -       Long time = _creatures.get(monster);
  205. -       if (time == null)
  206. -           return false;
  207. -      
  208. -       // Get corpse action interval, which is half the corpse decay.
  209. -       int corpseTime = monster.getTemplate().getCorpseTime() * 1000 / 2;
  210. -      
  211. -       // If the Monster is spoiled or seeded, double the corpse action interval.
  212. -       if (monster.getSpoilState().isSpoiled() || monster.getSeedState().isSeeded())
  213. -           corpseTime *= 2;
  214. -      
  215. -       // Check last corpse action time.
  216. -       return System.currentTimeMillis() < time - corpseTime;
  217. +       return _creatures.remove(creature) != null;
  218.     }
  219.    
  220.     public static final DecayTaskManager getInstance()
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement