Hi there! I am learning Java now so just randomly checking code (Yeah, I did play Lineage 2 a lot few years ago, that's why I'm interested in opensource l2j).
org.l2jmobius.gameserver.model.stats.IStatsFunction.java
static double calcEnchantedPAtkBonus(ItemInstance item, double blessedBonus, int enchant) { switch (item.getItem().getCrystalTypePlus()) { case R: { if (item.getWeaponItem().getBodyPart() == Item.SLOT_LR_HAND) { if (item.getWeaponItem().getItemType().isRanged()) { return (12 * blessedBonus * enchant) + (24 * blessedBonus * Math.max(0, enchant - 3)); } return (7 * blessedBonus * enchant) + (14 * blessedBonus * Math.max(0, enchant - 3)); } return (6 * blessedBonus * enchant) + (12 * blessedBonus * Math.max(0, enchant - 3)); } case S: { if (item.getWeaponItem().getBodyPart() == Item.SLOT_LR_HAND) { if (item.getWeaponItem().getItemType().isRanged()) { // P. Atk. increases by 10 for bows. // Starting at +4, P. Atk. bonus double. return (10 * enchant) + (20 * Math.max(0, enchant - 3)); } // P. Atk. increases by 6 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons. // Starting at +4, P. Atk. bonus double. return (6 * enchant) + (12 * Math.max(0, enchant - 3)); } // P. Atk. increases by 5 for one-handed swords, one-handed blunts, daggers, spears, and other weapons. // Starting at +4, P. Atk. bonus double. return (5 * enchant) + (10 * Math.max(0, enchant - 3)); } case A: { if (item.getWeaponItem().getBodyPart() == Item.SLOT_LR_HAND) { if (item.getWeaponItem().getItemType().isRanged()) { // P. Atk. increases by 8 for bows. // Starting at +4, P. Atk. bonus double. return (8 * enchant) + (16 * Math.max(0, enchant - 3)); } // P. Atk. increases by 5 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons. // Starting at +4, P. Atk. bonus double. return (5 * enchant) + (10 * Math.max(0, enchant - 3)); } // P. Atk. increases by 4 for one-handed swords, one-handed blunts, daggers, spears, and other weapons. // Starting at +4, P. Atk. bonus double. return (4 * enchant) + (8 * Math.max(0, enchant - 3)); } case B: case C: { if (item.getWeaponItem().getBodyPart() == Item.SLOT_LR_HAND) { if (item.getWeaponItem().getItemType().isRanged()) { // P. Atk. increases by 6 for bows. // Starting at +4, P. Atk. bonus double. return (6 * enchant) + (12 * Math.max(0, enchant - 3)); } // P. Atk. increases by 4 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons. // Starting at +4, P. Atk. bonus double. return (4 * enchant) + (8 * Math.max(0, enchant - 3)); } // P. Atk. increases by 3 for one-handed swords, one-handed blunts, daggers, spears, and other weapons. // Starting at +4, P. Atk. bonus double. return (3 * enchant) + (6 * Math.max(0, enchant - 3)); } default: { if (item.getWeaponItem().getItemType().isRanged()) { // Bows increase by 4. // Starting at +4, P. Atk. bonus double. return (4 * enchant) + (8 * Math.max(0, enchant - 3)); } // P. Atk. increases by 2 for all weapons with the exception of bows. // Starting at +4, P. Atk. bonus double. return (2 * enchant) + (4 * Math.max(0, enchant - 3)); } } }
static double calcEnchantedPAtkBonus(ItemInstance item, double blessedBonus, int enchant) { switch (item.getItem().getCrystalTypePlus()) { case R: { if (item.getWeaponItem().getBodyPart() == Item.SLOT_LR_HAND && item.getWeaponItem().getItemType() != POLE) { if (item.getWeaponItem().getItemType().isRanged()) { return (12 * blessedBonus * enchant) + (24 * blessedBonus * Math.max(0, enchant - 3)); } return (7 * blessedBonus * enchant) + (14 * blessedBonus * Math.max(0, enchant - 3)); } return (6 * blessedBonus * enchant) + (12 * blessedBonus * Math.max(0, enchant - 3)); } case S: { if (item.getWeaponItem().getBodyPart() == Item.SLOT_LR_HAND && item.getWeaponItem().getItemType() != POLE) { if (item.getWeaponItem().getItemType().isRanged()) { // P. Atk. increases by 10 for bows. // Starting at +4, P. Atk. bonus double. return (10 * enchant) + (20 * Math.max(0, enchant - 3)); } // P. Atk. increases by 6 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons. // Starting at +4, P. Atk. bonus double. return (6 * enchant) + (12 * Math.max(0, enchant - 3)); } // P. Atk. increases by 5 for one-handed swords, one-handed blunts, daggers, spears, and other weapons. // Starting at +4, P. Atk. bonus double. return (5 * enchant) + (10 * Math.max(0, enchant - 3)); } case A: { if (item.getWeaponItem().getBodyPart() == Item.SLOT_LR_HAND && item.getWeaponItem().getItemType() != POLE) { if (item.getWeaponItem().getItemType().isRanged()) { // P. Atk. increases by 8 for bows. // Starting at +4, P. Atk. bonus double. return (8 * enchant) + (16 * Math.max(0, enchant - 3)); } // P. Atk. increases by 5 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons. // Starting at +4, P. Atk. bonus double. return (5 * enchant) + (10 * Math.max(0, enchant - 3)); } // P. Atk. increases by 4 for one-handed swords, one-handed blunts, daggers, spears, and other weapons. // Starting at +4, P. Atk. bonus double. return (4 * enchant) + (8 * Math.max(0, enchant - 3)); } case B: case C: { if (item.getWeaponItem().getBodyPart() == Item.SLOT_LR_HAND && item.getWeaponItem().getItemType() != POLE) { if (item.getWeaponItem().getItemType().isRanged()) { // P. Atk. increases by 6 for bows. // Starting at +4, P. Atk. bonus double. return (6 * enchant) + (12 * Math.max(0, enchant - 3)); } // P. Atk. increases by 4 for two-handed swords, two-handed blunts, dualswords, and two-handed combat weapons. // Starting at +4, P. Atk. bonus double. return (4 * enchant) + (8 * Math.max(0, enchant - 3)); } // P. Atk. increases by 3 for one-handed swords, one-handed blunts, daggers, spears, and other weapons. // Starting at +4, P. Atk. bonus double. return (3 * enchant) + (6 * Math.max(0, enchant - 3)); } default: { if (item.getWeaponItem().getItemType().isRanged()) { // Bows increase by 4. // Starting at +4, P. Atk. bonus double. return (4 * enchant) + (8 * Math.max(0, enchant - 3)); } // P. Atk. increases by 2 for all weapons with the exception of bows. // Starting at +4, P. Atk. bonus double. return (2 * enchant) + (4 * Math.max(0, enchant - 3)); } } }
if ((item.getWeaponItem().getBodyPart() == Item.SLOT_LR_HAND) && (item.getWeaponItem().getItemType() != WeaponType.POLE))