1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-13 10:42:54 +00:00

Character calculators

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-23 23:49:19 -03:00
parent 1909bb06cc
commit a1b1211616
206 changed files with 4749 additions and 1170 deletions

View File

@@ -157,6 +157,10 @@ public class CharacterAppearance {
* <b>This is not persisted!</b>
*/
private RGBColor titleColor = RGBColor.fromInteger(0xFFFF77);
/**
* The visibility status
*/
private boolean visible;
public CharacterAppearance(L2Character character) {
this.character = character;
@@ -267,6 +271,21 @@ public class CharacterAppearance {
this.titleColor = titleColor;
}
/**
* @return the visibility state
*/
public boolean isVisible() {
return visible;
}
/**
* @param visible
* the visibility state to set
*/
public void setVisible(boolean visible) {
this.visible = visible;
}
/**
* @return the character
*/

View File

@@ -31,22 +31,19 @@ public enum CharacterClass {
HUMAN_FIGHTER), GLADIATOR(0x02, WARRIOR), WARLORD(0x03, WARRIOR), KNIGHT(
0x04, HUMAN_FIGHTER), PALADIN(0x05, KNIGHT), DARK_AVENGER(0x06,
KNIGHT), ROGUE(0x07, HUMAN_FIGHTER), TREASURE_HUNTER(0x08, ROGUE), HAWKEYE(
0x09, ROGUE),
// 3rd classes
DUELIST(0x58, GLADIATOR), DREADNOUGHT(0x59, WARLORD), PHOENIX_KNIGHT(0x5a,
PALADIN), HELL_KNIGHT(0x5b, DARK_AVENGER), SAGITTARIUS(0x5c,
0x09, ROGUE), DUELIST(0x58, GLADIATOR), DREADNOUGHT(0x59, WARLORD), PHOENIX_KNIGHT(
0x5a, PALADIN), HELL_KNIGHT(0x5b, DARK_AVENGER), SAGITTARIUS(0x5c,
HAWKEYE), ADVENTURER(0x5d, TREASURE_HUNTER),
/**
* Human mystic
*/
HUMAN_MYSTIC(0x0a, ClassType.MYSTIC, ActorRace.HUMAN), WIZARD(0x0b, HUMAN_MYSTIC), SORCEROR(
0x0c, WIZARD), NECROMANCER(0x0d, WIZARD), WARLOCK(0x0e, true,
WIZARD), CLERIC(0x0f, ClassType.PRIEST, HUMAN_MYSTIC), BISHOP(0x10,
CLERIC), PROPHET(0x11, CLERIC),
// 3rd classes
ARCHMAGE(0x5e, SORCEROR), SOULTAKER(0x5f, NECROMANCER), ARCANA_LORD(0x60,
WARLOCK), CARDINAL(0x61, BISHOP), HIEROPHANT(0x62, PROPHET),
HUMAN_MYSTIC(0x0a, ClassType.MYSTIC, ActorRace.HUMAN), WIZARD(0x0b,
HUMAN_MYSTIC), SORCEROR(0x0c, WIZARD), NECROMANCER(0x0d, WIZARD), WARLOCK(
0x0e, true, WIZARD), CLERIC(0x0f, ClassType.PRIEST, HUMAN_MYSTIC), BISHOP(
0x10, CLERIC), PROPHET(0x11, CLERIC), ARCHMAGE(0x5e, SORCEROR), SOULTAKER(
0x5f, NECROMANCER), ARCANA_LORD(0x60, WARLOCK), CARDINAL(0x61,
BISHOP), HIEROPHANT(0x62, PROPHET),
/**
* Elven fighter
@@ -54,9 +51,8 @@ public enum CharacterClass {
ELVEN_FIGHTER(0x12, ClassType.FIGHTER, ActorRace.ELF), ELVEN_KNIGHT(0x13,
ELVEN_FIGHTER), TEMPLE_KNIGHT(0x14, ELVEN_KNIGHT), SWORD_SINGER(
0x15, ELVEN_KNIGHT), ELVEN_SCOUT(0x16, ELVEN_FIGHTER), PLAINS_WALKER(
0x17, ELVEN_SCOUT), SILVER_RANGER(0x18, ELVEN_SCOUT),
// 3rd classes
EVA_TEMPLAR(0x63, TEMPLE_KNIGHT), SWORD_MUSE(0x64, SWORD_SINGER), WIND_RIDER(
0x17, ELVEN_SCOUT), SILVER_RANGER(0x18, ELVEN_SCOUT), EVA_TEMPLAR(
0x63, TEMPLE_KNIGHT), SWORD_MUSE(0x64, SWORD_SINGER), WIND_RIDER(
0x65, PLAINS_WALKER), MOONLIGHT_SENTINEL(0x66, SILVER_RANGER),
/**
* Elven mystic
@@ -64,20 +60,17 @@ public enum CharacterClass {
ELVEN_MYSTIC(0x19, ClassType.MYSTIC, ActorRace.ELF), ELVEN_WIZARD(0x1a,
ELVEN_MYSTIC), SPELLSINGER(0x1b, ELVEN_WIZARD), ELEMENTAL_SUMMONER(
0x1c, true, ELVEN_WIZARD), ORACLE(0x1d, ClassType.PRIEST,
ELVEN_MYSTIC), ELDER(0x1e, ORACLE),
// 3rd classes
MYSTIC_MUSE(0x67, SPELLSINGER), ELEMENTAL_MASTER(0x68, ELEMENTAL_SUMMONER), EVA_SAINT(
0x69, ELDER),
ELVEN_MYSTIC), ELDER(0x1e, ORACLE), MYSTIC_MUSE(0x67, SPELLSINGER), ELEMENTAL_MASTER(
0x68, ELEMENTAL_SUMMONER), EVA_SAINT(0x69, ELDER),
/**
* Dark elf fighter
*/
DARK_FIGHTER(0x1f, ClassType.FIGHTER, ActorRace.DARK_ELF), PALUS_KNIGHT(0x20,
DARK_FIGHTER), SHILLIEN_KNIGHT(0x21, PALUS_KNIGHT), BLADEDANCER(
DARK_FIGHTER(0x1f, ClassType.FIGHTER, ActorRace.DARK_ELF), PALUS_KNIGHT(
0x20, DARK_FIGHTER), SHILLIEN_KNIGHT(0x21, PALUS_KNIGHT), BLADEDANCER(
0x22, PALUS_KNIGHT), ASSASSIN(0x23, DARK_FIGHTER), ABYSS_WALKER(
0x24, ASSASSIN), PHANTOM_RANGER(0x25, ASSASSIN),
// 3rd classes
SHILLIEN_TEMPLAR(0x6a, SHILLIEN_KNIGHT), spectralDancer(0x6b, BLADEDANCER), GHOST_HUNTER(
0x24, ASSASSIN), PHANTOM_RANGER(0x25, ASSASSIN), SHILLIEN_TEMPLAR(
0x6a, SHILLIEN_KNIGHT), spectralDancer(0x6b, BLADEDANCER), GHOST_HUNTER(
0x6c, ABYSS_WALKER), GHOST_SENTINEL(0x6d, PHANTOM_RANGER),
/**
@@ -86,9 +79,8 @@ public enum CharacterClass {
DARK_MYSTIC(0x26, ClassType.MYSTIC, ActorRace.DARK_ELF), DARK_WIZARD(0x27,
DARK_MYSTIC), SPELLHOWLER(0x28, DARK_WIZARD), PHANTOM_SUMMONER(
0x29, true, DARK_WIZARD), SHILLIEN_ORACLE(0x2a, ClassType.PRIEST,
DARK_MYSTIC), SHILLIEN_ELDER(0x2b, SHILLIEN_ORACLE),
// 3rd classes
STORM_SCREAMER(0x6e, SPELLHOWLER), SPECTRAL_MASTER(0x6f, PHANTOM_SUMMONER), SHILLIEAN_SAINT(
DARK_MYSTIC), SHILLIEN_ELDER(0x2b, SHILLIEN_ORACLE), STORM_SCREAMER(
0x6e, SPELLHOWLER), SPECTRAL_MASTER(0x6f, PHANTOM_SUMMONER), SHILLIEAN_SAINT(
0x70, SHILLIEN_ELDER),
/**
@@ -96,26 +88,24 @@ public enum CharacterClass {
*/
ORC_FIGHTER(0x2c, ClassType.FIGHTER, ActorRace.ORC), ORC_RAIDER(0x2d,
ORC_FIGHTER), DESTROYER(0x2e, ORC_RAIDER), ORC_MONK(0x2f,
ORC_FIGHTER), TYRANT(0x30, ORC_RAIDER),
// 3rd classes
TITAN(0x71, DESTROYER), GRAND_KHAUATARI(0x72, TYRANT),
ORC_FIGHTER), TYRANT(0x30, ORC_RAIDER), TITAN(0x71, DESTROYER), GRAND_KHAUATARI(
0x72, TYRANT),
/**
* Orc mystic
*/
ORC_MYSTIC(0x31, ClassType.MYSTIC, ActorRace.ORC), ORC_SHAMAN(0x32, ORC_MYSTIC), OVERLORD(
0x33, ORC_SHAMAN), WARCRYER(0x34, ORC_SHAMAN),
// 3rd classes
DOMINATOR(0x73, OVERLORD), DOOMCRYER(0x74, WARCRYER),
ORC_MYSTIC(0x31, ClassType.FIGHTER, ActorRace.ORC), ORC_SHAMAN(0x32,
ClassType.MYSTIC, ORC_MYSTIC), OVERLORD(0x33, ORC_SHAMAN), WARCRYER(
0x34, ORC_SHAMAN), DOMINATOR(0x73, OVERLORD), DOOMCRYER(0x74,
WARCRYER),
/**
* Dwarf fighter
*/
DWARVEN_FIGHTER(0x35, ClassType.FIGHTER, ActorRace.DWARF), SCAVENGER(0x36,
DWARVEN_FIGHTER), BOUNTY_HUNTER(0x37, SCAVENGER), ARTISAN(0x38,
DWARVEN_FIGHTER), WARSMITH(0x39, ARTISAN),
// 3rd classes
FORTUNE_SEEKER(0x75, BOUNTY_HUNTER), MAESTRO(0x76, WARSMITH),
DWARVEN_FIGHTER), WARSMITH(0x39, ARTISAN), FORTUNE_SEEKER(0x75,
BOUNTY_HUNTER), MAESTRO(0x76, WARSMITH),
/**
* Kamael male soldier
@@ -194,8 +184,8 @@ public enum CharacterClass {
* @param parent
* the parent
*/
private CharacterClass(int id, ClassType type, boolean summoner, ActorRace race,
CharacterClass parent) {
private CharacterClass(int id, ClassType type, boolean summoner,
ActorRace race, CharacterClass parent) {
this.id = id;
this.type = type;
this.summoner = summoner;

View File

@@ -65,6 +65,10 @@ public class CharacterInventory implements Iterable<Item> {
return null;
}
public boolean has(InventoryPaperdoll paperdoll) {
return getItem(paperdoll) != null;
}
/**
* This method will add new items to the inventory. This is normally called
* from the DAO object.

View File

@@ -17,6 +17,8 @@
package com.l2jserver.model.world.character;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@@ -57,6 +59,7 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
*/
public void register(Shortcut shortcut) {
shortcuts.add(shortcut);
Collections.sort(shortcuts, new ShortcutSlotComparator());
}
/**
@@ -67,6 +70,7 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
*/
public void unregister(Shortcut shortcut) {
shortcuts.remove(shortcut);
Collections.sort(shortcuts, new ShortcutSlotComparator());
}
/**
@@ -90,6 +94,8 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
shortcut1.setPage(shortcut2.getPage());
shortcut2.setSlot(slot1);
shortcut2.setPage(page1);
Collections.sort(shortcuts, new ShortcutSlotComparator());
}
/**
@@ -115,6 +121,7 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
*/
public void load(Collection<Shortcut> shortcuts) {
this.shortcuts.addAll(shortcuts);
Collections.sort(this.shortcuts, new ShortcutSlotComparator());
}
@Override
@@ -128,4 +135,12 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
public L2Character getCharacter() {
return character;
}
public static class ShortcutSlotComparator implements Comparator<Shortcut> {
@Override
public int compare(Shortcut o1, Shortcut o2) {
return ((o1.getPage() * o1.getSlot()) - (o2.getPage() * o2
.getSlot()));
}
}
}

View File

@@ -0,0 +1,230 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.actor.stat.Stats.StatType;
import com.l2jserver.model.world.character.calculator.BaseAttackAccuracyCalculator;
import com.l2jserver.model.world.character.calculator.BaseAttackEvasionCalculator;
import com.l2jserver.model.world.character.calculator.BaseCPCalculator;
import com.l2jserver.model.world.character.calculator.BaseConcentrationCalculator;
import com.l2jserver.model.world.character.calculator.BaseDexterityCalculator;
import com.l2jserver.model.world.character.calculator.BaseHPCalculator;
import com.l2jserver.model.world.character.calculator.BaseIntelligenceCalculator;
import com.l2jserver.model.world.character.calculator.BaseMPCalculator;
import com.l2jserver.model.world.character.calculator.BaseMagicalAttackCalculator;
import com.l2jserver.model.world.character.calculator.BaseMagicalAttackSpeedCalculator;
import com.l2jserver.model.world.character.calculator.BaseMagicalCriticalRateCalculator;
import com.l2jserver.model.world.character.calculator.BaseMagicalDefenseCalculator;
import com.l2jserver.model.world.character.calculator.BaseMentalityCalculator;
import com.l2jserver.model.world.character.calculator.BasePhysicalAttackCalculator;
import com.l2jserver.model.world.character.calculator.BasePhysicalAttackSpeedCalculator;
import com.l2jserver.model.world.character.calculator.BasePhysicalCriticalRateCalculator;
import com.l2jserver.model.world.character.calculator.BasePhysicalDefenseCalculator;
import com.l2jserver.model.world.character.calculator.BaseRunSpeedCalculator;
import com.l2jserver.model.world.character.calculator.BaseStrengthCalculator;
import com.l2jserver.model.world.character.calculator.BaseWalkSpeedCalculator;
import com.l2jserver.model.world.character.calculator.BaseWitnessCalculator;
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
import com.l2jserver.model.world.character.calculator.CharacterCalculatorContext;
import com.l2jserver.util.calculator.Calculator;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class CharacterStats {
private static final CharacterCalculator BASE_HP_CALCULATOR = new BaseHPCalculator();
private static final CharacterCalculator BASE_MP_CALCULATOR = new BaseMPCalculator();
private static final CharacterCalculator BASE_CP_CALCULATOR = new BaseCPCalculator();
private static final CharacterCalculator BASE_INT_CALCULATOR = new BaseIntelligenceCalculator();
private static final CharacterCalculator BASE_STR_CALCULATOR = new BaseStrengthCalculator();
private static final CharacterCalculator BASE_CON_CALCULATOR = new BaseConcentrationCalculator();
private static final CharacterCalculator BASE_MEN_CALCULATOR = new BaseMentalityCalculator();
private static final CharacterCalculator BASE_DEX_CALCULATOR = new BaseDexterityCalculator();
private static final CharacterCalculator BASE_WIT_CALCULATOR = new BaseWitnessCalculator();
private static final CharacterCalculator BASE_RUN_SPEED_CALCULATOR = new BaseRunSpeedCalculator();
private static final CharacterCalculator BASE_WALK_SPEED_CALCULATOR = new BaseWalkSpeedCalculator();
private static final CharacterCalculator BASE_PHYSICAL_ATTACK_CALCULATOR = new BasePhysicalAttackCalculator();
private static final CharacterCalculator BASE_PHYSICAL_ATTACK_SPEED_CALCULATOR = new BasePhysicalAttackSpeedCalculator();
private static final CharacterCalculator BASE_PHYSICAL_CRITICAL_RATE_CALCULATOR = new BasePhysicalCriticalRateCalculator();
private static final CharacterCalculator BASE_PHYSICAL_DEFENSE_CALCULATOR = new BasePhysicalDefenseCalculator();
private static final CharacterCalculator BASE_MAGICAL_ATTACK_CALCULATOR = new BaseMagicalAttackCalculator();
private static final CharacterCalculator BASE_MAGICAL_ATTACK_SPEED_CALCULATOR = new BaseMagicalAttackSpeedCalculator();
private static final CharacterCalculator BASE_MAGICAL_CRITICAL_RATE_CALCULATOR = new BaseMagicalCriticalRateCalculator();
private static final CharacterCalculator BASE_MAGICAL_DEFENSE_CALCULATOR = new BaseMagicalDefenseCalculator();
private static final CharacterCalculator BASE_ATTACK_ACCURACY_CALCULATOR = new BaseAttackAccuracyCalculator();
private static final CharacterCalculator BASE_ATTACK_EVASION_CALCULATOR = new BaseAttackEvasionCalculator();
private final L2Character character;
@SuppressWarnings("unchecked")
private final Calculator<CharacterCalculatorContext>[] calculators = new Calculator[StatType
.values().length];
public CharacterStats(L2Character character) {
this.character = character;
for (int i = 0; i < calculators.length; i++) {
calculators[i] = new Calculator<CharacterCalculatorContext>();
}
// bind default functions
getCalculator(StatType.MAX_HP).importFunctions(BASE_HP_CALCULATOR);
getCalculator(StatType.MAX_MP).importFunctions(BASE_MP_CALCULATOR);
getCalculator(StatType.MAX_CP).importFunctions(BASE_CP_CALCULATOR);
getCalculator(StatType.STAT_INT).importFunctions(BASE_INT_CALCULATOR);
getCalculator(StatType.STAT_STR).importFunctions(BASE_STR_CALCULATOR);
getCalculator(StatType.STAT_CON).importFunctions(BASE_CON_CALCULATOR);
getCalculator(StatType.STAT_MEN).importFunctions(BASE_MEN_CALCULATOR);
getCalculator(StatType.STAT_DEX).importFunctions(BASE_DEX_CALCULATOR);
getCalculator(StatType.STAT_WIT).importFunctions(BASE_WIT_CALCULATOR);
getCalculator(StatType.RUN_SPEED).importFunctions(
BASE_RUN_SPEED_CALCULATOR);
getCalculator(StatType.WALK_SPEED).importFunctions(
BASE_WALK_SPEED_CALCULATOR);
getCalculator(StatType.POWER_ATTACK).importFunctions(
BASE_PHYSICAL_ATTACK_CALCULATOR);
getCalculator(StatType.POWER_ATTACK_SPEED).importFunctions(
BASE_PHYSICAL_ATTACK_SPEED_CALCULATOR);
getCalculator(StatType.CRITICAL_RATE).importFunctions(
BASE_PHYSICAL_CRITICAL_RATE_CALCULATOR);
getCalculator(StatType.POWER_DEFENSE).importFunctions(
BASE_PHYSICAL_DEFENSE_CALCULATOR);
getCalculator(StatType.MAGIC_ATTACK).importFunctions(
BASE_MAGICAL_ATTACK_CALCULATOR);
getCalculator(StatType.MAGIC_ATTACK_SPEED).importFunctions(
BASE_MAGICAL_ATTACK_SPEED_CALCULATOR);
getCalculator(StatType.MCRITICAL_RATE).importFunctions(
BASE_MAGICAL_CRITICAL_RATE_CALCULATOR);
getCalculator(StatType.MAGIC_DEFENSE).importFunctions(
BASE_MAGICAL_DEFENSE_CALCULATOR);
getCalculator(StatType.ACCURACY_COMBAT).importFunctions(
BASE_ATTACK_ACCURACY_CALCULATOR);
getCalculator(StatType.EVASION_RATE).importFunctions(
BASE_ATTACK_EVASION_CALCULATOR);
// TODO henna stats calculators
}
public int getMaxHP() {
return (int) calc(StatType.MAX_HP);
}
public int getMaxMP() {
return (int) calc(StatType.MAX_MP);
}
public int getMaxCP() {
return (int) calc(StatType.MAX_CP);
}
public int getIntelligence() {
return (int) calc(StatType.STAT_INT);
}
public int getStrength() {
return (int) calc(StatType.STAT_STR);
}
public int getConcentration() {
return (int) calc(StatType.STAT_CON);
}
public int getMentality() {
return (int) calc(StatType.STAT_MEN);
}
public int getDexterity() {
return (int) calc(StatType.STAT_DEX);
}
public int getWitness() {
return (int) calc(StatType.STAT_WIT);
}
public int getRunSpeed() {
return (int) calc(StatType.RUN_SPEED);
}
public int getWalkSpeed() {
return (int) calc(StatType.WALK_SPEED);
}
public int getPhysicalAttack() {
return (int) calc(StatType.POWER_ATTACK);
}
public int getPhysicalAttackSpeed() {
return (int) calc(StatType.POWER_ATTACK_SPEED);
}
public int getPhysicalCriticalRate() {
return (int) calc(StatType.CRITICAL_RATE);
}
public int getPhysicalDefense() {
return (int) calc(StatType.POWER_DEFENSE);
}
public int getMagicalAttack() {
return (int) calc(StatType.MAGIC_ATTACK);
}
public int getMagicalAttackSpeed() {
return (int) calc(StatType.MAGIC_ATTACK_SPEED);
}
public int getMagicalCriticalRate() {
return (int) calc(StatType.MCRITICAL_RATE);
}
public int getMagicalDefense() {
return (int) calc(StatType.MAGIC_DEFENSE);
}
public int getAccuracy() {
return (int) calc(StatType.ACCURACY_COMBAT);
}
public int getEvasionRate() {
return (int) calc(StatType.EVASION_RATE);
}
// public void add(StatType type, Calculator<?> calculator) {
// getCalculator(type).importFunctions(calculator);
// }
protected Calculator<CharacterCalculatorContext> getCalculator(StatType type) {
return calculators[type.ordinal()];
}
public double calc(StatType type) {
final CharacterCalculatorContext ctx = new CharacterCalculatorContext(
character);
getCalculator(type).calculate(ctx);
return ctx.result;
}
}

View File

@@ -0,0 +1,51 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import org.apache.commons.math.util.FastMath;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BaseAttackAccuracyCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseAttackAccuracyCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getAccuracy();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final L2Character c = ctx.character;
final int level = c.getLevel();
ctx.result += FastMath.sqrt(c.getStats().getDexterity()) * 6;
ctx.result += level;
if (level > 77)
ctx.result += (level - 77) + 1;
if (level > 69)
ctx.result += (level - 69);
}
});
}
}

View File

@@ -0,0 +1,51 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import org.apache.commons.math.util.FastMath;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BaseAttackEvasionCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseAttackEvasionCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getEvasionChance();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final L2Character c = ctx.character;
final int level = c.getLevel();
ctx.result += FastMath.sqrt(c.getStats().getDexterity()) * 6;
ctx.result += level;
if (level > 77)
ctx.result += (level - 77) + 1;
if (level > 69)
ctx.result += (level - 69);
}
});
}
}

View File

@@ -0,0 +1,55 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BaseCPCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseCPCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getCpBase();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final CharacterTemplate template = ctx.character.getTemplate();
int lvl = ctx.character.getLevel() - template.getMinimumLevel();
double mod = template.getCpMultiplier() * lvl;
double max = (template.getCpAdd() + mod) * lvl;
double min = (template.getCpAdd() * lvl) + mod;
ctx.result += (max + min) / 2;
}
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result *= BaseStats.CON.calculateBonus(ctx.character
.getStats().getConcentration());
}
});
}
}

View File

@@ -0,0 +1,34 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class BaseConcentrationCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseConcentrationCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getConcentration();
}
});
}
}

View File

@@ -0,0 +1,35 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class BaseDexterityCalculator extends
CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseDexterityCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getDextry();
}
});
}
}

View File

@@ -0,0 +1,55 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BaseHPCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseHPCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getHpBase();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final CharacterTemplate template = ctx.character.getTemplate();
int lvl = ctx.character.getLevel() - template.getMinimumLevel();
double mod = template.getHpMultiplier() * lvl;
double max = (template.getHpAdd() + mod) * lvl;
double min = (template.getHpAdd() * lvl) + mod;
ctx.result += (max + min) / 2;
}
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result *= BaseStats.CON.calculateBonus(ctx.character
.getStats().getConcentration());
}
});
}
}

View File

@@ -0,0 +1,34 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class BaseIntelligenceCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseIntelligenceCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getIntelligence();
}
});
}
}

View File

@@ -0,0 +1,55 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BaseMPCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseMPCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getMpBase();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final CharacterTemplate template = ctx.character.getTemplate();
int lvl = ctx.character.getLevel() - template.getMinimumLevel();
double mod = template.getMpMultiplier() * lvl;
double max = (template.getMpAdd() + mod) * lvl;
double min = (template.getMpAdd() * lvl) + mod;
ctx.result += (max + min) / 2;
}
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result *= BaseStats.MEN.calculateBonus(ctx.character
.getStats().getMentality());
}
});
}
}

View File

@@ -0,0 +1,46 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BaseMagicalAttackCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseMagicalAttackCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getMagicalAttack();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final L2Character c = ctx.character;
ctx.result *= Math
.pow(((100.0 - 11 + c.getLevel()) / 100.0), 2)
* Math.pow(BaseStats.INT.calculateBonus(c.getStats()
.getIntelligence()), 2);
}
});
}
}

View File

@@ -0,0 +1,42 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BaseMagicalAttackSpeedCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseMagicalAttackSpeedCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getCastSpeed();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result *= BaseStats.WIT.calculateBonus(ctx.character
.getStats().getWitness());
}
});
}
}

View File

@@ -0,0 +1,46 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class BaseMagicalCriticalRateCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseMagicalCriticalRateCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
// XXX is the same as physical????
ctx.result = ctx.character.getTemplate().getCriticalChance();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x300) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final L2Character c = ctx.character;
// TODO only apply if using a weapon
ctx.result *= BaseStats.WIT.calculateBonus(c.getStats()
.getWitness());
}
});
}
}

View File

@@ -0,0 +1,64 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.LEFT_EAR;
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.LEFT_FINGER;
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.NECK;
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.RIGHT_EAR;
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.RIGHT_FINGER;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.model.world.character.CharacterInventory;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class BaseMagicalDefenseCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseMagicalDefenseCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getMagicalDefense();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final L2Character c = ctx.character;
final CharacterInventory inv = c.getInventory();
if (inv.has(LEFT_FINGER))
ctx.result -= 5;
if (inv.has(RIGHT_FINGER))
ctx.result -= 5;
if (inv.has(LEFT_EAR))
ctx.result -= 9;
if (inv.has(RIGHT_EAR))
ctx.result -= 9;
if (inv.has(NECK))
ctx.result -= 13;
ctx.result *= BaseStats.MEN.calculateBonus(c.getStats()
.getMentality())
* ((100.0 - 11 + c.getLevel()) / 100.0);
}
});
}
}

View File

@@ -0,0 +1,34 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class BaseMentalityCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseMentalityCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getMentality();
}
});
}
}

View File

@@ -0,0 +1,44 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BasePhysicalAttackCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BasePhysicalAttackCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getPhysicalAttack();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x100) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final L2Character c = ctx.character;
ctx.result *= BaseStats.STR.calculateBonus(c.getStats()
.getStrength()) * ((100.0 - 11 + c.getLevel()) / 100.0);
}
});
}
}

View File

@@ -0,0 +1,42 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BasePhysicalAttackSpeedCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BasePhysicalAttackSpeedCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getAttackSpeed();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result *= BaseStats.DEX.calculateBonus(ctx.character
.getStats().getDexterity());
}
});
}
}

View File

@@ -0,0 +1,47 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class BasePhysicalCriticalRateCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BasePhysicalCriticalRateCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getCriticalChance();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x090) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final L2Character c = ctx.character;
ctx.result *= BaseStats.DEX.calculateBonus(c.getStats()
.getDexterity());
ctx.result *= 10;
// TODO l2j uses another variable here, must check why
}
});
}
}

View File

@@ -0,0 +1,69 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.CHEST;
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.FEET;
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.GLOVES;
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.HEAD;
import static com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll.LEGS;
import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.character.CharacterClass;
import com.l2jserver.model.world.character.CharacterClass.ClassType;
import com.l2jserver.model.world.character.CharacterInventory;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class BasePhysicalDefenseCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BasePhysicalDefenseCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getPhysicalDefense();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x200) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
final L2Character c = ctx.character;
final CharacterInventory inv = c.getInventory();
// orc mystics are a special case
boolean hasMagePDef = (c.getCharacterClass().type == ClassType.MYSTIC || c
.getCharacterClass() == CharacterClass.ORC_MYSTIC);
if (inv.has(HEAD))
ctx.result -= 12;
final Item chest = inv.getItem(CHEST);
if (chest != null)
ctx.result -= hasMagePDef ? 15 : 31;
if (inv.has(LEGS))
// FIXME full armor also applies here
ctx.result -= hasMagePDef ? 8 : 18;
if (inv.has(GLOVES))
ctx.result -= 8;
if (inv.has(FEET))
ctx.result -= 7;
ctx.result *= ((100.0 - 11 + c.getLevel()) / 100.0);
}
});
}
}

View File

@@ -0,0 +1,42 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BaseRunSpeedCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseRunSpeedCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getRunSpeed();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x300) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result *= BaseStats.DEX.calculateBonus(ctx.character
.getStats().getDexterity());
}
});
}
}

View File

@@ -0,0 +1,34 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class BaseStrengthCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseStrengthCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getStrength();
}
});
}
}

View File

@@ -0,0 +1,42 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.world.actor.stat.BaseStats;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class BaseWalkSpeedCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseWalkSpeedCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getWalkSpeed();
}
}, new AbstractFunction<CharacterCalculatorContext>(0x300) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result *= BaseStats.DEX.calculateBonus(ctx.character
.getStats().getDexterity());
}
});
}
}

View File

@@ -0,0 +1,34 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.util.calculator.AbstractFunction;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class BaseWitnessCalculator extends CharacterCalculator {
@SuppressWarnings("unchecked")
public BaseWitnessCalculator() {
super(new AbstractFunction<CharacterCalculatorContext>(0x000) {
@Override
public void calculate(CharacterCalculatorContext ctx) {
ctx.result = ctx.character.getTemplate().getMentality();
}
});
}
}

View File

@@ -0,0 +1,31 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.util.calculator.Calculator;
import com.l2jserver.util.calculator.Function;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class CharacterCalculator extends Calculator<CharacterCalculatorContext> {
public CharacterCalculator(
Function<CharacterCalculatorContext>... functions) {
super(functions);
}
}

View File

@@ -0,0 +1,36 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.world.character.calculator;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.actor.calculator.ActorCalculatorContext;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class CharacterCalculatorContext extends ActorCalculatorContext {
/**
* The character instance
*/
public final L2Character character;
public CharacterCalculatorContext(L2Character character) {
super(character);
this.character = character;
}
}