FuncEnchant.java 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 net.sf.l2j.gameserver.skills.funcs;
  16. import net.sf.l2j.gameserver.model.L2ItemInstance;
  17. import net.sf.l2j.gameserver.skills.Env;
  18. import net.sf.l2j.gameserver.skills.Stats;
  19. import net.sf.l2j.gameserver.templates.L2Item;
  20. import net.sf.l2j.gameserver.templates.L2WeaponType;
  21. public class FuncEnchant extends Func
  22. {
  23. public FuncEnchant(Stats pStat, int pOrder, Object owner, @SuppressWarnings("unused")
  24. Lambda lambda)
  25. {
  26. super(pStat, pOrder, owner);
  27. }
  28. @Override
  29. public void calc(Env env)
  30. {
  31. if (cond != null && !cond.test(env))
  32. return;
  33. //
  34. L2ItemInstance item = (L2ItemInstance) funcOwner;
  35. //
  36. if (item.getItem().getCrystalType() == L2Item.CRYSTAL_NONE)
  37. return;
  38. int enchant = item.getEnchantLevel();
  39. int overenchant = 0;
  40. if (enchant > 3)
  41. {
  42. overenchant = enchant - 3;
  43. enchant = 3;
  44. }
  45. if (stat == Stats.MAGIC_DEFENCE || stat == Stats.POWER_DEFENCE)
  46. {
  47. env.value += enchant + 3 * overenchant;
  48. return;
  49. }
  50. if (stat == Stats.MAGIC_ATTACK)
  51. {
  52. switch (item.getItem().getCrystalType())
  53. {
  54. case L2Item.CRYSTAL_S:
  55. case L2Item.CRYSTAL_S80:
  56. env.value += 4 * enchant + 8 * overenchant;
  57. break;
  58. case L2Item.CRYSTAL_A:
  59. env.value += 3 * enchant + 6 * overenchant;
  60. break;
  61. case L2Item.CRYSTAL_B:
  62. env.value += 3 * enchant + 6 * overenchant;
  63. break;
  64. case L2Item.CRYSTAL_C:
  65. env.value += 3 * enchant + 6 * overenchant;
  66. break;
  67. case L2Item.CRYSTAL_D:
  68. env.value += 2 * enchant + 4 * overenchant;
  69. break;
  70. }
  71. return;
  72. }
  73. if (item.getItemType() instanceof L2WeaponType)
  74. {
  75. L2WeaponType type = (L2WeaponType) item.getItemType();
  76. switch (item.getItem().getCrystalType())
  77. {
  78. case L2Item.CRYSTAL_A:
  79. switch(type)
  80. {
  81. case BOW:
  82. case CROSSBOW:
  83. env.value += 8 * enchant + 16 * overenchant;
  84. break;
  85. case DUALFIST:
  86. case DUAL:
  87. case SWORD:
  88. case RAPIER:
  89. if (item.getItem().getBodyPart() == L2Item.SLOT_LR_HAND)
  90. {
  91. env.value += 5 * enchant + 10 * overenchant;
  92. break;
  93. }
  94. default:
  95. env.value += 4 * enchant + 8 * overenchant;
  96. break;
  97. }
  98. break;
  99. case L2Item.CRYSTAL_B:
  100. switch(type)
  101. {
  102. case BOW:
  103. case CROSSBOW:
  104. env.value += 6 * enchant + 12 * overenchant;
  105. break;
  106. case DUALFIST:
  107. case DUAL:
  108. case SWORD:
  109. case RAPIER:
  110. if (item.getItem().getBodyPart() == L2Item.SLOT_LR_HAND)
  111. {
  112. env.value += 4 * enchant + 8 * overenchant;
  113. break;
  114. }
  115. default:
  116. env.value += 3 * enchant + 6 * overenchant;
  117. break;
  118. }
  119. break;
  120. case L2Item.CRYSTAL_C:
  121. switch(type)
  122. {
  123. case BOW:
  124. case CROSSBOW:
  125. env.value += 6 * enchant + 12 * overenchant;
  126. break;
  127. case DUALFIST:
  128. case DUAL:
  129. case SWORD:
  130. case RAPIER:
  131. if (item.getItem().getBodyPart() == L2Item.SLOT_LR_HAND)
  132. {
  133. env.value += 4 * enchant + 8 * overenchant;
  134. break;
  135. }
  136. default:
  137. env.value += 3 * enchant + 6 * overenchant;
  138. break;
  139. }
  140. break;
  141. case L2Item.CRYSTAL_D:
  142. switch(type)
  143. {
  144. case BOW:
  145. case CROSSBOW:
  146. {
  147. env.value += 4 * enchant + 8 * overenchant;
  148. break;
  149. }
  150. //case DUALFIST:
  151. //case DUAL:
  152. //case SWORD:
  153. //case RAPIER:
  154. // if (item.getItem().getBodyPart() == L2Item.SLOT_LR_HAND)
  155. // {
  156. // break;
  157. // }
  158. default:
  159. env.value += 2 * enchant + 4 * overenchant;
  160. break;
  161. }
  162. break;
  163. case L2Item.CRYSTAL_S:
  164. case L2Item.CRYSTAL_S80:
  165. switch(type)
  166. {
  167. case BOW:
  168. case CROSSBOW:
  169. env.value += 10 * enchant + 20 * overenchant;
  170. break;
  171. case DUALFIST:
  172. case DUAL:
  173. case SWORD:
  174. case RAPIER:
  175. if (item.getItem().getBodyPart() == L2Item.SLOT_LR_HAND)
  176. {
  177. env.value += 4 * enchant + 12 * overenchant;
  178. break;
  179. }
  180. default:
  181. env.value += 4 * enchant + 10 * overenchant;
  182. break;
  183. }
  184. break;
  185. }
  186. }
  187. return;
  188. }
  189. }