1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-08 08:23:11 +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

@@ -19,8 +19,9 @@ package com.l2jserver.model.id.compound;
import com.l2jserver.model.id.ID;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
* The compound {@link ID} is composed of two IDs.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class AbstractCompoundID<T1, T2> extends ID<AbstractCompoundID<T1, T2>> {
/**
@@ -33,8 +34,12 @@ public class AbstractCompoundID<T1, T2> extends ID<AbstractCompoundID<T1, T2>> {
private final T2 id2;
/**
* Creates a new compound ID
*
* @param id1
* the first id
* @param id2
* the second id
*/
protected AbstractCompoundID(T1 id1, T2 id2) {
super(null);

View File

@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
import com.l2jserver.model.id.template.ActorTemplateID;
import com.l2jserver.model.world.Actor;
import com.l2jserver.model.world.actor.ActorAttributes;
import com.l2jserver.model.world.actor.stat.Stats;
/**
* Template for {@link Actor}
@@ -72,6 +73,8 @@ public abstract class ActorTemplate<T extends Actor> extends
}
protected abstract T createInstance();
public abstract Stats getTemplateStat();
/**
* @return the baseAttributes
@@ -488,5 +491,4 @@ public abstract class ActorTemplate<T extends Actor> extends
return craft;
}
}
}

View File

@@ -19,6 +19,7 @@ package com.l2jserver.model.template;
import com.l2jserver.model.id.template.CharacterTemplateID;
import com.l2jserver.model.world.Actor.ActorRace;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.actor.stat.Stats;
import com.l2jserver.model.world.character.CharacterClass;
import com.l2jserver.util.dimensional.Point;
@@ -37,6 +38,20 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
*/
protected final Point spawnLocation;
protected double hpBase;
protected double hpAdd;
protected double hpMultiplier;
protected double mpBase;
protected double mpAdd;
protected double mpMultiplier;
protected double cpBase;
protected double cpAdd;
protected double cpMultiplier;
protected int minimumLevel;
protected Integer attackDamage = null;
protected AttackType attackType;
@@ -70,7 +85,7 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
@Override
public L2Character createInstance() {
final L2Character character = new L2Character(this.getID(), attributes);
final L2Character character = new L2Character(this.getID());
character.setRace(getRace());
character.setCharacterClass(characterClass);
@@ -79,6 +94,11 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
return character;
}
@Override
public Stats getTemplateStat() {
return null;
}
/**
* @return the race
*/
@@ -100,6 +120,90 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
return spawnLocation;
}
/**
* @return the hpBase
*/
public double getHpBase() {
return hpBase;
}
/**
* @return the hpAdd
*/
public double getHpAdd() {
return hpAdd;
}
/**
* @return the hpMultiplier
*/
public double getHpMultiplier() {
return hpMultiplier;
}
/**
* @return the mpBase
*/
public double getMpBase() {
return mpBase;
}
/**
* @return the mpAdd
*/
public double getMpAdd() {
return mpAdd;
}
/**
* @return the mpMultiplier
*/
public double getMpMultiplier() {
return mpMultiplier;
}
/**
* @return the cpBase
*/
public double getCpBase() {
return cpBase;
}
/**
* @return the cpAdd
*/
public double getCpAdd() {
return cpAdd;
}
/**
* @return the cpMultiplier
*/
public double getCpMultiplier() {
return cpMultiplier;
}
/**
* @return the minimumLevel
*/
public int getMinimumLevel() {
return minimumLevel;
}
/**
* @return the attackDamage
*/
public Integer getAttackDamage() {
return attackDamage;
}
/**
* @return the attackType
*/
public AttackType getAttackType() {
return attackType;
}
/**
* @return the male collision radius
*/

View File

@@ -28,6 +28,7 @@ import com.l2jserver.model.world.Actor;
import com.l2jserver.model.world.Actor.ActorSex;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.NPC;
import com.l2jserver.model.world.actor.stat.Stats;
import com.l2jserver.service.game.character.CannotSetTargetServiceException;
import com.l2jserver.service.game.character.CharacterService;
import com.l2jserver.service.network.NetworkService;
@@ -57,6 +58,8 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
*/
@Inject
protected ItemTemplateIDProvider itemTemplateIdProvider;
protected Stats stats;
/**
* The NPC name
@@ -118,7 +121,7 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
/**
* The NPC sp
*/
protected long sp;
protected int sp;
/**
* The NPC agressive state
@@ -228,11 +231,20 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
public void receiveAttack(NPC npc, Calculator calculator, Actor attacker) {
// TODO add attributes to calculator!
}
@Override
public NPC createInstance() {
return new NPC(this.getID());
}
@Override
public Stats getTemplateStat() {
return null;
}
/**
* @return the name
@@ -328,7 +340,7 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
/**
* @return the sp
*/
public long getSp() {
public int getSp() {
return sp;
}

View File

@@ -16,21 +16,14 @@
*/
package com.l2jserver.model.template.item;
import java.util.Map;
import java.util.Map.Entry;
import com.l2jserver.model.id.template.ItemTemplateID;
import com.l2jserver.model.template.ItemTemplate;
import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.actor.stat.Stats;
import com.l2jserver.model.world.actor.stat.Stats.StatType;
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
import com.l2jserver.util.calculator.Calculator;
import com.l2jserver.util.calculator.DivisionFunction;
import com.l2jserver.util.calculator.Function;
import com.l2jserver.util.calculator.MultiplicationFunction;
import com.l2jserver.util.calculator.SetFunction;
import com.l2jserver.util.calculator.SubtractFunction;
import com.l2jserver.util.calculator.SumFunction;
import com.l2jserver.util.factory.CollectionFactory;
/**
* Template for Weapon {@link Item}
@@ -59,7 +52,7 @@ public abstract class WeaponTemplate extends ItemTemplate {
/**
* The weapon's attributes
*/
protected final WeaponAttribute attribute = new WeaponAttribute();
protected final Stats stats = new Stats();
/**
* This weapon random damage
@@ -130,145 +123,8 @@ public abstract class WeaponTemplate extends ItemTemplate {
* @param calc
* the calculator
*/
public void calculator(WeaponAttributeType type, Calculator calc) {
attribute.calculator(type, calc);
}
/**
* Attribute types for weapons
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum WeaponAttributeType {
PHYSICAL_ATTACK, MAGICAL_ATTACK, R_CRITICAL, PHYSICAL_ATTACK_SPEED;
}
/**
* This class handles the Weapon attributes an can add operations to the
* calculator
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class WeaponAttribute {
private final Map<WeaponAttributeType, Map<Integer, Function<Double>>> operations = CollectionFactory
.newMap();
/**
* Sets the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to set
*/
public void set(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SetFunction(value));
}
/**
* Adds <tt>value</tt> to the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be summed
*/
public void add(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SumFunction(value));
}
/**
* Subtracts <tt>value</tt> from the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be subtracted
*/
public void sub(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new SubtractFunction(value));
}
/**
* Multiply <tt>value</tt> the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be multiplied
*/
public void mult(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new MultiplicationFunction(value));
}
/**
* Divides by <tt>value</tt> the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be divided by
*/
public void div(WeaponAttributeType type, int order, double value) {
getMap(type).put(order, new DivisionFunction(value));
}
/**
* Performs an enchant operation. Note that this is not implemented yet!
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* TODO
*/
public void enchant(WeaponAttributeType type, int order, double value) {
// TODO enchant operation for weapon
}
/**
* Returns the Order-Operation map for <tt>type</tt>
*
* @param type
* the type
* @return the order-operation map
*/
private Map<Integer, Function<Double>> getMap(WeaponAttributeType type) {
Map<Integer, Function<Double>> map = operations.get(type);
if (map == null) {
map = CollectionFactory.newMap();
operations.put(type, map);
}
return map;
}
/**
* Creates the calculator object for this weapon
*
* @param type
* the type
* @param calculator
* the calculator
*/
private void calculator(WeaponAttributeType type, Calculator calculator) {
final Map<Integer, Function<Double>> operations = this.operations
.get(type);
for (final Entry<Integer, Function<Double>> entry : operations
.entrySet()) {
calculator.add(entry.getKey(), entry.getValue());
}
}
public void calculator(StatType type, Calculator calc) {
stats.calculator(type, calc);
}
/**
@@ -409,7 +265,7 @@ public abstract class WeaponTemplate extends ItemTemplate {
/**
* @return the attribute
*/
public WeaponAttribute getAttribute() {
return attribute;
public Stats getAttribute() {
return stats;
}
}

View File

@@ -105,11 +105,21 @@ public abstract class Actor extends PositionableObject {
/**
* The actor HP
*/
protected int hp;
protected double HP;
/**
* The actor MP
*/
protected int mp;
protected double MP;
/**
* The actor experience points
*/
protected long experience;
/**
* The actor sp points
*/
protected int sp;
/**
* The currently effects active on the actor
*/
@@ -119,33 +129,10 @@ public abstract class Actor extends PositionableObject {
*/
protected final ActorSkillContainer skills = new ActorSkillContainer(this);
public Actor(ActorTemplateID<?> templateID) {
protected Actor(ActorTemplateID<?> templateID) {
this.templateID = templateID;
}
public int getHP() {
return hp;
}
public void setHP(int hp) {
this.hp = hp;
}
/**
* @return the mp
*/
public int getMP() {
return mp;
}
/**
* @param mp
* the mp to set
*/
public void setMP(int mp) {
this.mp = mp;
}
/**
* @return the race
*/
@@ -176,14 +163,81 @@ public abstract class Actor extends PositionableObject {
this.sex = sex;
}
/**
* @return the level
*/
public int getLevel() {
return level;
}
/**
* @param level
* the level to set
*/
public void setLevel(int level) {
this.level = level;
}
/**
* @return the hP
*/
public double getHP() {
return HP;
}
/**
* @param hP
* the hP to set
*/
public void setHP(double hP) {
HP = hP;
}
/**
* @return the mP
*/
public double getMP() {
return MP;
}
/**
* @param mP
* the mP to set
*/
public void setMP(double mP) {
MP = mP;
}
/**
* @return the experience
*/
public long getExperience() {
return experience;
}
/**
* @param experience
* the experience to set
*/
public void setExperience(long experience) {
this.experience = experience;
}
/**
* @return the sp
*/
public int getSP() {
return sp;
}
/**
* @param sp
* the sp to set
*/
public void setSP(int sp) {
this.sp = sp;
}
/**
* @return the active effects on this actor
*/

View File

@@ -32,6 +32,7 @@ import com.l2jserver.model.world.character.CharacterClass;
import com.l2jserver.model.world.character.CharacterFriendList;
import com.l2jserver.model.world.character.CharacterInventory;
import com.l2jserver.model.world.character.CharacterShortcutContainer;
import com.l2jserver.model.world.character.CharacterStats;
import com.l2jserver.util.dimensional.Point;
/**
@@ -83,10 +84,20 @@ public class L2Character extends Player {
* The character name
*/
private String name;
/**
* The character title. Can be null.
*/
private String title;
/**
* The class of the character
*/
private CharacterClass characterClass;
/**
* The character CP
*/
private double CP;
/**
* The character's status
*/
@@ -96,6 +107,24 @@ public class L2Character extends Player {
*/
private Date lastAccess;
/**
* The character stat
*/
private final CharacterStats stats = new CharacterStats(this);
/**
* The character karma points
*/
private int karma;
/**
* The character PK kills
*/
private int pkKills;
/**
* The character PVP kills
*/
private int pvpKills;
// ////////////////////////////////////
// / RUNTIME
// ////////////////////////////////////
@@ -136,7 +165,26 @@ public class L2Character extends Player {
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum CharacterState {
TELEPORTING, CASTING, ATTACKING, MOVING;
/**
* This state indicates the character is being teleported
*/
TELEPORTING,
/**
* This state indicates the character is casting a skill
*/
CASTING,
/**
* This state indicates the character is attacking
*/
ATTACKING,
/**
* This state indicates the character is moving
*/
MOVING,
/**
* This state indicates the character is dead
*/
DEAD;
}
/**
@@ -150,10 +198,9 @@ public class L2Character extends Player {
* @param baseAttributes
* the base attribute for this character
*/
public L2Character(CharacterTemplateID templateID,
CharacterTemplate.ActorBaseAttributes baseAttributes) {
public L2Character(CharacterTemplateID templateID) {
super(templateID);
this.baseAttributes = baseAttributes;
this.baseAttributes = templateID.getTemplate().getBaseAttributes();
this.attributes = new CharacterCalculatedAttributes(this);
}
@@ -235,6 +282,21 @@ public class L2Character extends Player {
this.name = name;
}
/**
* @return the title
*/
public String getTitle() {
return title;
}
/**
* @param title
* the title to set
*/
public void setTitle(String title) {
this.title = title;
}
/**
* @return the characterClass
*/
@@ -250,6 +312,21 @@ public class L2Character extends Player {
this.characterClass = characterClass;
}
/**
* @return the character CP
*/
public double getCP() {
return CP;
}
/**
* @param CP
* the character CP to set
*/
public void setCP(double CP) {
this.CP = CP;
}
/**
* @return the online
*/
@@ -280,6 +357,58 @@ public class L2Character extends Player {
this.lastAccess = lastAccess;
}
/**
* @return the stats
*/
public CharacterStats getStats() {
return stats;
}
/**
* @return the character karma points
*/
public int getKarma() {
return karma;
}
/**
* @param karma
* the character karma points to set
*/
public void setKarma(int karma) {
this.karma = karma;
}
/**
* @return the character PK kills
*/
public int getPkKills() {
return pkKills;
}
/**
* @param pkKills
* the character PK kills to set
*/
public void setPkKills(int pkKills) {
this.pkKills = pkKills;
}
/**
* @return the character PVP kills
*/
public int getPvpKills() {
return pvpKills;
}
/**
* @param pvpKills
* the character PVP kills to set
*/
public void setPvpKills(int pvpKills) {
this.pvpKills = pvpKills;
}
/**
* @return the moveType
*/
@@ -348,6 +477,34 @@ public class L2Character extends Player {
return state == CharacterState.MOVING;
}
/**
* @return true if character is dead
*/
public boolean isDead() {
return state == CharacterState.DEAD;
}
/**
* @return true if character is casting
*/
public boolean isCasting() {
return state == CharacterState.CASTING;
}
/**
* @return true if character is attacking
*/
public boolean isAttacking() {
return state == CharacterState.ATTACKING;
}
/**
* @return true if character is alive
*/
public boolean isAlive() {
return !isDead();
}
/**
* @return the targetLocation
*/

View File

@@ -30,11 +30,6 @@ import com.l2jserver.service.game.ai.AIScript;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class NPC extends Actor {
public int oldId;
public int tpl;
/**
* Creates a new instance
*
@@ -45,6 +40,62 @@ public class NPC extends Actor {
super(templateID);
}
@Override
public ActorSex getSex() {
return this.getTemplate().getSex();
}
@Override
public void setSex(ActorSex sex) {
throw new UnsupportedOperationException();
}
@Override
public int getLevel() {
return this.getTemplate().getLevel();
}
@Override
public void setLevel(int level) {
throw new UnsupportedOperationException();
}
public double getMaxHP() {
return this.getTemplate().getMaxHP();
}
public void setMaxHP(double maxHP) {
throw new UnsupportedOperationException();
}
public double getMaxMP() {
return this.getTemplate().getMaxHP();
}
public void setMaxMP(double maxMP) {
throw new UnsupportedOperationException();
}
@Override
public long getExperience() {
return this.getTemplate().getExperience();
}
@Override
public void setExperience(long experience) {
throw new UnsupportedOperationException();
}
@Override
public int getSP() {
return this.getTemplate().getSp();
}
@Override
public void setSP(int sp) {
throw new UnsupportedOperationException();
}
/**
* @return the NPC template ID
*/

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.actor.calculator;
import com.l2jserver.model.world.Actor;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ActorCalculator {
private final Actor actor;
public ActorCalculator(Actor actor) {
this.actor = actor;
}
public double calculateMaxHP() {
return 0;
}
}

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.actor.calculator;
import com.l2jserver.model.world.Actor;
import com.l2jserver.util.calculator.CalculatorContext;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class ActorCalculatorContext extends CalculatorContext {
/**
* The character instance
*/
public final Actor actor;
public ActorCalculatorContext(Actor actor) {
this.actor = actor;
}
}

View File

@@ -0,0 +1,93 @@
/*
* 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.actor.stat;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum BaseStats {
STR(0.29, 0.3, 0.31, 0.32, 0.34, 0.35, 0.36, 0.37, 0.39, 0.4, 0.42, 0.43,
0.45, 0.46, 0.48, 0.5, 0.51, 0.53, 0.55, 0.57, 0.59, 0.61, 0.63,
0.66, 0.68, 0.71, 0.73, 0.76, 0.78, 0.81, 0.84, 0.87, 0.9, 0.94,
0.97, 1.01, 1.04, 1.08, 1.12, 1.16, 1.2, 1.24, 1.29, 1.33, 1.38,
1.43, 1.48, 1.54, 1.59, 1.65, 1.71, 1.77, 1.83, 1.9, 1.97, 2.04,
2.11, 2.19, 2.27, 2.35, 2.43, 2.52, 2.61, 2.71, 2.8, 2.91, 3.01,
3.12, 3.23, 3.35, 3.47, 3.59, 3.72, 3.86, 3.99, 4.14, 4.29, 4.44,
4.6, 4.77, 4.94, 5.12, 5.3, 5.49, 5.69, 5.89, 6.11, 6.33, 6.55,
6.79, 7.03, 7.29, 7.55, 7.82, 8.1, 8.39, 8.7, 9.01, 9.33, 9.67),
INT(0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.61, 0.62, 0.63, 0.64, 0.65, 0.67,
0.68, 0.69, 0.71, 0.72, 0.74, 0.75, 0.77, 0.78, 0.8, 0.81, 0.83,
0.85, 0.86, 0.88, 0.9, 0.92, 0.94, 0.95, 0.97, 0.99, 1.01, 1.03,
1.05, 1.07, 1.1, 1.12, 1.14, 1.16, 1.19, 1.21, 1.23, 1.26, 1.28,
1.31, 1.34, 1.36, 1.39, 1.42, 1.45, 1.47, 1.5, 1.53, 1.57, 1.6,
1.63, 1.66, 1.69, 1.73, 1.76, 1.8, 1.83, 1.87, 1.91, 1.95, 1.99,
2.02, 2.07, 2.11, 2.15, 2.19, 2.24, 2.28, 2.33, 2.37, 2.42, 2.47,
2.52, 2.57, 2.62, 2.67, 2.73, 2.78, 2.84, 2.89, 2.95, 3.01, 3.07,
3.13, 3.19, 3.26, 3.32, 3.39, 3.46, 3.53, 3.6, 3.67, 3.74, 3.82),
DEX(0.84, 0.85, 0.86, 0.86, 0.87, 0.88, 0.89, 0.9, 0.9, 0.91, 0.92, 0.93,
0.94, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1, 1.01, 1.01, 1.02,
1.03, 1.04, 1.05, 1.06, 1.07, 1.08, 1.09, 1.1, 1.11, 1.12, 1.13,
1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.2, 1.21, 1.22, 1.24, 1.25,
1.26, 1.27, 1.28, 1.29, 1.3, 1.32, 1.33, 1.34, 1.35, 1.36, 1.38,
1.39, 1.4, 1.41, 1.43, 1.44, 1.45, 1.47, 1.48, 1.49, 1.51, 1.52,
1.53, 1.55, 1.56, 1.57, 1.59, 1.6, 1.62, 1.63, 1.65, 1.66, 1.68,
1.69, 1.71, 1.72, 1.74, 1.75, 1.77, 1.78, 1.8, 1.82, 1.83, 1.85,
1.87, 1.88, 1.9, 1.92, 1.93, 1.95, 1.97, 1.99, 2, 2.02, 2.04),
WIT(0.39, 0.4, 0.42, 0.44, 0.46, 0.48, 0.51, 0.53, 0.56, 0.58, 0.61, 0.64,
0.68, 0.71, 0.75, 0.78, 0.82, 0.86, 0.91, 0.95, 1, 1.05, 1.1, 1.16,
1.22, 1.28, 1.34, 1.41, 1.48, 1.55, 1.63, 1.71, 1.8, 1.89, 1.98,
2.08, 2.18, 2.29, 2.41, 2.53, 2.65, 2.79, 2.93, 3.07, 3.23, 3.39,
3.56, 3.73, 3.92, 4.12, 4.32, 4.54, 4.76, 5, 5.25, 5.52, 5.79,
6.08, 6.39, 6.7, 7.04, 7.39, 7.76, 8.15, 8.56, 8.99, 9.43, 9.91,
10.4, 10.92, 11.47, 12.04, 12.64, 13.27, 13.94, 14.64, 15.37,
16.14, 16.94, 17.79, 18.68, 19.61, 20.59, 21.62, 22.7, 23.84,
25.03, 26.28, 27.6, 28.98, 30.43, 31.95, 33.55, 35.22, 36.98,
38.83, 40.77, 42.81, 44.95, 47.2),
CON(0.45, 0.46, 0.47, 0.48, 0.5, 0.51, 0.53, 0.54, 0.56, 0.58, 0.59, 0.61,
0.63, 0.65, 0.67, 0.69, 0.71, 0.73, 0.75, 0.77, 0.8, 0.82, 0.85,
0.87, 0.9, 0.93, 0.95, 0.98, 1.01, 1.04, 1.07, 1.1, 1.14, 1.17,
1.21, 1.24, 1.28, 1.32, 1.36, 1.4, 1.44, 1.48, 1.53, 1.58, 1.62,
1.67, 1.72, 1.77, 1.83, 1.88, 1.94, 2, 2.06, 2.12, 2.18, 2.25,
2.31, 2.38, 2.45, 2.53, 2.6, 2.68, 2.76, 2.84, 2.93, 3.02, 3.11,
3.2, 3.3, 3.4, 3.5, 3.6, 3.71, 3.82, 3.94, 4.06, 4.18, 4.3, 4.43,
4.56, 4.7, 4.84, 4.99, 5.14, 5.29, 5.45, 5.61, 5.78, 5.96, 6.13,
6.32, 6.51, 6.7, 6.9, 7.11, 7.33, 7.54, 7.77, 8, 8.24),
MEN(1, 1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.07, 1.08, 1.09, 1.11, 1.12,
1.13, 1.14, 1.15, 1.16, 1.17, 1.19, 1.2, 1.21, 1.22, 1.23, 1.25,
1.26, 1.27, 1.28, 1.3, 1.31, 1.32, 1.34, 1.35, 1.36, 1.38, 1.39,
1.4, 1.42, 1.43, 1.45, 1.46, 1.48, 1.49, 1.5, 1.52, 1.53, 1.55,
1.57, 1.58, 1.6, 1.61, 1.63, 1.65, 1.66, 1.68, 1.7, 1.71, 1.73,
1.75, 1.76, 1.78, 1.8, 1.82, 1.84, 1.85, 1.87, 1.89, 1.91, 1.93,
1.95, 1.97, 1.99, 2.01, 2.03, 2.05, 2.07, 2.09, 2.11, 2.13, 2.15,
2.17, 2.2, 2.22, 2.24, 2.26, 2.29, 2.31, 2.33, 2.35, 2.38, 2.4,
2.43, 2.45, 2.47, 2.5, 2.52, 2.55, 2.58, 2.6, 2.63, 2.65, 2.68);
public double[] bonus;
BaseStats(double... bonus) {
this.bonus = bonus;
}
public double calculateBonus(int n) {
return bonus[n];
}
}

View File

@@ -0,0 +1,264 @@
package com.l2jserver.model.world.actor.stat;
import java.util.List;
import java.util.Map;
import com.l2jserver.util.calculator.Calculator;
import com.l2jserver.util.calculator.CalculatorContext;
import com.l2jserver.util.calculator.DivisionFunction;
import com.l2jserver.util.calculator.Function;
import com.l2jserver.util.calculator.MultiplicationFunction;
import com.l2jserver.util.calculator.SetFunction;
import com.l2jserver.util.calculator.SubtractFunction;
import com.l2jserver.util.calculator.SumFunction;
import com.l2jserver.util.factory.CollectionFactory;
/**
* This class handles the stats an can add operations to the calculator
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Stats {
/**
* Attribute types for weapons
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public enum StatType {
MAX_HP, MAX_MP, MAX_CP, REGENERATE_HP_RATE, REGENERATE_CP_RATE, REGENERATE_MP_RATE, RECHARGE_MP_RATE, HEAL_EFFECTIVNESS, HEAL_PROFICIENCY, HEAL_STATIC_BONUS,
// Atk & Def
POWER_DEFENSE, MAGIC_DEFENSE, POWER_ATTACK, MAGIC_ATTACK, PHYSICAL_SKILL_POWER, POWER_ATTACK_SPEED, MAGIC_ATTACK_SPEED, // how
// fast
// a
// spell
// is
// casted
MAGIC_REUSE_RATE, // how fast spells becomes ready to reuse
SHIELD_DEFENCE, CRITICAL_DAMAGE, CRITICAL_DAMAGE_ADD, // this is another
// type for
// special
// critical
// damage mods -
// vicious
// stance, crit
// power and
// crit damage
// SA
// it was totally bad since now...
MAGIC_CRIT_DMG,
PVP_PHYSICAL_DMG, PVP_MAGICAL_DMG, PVP_PHYS_SKILL_DMG,
PVP_PHYSICAL_DEF, PVP_MAGICAL_DEF, PVP_PHYS_SKILL_DEF,
PVE_PHYSICAL_DMG, PVE_PHYS_SKILL_DMG, PVE_BOW_DMG, PVE_BOW_SKILL_DMG, PVE_MAGICAL_DMG,
// Atk & Def rates
EVASION_RATE, P_SKILL_EVASION, CRIT_DAMAGE_EVASION, SHIELD_RATE, CRITICAL_RATE, BLOW_RATE, LETHAL_RATE, MCRITICAL_RATE, EXPSP_RATE, ATTACK_CANCEL,
// Accuracy and range
ACCURACY_COMBAT, POWER_ATTACK_RANGE, MAGIC_ATTACK_RANGE, POWER_ATTACK_ANGLE, ATTACK_COUNT_MAX,
// Run speed,
// walk & escape speed are calculated proportionally,
// magic speed is a buff
RUN_SPEED, WALK_SPEED,
//
// Player-only stats
//
STAT_STR, STAT_CON, STAT_DEX, STAT_INT, STAT_WIT, STAT_MEN,
//
// Special stats, share one slot in Calculator
//
// stats of various abilities
BREATH, FALL, LIMIT_HP, // non-displayed hp limit
//
AGGRESSION, // locks a mob on tank caster
BLEED, // by daggers, like poison
POISON, // by magic, hp dmg over time
STUN, // disable move/ATTACK for a period of time
ROOT, // disable movement, but not ATTACK
MOVEMENT, // slowdown movement, debuff
CONFUSION, // mob changes target, opposite to aggression/hate
SLEEP, // sleep until attacked
VALAKAS, VALAKAS_RES,
//
AGGRESSION_VULN, BLEED_VULN, POISON_VULN, STUN_VULN, PARALYZE_VULN, ROOT_VULN, SLEEP_VULN, CONFUSION_VULN, MOVEMENT_VULN, FIRE_RES, WIND_RES, WATER_RES, EARTH_RES, HOLY_RES, DARK_RES,
// Skills Power
FIRE_POWER, WATER_POWER, WIND_POWER, EARTH_POWER, HOLY_POWER, DARK_POWER, CANCEL_VULN, // Resistance
// for
// cancel
// type
// skills
DERANGEMENT_VULN, DEBUFF_VULN, BUFF_VULN, CRIT_VULN, // Resistence to
// Crit DMG in
// percent.
CRIT_ADD_VULN, // Resistence to Crit DMG in value .
MAGIC_DAMAGE_VULN, MAGIC_SUCCESS_RES, MAGIC_FAILURE_RATE,
AGGRESSION_PROF, BLEED_PROF, POISON_PROF, STUN_PROF, PARALYZE_PROF, ROOT_PROF, SLEEP_PROF, CONFUSION_PROF, PROF, CANCEL_PROF, DERANGEMENT_PROF, DEBUFF_PROF, CRIT_PROF,
NONE_WPN_VULN, // Shields!!!
SWORD_WPN_VULN, BLUNT_WPN_VULN, DAGGER_WPN_VULN, BOW_WPN_VULN, CROSSBOW_WPN_VULN, POLE_WPN_VULN, ETC_WPN_VULN, FIST_WPN_VULN, DUAL_WPN_VULN, DUALFIST_WPN_VULN, BIGSWORD_WPN_VULN, BIGBLUNT_WPN_VULN, DUALDAGGER_WPN_VULN, RAPIER_WPN_VULN, ANCIENT_WPN_VULN, PET_WPN_VULN,
REFLECT_DAMAGE_PERCENT, REFLECT_SKILL_MAGIC, REFLECT_SKILL_PHYSIC, VENGEANCE_SKILL_MAGIC_DAMAGE, VENGEANCE_SKILL_PHYSICAL_DAMAGE, ABSORB_DAMAGE_PERCENT, TRANSFER_DAMAGE_PERCENT, ABSORB_MANA_DAMAGE_PERCENT,
MAX_LOAD, WEIGHT_LIMIT,
PATK_PLANTS, PATK_INSECTS, PATK_ANIMALS, PATK_MONSTERS, PATK_DRAGONS, PATK_GIANTS, PATK_MCREATURES,
PDEF_PLANTS, PDEF_INSECTS, PDEF_ANIMALS, PDEF_MONSTERS, PDEF_DRAGONS, PDEF_GIANTS, PDEF_MCREATURES,
ATK_REUSE, P_REUSE,
// ExSkill :)
INV_LIM, WH_LIM, FREIGHT_LIM, P_SELL_LIM, P_BUY_LIM, REC_D_LIM, REC_C_LIM,
// C4 Stats
PHYSICAL_MP_CONSUME_RATE, MAGICAL_MP_CONSUME_RATE, DANCE_MP_CONSUME_RATE, BOW_MP_CONSUME_RATE, HP_CONSUME_RATE, MP_CONSUME, SOULSHOT_COUNT,
// T1 stats
transformId, TALISMAN_SLOTS, CLOAK_SLOT,
// Shield Stats
SHIELD_DEFENCE_ANGLE,
// Skill mastery
SKILL_MASTERY,
// vitality
VITALITY_CONSUME_RATE;
// PHYSICAL_ATTACK, MAGICAL_ATTACK, CRITICAL_RATE,
// PHYSICAL_ATTACK_SPEED;
}
private final Map<StatType, List<Function<CalculatorContext>>> operations = CollectionFactory
.newMap();
/**
* Sets the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to set
*/
public void set(Stats.StatType type, int order, double value) {
func(type, new SetFunction(order, value));
}
/**
* Adds <tt>value</tt> to the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be summed
*/
public void add(Stats.StatType type, int order, double value) {
func(type, new SumFunction(order, value));
}
/**
* Subtracts <tt>value</tt> from the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be subtracted
*/
public void sub(Stats.StatType type, int order, double value) {
func(type, new SubtractFunction(order, value));
}
/**
* Multiply <tt>value</tt> the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be multiplied
*/
public void mult(Stats.StatType type, int order, double value) {
func(type, new MultiplicationFunction(order, value));
}
/**
* Divides by <tt>value</tt> the result of an calculator
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* the value to be divided by
*/
public void div(Stats.StatType type, int order, double value) {
func(type, new DivisionFunction(order, value));
}
/**
* Performs an enchant operation. Note that this is not implemented yet!
*
* @param type
* the attribute type
* @param order
* the calculation order
* @param value
* TODO
*/
public void enchant(Stats.StatType type, int order, double value) {
// TODO enchant operation for weapon
}
public void func(StatType type, Function<CalculatorContext> function) {
getMap(type).add(function);
}
/**
* Returns the Order-Operation map for <tt>type</tt>
*
* @param type
* the type
* @return the order-operation map
*/
private List<Function<CalculatorContext>> getMap(Stats.StatType type) {
List<Function<CalculatorContext>> list = operations.get(type);
if (list == null) {
list = CollectionFactory.newList();
operations.put(type, list);
}
return list;
}
/**
* Creates the calculator object for this weapon
*
* @param type
* the type
* @param calculator
* the calculator
*/
public void calculator(Stats.StatType type,
Calculator<CalculatorContext> calculator) {
final List<Function<CalculatorContext>> operations = this.operations
.get(type);
if (operations == null || operations.size() == 0)
return;
for (final Function<CalculatorContext> func : operations) {
calculator.add(func);
}
}
}

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;
}
}