Func.java 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.skills.funcs;
  16. import com.l2jserver.gameserver.skills.Env;
  17. import com.l2jserver.gameserver.skills.Stats;
  18. import com.l2jserver.gameserver.skills.conditions.Condition;
  19. /**
  20. * A Func object is a component of a Calculator created to manage and dynamically calculate the effect of a character property (ex : MAX_HP, REGENERATE_HP_RATE...).
  21. * In fact, each calculator is a table of Func object in which each Func represents a mathematic function : <BR><BR>
  22. *
  23. * FuncAtkAccuracy -> Math.sqrt(_player.getDEX())*6+_player.getLevel()<BR><BR>
  24. *
  25. * When the calc method of a calculator is launched, each mathematic function is called according to its priority <B>_order</B>.
  26. * Indeed, Func with lowest priority order is executed firsta and Funcs with the same order are executed in unspecified order.
  27. * The result of the calculation is stored in the value property of an Env class instance.<BR><BR>
  28. *
  29. */
  30. public abstract class Func {
  31. /** Statistics, that is affected by this function (See L2Character.CALCULATOR_XXX constants) */
  32. public final Stats stat;
  33. /**
  34. * Order of functions calculation.
  35. * Functions with lower order are executed first.
  36. * Functions with the same order are executed in unspecified order.
  37. * Usually add/substruct functions has lowest order,
  38. * then bonus/penalty functions (multiplay/divide) are
  39. * applied, then functions that do more complex calculations
  40. * (non-linear functions).
  41. */
  42. public final int order;
  43. /**
  44. * Owner can be an armor, weapon, skill, system event, quest, etc
  45. * Used to remove all functions added by this owner.
  46. */
  47. public final Object funcOwner;
  48. /** Function may be disabled by attached condition. */
  49. public Condition cond;
  50. /**
  51. * Constructor of Func.<BR><BR>
  52. * @param pStat
  53. * @param pOrder
  54. * @param owner
  55. */
  56. public Func(Stats pStat, int pOrder, Object owner)
  57. {
  58. stat = pStat;
  59. order = pOrder;
  60. funcOwner = owner;
  61. }
  62. /**
  63. * Add a condition to the Func.<BR><BR>
  64. * @param pCond
  65. */
  66. public void setCondition(Condition pCond)
  67. {
  68. cond = pCond;
  69. }
  70. /**
  71. * Run the mathematic function of the Func.<BR><BR>
  72. * @param env
  73. */
  74. public abstract void calc(Env env);
  75. }