IKillerChanceModifierStrategy.java 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.model.actor.L2Character;
  22. import com.l2jserver.gameserver.model.drops.GeneralDropItem;
  23. import com.l2jserver.gameserver.model.drops.IDropItem;
  24. import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  25. import com.l2jserver.gameserver.util.Util;
  26. /**
  27. * @author Battlecruiser
  28. */
  29. public interface IKillerChanceModifierStrategy extends INonGroupedKillerChanceModifierStrategy
  30. {
  31. public static final IKillerChanceModifierStrategy DEFAULT_STRATEGY = (item, victim, killer) ->
  32. {
  33. int levelDifference = victim.getLevel() - killer.getLevel();
  34. if ((victim.isRaid()) && Config.DEEPBLUE_DROP_RULES_RAID)
  35. {
  36. // FIXME: Config?
  37. return Math.max(0, Math.min(1, (levelDifference * 0.15) + 1));
  38. }
  39. else if (Config.DEEPBLUE_DROP_RULES)
  40. {
  41. return Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100.0) / 100;
  42. }
  43. return 1;
  44. };
  45. public static final INonGroupedKillerChanceModifierStrategy DEFAULT_NONGROUP_STRATEGY = (item, victim, killer) ->
  46. {
  47. if (((!(victim.isRaid())) && Config.DEEPBLUE_DROP_RULES) || ((victim.isRaid()) && Config.DEEPBLUE_DROP_RULES_RAID))
  48. {
  49. int levelDifference = victim.getLevel() - killer.getLevel();
  50. if (item.getItemId() == Inventory.ADENA_ID)
  51. {
  52. return Util.map(levelDifference, -Config.DROP_ADENA_MAX_LEVEL_DIFFERENCE, -Config.DROP_ADENA_MIN_LEVEL_DIFFERENCE, Config.DROP_ADENA_MIN_LEVEL_GAP_CHANCE, 100.0) / 100;
  53. }
  54. return Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100.0) / 100;
  55. }
  56. return 1;
  57. };
  58. IKillerChanceModifierStrategy NO_RULES = (item, victim, killer) -> 1;
  59. public double getKillerChanceModifier(IDropItem item, L2Character victim, L2Character killer);
  60. @Override
  61. public default double getKillerChanceModifier(GeneralDropItem item, L2Character victim, L2Character killer)
  62. {
  63. return getKillerChanceModifier((IDropItem) item, victim, killer);
  64. }
  65. }