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

Implemented XML templates

This commit is contained in:
2011-05-24 22:55:31 -03:00
parent 6497016e14
commit cc44946831
10377 changed files with 309163 additions and 6171 deletions

View File

@@ -1,142 +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;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.actor.ActorAttributes;
/**
* This {@link ActorAttributes} implementation calculates the <b>real</b>
* character attributes based on it's {@link CharacterTemplate} and active
* buffs.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterCalculatedAttributes implements ActorAttributes {
/**
* The character
*/
private final L2Character character;
/**
* The base attributes (from {@link CharacterTemplate})
*/
private final ActorAttributes baseAttributes;
public CharacterCalculatedAttributes(L2Character character) {
this.character = character;
this.baseAttributes = this.character.getBaseAttributes();
}
@Override
public int getIntelligence() {
return baseAttributes.getIntelligence();
}
@Override
public int getStrength() {
return baseAttributes.getStrength();
}
@Override
public int getConcentration() {
return baseAttributes.getConcentration();
}
@Override
public int getMentality() {
return baseAttributes.getMentality();
}
@Override
public int getDexterity() {
return baseAttributes.getDexterity();
}
@Override
public int getWitness() {
return baseAttributes.getWitness();
}
@Override
public double getPhysicalAttack() {
return baseAttributes.getPhysicalAttack();
}
@Override
public double getMagicalAttack() {
return baseAttributes.getMagicalAttack();
}
@Override
public double getPhysicalDefense() {
return baseAttributes.getPhysicalDefense();
}
@Override
public double getMagicalDefense() {
return baseAttributes.getMagicalDefense();
}
@Override
public int getAttackSpeed() {
return baseAttributes.getAttackSpeed();
}
@Override
public int getCastSpeed() {
return baseAttributes.getCastSpeed();
}
@Override
public int getAccuracy() {
return baseAttributes.getAccuracy();
}
@Override
public int getCriticalChance() {
return baseAttributes.getCriticalChance();
}
@Override
public int getEvasionChance() {
return baseAttributes.getEvasionChance();
}
@Override
public double getRunSpeed() {
return baseAttributes.getRunSpeed();
}
@Override
public double getWalkSpeed() {
//FIXME this is a temporary work arround
return getRunSpeed();
//return baseAttributes.getWalkSpeed();
}
@Override
public int getMaxWeigth() {
return baseAttributes.getMaxWeigth();
}
@Override
public boolean canCraft() {
return baseAttributes.canCraft();
}
}

View File

@@ -212,6 +212,10 @@ public class CharacterStats {
public int getEvasionRate() {
return (int) calc(StatType.EVASION_RATE);
}
public int getMaximumLoad() {
return (int) calc(StatType.MAX_LOAD);
}
// public void add(StatType type, Calculator<?> calculator) {
// getCalculator(type).importFunctions(calculator);

View File

@@ -32,7 +32,7 @@ public class BaseAttackAccuracyCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getAccuracy();
ctx.result = c.getTemplate().getBaseAccuracy();
}
}, new AbstractFunction<L2Character>(0x100) {
@Override

View File

@@ -32,7 +32,7 @@ public class BaseAttackEvasionCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getEvasionChance();
ctx.result = c.getTemplate().getBaseEvasion();
}
}, new AbstractFunction<L2Character>(0x100) {
@Override

View File

@@ -32,7 +32,7 @@ public class BaseCPCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getCpBase();
ctx.result = c.getTemplate().getBaseCP();
}
}, new AbstractFunction<L2Character>(0x100) {
@Override
@@ -40,9 +40,9 @@ public class BaseCPCalculator extends CharacterCalculator {
final CharacterTemplate template = c.getTemplate();
int lvl = c.getLevel() - template.getMinimumLevel();
double mod = template.getCpMultiplier() * lvl;
double max = (template.getCpAdd() + mod) * lvl;
double min = (template.getCpAdd() * lvl) + mod;
double mod = template.getBaseCPModifier() * lvl;
double max = (template.getBaseCPAdd() + mod) * lvl;
double min = (template.getBaseCPAdd() * lvl) + mod;
ctx.result += (max + min) / 2;
}

View File

@@ -29,7 +29,7 @@ public class BaseConcentrationCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getConcentration();
ctx.result = c.getTemplate().getBaseConcentration();
}
});
}

View File

@@ -29,7 +29,7 @@ public class BaseDexterityCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getDextry();
ctx.result = c.getTemplate().getBaseDexterity();
}
});
}

View File

@@ -32,7 +32,7 @@ public class BaseHPCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getHpBase();
ctx.result = c.getTemplate().getBaseHP();
}
}, new AbstractFunction<L2Character>(0x100) {
@Override
@@ -40,9 +40,9 @@ public class BaseHPCalculator extends CharacterCalculator {
final CharacterTemplate template = c.getTemplate();
int lvl = c.getLevel() - template.getMinimumLevel();
double mod = template.getHpMultiplier() * lvl;
double max = (template.getHpAdd() + mod) * lvl;
double min = (template.getHpAdd() * lvl) + mod;
double mod = template.getBaseHP() * lvl;
double max = (template.getBaseHPAdd() + mod) * lvl;
double min = (template.getBaseHPAdd() * lvl) + mod;
ctx.result += (max + min) / 2;
}

View File

@@ -0,0 +1,150 @@
/*
* 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;
/**
* @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;
}
});
}
}

View File

@@ -29,7 +29,7 @@ public class BaseIntelligenceCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getIntelligence();
ctx.result = c.getTemplate().getBaseIntelligence();
}
});
}

View File

@@ -32,7 +32,7 @@ public class BaseMPCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getMpBase();
ctx.result = c.getTemplate().getBaseBaseMP();
}
}, new AbstractFunction<L2Character>(0x100) {
@Override
@@ -40,9 +40,9 @@ public class BaseMPCalculator extends CharacterCalculator {
final CharacterTemplate template = c.getTemplate();
int lvl = c.getLevel() - template.getMinimumLevel();
double mod = template.getMpMultiplier() * lvl;
double max = (template.getMpAdd() + mod) * lvl;
double min = (template.getMpAdd() * lvl) + mod;
double mod = template.getBaseMPModifier() * lvl;
double max = (template.getBaseMPAdd() + mod) * lvl;
double min = (template.getBaseMPAdd() * lvl) + mod;
ctx.result += (max + min) / 2;
}

View File

@@ -31,7 +31,7 @@ public class BaseMagicalAttackCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getMagicalAttack();
ctx.result = c.getTemplate().getBaseMagicalAttack();
}
}, new AbstractFunction<L2Character>(0x200) {
@Override

View File

@@ -31,7 +31,7 @@ public class BaseMagicalAttackSpeedCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getCastSpeed();
ctx.result = c.getTemplate().getBaseMagicalAttackSpeed();
}
}, new AbstractFunction<L2Character>(0x200) {
@Override

View File

@@ -31,7 +31,7 @@ public class BaseMagicalCriticalRateCalculator extends CharacterCalculator {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
// XXX is the same as physical????
ctx.result = c.getTemplate().getCriticalChance();
ctx.result = c.getTemplate().getBaseCritical();
}
}, new AbstractFunction<L2Character>(0x300) {
@Override

View File

@@ -37,7 +37,7 @@ public class BaseMagicalDefenseCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getMagicalDefense();
ctx.result = c.getTemplate().getBaseMagicalDefense();
}
}, new AbstractFunction<L2Character>(0x200) {
@Override

View File

@@ -29,7 +29,7 @@ public class BaseMentalityCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getMentality();
ctx.result = c.getTemplate().getBaseMentality();
}
});
}

View File

@@ -31,7 +31,7 @@ public class BasePhysicalAttackCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getPhysicalAttack();
ctx.result = c.getTemplate().getBasePhysicalAttack();
}
}, new AbstractFunction<L2Character>(0x100) {
@Override

View File

@@ -31,7 +31,7 @@ public class BasePhysicalAttackSpeedCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getAttackSpeed();
ctx.result = c.getTemplate().getBasePhysicalAttackSpeed();
}
}, new AbstractFunction<L2Character>(0x200) {
@Override

View File

@@ -30,7 +30,7 @@ public class BasePhysicalCriticalRateCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getCriticalChance();
ctx.result = c.getTemplate().getBaseCritical();
}
}, new AbstractFunction<L2Character>(0x090) {
@Override

View File

@@ -39,7 +39,7 @@ public class BasePhysicalDefenseCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getPhysicalDefense();
ctx.result = c.getTemplate().getBasePhysicalDefense();
}
}, new AbstractFunction<L2Character>(0x200) {
@Override

View File

@@ -31,7 +31,7 @@ public class BaseRunSpeedCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getRunSpeed();
ctx.result = c.getTemplate().getBaseRunSpeed();
}
}, new AbstractFunction<L2Character>(0x300) {
@Override

View File

@@ -29,7 +29,7 @@ public class BaseStrengthCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getStrength();
ctx.result = c.getTemplate().getBaseStrength();
}
});
}

View File

@@ -31,7 +31,7 @@ public class BaseWalkSpeedCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getWalkSpeed();
ctx.result = c.getTemplate().getBaseWalkSpeed();
}
}, new AbstractFunction<L2Character>(0x300) {
@Override

View File

@@ -29,7 +29,7 @@ public class BaseWitnessCalculator extends CharacterCalculator {
super(new AbstractFunction<L2Character>(0x000) {
@Override
public void calculate(L2Character c, CalculatorContext ctx) {
ctx.result = c.getTemplate().getMentality();
ctx.result = c.getTemplate().getBaseWitness();
}
});
}