HotSprings.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package ai.group_template;
  20. import ai.npc.AbstractNpcAI;
  21. import com.l2jserver.gameserver.datatables.SkillData;
  22. import com.l2jserver.gameserver.model.actor.L2Character;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.skills.BuffInfo;
  26. import com.l2jserver.gameserver.model.skills.Skill;
  27. /**
  28. * Hot Springs AI.
  29. * @author Pandragon
  30. */
  31. public final class HotSprings extends AbstractNpcAI
  32. {
  33. // NPCs
  34. private static final int BANDERSNATCHLING = 21314;
  35. private static final int FLAVA = 21316;
  36. private static final int ATROXSPAWN = 21317;
  37. private static final int NEPENTHES = 21319;
  38. private static final int ATROX = 21321;
  39. private static final int BANDERSNATCH = 21322;
  40. // Skills
  41. private static final int RHEUMATISM = 4551;
  42. private static final int CHOLERA = 4552;
  43. private static final int FLU = 4553;
  44. private static final int MALARIA = 4554;
  45. // Misc
  46. private static final int DISEASE_CHANCE = 10;
  47. private HotSprings()
  48. {
  49. super(HotSprings.class.getSimpleName(), "ai/group_template");
  50. addAttackId(BANDERSNATCHLING, FLAVA, ATROXSPAWN, NEPENTHES, ATROX, BANDERSNATCH);
  51. }
  52. @Override
  53. public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon)
  54. {
  55. if (getRandom(100) < DISEASE_CHANCE)
  56. {
  57. tryToInfect(npc, attacker, MALARIA);
  58. }
  59. if (getRandom(100) < DISEASE_CHANCE)
  60. {
  61. switch (npc.getId())
  62. {
  63. case BANDERSNATCHLING:
  64. case ATROX:
  65. {
  66. tryToInfect(npc, attacker, RHEUMATISM);
  67. break;
  68. }
  69. case FLAVA:
  70. case NEPENTHES:
  71. {
  72. tryToInfect(npc, attacker, CHOLERA);
  73. break;
  74. }
  75. case ATROXSPAWN:
  76. case BANDERSNATCH:
  77. {
  78. tryToInfect(npc, attacker, FLU);
  79. break;
  80. }
  81. }
  82. }
  83. return super.onAttack(npc, attacker, damage, isSummon);
  84. }
  85. private void tryToInfect(L2Npc npc, L2Character player, int diseaseId)
  86. {
  87. final BuffInfo info = player.getEffectList().getBuffInfoBySkillId(diseaseId);
  88. final int skillLevel = (info == null) ? 1 : (info.getSkill().getLevel() < 10) ? info.getSkill().getLevel() + 1 : 10;
  89. final Skill skill = SkillData.getInstance().getSkill(diseaseId, skillLevel);
  90. if ((skill != null) && !npc.isCastingNow() && npc.checkDoCastConditions(skill))
  91. {
  92. npc.setTarget(player);
  93. npc.doCast(skill);
  94. }
  95. }
  96. public static void main(String[] args)
  97. {
  98. new HotSprings();
  99. }
  100. }