Advertisement
CostyKiller

Homunculus counter for killed mobs

Jun 6th, 2021
1,140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.63 KB | None | 0 0
  1. Index: dist/game/data/scripts/ai/others/HomunculusKilledMobsCounter.java
  2. ===================================================================
  3. --- dist/game/data/scripts/ai/others/HomunculusKilledMobsCounter.java   (nonexistent)
  4. +++ dist/game/data/scripts/ai/others/HomunculusKilledMobsCounter.java   (working copy)
  5. @@ -0,0 +1,61 @@
  6. +/*
  7. + * This file is part of the L2J Mobius project.
  8. + *
  9. + * This program is free software: you can redistribute it and/or modify
  10. + * it under the terms of the GNU General Public License as published by
  11. + * the Free Software Foundation, either version 3 of the License, or
  12. + * (at your option) any later version.
  13. + *
  14. + * This program is distributed in the hope that it will be useful,
  15. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. + * General Public License for more details.
  18. + *
  19. + * You should have received a copy of the GNU General Public License
  20. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. + */
  22. +package ai.others;
  23. +
  24. +import org.l2jmobius.gameserver.model.actor.Creature;
  25. +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
  26. +import org.l2jmobius.gameserver.model.events.EventType;
  27. +import org.l2jmobius.gameserver.model.events.ListenerRegisterType;
  28. +import org.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
  29. +import org.l2jmobius.gameserver.model.events.annotations.RegisterType;
  30. +import org.l2jmobius.gameserver.model.events.impl.creature.npc.OnAttackableKill;
  31. +import org.l2jmobius.gameserver.model.variables.PlayerVariables;
  32. +import org.l2jmobius.gameserver.network.serverpackets.homunculus.ExHomunculusPointInfo;
  33. +
  34. +import ai.AbstractNpcAI;
  35. +
  36. +/**
  37. + * @author CostyKiller
  38. + */
  39. +public class HomunculusKilledMobsCounter extends AbstractNpcAI
  40. +{
  41. +  
  42. +   @RegisterEvent(EventType.ON_ATTACKABLE_KILL)
  43. +   @RegisterType(ListenerRegisterType.GLOBAL_MONSTERS)
  44. +   public void onAttackableKill(OnAttackableKill event)
  45. +   {
  46. +       final Creature creature = event.getTarget();
  47. +       if ((creature != null) && creature.isMonster())
  48. +       {
  49. +           final PlayerInstance player = event.getAttacker().getActingPlayer();
  50. +           if (player != null)
  51. +           {
  52. +               int killedMobs = player.getVariables().getInt(PlayerVariables.HOMUNCULUS_KILLED_MOBS, 0);
  53. +               if (killedMobs < 500)
  54. +               {
  55. +                   player.getVariables().set(PlayerVariables.HOMUNCULUS_KILLED_MOBS, killedMobs + 1);
  56. +                   player.sendPacket(new ExHomunculusPointInfo(player));
  57. +               }
  58. +           }
  59. +       }
  60. +   }
  61. +  
  62. +   public static void main(String[] args)
  63. +   {
  64. +       new HomunculusKilledMobsCounter();
  65. +   }
  66. +}
  67. \ No newline at end of file
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement