mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-09 08:52:51 +00:00
Implemented NPC and Actor calculators. Updated L2Character calculators
to match abstraction Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -58,16 +58,16 @@ public class SM_NPC_INFO extends AbstractServerPacket {
|
||||
buffer.writeInt(npc.getPoint().getZ());
|
||||
buffer.writeInt((int) npc.getPoint().getAngle());
|
||||
buffer.writeInt(0x00); // unk
|
||||
buffer.writeInt((int) template.getMagicalAttackSpeed());
|
||||
buffer.writeInt((int) template.getPhysicalAttackSpeed());
|
||||
buffer.writeInt((int) template.getRunSpeed());
|
||||
buffer.writeInt((int) template.getWalkSpeed());
|
||||
buffer.writeInt((int) template.getRunSpeed()); // swim run speed
|
||||
buffer.writeInt((int) template.getWalkSpeed()); // swim walk speed
|
||||
buffer.writeInt((int) template.getRunSpeed()); // swim run speed
|
||||
buffer.writeInt((int) template.getWalkSpeed()); // swim walk speed
|
||||
buffer.writeInt((int) template.getRunSpeed()); // fly run speed
|
||||
buffer.writeInt((int) template.getWalkSpeed()); // fly run speed
|
||||
buffer.writeInt(npc.getStats().getMagicalAttackSpeed());
|
||||
buffer.writeInt(npc.getStats().getPhysicalAttackSpeed());
|
||||
buffer.writeInt(npc.getStats().getRunSpeed());
|
||||
buffer.writeInt(npc.getStats().getWalkSpeed());
|
||||
buffer.writeInt(npc.getStats().getRunSpeed()); // swim run speed
|
||||
buffer.writeInt(npc.getStats().getWalkSpeed()); // swim walk speed
|
||||
buffer.writeInt(npc.getStats().getRunSpeed()); // swim run speed
|
||||
buffer.writeInt(npc.getStats().getWalkSpeed()); // swim walk speed
|
||||
buffer.writeInt(npc.getStats().getRunSpeed()); // fly run speed
|
||||
buffer.writeInt(npc.getStats().getWalkSpeed()); // fly run speed
|
||||
buffer.writeDouble(0x01); // TODO
|
||||
buffer.writeDouble(0x01);// TODO
|
||||
buffer.writeDouble(template.getCollisionRadius());
|
||||
@@ -79,7 +79,7 @@ public class SM_NPC_INFO extends AbstractServerPacket {
|
||||
.getLeftHand().getID() : 0x00));
|
||||
buffer.writeByte(1); // name above char 1=true ... ??
|
||||
buffer.writeByte(0x00); // is running
|
||||
buffer.writeByte(0x00); // is in combat
|
||||
buffer.writeByte((npc.isAttacking() ? 0x01 : 0x00)); // is in combat
|
||||
buffer.writeByte(0x00); // is like dead (faking)
|
||||
buffer.writeByte(0x00); // 0=teleported 1=default 2=summoned
|
||||
BufferUtils.writeString(buffer, template.getName());
|
||||
@@ -102,8 +102,11 @@ public class SM_NPC_INFO extends AbstractServerPacket {
|
||||
buffer.writeInt(0x00); // C6 -- is flying
|
||||
buffer.writeInt(0x00); // unk
|
||||
buffer.writeInt(0x00);// CT1.5 Pet form and skills, Color effect
|
||||
buffer.writeByte((template.getDisplayName() ? 0x01 : 0x00)); // hide name
|
||||
buffer.writeByte((template.getDisplayName() ? 0x01 : 0x00)); // hide name, again
|
||||
buffer.writeByte((template.getDisplayName() ? 0x01 : 0x00)); // hide
|
||||
// name
|
||||
buffer.writeByte((template.getDisplayName() ? 0x01 : 0x00)); // hide
|
||||
// name,
|
||||
// again
|
||||
|
||||
buffer.writeInt(0x00); // special effects
|
||||
buffer.writeInt(0x00); // display effect
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.l2jserver.model.id.template.ActorTemplateID;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.actor.ActorEffects;
|
||||
import com.l2jserver.model.world.actor.ActorSkillContainer;
|
||||
import com.l2jserver.model.world.actor.stat.ActorStats;
|
||||
|
||||
/**
|
||||
* Abstract {@link Actor} class.
|
||||
@@ -132,6 +133,8 @@ public abstract class Actor extends PositionableObject {
|
||||
protected Actor(ActorTemplateID<?> templateID) {
|
||||
this.templateID = templateID;
|
||||
}
|
||||
|
||||
public abstract ActorStats<?> getStats();
|
||||
|
||||
/**
|
||||
* @return the race
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.l2jserver.model.id.TemplateID;
|
||||
import com.l2jserver.model.id.object.NPCID;
|
||||
import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.npc.NPCStats;
|
||||
import com.l2jserver.service.game.ai.AIScript;
|
||||
|
||||
/**
|
||||
@@ -29,6 +30,8 @@ import com.l2jserver.service.game.ai.AIScript;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPC extends Actor {
|
||||
private NPCStats stats;
|
||||
|
||||
private NPCState state;
|
||||
|
||||
public enum NPCState {
|
||||
@@ -45,6 +48,13 @@ public class NPC extends Actor {
|
||||
super(templateID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the stats
|
||||
*/
|
||||
public NPCStats getStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.l2jserver.model.world;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.ItemID;
|
||||
import com.l2jserver.model.id.template.ActorTemplateID;
|
||||
import com.l2jserver.model.world.actor.stat.ActorStats;
|
||||
|
||||
/**
|
||||
* This class represents an Pet in the Lineage II World
|
||||
@@ -82,4 +83,13 @@ public class Pet extends Player {
|
||||
public void setItemID(ItemID itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.l2jserver.model.world.Actor#getStats()
|
||||
*/
|
||||
@Override
|
||||
public ActorStats<?> getStats() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,20 +16,13 @@
|
||||
*/
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ActorCalculator {
|
||||
@SuppressWarnings("unused")
|
||||
private final Actor actor;
|
||||
|
||||
public ActorCalculator(Actor actor) {
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
public double calculateMaxHP() {
|
||||
return 0;
|
||||
public class ActorCalculator extends Calculator<ActorCalculatorContext> {
|
||||
public ActorCalculator(ActorCalculatorFunction... functions) {
|
||||
super(functions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
|
||||
/**
|
||||
* An calculator for character formulas.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class ActorCalculatorFunction extends
|
||||
AbstractFunction<ActorCalculatorContext> {
|
||||
public ActorCalculatorFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final double calculate(ActorCalculatorContext ctx, double value) {
|
||||
return calculate(ctx.actor, ctx.actor.getTemplate(), value);
|
||||
}
|
||||
|
||||
protected abstract double calculate(Actor a,
|
||||
ActorTemplate<?> t, double value);
|
||||
}
|
||||
@@ -14,13 +14,12 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* Calculates the character base accuracy.
|
||||
@@ -37,25 +36,20 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseAttackAccuracyCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseAttackAccuracyCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class AttackAccuracyBonusCalculator extends ActorCalculator {
|
||||
public AttackAccuracyBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseAccuracy();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x100) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
final int level = c.getLevel();
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
final int level = a.getLevel();
|
||||
|
||||
ctx.result += FastMath.sqrt(c.getStats().getDexterity()) * 6;
|
||||
ctx.result += level;
|
||||
value += FastMath.sqrt(a.getStats().getDexterity()) * 6;
|
||||
value += level;
|
||||
if (level > 77)
|
||||
ctx.result += (level - 77) + 1;
|
||||
value += (level - 77) + 1;
|
||||
if (level > 69)
|
||||
ctx.result += (level - 69);
|
||||
value += (level - 69);
|
||||
return value;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -14,13 +14,12 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import org.apache.commons.math.util.FastMath;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* Calculates the character evasion
|
||||
@@ -37,25 +36,20 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseAttackEvasionCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseAttackEvasionCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class AttackEvasionBonusCalculator extends ActorCalculator {
|
||||
public AttackEvasionBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseEvasion();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x100) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
final int level = c.getLevel();
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
final int level = a.getLevel();
|
||||
|
||||
ctx.result += FastMath.sqrt(c.getStats().getDexterity()) * 6;
|
||||
ctx.result += level;
|
||||
value += FastMath.sqrt(a.getStats().getDexterity()) * 6;
|
||||
value += level;
|
||||
if (level > 77)
|
||||
ctx.result += (level - 77) + 1;
|
||||
value += (level - 77) + 1;
|
||||
if (level > 69)
|
||||
ctx.result += (level - 69);
|
||||
value += (level - 69);
|
||||
return value;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -14,12 +14,11 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the character base magical attack
|
||||
@@ -31,20 +30,14 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseMagicalAttackCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseMagicalAttackCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class MagicalAttackBonusCalculator extends ActorCalculator {
|
||||
public MagicalAttackBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseMagicalAttack();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result *= Math
|
||||
.pow(((100.0 - 11 + c.getLevel()) / 100.0), 2)
|
||||
* Math.pow(BaseStats.INT.calculateBonus(c.getStats()
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
return value
|
||||
* Math.pow(((100.0 - 11 + a.getLevel()) / 100.0), 2)
|
||||
* Math.pow(BaseStats.INT.calculateBonus(a.getStats()
|
||||
.getIntelligence()), 2);
|
||||
}
|
||||
});
|
||||
@@ -14,12 +14,11 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the base magical attack speed
|
||||
@@ -31,19 +30,14 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseMagicalAttackSpeedCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseMagicalAttackSpeedCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class MagicalAttackSpeedBonusCalculator extends ActorCalculator {
|
||||
public MagicalAttackSpeedBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseMagicalAttackSpeed();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result *= BaseStats.WIT.calculateBonus(c.getStats()
|
||||
.getWitness());
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
return value
|
||||
* BaseStats.WIT.calculateBonus(a.getStats()
|
||||
.getWitness());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is part of l2jse rver <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.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
|
||||
/**
|
||||
* Calculates the base magical attack critical rate
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseCritical(); // must be checked
|
||||
* ctx.result *= BaseStats.WIT.calculateBonus(c.getStats().getWitness());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MagicalCriticalRateBonusCalculator extends ActorCalculator {
|
||||
public MagicalCriticalRateBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x300) {
|
||||
@Override
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
// TODO only apply if using a weapon
|
||||
return value
|
||||
* BaseStats.WIT.calculateBonus(a.getStats()
|
||||
.getWitness());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
|
||||
/**
|
||||
* Calculates the character base magical defense.
|
||||
*
|
||||
* <pre>
|
||||
* 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);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MagicalDefenseBonusCalculator extends ActorCalculator {
|
||||
public MagicalDefenseBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x200) {
|
||||
@Override
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
// 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;
|
||||
|
||||
return value
|
||||
* BaseStats.MEN.calculateBonus(a.getStats()
|
||||
.getMentality())
|
||||
* ((100.0 - 11 + a.getLevel()) / 100.0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
|
||||
/**
|
||||
* Calculates the actor maximum HP bonus
|
||||
*
|
||||
* <pre>
|
||||
* return value * BaseStats.CON.calculateBonus(c.getStats().getConcentration());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MaximumHPBonusCalculator extends ActorCalculator {
|
||||
public MaximumHPBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x200) {
|
||||
@Override
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
return value
|
||||
* BaseStats.CON.calculateBonus(a.getStats()
|
||||
.getConcentration());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
|
||||
/**
|
||||
* Calculates the actor maximum HP bonus
|
||||
*
|
||||
* <pre>
|
||||
* return value * BaseStats.CON.calculateBonus(c.getStats().getConcentration());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MaximumMPBonusCalculator extends ActorCalculator {
|
||||
public MaximumMPBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x200) {
|
||||
@Override
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
return value
|
||||
* BaseStats.MEN.calculateBonus(a.getStats()
|
||||
.getMentality());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,11 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the character base physical attack
|
||||
@@ -32,19 +31,15 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BasePhysicalAttackCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BasePhysicalAttackCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class PhysicalAttackBonusCalculator extends ActorCalculator {
|
||||
public PhysicalAttackBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x100) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBasePhysicalAttack();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x100) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result *= BaseStats.STR.calculateBonus(c.getStats()
|
||||
.getStrength()) * ((100.0 - 11 + c.getLevel()) / 100.0);
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
return value
|
||||
* BaseStats.STR.calculateBonus(a.getStats()
|
||||
.getStrength())
|
||||
* ((100.0 - 11 + a.getLevel()) / 100.0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -14,12 +14,11 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the character base physical attack speed
|
||||
@@ -31,19 +30,14 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BasePhysicalAttackSpeedCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BasePhysicalAttackSpeedCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class PhysicalAttackSpeedBonusCalculator extends ActorCalculator {
|
||||
public PhysicalAttackSpeedBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBasePhysicalAttackSpeed();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result *= BaseStats.DEX.calculateBonus(c.getStats()
|
||||
.getDexterity());
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
return value
|
||||
* BaseStats.DEX.calculateBonus(a.getStats()
|
||||
.getDexterity());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -14,12 +14,11 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the character base critical rate
|
||||
@@ -32,21 +31,14 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BasePhysicalCriticalRateCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BasePhysicalCriticalRateCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class PhysicalCriticalRateBonusCalculator extends ActorCalculator {
|
||||
public PhysicalCriticalRateBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x090) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseCritical();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x090) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result *= BaseStats.DEX.calculateBonus(c.getStats()
|
||||
.getDexterity());
|
||||
ctx.result *= 10;
|
||||
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
return value
|
||||
* BaseStats.DEX.calculateBonus(a.getStats()
|
||||
.getDexterity()) * 10;
|
||||
// TODO l2j uses another variable here, must check why
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* Calculates the character base physical defense
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBasePhysicalDefense();
|
||||
*
|
||||
* 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))
|
||||
* 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);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class PhysicalDefenseBonusCalculator extends ActorCalculator {
|
||||
public PhysicalDefenseBonusCalculator() {
|
||||
super(new ActorCalculatorFunction(0x200) {
|
||||
@Override
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
// 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;
|
||||
return value * ((100.0 - 11 + a.getLevel()) / 100.0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,36 +14,32 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base run speed
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseRunSpeed();
|
||||
* ctx.result *= BaseStats.DEX.calculateBonus(c.getStats().getDexterity());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseRunSpeedCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseRunSpeedCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class RunSpeedBonusCalculator extends CharacterCalculator {
|
||||
public RunSpeedBonusCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x300) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseRunSpeed();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x300) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result *= BaseStats.DEX.calculateBonus(c.getStats()
|
||||
.getDexterity());
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return value
|
||||
* BaseStats.DEX.calculateBonus(c.getStats()
|
||||
.getDexterity());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -14,36 +14,32 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base walk speed
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseWalkSpeed();
|
||||
* ctx.result *= BaseStats.DEX.calculateBonus(c.getStats().getDexterity());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseWalkSpeedCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseWalkSpeedCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class WalkSpeedBonusCalculator extends CharacterCalculator {
|
||||
public WalkSpeedBonusCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x300) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseWalkSpeed();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x300) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result *= BaseStats.DEX.calculateBonus(c.getStats()
|
||||
.getDexterity());
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return value
|
||||
* BaseStats.DEX.calculateBonus(c.getStats()
|
||||
.getDexterity());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -16,10 +16,339 @@
|
||||
*/
|
||||
package com.l2jserver.model.world.actor.stat;
|
||||
|
||||
import com.l2jserver.model.world.actor.calculator.ActorCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.ActorCalculatorContext;
|
||||
import com.l2jserver.model.world.actor.calculator.AttackAccuracyBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.AttackEvasionBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.MagicalAttackBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.MagicalAttackSpeedBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.MagicalCriticalRateBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.MagicalDefenseBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.MaximumHPBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.MaximumMPBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.PhysicalAttackBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.PhysicalAttackSpeedBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.PhysicalCriticalRateBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.PhysicalDefenseBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.RunSpeedBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.WalkSpeedBonusCalculator;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ActorStats {
|
||||
public abstract class ActorStats<T extends ActorCalculatorContext> {
|
||||
// bonuses
|
||||
/**
|
||||
* The calculator for base maximum HP
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator HP_BONUS_CALCULATOR = new MaximumHPBonusCalculator();
|
||||
/**
|
||||
* The calculator for base maximum HP
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator MP_BONUS_CALCULATOR = new MaximumMPBonusCalculator();
|
||||
/**
|
||||
* The calculator for run speed bonus
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator RUN_SPEED_BONUS_CALCULATOR = new RunSpeedBonusCalculator();
|
||||
/**
|
||||
* The calculator for walk speed bonus
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator WALK_SPEED_BONUS_CALCULATOR = new WalkSpeedBonusCalculator();
|
||||
|
||||
/**
|
||||
* The calculator base physical attack
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator PHYSICAL_ATTACK_BONUS_CALCULATOR = new PhysicalAttackBonusCalculator();
|
||||
/**
|
||||
* The calculator base physical attack speed
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator PHYSICAL_ATTACK_SPEED_BONUS_CALCULATOR = new PhysicalAttackSpeedBonusCalculator();
|
||||
/**
|
||||
* The calculator base physical attack critical rate
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator PHYSICAL_CRITICAL_RATE_BONUS_CALCULATOR = new PhysicalCriticalRateBonusCalculator();
|
||||
/**
|
||||
* The calculator base physical defense
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator PHYSICAL_DEFENSE_BONUS_CALCULATOR = new PhysicalDefenseBonusCalculator();
|
||||
|
||||
/**
|
||||
* The calculator base magical attack
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator MAGICAL_ATTACK_BONUS_CALCULATOR = new MagicalAttackBonusCalculator();
|
||||
/**
|
||||
* The calculator base magical attack speed
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator MAGICAL_ATTACK_SPEED_BONUS_CALCULATOR = new MagicalAttackSpeedBonusCalculator();
|
||||
/**
|
||||
* The calculator base magical attack critical rate
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator MAGICAL_CRITICAL_RATE_BONUS_CALCULATOR = new MagicalCriticalRateBonusCalculator();
|
||||
/**
|
||||
* The calculator base magical defense
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator MAGICAL_DEFENSE_BONUS_CALCULATOR = new MagicalDefenseBonusCalculator();
|
||||
|
||||
/**
|
||||
* The calculator base attack accuracy
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator ATTACK_ACCURACY_BONUS_CALCULATOR = new AttackAccuracyBonusCalculator();
|
||||
/**
|
||||
* The calculator base evasion
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final ActorCalculator ATTACK_EVASION_BONUS_CALCULATOR = new AttackEvasionBonusCalculator();
|
||||
|
||||
/**
|
||||
* The list of calculators for this character
|
||||
* <p>
|
||||
* It is safe to use an array since this number cannot be changed in
|
||||
* runtime, it would be required to be able to change the {@link StatType}
|
||||
* enum. Also, an full-sized array is created because this way we don't need
|
||||
* to change the array size very often. A bit of memory is "lost", but the
|
||||
* speed gain is much higher.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private final Calculator<T>[] calculators = new Calculator[StatType
|
||||
.values().length];
|
||||
|
||||
public ActorStats() {
|
||||
for (int i = 0; i < calculators.length; i++) {
|
||||
calculators[i] = new Calculator<T>();
|
||||
}
|
||||
|
||||
// bonuses
|
||||
add(StatType.MAX_HP, HP_BONUS_CALCULATOR);
|
||||
add(StatType.MAX_MP, MP_BONUS_CALCULATOR);
|
||||
|
||||
add(StatType.RUN_SPEED, RUN_SPEED_BONUS_CALCULATOR);
|
||||
add(StatType.WALK_SPEED, WALK_SPEED_BONUS_CALCULATOR);
|
||||
|
||||
add(StatType.POWER_ATTACK, PHYSICAL_ATTACK_BONUS_CALCULATOR);
|
||||
add(StatType.POWER_ATTACK_SPEED, PHYSICAL_ATTACK_SPEED_BONUS_CALCULATOR);
|
||||
add(StatType.CRITICAL_RATE, PHYSICAL_CRITICAL_RATE_BONUS_CALCULATOR);
|
||||
add(StatType.POWER_DEFENSE, PHYSICAL_DEFENSE_BONUS_CALCULATOR);
|
||||
|
||||
add(StatType.MAGIC_ATTACK, MAGICAL_ATTACK_BONUS_CALCULATOR);
|
||||
add(StatType.MAGIC_ATTACK_SPEED, MAGICAL_ATTACK_SPEED_BONUS_CALCULATOR);
|
||||
add(StatType.MCRITICAL_RATE, MAGICAL_CRITICAL_RATE_BONUS_CALCULATOR);
|
||||
add(StatType.MAGIC_DEFENSE, MAGICAL_DEFENSE_BONUS_CALCULATOR);
|
||||
|
||||
add(StatType.ACCURACY_COMBAT, ATTACK_ACCURACY_BONUS_CALCULATOR);
|
||||
add(StatType.EVASION_RATE, ATTACK_EVASION_BONUS_CALCULATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated maximum HP
|
||||
*/
|
||||
public int getMaxHP() {
|
||||
return (int) calc(StatType.MAX_HP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated maximum MP
|
||||
*/
|
||||
public int getMaxMP() {
|
||||
return (int) calc(StatType.MAX_MP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated intelligence
|
||||
*/
|
||||
public int getIntelligence() {
|
||||
return (int) calc(StatType.STAT_INT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated strength
|
||||
*/
|
||||
public int getStrength() {
|
||||
return (int) calc(StatType.STAT_STR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated concentration
|
||||
*/
|
||||
public int getConcentration() {
|
||||
return (int) calc(StatType.STAT_CON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated mentality
|
||||
*/
|
||||
public int getMentality() {
|
||||
return (int) calc(StatType.STAT_MEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated dexterity
|
||||
*/
|
||||
public int getDexterity() {
|
||||
return (int) calc(StatType.STAT_DEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated witness
|
||||
*/
|
||||
public int getWitness() {
|
||||
return (int) calc(StatType.STAT_WIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated run speed
|
||||
*/
|
||||
public int getRunSpeed() {
|
||||
return (int) calc(StatType.RUN_SPEED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated walk speed
|
||||
*/
|
||||
public int getWalkSpeed() {
|
||||
return (int) calc(StatType.WALK_SPEED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated physical attack
|
||||
*/
|
||||
public int getPhysicalAttack() {
|
||||
return (int) calc(StatType.POWER_ATTACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated physical attack speed
|
||||
*/
|
||||
public int getPhysicalAttackSpeed() {
|
||||
return (int) calc(StatType.POWER_ATTACK_SPEED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated physical attack critical rate
|
||||
*/
|
||||
public int getPhysicalCriticalRate() {
|
||||
return (int) calc(StatType.CRITICAL_RATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated physical defense
|
||||
*/
|
||||
public int getPhysicalDefense() {
|
||||
return (int) calc(StatType.POWER_DEFENSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated magical attack
|
||||
*/
|
||||
public int getMagicalAttack() {
|
||||
return (int) calc(StatType.MAGIC_ATTACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated magical attack speed
|
||||
*/
|
||||
public int getMagicalAttackSpeed() {
|
||||
return (int) calc(StatType.MAGIC_ATTACK_SPEED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated magical attack critical rate
|
||||
*/
|
||||
public int getMagicalCriticalRate() {
|
||||
return (int) calc(StatType.MCRITICAL_RATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated magical defense
|
||||
*/
|
||||
public int getMagicalDefense() {
|
||||
return (int) calc(StatType.MAGIC_DEFENSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated accuracy
|
||||
*/
|
||||
public int getAccuracy() {
|
||||
return (int) calc(StatType.ACCURACY_COMBAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated evasion rate
|
||||
*/
|
||||
public int getEvasionRate() {
|
||||
return (int) calc(StatType.EVASION_RATE);
|
||||
}
|
||||
|
||||
public void add(StatType type, ActorCalculator calculator) {
|
||||
getCalculator(type).importFunctions(calculator);
|
||||
}
|
||||
|
||||
public void remove(StatType type, ActorCalculator calculator) {
|
||||
getCalculator(type).removeFunctions(calculator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param the
|
||||
* calculator {@link StatType}
|
||||
* @return the calculator object associated with the given <tt>type</tt>
|
||||
*/
|
||||
protected Calculator<T> getCalculator(StatType type) {
|
||||
return calculators[type.ordinal()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the calculation of an given {@link StatType}
|
||||
*
|
||||
* @param type
|
||||
* the type
|
||||
* @return the value calculated
|
||||
*/
|
||||
protected double calc(StatType type) {
|
||||
final T ctx = createContext();
|
||||
return getCalculator(type).calculate(ctx);
|
||||
}
|
||||
|
||||
protected abstract T createContext();
|
||||
}
|
||||
|
||||
118
src/main/java/com/l2jserver/model/world/actor/stat/StatType.java
Normal file
118
src/main/java/com/l2jserver/model/world/actor/stat/StatType.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package com.l2jserver.model.world.actor.stat;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
@@ -1,262 +0,0 @@
|
||||
package com.l2jserver.model.world.actor.stat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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<Actor>>> 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<Actor>(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<Actor>(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<Actor>(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<Actor>(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<Actor>(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<Actor> 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<Actor>> getMap(Stats.StatType type) {
|
||||
List<Function<Actor>> 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<Actor> calculator) {
|
||||
final List<Function<Actor>> operations = this.operations.get(type);
|
||||
if (operations == null || operations.size() == 0)
|
||||
return;
|
||||
for (final Function<Actor> func : operations) {
|
||||
calculator.add(func);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,30 +18,34 @@ package com.l2jserver.model.world.character;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.actor.stat.ActorStats;
|
||||
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.actor.stat.StatType;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorContext;
|
||||
import com.l2jserver.model.world.character.calculator.MaximumCPAddCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.MaximumCPBonusCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.MaximumHPAddCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.MaximumMPAddCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseAttackAccuracyCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseAttackEvasionCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseCPCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseConcentrationCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseDexterityCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseHPCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseIntelligenceCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseMPCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseMagicalAttackCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseMagicalAttackSpeedCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseMagicalCriticalRateCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseMagicalDefenseCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseMentalityCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBasePhysicalAttackCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBasePhysicalAttackSpeedCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBasePhysicalCriticalRateCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBasePhysicalDefenseCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseRunSpeedCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseStrengthCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseWalkSpeedCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseWitnessCalculator;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
|
||||
/**
|
||||
@@ -61,28 +65,29 @@ import com.l2jserver.util.calculator.Calculator;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterStats extends ActorStats {
|
||||
/**
|
||||
* The calculator for base maximum HP
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_HP_CALCULATOR = new BaseHPCalculator();
|
||||
public class CharacterStats extends ActorStats<CharacterCalculatorContext> {
|
||||
// base calculators
|
||||
/**
|
||||
* The calculator for base maximum MP
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_MP_CALCULATOR = new BaseMPCalculator();
|
||||
private static final CharacterCalculator BASE_HP_CALCULATOR = new CharacterBaseHPCalculator();
|
||||
/**
|
||||
* The calculator for base maximum MP
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_MP_CALCULATOR = new CharacterBaseMPCalculator();
|
||||
/**
|
||||
* The calculator for base maximum CP
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_CP_CALCULATOR = new BaseCPCalculator();
|
||||
private static final CharacterCalculator BASE_CP_CALCULATOR = new CharacterBaseCPCalculator();
|
||||
|
||||
/**
|
||||
* The calculator for base intelligence
|
||||
@@ -90,42 +95,42 @@ public class CharacterStats extends ActorStats {
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_INT_CALCULATOR = new BaseIntelligenceCalculator();
|
||||
private static final CharacterCalculator BASE_INT_CALCULATOR = new CharacterBaseIntelligenceCalculator();
|
||||
/**
|
||||
* The calculator for base strength
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_STR_CALCULATOR = new BaseStrengthCalculator();
|
||||
private static final CharacterCalculator BASE_STR_CALCULATOR = new CharacterBaseStrengthCalculator();
|
||||
/**
|
||||
* The calculator for base concentration
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_CON_CALCULATOR = new BaseConcentrationCalculator();
|
||||
private static final CharacterCalculator BASE_CON_CALCULATOR = new CharacterBaseConcentrationCalculator();
|
||||
/**
|
||||
* The calculator for base mentality
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_MEN_CALCULATOR = new BaseMentalityCalculator();
|
||||
private static final CharacterCalculator BASE_MEN_CALCULATOR = new CharacterBaseMentalityCalculator();
|
||||
/**
|
||||
* The calculator for base dexterity
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_DEX_CALCULATOR = new BaseDexterityCalculator();
|
||||
private static final CharacterCalculator BASE_DEX_CALCULATOR = new CharacterBaseDexterityCalculator();
|
||||
/**
|
||||
* The calculator for base witness
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_WIT_CALCULATOR = new BaseWitnessCalculator();
|
||||
private static final CharacterCalculator BASE_WIT_CALCULATOR = new CharacterBaseWitnessCalculator();
|
||||
|
||||
/**
|
||||
* The calculator for base run speed
|
||||
@@ -133,14 +138,14 @@ public class CharacterStats extends ActorStats {
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_RUN_SPEED_CALCULATOR = new BaseRunSpeedCalculator();
|
||||
private static final CharacterCalculator BASE_RUN_SPEED_CALCULATOR = new CharacterBaseRunSpeedCalculator();
|
||||
/**
|
||||
* The calculator for base walk speed
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_WALK_SPEED_CALCULATOR = new BaseWalkSpeedCalculator();
|
||||
private static final CharacterCalculator BASE_WALK_SPEED_CALCULATOR = new CharacterBaseWalkSpeedCalculator();
|
||||
|
||||
/**
|
||||
* The calculator base physical attack
|
||||
@@ -148,28 +153,28 @@ public class CharacterStats extends ActorStats {
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_PHYSICAL_ATTACK_CALCULATOR = new BasePhysicalAttackCalculator();
|
||||
private static final CharacterCalculator BASE_PHYSICAL_ATTACK_CALCULATOR = new CharacterBasePhysicalAttackCalculator();
|
||||
/**
|
||||
* The calculator base physical attack speed
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_PHYSICAL_ATTACK_SPEED_CALCULATOR = new BasePhysicalAttackSpeedCalculator();
|
||||
private static final CharacterCalculator BASE_PHYSICAL_ATTACK_SPEED_CALCULATOR = new CharacterBasePhysicalAttackSpeedCalculator();
|
||||
/**
|
||||
* The calculator base physical attack critical rate
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_PHYSICAL_CRITICAL_RATE_CALCULATOR = new BasePhysicalCriticalRateCalculator();
|
||||
private static final CharacterCalculator BASE_PHYSICAL_CRITICAL_RATE_CALCULATOR = new CharacterBasePhysicalCriticalRateCalculator();
|
||||
/**
|
||||
* The calculator base physical defense
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_PHYSICAL_DEFENSE_CALCULATOR = new BasePhysicalDefenseCalculator();
|
||||
private static final CharacterCalculator BASE_PHYSICAL_DEFENSE_CALCULATOR = new CharacterBasePhysicalDefenseCalculator();
|
||||
|
||||
/**
|
||||
* The calculator base magical attack
|
||||
@@ -177,28 +182,28 @@ public class CharacterStats extends ActorStats {
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_MAGICAL_ATTACK_CALCULATOR = new BaseMagicalAttackCalculator();
|
||||
private static final CharacterCalculator BASE_MAGICAL_ATTACK_CALCULATOR = new CharacterBaseMagicalAttackCalculator();
|
||||
/**
|
||||
* The calculator base magical attack speed
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_MAGICAL_ATTACK_SPEED_CALCULATOR = new BaseMagicalAttackSpeedCalculator();
|
||||
private static final CharacterCalculator BASE_MAGICAL_ATTACK_SPEED_CALCULATOR = new CharacterBaseMagicalAttackSpeedCalculator();
|
||||
/**
|
||||
* The calculator base magical attack critical rate
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_MAGICAL_CRITICAL_RATE_CALCULATOR = new BaseMagicalCriticalRateCalculator();
|
||||
private static final CharacterCalculator BASE_MAGICAL_CRITICAL_RATE_CALCULATOR = new CharacterBaseMagicalCriticalRateCalculator();
|
||||
/**
|
||||
* The calculator base magical defense
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_MAGICAL_DEFENSE_CALCULATOR = new BaseMagicalDefenseCalculator();
|
||||
private static final CharacterCalculator BASE_MAGICAL_DEFENSE_CALCULATOR = new CharacterBaseMagicalDefenseCalculator();
|
||||
|
||||
/**
|
||||
* The calculator base attack accuracy
|
||||
@@ -206,31 +211,51 @@ public class CharacterStats extends ActorStats {
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_ATTACK_ACCURACY_CALCULATOR = new BaseAttackAccuracyCalculator();
|
||||
private static final CharacterCalculator BASE_ATTACK_ACCURACY_CALCULATOR = new CharacterBaseAttackAccuracyCalculator();
|
||||
/**
|
||||
* The calculator base evasion
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_ATTACK_EVASION_CALCULATOR = new BaseAttackEvasionCalculator();
|
||||
private static final CharacterCalculator BASE_ATTACK_EVASION_CALCULATOR = new CharacterBaseAttackEvasionCalculator();
|
||||
|
||||
// BONUS
|
||||
/**
|
||||
* The calculator for CP bonus
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator CP_BONUS_CALCULATOR = new MaximumCPBonusCalculator();
|
||||
|
||||
// ADD
|
||||
/**
|
||||
* The calculator for HP add
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator HP_ADD_CALCULATOR = new MaximumHPAddCalculator();
|
||||
/**
|
||||
* The calculator for MP add
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator MP_ADD_CALCULATOR = new MaximumMPAddCalculator();
|
||||
/**
|
||||
* The calculator for CP add
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator CP_ADD_CALCULATOR = new MaximumCPAddCalculator();
|
||||
|
||||
/**
|
||||
* The character
|
||||
*/
|
||||
private final L2Character character;
|
||||
/**
|
||||
* The list of calculators for this character
|
||||
* <p>
|
||||
* It is safe to use an array since this number cannot be changed in
|
||||
* runtime, it would be required to be able to change the {@link StatType}
|
||||
* enum. Also, an full-sized array is created because this way we don't need
|
||||
* to change the array size very often. A bit of memory is "lost", but the
|
||||
* speed gain is much higher.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private final Calculator<L2Character>[] calculators = new Calculator[StatType
|
||||
.values().length];
|
||||
|
||||
/**
|
||||
* Creates a new {@link CharacterStats} and adds default calculators
|
||||
@@ -239,12 +264,10 @@ public class CharacterStats extends ActorStats {
|
||||
* the character
|
||||
*/
|
||||
public CharacterStats(L2Character character) {
|
||||
super();
|
||||
this.character = character;
|
||||
for (int i = 0; i < calculators.length; i++) {
|
||||
calculators[i] = new Calculator<L2Character>();
|
||||
}
|
||||
|
||||
// import default functions
|
||||
// base
|
||||
add(StatType.MAX_HP, BASE_HP_CALCULATOR);
|
||||
add(StatType.MAX_MP, BASE_MP_CALCULATOR);
|
||||
add(StatType.MAX_CP, BASE_CP_CALCULATOR);
|
||||
@@ -272,23 +295,17 @@ public class CharacterStats extends ActorStats {
|
||||
add(StatType.ACCURACY_COMBAT, BASE_ATTACK_ACCURACY_CALCULATOR);
|
||||
add(StatType.EVASION_RATE, BASE_ATTACK_EVASION_CALCULATOR);
|
||||
|
||||
// add hp/mp/cp add functions
|
||||
add(StatType.MAX_HP, HP_ADD_CALCULATOR);
|
||||
add(StatType.MAX_MP, MP_ADD_CALCULATOR);
|
||||
add(StatType.MAX_CP, CP_ADD_CALCULATOR);
|
||||
|
||||
// bonus
|
||||
add(StatType.MAX_CP, CP_BONUS_CALCULATOR);
|
||||
|
||||
// TODO henna stats calculators
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated maximum HP
|
||||
*/
|
||||
public int getMaxHP() {
|
||||
return (int) calc(StatType.MAX_HP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated maximum MP
|
||||
*/
|
||||
public int getMaxMP() {
|
||||
return (int) calc(StatType.MAX_MP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated maximum CP
|
||||
*/
|
||||
@@ -296,132 +313,6 @@ public class CharacterStats extends ActorStats {
|
||||
return (int) calc(StatType.MAX_CP);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated intelligence
|
||||
*/
|
||||
public int getIntelligence() {
|
||||
return (int) calc(StatType.STAT_INT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated strength
|
||||
*/
|
||||
public int getStrength() {
|
||||
return (int) calc(StatType.STAT_STR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated concentration
|
||||
*/
|
||||
public int getConcentration() {
|
||||
return (int) calc(StatType.STAT_CON);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated mentality
|
||||
*/
|
||||
public int getMentality() {
|
||||
return (int) calc(StatType.STAT_MEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated dexterity
|
||||
*/
|
||||
public int getDexterity() {
|
||||
return (int) calc(StatType.STAT_DEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated witness
|
||||
*/
|
||||
public int getWitness() {
|
||||
return (int) calc(StatType.STAT_WIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated run speed
|
||||
*/
|
||||
public int getRunSpeed() {
|
||||
return (int) calc(StatType.RUN_SPEED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated walk speed
|
||||
*/
|
||||
public int getWalkSpeed() {
|
||||
return (int) calc(StatType.WALK_SPEED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated physical attack
|
||||
*/
|
||||
public int getPhysicalAttack() {
|
||||
return (int) calc(StatType.POWER_ATTACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated physical attack speed
|
||||
*/
|
||||
public int getPhysicalAttackSpeed() {
|
||||
return (int) calc(StatType.POWER_ATTACK_SPEED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated physical attack critical rate
|
||||
*/
|
||||
public int getPhysicalCriticalRate() {
|
||||
return (int) calc(StatType.CRITICAL_RATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated physical defense
|
||||
*/
|
||||
public int getPhysicalDefense() {
|
||||
return (int) calc(StatType.POWER_DEFENSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated magical attack
|
||||
*/
|
||||
public int getMagicalAttack() {
|
||||
return (int) calc(StatType.MAGIC_ATTACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated magical attack speed
|
||||
*/
|
||||
public int getMagicalAttackSpeed() {
|
||||
return (int) calc(StatType.MAGIC_ATTACK_SPEED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated magical attack critical rate
|
||||
*/
|
||||
public int getMagicalCriticalRate() {
|
||||
return (int) calc(StatType.MCRITICAL_RATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated magical defense
|
||||
*/
|
||||
public int getMagicalDefense() {
|
||||
return (int) calc(StatType.MAGIC_DEFENSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated accuracy
|
||||
*/
|
||||
public int getAccuracy() {
|
||||
return (int) calc(StatType.ACCURACY_COMBAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated evasion rate
|
||||
*/
|
||||
public int getEvasionRate() {
|
||||
return (int) calc(StatType.EVASION_RATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the calculated maximum load
|
||||
*/
|
||||
@@ -429,34 +320,8 @@ public class CharacterStats extends ActorStats {
|
||||
return (int) calc(StatType.MAX_LOAD);
|
||||
}
|
||||
|
||||
public void add(StatType type, Calculator<L2Character> calculator) {
|
||||
getCalculator(type).importFunctions(calculator);
|
||||
}
|
||||
|
||||
public void remove(StatType type, Calculator<L2Character> calculator) {
|
||||
getCalculator(type).removeFunctions(calculator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param the
|
||||
* calculator {@link StatType}
|
||||
* @return the calculator object associated with the given <tt>type</tt>
|
||||
*/
|
||||
protected Calculator<L2Character> getCalculator(StatType type) {
|
||||
return calculators[type.ordinal()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the calculation of an given {@link StatType}
|
||||
*
|
||||
* @param type
|
||||
* the type
|
||||
* @return the value calculated
|
||||
*/
|
||||
public double calc(StatType type) {
|
||||
final CharacterCalculatorContext ctx = new CharacterCalculatorContext(
|
||||
character);
|
||||
getCalculator(type).calculate(character, ctx);
|
||||
return ctx.result;
|
||||
@Override
|
||||
protected CharacterCalculatorContext createContext() {
|
||||
return new CharacterCalculatorContext(character);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* 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.L2Character;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the character maximum CP
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseCP();
|
||||
*
|
||||
* int lvl = c.getLevel() - template.getMinimumLevel();
|
||||
* double mod = template.getBaseCPModifier() * lvl;
|
||||
* double max = (template.getBaseCPAdd() + mod) * lvl;
|
||||
* double min = (template.getBaseCPAdd() * lvl) + mod;
|
||||
* ctx.result += (max + min) / 2;
|
||||
*
|
||||
* ctx.result *= BaseStats.CON.calculateBonus(c.getStats().getConcentration());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseCPCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseCPCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseCP();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x100) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
final CharacterTemplate template = c.getTemplate();
|
||||
|
||||
int lvl = c.getLevel() - template.getMinimumLevel();
|
||||
double mod = template.getBaseCPModifier() * lvl;
|
||||
double max = (template.getBaseCPAdd() + mod) * lvl;
|
||||
double min = (template.getBaseCPAdd() * lvl) + mod;
|
||||
|
||||
ctx.result += (max + min) / 2;
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result *= BaseStats.CON.calculateBonus(c.getStats()
|
||||
.getConcentration());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* 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.L2Character;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the character maximum HP
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseHP();
|
||||
*
|
||||
* int lvl = c.getLevel() - template.getMinimumLevel();
|
||||
* double mod = template.getBaseHP() * lvl;
|
||||
* double max = (template.getBaseHPAdd() + mod) * lvl;
|
||||
* double min = (template.getBaseHPAdd() * lvl) + mod;
|
||||
* ctx.result += (max + min) / 2;
|
||||
*
|
||||
* ctx.result *= BaseStats.CON.calculateBonus(c.getStats().getConcentration());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseHPCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseHPCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseHP();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x100) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
final CharacterTemplate template = c.getTemplate();
|
||||
|
||||
int lvl = c.getLevel() - template.getMinimumLevel();
|
||||
double mod = template.getBaseHP() * lvl;
|
||||
double max = (template.getBaseHPAdd() + mod) * lvl;
|
||||
double min = (template.getBaseHPAdd() * lvl) + mod;
|
||||
|
||||
ctx.result += (max + min) / 2;
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result *= BaseStats.CON.calculateBonus(c.getStats()
|
||||
.getConcentration());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
* 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.L2Character.CharacterMoveType;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the character base HP regeneration
|
||||
*
|
||||
* <pre>
|
||||
* TODO base hp regen
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseHPRegenerationCalculator extends CharacterCalculator {
|
||||
/**
|
||||
* Retail value is 100
|
||||
*/
|
||||
public static final double HP_REGEN_MULTIPLIER = 100;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseHPRegenerationCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
// TODO set base hp regen
|
||||
ctx.result = 0;
|
||||
|
||||
// initial value is changed here
|
||||
ctx.result += (c.getLevel() > 10) ? ((c.getLevel() - 1) / 10.0)
|
||||
: 0.5;
|
||||
|
||||
// Add CON bonus
|
||||
ctx.result *= ((100.0 - 11 + c.getLevel()) / 100.0)
|
||||
* BaseStats.CON.calculateBonus(c.getStats()
|
||||
.getConcentration());
|
||||
|
||||
if (ctx.result < 0)
|
||||
ctx.result = 0;
|
||||
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(Integer.MAX_VALUE) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
double hpRegenMultiplier = HP_REGEN_MULTIPLIER;
|
||||
double hpRegenBonus = 0;
|
||||
|
||||
// TODO SevenSigns Festival modifier
|
||||
// if (SevenSignsFestival.getInstance().isFestivalInProgress()
|
||||
// && player.isFestivalParticipant())
|
||||
// hpRegenMultiplier *= calcFestivalRegenModifier(player);
|
||||
// else {
|
||||
// double siegeModifier = calcSiegeRegenModifer(player);
|
||||
// if (siegeModifier > 0)
|
||||
// hpRegenMultiplier *= siegeModifier;
|
||||
// }
|
||||
|
||||
// TODO clan hall regen
|
||||
// if (player.isInsideZone(L2Character.ZONE_CLANHALL)
|
||||
// && player.getClan() != null
|
||||
// && player.getClan().getHasHideout() > 0) {
|
||||
// L2ClanHallZone zone = ZoneManager.getInstance().getZone(
|
||||
// player, L2ClanHallZone.class);
|
||||
// int posChIndex = zone == null ? -1 : zone.getClanHallId();
|
||||
// int clanHallIndex = player.getClan().getHasHideout();
|
||||
// if (clanHallIndex > 0 && clanHallIndex == posChIndex) {
|
||||
// ClanHall clansHall = ClanHallManager.getInstance()
|
||||
// .getClanHallById(clanHallIndex);
|
||||
// if (clansHall != null)
|
||||
// if (clansHall.getFunction(ClanHall.FUNC_RESTORE_HP) != null)
|
||||
// hpRegenMultiplier *= 1 + (double) clansHall
|
||||
// .getFunction(ClanHall.FUNC_RESTORE_HP)
|
||||
// .getLvl() / 100;
|
||||
// }
|
||||
// }
|
||||
|
||||
// TODO castle regen
|
||||
// if (player.isInsideZone(L2Character.ZONE_CASTLE)
|
||||
// && player.getClan() != null
|
||||
// && player.getClan().getHasCastle() > 0) {
|
||||
// L2CastleZone zone = ZoneManager.getInstance().getZone(
|
||||
// player, L2CastleZone.class);
|
||||
// int posCastleIndex = zone == null ? -1 : zone.getCastleId();
|
||||
// int castleIndex = player.getClan().getHasCastle();
|
||||
// if (castleIndex > 0 && castleIndex == posCastleIndex) {
|
||||
// Castle castle = CastleManager.getInstance()
|
||||
// .getCastleById(castleIndex);
|
||||
// if (castle != null)
|
||||
// if (castle.getFunction(Castle.FUNC_RESTORE_HP) != null)
|
||||
// hpRegenMultiplier *= 1 + (double) castle
|
||||
// .getFunction(Castle.FUNC_RESTORE_HP)
|
||||
// .getLvl() / 100;
|
||||
// }
|
||||
// }
|
||||
|
||||
// TODO fort regen
|
||||
// if (player.isInsideZone(L2Character.ZONE_FORT)
|
||||
// && player.getClan() != null
|
||||
// && player.getClan().getHasFort() > 0) {
|
||||
// L2FortZone zone = ZoneManager.getInstance().getZone(player,
|
||||
// L2FortZone.class);
|
||||
// int posFortIndex = zone == null ? -1 : zone.getFortId();
|
||||
// int fortIndex = player.getClan().getHasFort();
|
||||
// if (fortIndex > 0 && fortIndex == posFortIndex) {
|
||||
// Fort fort = FortManager.getInstance().getFortById(
|
||||
// fortIndex);
|
||||
// if (fort != null)
|
||||
// if (fort.getFunction(Fort.FUNC_RESTORE_HP) != null)
|
||||
// hpRegenMultiplier *= 1 + (double) fort
|
||||
// .getFunction(Fort.FUNC_RESTORE_HP)
|
||||
// .getLvl() / 100;
|
||||
// }
|
||||
// }
|
||||
|
||||
// TODO Mother Tree effect is calculated at last
|
||||
// if (player.isInsideZone(L2Character.ZONE_MOTHERTREE)) {
|
||||
// L2MotherTreeZone zone = ZoneManager.getInstance().getZone(
|
||||
// player, L2MotherTreeZone.class);
|
||||
// int hpBonus = zone == null ? 0 : zone.getHpRegenBonus();
|
||||
// hpRegenBonus += hpBonus;
|
||||
// }
|
||||
|
||||
// Calculate Movement bonus
|
||||
// if (player.isSitting())
|
||||
// hpRegenMultiplier *= 1.5; // Sitting
|
||||
// else
|
||||
if (c.isIdle())
|
||||
hpRegenMultiplier *= 1.1; // Staying
|
||||
else if (c.getMoveType() == CharacterMoveType.RUN)
|
||||
hpRegenMultiplier *= 0.7; // Running
|
||||
|
||||
ctx.result = ctx.result * hpRegenMultiplier + hpRegenBonus;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* 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.L2Character;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the character base MP
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseBaseMP();
|
||||
*
|
||||
* int lvl = c.getLevel() - template.getMinimumLevel();
|
||||
* double mod = template.getBaseMPModifier() * lvl;
|
||||
* double max = (template.getBaseMPAdd() + mod) * lvl;
|
||||
* double min = (template.getBaseMPAdd() * lvl) + mod;
|
||||
* ctx.result += (max + min) / 2;
|
||||
*
|
||||
* ctx.result *= BaseStats.MEN.calculateBonus(c.getStats().getMentality());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseMPCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseMPCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseBaseMP();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x100) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
final CharacterTemplate template = c.getTemplate();
|
||||
|
||||
int lvl = c.getLevel() - template.getMinimumLevel();
|
||||
double mod = template.getBaseMPModifier() * lvl;
|
||||
double max = (template.getBaseMPAdd() + mod) * lvl;
|
||||
double min = (template.getBaseMPAdd() * lvl) + mod;
|
||||
|
||||
ctx.result += (max + min) / 2;
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result *= BaseStats.MEN.calculateBonus(c.getStats()
|
||||
.getMentality());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the character base magical defense.
|
||||
*
|
||||
* <pre>
|
||||
* 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);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseMagicalDefenseCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseMagicalDefenseCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseMagicalDefense();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculates the character base physical defense
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBasePhysicalDefense();
|
||||
*
|
||||
* 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))
|
||||
* 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);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BasePhysicalDefenseCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BasePhysicalDefenseCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBasePhysicalDefense();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x200) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -16,17 +16,15 @@
|
||||
*/
|
||||
package com.l2jserver.model.world.character.calculator;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
import com.l2jserver.util.calculator.Function;
|
||||
import com.l2jserver.model.world.actor.calculator.ActorCalculator;
|
||||
|
||||
/**
|
||||
* An calculator for character formulas.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterCalculator extends Calculator<L2Character> {
|
||||
public CharacterCalculator(Function<L2Character>... functions) {
|
||||
public class CharacterCalculator extends ActorCalculator {
|
||||
public CharacterCalculator(CharacterCalculatorFunction... functions) {
|
||||
super(functions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.ActorTemplate;
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.actor.calculator.ActorCalculatorFunction;
|
||||
|
||||
/**
|
||||
* An calculator for character formulas.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class CharacterCalculatorFunction extends
|
||||
ActorCalculatorFunction {
|
||||
public CharacterCalculatorFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final double calculate(Actor a, ActorTemplate<?> actorTemplate,
|
||||
double value) {
|
||||
return calculate((L2Character) a, (CharacterTemplate) actorTemplate,
|
||||
value);
|
||||
}
|
||||
|
||||
protected abstract double calculate(L2Character c, CharacterTemplate t,
|
||||
double value);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.L2Character;
|
||||
|
||||
/**
|
||||
* Calculates the character base CP
|
||||
*
|
||||
* <pre>
|
||||
* int lvl = c.getLevel() - template.getMinimumLevel();
|
||||
* double mod = template.getBaseCPModifier() * lvl;
|
||||
* double max = (template.getBaseCPAdd() + mod) * lvl;
|
||||
* double min = (template.getBaseCPAdd() * lvl) + mod;
|
||||
* ctx.result += (max + min) / 2;
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MaximumCPAddCalculator extends CharacterCalculator {
|
||||
public MaximumCPAddCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x100) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
int lvl = c.getLevel() - t.getMinimumLevel();
|
||||
double mod = t.getBaseCPModifier() * lvl;
|
||||
double max = (t.getBaseCPAdd() + mod) * lvl;
|
||||
double min = (t.getBaseCPAdd() * lvl) + mod;
|
||||
|
||||
return value + (max + min) / 2;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.L2Character;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
|
||||
/**
|
||||
* Calculates the character base CP
|
||||
*
|
||||
* <pre>
|
||||
* int lvl = c.getLevel() - template.getMinimumLevel();
|
||||
* double mod = template.getBaseCPModifier() * lvl;
|
||||
* double max = (template.getBaseCPAdd() + mod) * lvl;
|
||||
* double min = (template.getBaseCPAdd() * lvl) + mod;
|
||||
* ctx.result += (max + min) / 2;
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MaximumCPBonusCalculator extends CharacterCalculator {
|
||||
public MaximumCPBonusCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x100) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return value
|
||||
* BaseStats.CON.calculateBonus(c.getStats()
|
||||
.getConcentration());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.L2Character;
|
||||
|
||||
/**
|
||||
* Calculates the character maximum HP
|
||||
*
|
||||
* <pre>
|
||||
* int lvl = c.getLevel() - template.getMinimumLevel();
|
||||
* double mod = template.getBaseHPModifier() * lvl;
|
||||
* double max = (template.getBaseHPAdd() + mod) * lvl;
|
||||
* double min = (template.getBaseHPAdd() * lvl) + mod;
|
||||
* ctx.result += (max + min) / 2;
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MaximumHPAddCalculator extends CharacterCalculator {
|
||||
public MaximumHPAddCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x100) {
|
||||
@Override
|
||||
public double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
int lvl = c.getLevel() - t.getMinimumLevel();
|
||||
double mod = t.getBaseHPModifier() * lvl;
|
||||
double max = (t.getBaseHPAdd() + mod) * lvl;
|
||||
double min = (t.getBaseHPAdd() * lvl) + mod;
|
||||
|
||||
return value + (max + min) / 2;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.L2Character;
|
||||
|
||||
/**
|
||||
* Calculates the character base MP
|
||||
*
|
||||
* <pre>
|
||||
* int lvl = c.getLevel() - template.getMinimumLevel();
|
||||
* double mod = template.getBaseMPModifier() * lvl;
|
||||
* double max = (template.getBaseMPAdd() + mod) * lvl;
|
||||
* double min = (template.getBaseMPAdd() * lvl) + mod;
|
||||
* ctx.result += (max + min) / 2;
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MaximumMPAddCalculator extends CharacterCalculator {
|
||||
public MaximumMPAddCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x100) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
int lvl = c.getLevel() - t.getMinimumLevel();
|
||||
double mod = t.getBaseMPModifier() * lvl;
|
||||
double max = (t.getBaseMPAdd() + mod) * lvl;
|
||||
double min = (t.getBaseMPAdd() * lvl) + mod;
|
||||
|
||||
return value + (max + min) / 2;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base accuracy.
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseAccuracy();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseAttackAccuracyCalculator extends CharacterCalculator {
|
||||
public CharacterBaseAttackAccuracyCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseAccuracy();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character evasion
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseEvasion();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseAttackEvasionCalculator extends CharacterCalculator {
|
||||
public CharacterBaseAttackEvasionCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseEvasion();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character maximum CP
|
||||
*
|
||||
* <pre>
|
||||
* return c.getTemplate().getBaseCP();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseCPCalculator extends CharacterCalculator {
|
||||
public CharacterBaseCPCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseCP();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,12 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.character.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character concentration
|
||||
@@ -29,13 +30,13 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseConcentrationCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseConcentrationCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class CharacterBaseConcentrationCalculator extends CharacterCalculator {
|
||||
public CharacterBaseConcentrationCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseConcentration();
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseConcentration();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -14,11 +14,12 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.character.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base dexterity
|
||||
@@ -29,13 +30,13 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseDexterityCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseDexterityCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class CharacterBaseDexterityCalculator extends CharacterCalculator {
|
||||
public CharacterBaseDexterityCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseDexterity();
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseDexterity();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character maximum HP
|
||||
*
|
||||
* <pre>
|
||||
* return c.getTemplate().getBaseHP();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseHPCalculator extends CharacterCalculator {
|
||||
public CharacterBaseHPCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseHP();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,12 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.character.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base intelligence
|
||||
@@ -29,13 +30,13 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseIntelligenceCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseIntelligenceCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class CharacterBaseIntelligenceCalculator extends CharacterCalculator {
|
||||
public CharacterBaseIntelligenceCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseIntelligence();
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseIntelligence();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character maximum HP
|
||||
*
|
||||
* <pre>
|
||||
* return c.getTemplate().getBaseMP();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseMPCalculator extends CharacterCalculator {
|
||||
public CharacterBaseMPCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseBaseMP();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base magical attack
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result *= (((100.0 - 11 + c.getLevel()) / 100.0) ˆ 2)
|
||||
* * (BaseStats.INT.calculateBonus(c.getStats().getIntelligence()) ˆ 2);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseMagicalAttackCalculator extends CharacterCalculator {
|
||||
public CharacterBaseMagicalAttackCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseMagicalAttack();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the base magical attack speed
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseMagicalAttackSpeed();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseMagicalAttackSpeedCalculator extends CharacterCalculator {
|
||||
public CharacterBaseMagicalAttackSpeedCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseMagicalAttackSpeed();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,12 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.character.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the base magical attack critical rate
|
||||
@@ -31,21 +31,14 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseMagicalCriticalRateCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseMagicalCriticalRateCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class CharacterBaseMagicalCriticalRateCalculator extends
|
||||
CharacterCalculator {
|
||||
public CharacterBaseMagicalCriticalRateCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
// XXX is the same as physical????
|
||||
ctx.result = c.getTemplate().getBaseCritical();
|
||||
}
|
||||
}, new AbstractFunction<L2Character>(0x300) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
// TODO only apply if using a weapon
|
||||
ctx.result *= BaseStats.WIT.calculateBonus(c.getStats()
|
||||
.getWitness());
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseCritical();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base magical defense.
|
||||
*
|
||||
* <pre>
|
||||
* 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);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseMagicalDefenseCalculator extends CharacterCalculator {
|
||||
public CharacterBaseMagicalDefenseCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseMagicalDefense();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,12 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.character.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base mentality
|
||||
@@ -29,13 +30,13 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseMentalityCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseMentalityCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class CharacterBaseMentalityCalculator extends CharacterCalculator {
|
||||
public CharacterBaseMentalityCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseMentality();
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseMentality();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base physical attack
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBasePhysicalAttack();
|
||||
* ctx.result *= BaseStats.STR.calculateBonus(c.getStats().getStrength())
|
||||
* * ((100.0 - 11 + c.getLevel()) / 100.0);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBasePhysicalAttackCalculator extends CharacterCalculator {
|
||||
public CharacterBasePhysicalAttackCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBasePhysicalAttack();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base physical attack speed
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBasePhysicalAttackSpeed();
|
||||
* ctx.result *= BaseStats.DEX.calculateBonus(c.getStats().getDexterity());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBasePhysicalAttackSpeedCalculator extends
|
||||
CharacterCalculator {
|
||||
public CharacterBasePhysicalAttackSpeedCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBasePhysicalAttackSpeed();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base critical rate
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseCritical();
|
||||
* ctx.result *= BaseStats.DEX.calculateBonus(c.getStats().getDexterity());
|
||||
* ctx.result *= 10;
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBasePhysicalCriticalRateCalculator extends
|
||||
CharacterCalculator {
|
||||
public CharacterBasePhysicalCriticalRateCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseCritical();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base physical defense
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBasePhysicalDefense();
|
||||
*
|
||||
* 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))
|
||||
* 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);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBasePhysicalDefenseCalculator extends CharacterCalculator {
|
||||
public CharacterBasePhysicalDefenseCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBasePhysicalDefense();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base run speed
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseRunSpeed();
|
||||
* ctx.result *= BaseStats.DEX.calculateBonus(c.getStats().getDexterity());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseRunSpeedCalculator extends CharacterCalculator {
|
||||
public CharacterBaseRunSpeedCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseRunSpeed();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base strength
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseStrength();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseStrengthCalculator extends CharacterCalculator {
|
||||
public CharacterBaseStrengthCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseStrength();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base walk speed
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseWalkSpeed();
|
||||
* ctx.result *= BaseStats.DEX.calculateBonus(c.getStats().getDexterity());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseWalkSpeedCalculator extends CharacterCalculator {
|
||||
public CharacterBaseWalkSpeedCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseWalkSpeed();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.base;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base witness
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseWitness();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterBaseWitnessCalculator extends CharacterCalculator {
|
||||
public CharacterBaseWitnessCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
return t.getBaseWitness();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
256
src/main/java/com/l2jserver/model/world/npc/NPCStats.java
Normal file
256
src/main/java/com/l2jserver/model/world/npc/NPCStats.java
Normal file
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* 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.npc;
|
||||
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.actor.stat.ActorStats;
|
||||
import com.l2jserver.model.world.actor.stat.StatType;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorContext;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseAttackAccuracyCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseAttackEvasionCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseConcentrationCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseDexterityCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseHPCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseIntelligenceCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseMPCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseMagicalAttackCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseMagicalAttackSpeedCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseMagicalCriticalRateCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseMagicalDefenseCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseMentalityCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBasePhysicalAttackCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBasePhysicalAttackSpeedCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBasePhysicalCriticalRateCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBasePhysicalDefenseCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseRunSpeedCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseStrengthCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseWalkSpeedCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseWitnessCalculator;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
|
||||
/**
|
||||
* This class is responsible for calculating the real NPC stats. The real stats
|
||||
* vary from the values from the templates, also, skills and items equipped can
|
||||
* change those values. Once an buff is applied, a new calculator is
|
||||
* {@link Calculator#importFunctions(Calculator) imported} and their functions
|
||||
* are added to this class calculator. Once the skill effect has past away, all
|
||||
* the functions that were imported are now
|
||||
* {@link Calculator#removeFunctions(Calculator) removed} and the calculator
|
||||
* return to its original state.
|
||||
* <p>
|
||||
* Another important note is that calculators should perform calculations as
|
||||
* fast as possible.
|
||||
* <p>
|
||||
* <i><b>IMPORTANT</b>: NEVER TOUCH THE STATIC CALCULATORS!</i>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCStats extends ActorStats<NPCCalculatorContext> {
|
||||
/**
|
||||
* The calculator for base maximum MP
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_HP_CALCULATOR = new NPCBaseHPCalculator();
|
||||
/**
|
||||
* The calculator for base maximum MP
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_MP_CALCULATOR = new NPCBaseMPCalculator();
|
||||
|
||||
/**
|
||||
* The calculator for base intelligence
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_INT_CALCULATOR = new NPCBaseIntelligenceCalculator();
|
||||
/**
|
||||
* The calculator for base strength
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_STR_CALCULATOR = new NPCBaseStrengthCalculator();
|
||||
/**
|
||||
* The calculator for base concentration
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_CON_CALCULATOR = new NPCBaseConcentrationCalculator();
|
||||
/**
|
||||
* The calculator for base mentality
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_MEN_CALCULATOR = new NPCBaseMentalityCalculator();
|
||||
/**
|
||||
* The calculator for base dexterity
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_DEX_CALCULATOR = new NPCBaseDexterityCalculator();
|
||||
/**
|
||||
* The calculator for base witness
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_WIT_CALCULATOR = new NPCBaseWitnessCalculator();
|
||||
|
||||
/**
|
||||
* The calculator for base run speed
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_RUN_SPEED_CALCULATOR = new NPCBaseRunSpeedCalculator();
|
||||
/**
|
||||
* The calculator for base walk speed
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_WALK_SPEED_CALCULATOR = new NPCBaseWalkSpeedCalculator();
|
||||
|
||||
/**
|
||||
* The calculator base physical attack
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_PHYSICAL_ATTACK_CALCULATOR = new NPCBasePhysicalAttackCalculator();
|
||||
/**
|
||||
* The calculator base physical attack speed
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_PHYSICAL_ATTACK_SPEED_CALCULATOR = new NPCBasePhysicalAttackSpeedCalculator();
|
||||
/**
|
||||
* The calculator base physical attack critical rate
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_PHYSICAL_CRITICAL_RATE_CALCULATOR = new NPCBasePhysicalCriticalRateCalculator();
|
||||
/**
|
||||
* The calculator base physical defense
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_PHYSICAL_DEFENSE_CALCULATOR = new NPCBasePhysicalDefenseCalculator();
|
||||
|
||||
/**
|
||||
* The calculator base magical attack
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_MAGICAL_ATTACK_CALCULATOR = new NPCBaseMagicalAttackCalculator();
|
||||
/**
|
||||
* The calculator base magical attack speed
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_MAGICAL_ATTACK_SPEED_CALCULATOR = new NPCBaseMagicalAttackSpeedCalculator();
|
||||
/**
|
||||
* The calculator base magical attack critical rate
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_MAGICAL_CRITICAL_RATE_CALCULATOR = new NPCBaseMagicalCriticalRateCalculator();
|
||||
/**
|
||||
* The calculator base magical defense
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_MAGICAL_DEFENSE_CALCULATOR = new NPCBaseMagicalDefenseCalculator();
|
||||
|
||||
/**
|
||||
* The calculator base attack accuracy
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_ATTACK_ACCURACY_CALCULATOR = new NPCBaseAttackAccuracyCalculator();
|
||||
/**
|
||||
* The calculator base evasion
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_ATTACK_EVASION_CALCULATOR = new NPCBaseAttackEvasionCalculator();
|
||||
|
||||
/**
|
||||
* The NPC
|
||||
*/
|
||||
private final NPC npc;
|
||||
|
||||
/**
|
||||
* Creates a new {@link NPCStats} and adds default calculators
|
||||
*
|
||||
* @param npc
|
||||
* the npc
|
||||
*/
|
||||
public NPCStats(NPC npc) {
|
||||
super();
|
||||
this.npc = npc;
|
||||
|
||||
add(StatType.MAX_HP, BASE_HP_CALCULATOR);
|
||||
add(StatType.MAX_MP, BASE_MP_CALCULATOR);
|
||||
|
||||
add(StatType.STAT_INT, BASE_INT_CALCULATOR);
|
||||
add(StatType.STAT_STR, BASE_STR_CALCULATOR);
|
||||
add(StatType.STAT_CON, BASE_CON_CALCULATOR);
|
||||
add(StatType.STAT_MEN, BASE_MEN_CALCULATOR);
|
||||
add(StatType.STAT_DEX, BASE_DEX_CALCULATOR);
|
||||
add(StatType.STAT_WIT, BASE_WIT_CALCULATOR);
|
||||
|
||||
add(StatType.RUN_SPEED, BASE_RUN_SPEED_CALCULATOR);
|
||||
add(StatType.WALK_SPEED, BASE_WALK_SPEED_CALCULATOR);
|
||||
|
||||
add(StatType.POWER_ATTACK, BASE_PHYSICAL_ATTACK_CALCULATOR);
|
||||
add(StatType.POWER_ATTACK_SPEED, BASE_PHYSICAL_ATTACK_SPEED_CALCULATOR);
|
||||
add(StatType.CRITICAL_RATE, BASE_PHYSICAL_CRITICAL_RATE_CALCULATOR);
|
||||
add(StatType.POWER_DEFENSE, BASE_PHYSICAL_DEFENSE_CALCULATOR);
|
||||
|
||||
add(StatType.MAGIC_ATTACK, BASE_MAGICAL_ATTACK_CALCULATOR);
|
||||
add(StatType.MAGIC_ATTACK_SPEED, BASE_MAGICAL_ATTACK_SPEED_CALCULATOR);
|
||||
add(StatType.MCRITICAL_RATE, BASE_MAGICAL_CRITICAL_RATE_CALCULATOR);
|
||||
add(StatType.MAGIC_DEFENSE, BASE_MAGICAL_DEFENSE_CALCULATOR);
|
||||
|
||||
add(StatType.ACCURACY_COMBAT, BASE_ATTACK_ACCURACY_CALCULATOR);
|
||||
add(StatType.EVASION_RATE, BASE_ATTACK_EVASION_CALCULATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected NPCCalculatorContext createContext() {
|
||||
return new NPCCalculatorContext(npc);
|
||||
}
|
||||
}
|
||||
@@ -16,17 +16,14 @@
|
||||
*/
|
||||
package com.l2jserver.model.world.npc.calculator;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
import com.l2jserver.util.calculator.Function;
|
||||
import com.l2jserver.model.world.actor.calculator.ActorCalculator;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class NPCCalculator extends Calculator<L2Character> {
|
||||
public NPCCalculator(
|
||||
Function<L2Character>... functions) {
|
||||
public class NPCCalculator extends ActorCalculator {
|
||||
public NPCCalculator(NPCCalculatorFunction... functions) {
|
||||
super(functions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.npc.calculator;
|
||||
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.actor.calculator.ActorCalculatorContext;
|
||||
|
||||
/**
|
||||
* Calculator context for {@link NPC} formulas
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCCalculatorContext extends ActorCalculatorContext {
|
||||
/**
|
||||
* The npc instance
|
||||
*/
|
||||
public final NPC npc;
|
||||
|
||||
public NPCCalculatorContext(NPC npc) {
|
||||
super(npc);
|
||||
this.npc = npc;
|
||||
}
|
||||
}
|
||||
@@ -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.npc.calculator;
|
||||
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.actor.calculator.ActorCalculatorFunction;
|
||||
|
||||
/**
|
||||
* An function for {@link NPC} formulas.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class NPCCalculatorFunction extends ActorCalculatorFunction {
|
||||
public NPCCalculatorFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final double calculate(Actor a, ActorTemplate<?> actorTemplate,
|
||||
double value) {
|
||||
return calculate((NPC) a, (NPCTemplate) actorTemplate, value);
|
||||
}
|
||||
|
||||
protected abstract double calculate(NPC c, NPCTemplate t, double value);
|
||||
}
|
||||
@@ -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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base accuracy.
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseAccuracy();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseAttackAccuracyCalculator extends NPCCalculator {
|
||||
public NPCBaseAttackAccuracyCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t, double value) {
|
||||
// return t.getEvasion()
|
||||
// TODO
|
||||
return value;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character evasion
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getEvasion();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseAttackEvasionCalculator extends NPCCalculator {
|
||||
public NPCBaseAttackEvasionCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getEvasion();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character concentration
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getConcentration();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseConcentrationCalculator extends NPCCalculator {
|
||||
public NPCBaseConcentrationCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getConcentration();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base dexterity
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getDexterity();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseDexterityCalculator extends NPCCalculator {
|
||||
public NPCBaseDexterityCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getDexterity();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character maximum HP
|
||||
*
|
||||
* <pre>
|
||||
* return c.getTemplate().getHP();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseHPCalculator extends NPCCalculator {
|
||||
public NPCBaseHPCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getMaximumHP();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base intelligence
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getIntelligence();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseIntelligenceCalculator extends NPCCalculator {
|
||||
public NPCBaseIntelligenceCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getIntelligence();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character maximum HP
|
||||
*
|
||||
* <pre>
|
||||
* return c.getTemplate().getMP();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseMPCalculator extends NPCCalculator {
|
||||
public NPCBaseMPCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public double calculate(NPC c, NPCTemplate t, double value) {
|
||||
return t.getMaximumMP();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base magical attack
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result *= (((100.0 - 11 + c.getLevel()) / 100.0) ˆ 2)
|
||||
* * (BaseStats.INT.calculateBonus(c.getStats().getIntelligence()) ˆ 2);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseMagicalAttackCalculator extends NPCCalculator {
|
||||
public NPCBaseMagicalAttackCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getMagicalAttack();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the base magical attack speed
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getMagicalAttackSpeed();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseMagicalAttackSpeedCalculator extends NPCCalculator {
|
||||
public NPCBaseMagicalAttackSpeedCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getMagicalAttackSpeed();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the base magical attack critical rate
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getCritical(); // must be checked
|
||||
* ctx.result *= BaseStats.WIT.calculateBonus(c.getStats().getWitness());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseMagicalCriticalRateCalculator extends
|
||||
NPCCalculator {
|
||||
public NPCBaseMagicalCriticalRateCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getCritical();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base magical defense.
|
||||
*
|
||||
* <pre>
|
||||
* 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);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseMagicalDefenseCalculator extends NPCCalculator {
|
||||
public NPCBaseMagicalDefenseCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getMagicalDefense();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base mentality
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getMentality();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseMentalityCalculator extends NPCCalculator {
|
||||
public NPCBaseMentalityCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getMentality();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base physical attack
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getPhysicalAttack();
|
||||
* ctx.result *= BaseStats.STR.calculateBonus(c.getStats().getStrength())
|
||||
* * ((100.0 - 11 + c.getLevel()) / 100.0);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBasePhysicalAttackCalculator extends NPCCalculator {
|
||||
public NPCBasePhysicalAttackCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getPhysicalAttack();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base physical attack speed
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getPhysicalAttackSpeed();
|
||||
* ctx.result *= BaseStats.DEX.calculateBonus(c.getStats().getDexterity());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBasePhysicalAttackSpeedCalculator extends
|
||||
NPCCalculator {
|
||||
public NPCBasePhysicalAttackSpeedCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getPhysicalAttackSpeed();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base critical rate
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseCritical();
|
||||
* ctx.result *= BaseStats.DEX.calculateBonus(c.getStats().getDexterity());
|
||||
* ctx.result *= 10;
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBasePhysicalCriticalRateCalculator extends NPCCalculator {
|
||||
public NPCBasePhysicalCriticalRateCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t, double value) {
|
||||
return t.getCritical();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base physical defense
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBasePhysicalDefense();
|
||||
*
|
||||
* 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))
|
||||
* 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);
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBasePhysicalDefenseCalculator extends NPCCalculator {
|
||||
public NPCBasePhysicalDefenseCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t, double value) {
|
||||
return t.getPhysicalDefense();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base run speed
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseRunSpeed();
|
||||
* ctx.result *= BaseStats.DEX.calculateBonus(c.getStats().getDexterity());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseRunSpeedCalculator extends NPCCalculator {
|
||||
public NPCBaseRunSpeedCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getRunSpeed();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,12 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base strength
|
||||
@@ -29,13 +30,13 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseStrengthCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseStrengthCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class NPCBaseStrengthCalculator extends NPCCalculator {
|
||||
public NPCBaseStrengthCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseStrength();
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getStrength();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -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.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base walk speed
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseWalkSpeed();
|
||||
* ctx.result *= BaseStats.DEX.calculateBonus(c.getStats().getDexterity());
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCBaseWalkSpeedCalculator extends NPCCalculator {
|
||||
public NPCBaseWalkSpeedCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getWalkSpeed();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,12 @@
|
||||
* 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;
|
||||
package com.l2jserver.model.world.npc.calculator.base;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base witness
|
||||
@@ -29,13 +30,13 @@ import com.l2jserver.util.calculator.CalculatorContext;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class BaseWitnessCalculator extends CharacterCalculator {
|
||||
@SuppressWarnings("unchecked")
|
||||
public BaseWitnessCalculator() {
|
||||
super(new AbstractFunction<L2Character>(0x000) {
|
||||
public class NPCBaseWitnessCalculator extends NPCCalculator {
|
||||
public NPCBaseWitnessCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public void calculate(L2Character c, CalculatorContext ctx) {
|
||||
ctx.result = c.getTemplate().getBaseWitness();
|
||||
protected double calculate(NPC c, NPCTemplate t,
|
||||
double value) {
|
||||
return t.getWitness();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -16,13 +16,12 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractFunction<O extends Actor> implements Function<O> {
|
||||
public abstract class AbstractFunction<T extends CalculatorContext> implements
|
||||
Function<T> {
|
||||
private final int order;
|
||||
|
||||
public AbstractFunction(int order) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
@@ -29,11 +28,13 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class Calculator<O extends Actor> extends AbstractFunction<O> {
|
||||
public class Calculator<T extends CalculatorContext> extends
|
||||
AbstractFunction<T> {
|
||||
/**
|
||||
* List of operations in this calculator
|
||||
*/
|
||||
private final List<Function<O>> functions = CollectionFactory.newList();
|
||||
private final List<Function<? super T>> functions = CollectionFactory
|
||||
.newList();
|
||||
|
||||
/**
|
||||
* Creates a new empty calculator. Functions can be add using
|
||||
@@ -50,9 +51,9 @@ public class Calculator<O extends Actor> extends AbstractFunction<O> {
|
||||
* @param functions
|
||||
* the calculator functions
|
||||
*/
|
||||
public Calculator(Function<O>... functions) {
|
||||
public Calculator(Function<? super T>... functions) {
|
||||
super(0x00);
|
||||
for (final Function<O> func : functions) {
|
||||
for (final Function<? super T> func : functions) {
|
||||
this.functions.add(func);
|
||||
}
|
||||
}
|
||||
@@ -68,7 +69,7 @@ public class Calculator<O extends Actor> extends AbstractFunction<O> {
|
||||
* @param function
|
||||
* the operation
|
||||
*/
|
||||
public void add(Function<O> function) {
|
||||
public void add(Function<? super T> function) {
|
||||
functions.add(function);
|
||||
Collections.sort(functions, FunctionOrderComparator.SHARED_INSTANCE);
|
||||
}
|
||||
@@ -83,10 +84,10 @@ public class Calculator<O extends Actor> extends AbstractFunction<O> {
|
||||
* @param calculator
|
||||
* the calculator
|
||||
*/
|
||||
public void importFunctions(Calculator<O> calculator) {
|
||||
for (final Function<O> function : calculator.functions) {
|
||||
public void importFunctions(Calculator<? super T> calculator) {
|
||||
for (final Function<? super T> function : calculator.functions) {
|
||||
if (function instanceof Calculator) {
|
||||
importFunctions((Calculator<O>) function);
|
||||
importFunctions((Calculator<? super T>) function);
|
||||
} else {
|
||||
functions.add(function);
|
||||
}
|
||||
@@ -101,10 +102,10 @@ public class Calculator<O extends Actor> extends AbstractFunction<O> {
|
||||
* @param calculator
|
||||
* the calculator
|
||||
*/
|
||||
public void removeFunctions(Calculator<O> calculator) {
|
||||
for (final Function<O> function : calculator.functions) {
|
||||
public void removeFunctions(Calculator<? super T> calculator) {
|
||||
for (final Function<? super T> function : calculator.functions) {
|
||||
if (function instanceof Calculator) {
|
||||
removeFunctions((Calculator<O>) function);
|
||||
removeFunctions((Calculator<? super T>) function);
|
||||
} else {
|
||||
functions.remove(function);
|
||||
}
|
||||
@@ -112,10 +113,15 @@ public class Calculator<O extends Actor> extends AbstractFunction<O> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(O object, CalculatorContext ctx) {
|
||||
for (final Function<O> function : functions) {
|
||||
function.calculate(object, ctx);
|
||||
public double calculate(T ctx, double value) {
|
||||
for (final Function<? super T> function : functions) {
|
||||
value = function.calculate(ctx, value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public double calculate(T ctx) {
|
||||
return calculate(ctx, 0);
|
||||
}
|
||||
|
||||
public static class FunctionOrderComparator implements
|
||||
|
||||
@@ -18,8 +18,7 @@ package com.l2jserver.util.calculator;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CalculatorContext {
|
||||
public double result;
|
||||
}
|
||||
|
||||
@@ -16,15 +16,13 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* This function performs a division: <blockquote><code>chain value /
|
||||
* value</code></blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class DivisionFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
public class DivisionFunction extends AbstractFunction<CalculatorContext> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
@@ -36,7 +34,7 @@ public class DivisionFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(O actor, CalculatorContext ctx) {
|
||||
ctx.result /= this.value;
|
||||
public double calculate(CalculatorContext ctx, double value) {
|
||||
return value / this.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* An function is nothing more than a mathematical operation.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Function<O extends Actor> {
|
||||
public interface Function<T extends CalculatorContext> {
|
||||
/**
|
||||
* Performs the operation in the calculation process.
|
||||
* <p>
|
||||
@@ -35,7 +33,7 @@ public interface Function<O extends Actor> {
|
||||
* the input value
|
||||
* @return the output value
|
||||
*/
|
||||
void calculate(O actor, CalculatorContext ctx);
|
||||
double calculate(T ctx, double value);
|
||||
|
||||
/**
|
||||
* @return the order this function will be executed
|
||||
|
||||
@@ -16,22 +16,19 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* This function performs an modulus: <blockquote><code>|chain value|</code>
|
||||
* </blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ModulusFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
public class ModulusFunction extends AbstractFunction<CalculatorContext> {
|
||||
public ModulusFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(O actor, CalculatorContext ctx) {
|
||||
if (ctx.result < 0)
|
||||
ctx.result *= -1;
|
||||
public double calculate(CalculatorContext ctx, double value) {
|
||||
return Math.abs(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,13 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* This function performs an multiplication: <blockquote><code>chain value *
|
||||
* value</code></blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MultiplicationFunction<O extends Actor> extends
|
||||
AbstractFunction<O> {
|
||||
public class MultiplicationFunction extends AbstractFunction<CalculatorContext> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
@@ -37,7 +34,7 @@ public class MultiplicationFunction<O extends Actor> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(O actor, CalculatorContext ctx) {
|
||||
ctx.result *= this.value;
|
||||
public double calculate(CalculatorContext ctx, double value) {
|
||||
return value * this.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,21 +16,19 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* This function performs an negate: <blockquote><code>-chain value</code>
|
||||
* </blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NegateFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
public class NegateFunction extends AbstractFunction<CalculatorContext> {
|
||||
public NegateFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(O actor, CalculatorContext ctx) {
|
||||
ctx.result = -ctx.result;
|
||||
public double calculate(CalculatorContext ctx, double value) {
|
||||
return -value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,13 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* This function performs a multiplication: <blockquote><code>chain value *
|
||||
* (value / 100)</code></blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class PercentFunction<O extends Actor> extends MultiplicationFunction<O> {
|
||||
public class PercentFunction extends MultiplicationFunction {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
|
||||
@@ -16,20 +16,18 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* This function performs an rounding in the number.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class RoundFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
public class RoundFunction extends AbstractFunction<CalculatorContext> {
|
||||
public RoundFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(O actor, CalculatorContext ctx) {
|
||||
ctx.result = Math.round(ctx.result);
|
||||
public double calculate(CalculatorContext ctx, double value) {
|
||||
return Math.round(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,12 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* This function performs an set. It ignores the input value and return its own.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SetFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
public class SetFunction extends AbstractFunction<CalculatorContext> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
@@ -35,7 +33,7 @@ public class SetFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(O actor, CalculatorContext ctx) {
|
||||
ctx.result = value;
|
||||
public double calculate(CalculatorContext ctx, double value) {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,13 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* This function performs an subtraction: <blockquote><code>chain value -
|
||||
* value</code></blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SubtractFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
public class SubtractFunction extends AbstractFunction<CalculatorContext> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
@@ -36,7 +34,7 @@ public class SubtractFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(O actor, CalculatorContext ctx) {
|
||||
ctx.result -= value;
|
||||
public double calculate(CalculatorContext ctx, double value) {
|
||||
return value - this.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,13 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* This function performs a sum: <blockquote><code>chain value +
|
||||
* value</code></blockquote>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SumFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
public class SumFunction extends AbstractFunction<CalculatorContext> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
@@ -36,7 +34,7 @@ public class SumFunction<O extends Actor> extends AbstractFunction<O> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(O actor, CalculatorContext ctx) {
|
||||
ctx.result += value;
|
||||
public double calculate(CalculatorContext ctx, double value) {
|
||||
return value + this.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,29 @@ public class Point {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the x
|
||||
*/
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the y
|
||||
*/
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new point from X and Y axis
|
||||
*
|
||||
* @param x
|
||||
* the x axis
|
||||
* @param y
|
||||
* the y axis
|
||||
* @return the new created Point
|
||||
*/
|
||||
public static final Point fromXY(int x, int y) {
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.l2jserver.util.geometry;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class Point3D {
|
||||
public class Point3D extends Point {
|
||||
/**
|
||||
* The point coordinate
|
||||
*/
|
||||
@@ -41,6 +41,7 @@ public class Point3D {
|
||||
* the angle
|
||||
*/
|
||||
public Point3D(Coordinate coordinate, double angle) {
|
||||
super(coordinate.getX(), coordinate.getY());
|
||||
this.coordinate = coordinate;
|
||||
this.angle = angle;
|
||||
}
|
||||
@@ -63,6 +64,7 @@ public class Point3D {
|
||||
* @return the x
|
||||
* @see com.l2jserver.util.geometry.Coordinate#getX()
|
||||
*/
|
||||
@Override
|
||||
public int getX() {
|
||||
return coordinate.getX();
|
||||
}
|
||||
@@ -71,6 +73,7 @@ public class Point3D {
|
||||
* @return the y
|
||||
* @see com.l2jserver.util.geometry.Coordinate#getY()
|
||||
*/
|
||||
@Override
|
||||
public int getY() {
|
||||
return coordinate.getY();
|
||||
}
|
||||
@@ -130,7 +133,7 @@ public class Point3D {
|
||||
* the angle
|
||||
* @return the new {@link Point3D} object created
|
||||
*/
|
||||
public static Point3D fromXYZA(int x, int y, int z, double angle) {
|
||||
public static final Point3D fromXYZA(int x, int y, int z, double angle) {
|
||||
return new Point3D(Coordinate.fromXYZ(x, y, z), angle);
|
||||
}
|
||||
|
||||
@@ -145,7 +148,7 @@ public class Point3D {
|
||||
* the z point
|
||||
* @return the new {@link Point3D} object created
|
||||
*/
|
||||
public static Point3D fromXYZ(int x, int y, int z) {
|
||||
public static final Point3D fromXYZ(int x, int y, int z) {
|
||||
return fromXYZA(x, y, z, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,6 @@ public class PolygonArea extends AbstractArea {
|
||||
|
||||
@Override
|
||||
public Point getClosestPoint(int x, int y) {
|
||||
|
||||
Point closestPoint = null;
|
||||
double closestDistance = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user