IChanceMultiplierStrategy.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server 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 Server 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 com.l2jserver.gameserver.model.drops.strategy;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.datatables.ItemTable;
  22. import com.l2jserver.gameserver.model.actor.L2Character;
  23. import com.l2jserver.gameserver.model.drops.GeneralDropItem;
  24. import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  25. /**
  26. * @author Battlecruiser
  27. */
  28. public interface IChanceMultiplierStrategy
  29. {
  30. public static final IChanceMultiplierStrategy DROP = DEFAULT_STRATEGY(Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER);
  31. public static final IChanceMultiplierStrategy SPOIL = DEFAULT_STRATEGY(Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER);
  32. public static final IChanceMultiplierStrategy STATIC = (item, victim) -> 1;
  33. public static final IChanceMultiplierStrategy QUEST = (item, victim) ->
  34. {
  35. double championmult;
  36. if ((item.getItemId() == Inventory.ADENA_ID) || (item.getItemId() == Inventory.ANCIENT_ADENA_ID))
  37. {
  38. championmult = Config.L2JMOD_CHAMPION_ADENAS_REWARDS;
  39. }
  40. else
  41. {
  42. championmult = Config.L2JMOD_CHAMPION_REWARDS;
  43. }
  44. return (Config.L2JMOD_CHAMPION_ENABLE && (victim != null) && victim.isChampion()) ? (Config.RATE_QUEST_DROP * championmult) : Config.RATE_QUEST_DROP;
  45. };
  46. public static IChanceMultiplierStrategy DEFAULT_STRATEGY(final double defaultMultiplier)
  47. {
  48. return (item, victim) ->
  49. {
  50. float multiplier = 1;
  51. if (victim.isChampion())
  52. {
  53. multiplier *= item.getItemId() != Inventory.ADENA_ID ? Config.L2JMOD_CHAMPION_REWARDS : Config.L2JMOD_CHAMPION_ADENAS_REWARDS;
  54. }
  55. Float dropChanceMultiplier = Config.RATE_DROP_CHANCE_MULTIPLIER.get(item.getItemId());
  56. if (dropChanceMultiplier != null)
  57. {
  58. multiplier *= dropChanceMultiplier;
  59. }
  60. else if (ItemTable.getInstance().getTemplate(item.getItemId()).hasExImmediateEffect())
  61. {
  62. multiplier *= Config.RATE_HERB_DROP_CHANCE_MULTIPLIER;
  63. }
  64. else if (victim.isRaid())
  65. {
  66. multiplier *= Config.RATE_RAID_DROP_CHANCE_MULTIPLIER;
  67. }
  68. else
  69. {
  70. multiplier *= defaultMultiplier;
  71. }
  72. return multiplier;
  73. };
  74. }
  75. public double getChanceMultiplier(GeneralDropItem item, L2Character victim);
  76. }