Enchant bonus data rework.

This commit is contained in:
MobiusDev 2016-03-23 13:27:18 +00:00
parent 3576fb4454
commit a2b0e531ac
14 changed files with 372 additions and 13 deletions

View File

@ -53,9 +53,9 @@ import com.l2jmobius.gameserver.data.xml.impl.CategoryData;
import com.l2jmobius.gameserver.data.xml.impl.ClassListData;
import com.l2jmobius.gameserver.data.xml.impl.DailyMissionData;
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemBonusData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemOptionsData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantSkillGroupsData;
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
@ -221,7 +221,7 @@ public final class GameServer
EnchantItemOptionsData.getInstance();
ItemCrystalizationData.getInstance();
OptionData.getInstance();
EnchantItemHPBonusData.getInstance();
EnchantItemBonusData.getInstance();
MerchantPriceConfigTable.getInstance().loadInstances();
BuyListData.getInstance();
MultisellData.getInstance();

View File

@ -38,7 +38,7 @@ import com.l2jmobius.util.data.xml.IXmlReader;
* This class holds the Enchant HP Bonus Data.
* @author MrPoke, Zoey76
*/
public class EnchantItemHPBonusData implements IXmlReader
public class EnchantItemBonusData implements IXmlReader
{
private final Map<CrystalType, List<Integer>> _armorHPBonuses = new EnumMap<>(CrystalType.class);
@ -47,7 +47,7 @@ public class EnchantItemHPBonusData implements IXmlReader
/**
* Instantiates a new enchant hp bonus data.
*/
protected EnchantItemHPBonusData()
protected EnchantItemBonusData()
{
load();
}
@ -98,10 +98,49 @@ public class EnchantItemHPBonusData implements IXmlReader
switch (item.getBodyPart())
{
case L2Item.SLOT_CHEST:
if (item.getCrystalTypePlus() == CrystalType.R)
{
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTPATK.getName(), -1, Stats.POWER_ATTACK, 0));
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTMATK.getName(), -1, Stats.MAGIC_ATTACK, 0));
break;
}
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTHP.getName(), -1, Stats.MAX_HP, 0));
break;
case L2Item.SLOT_FEET:
if (item.getCrystalTypePlus() == CrystalType.R)
{
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTRUNSPD.getName(), -1, Stats.MOVE_SPEED, 0));
break;
}
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTHP.getName(), -1, Stats.MAX_HP, 0));
break;
case L2Item.SLOT_GLOVES:
if (item.getCrystalTypePlus() == CrystalType.R)
{
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTACCEVAS.getName(), -1, Stats.ACCURACY_COMBAT, 0));
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTACCEVAS.getName(), -1, Stats.ACCURACY_MAGIC, 0));
break;
}
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTHP.getName(), -1, Stats.MAX_HP, 0));
break;
case L2Item.SLOT_HEAD:
if (item.getCrystalTypePlus() == CrystalType.R)
{
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTACCEVAS.getName(), -1, Stats.EVASION_RATE, 0));
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTACCEVAS.getName(), -1, Stats.MAGIC_EVASION_RATE, 0));
break;
}
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTHP.getName(), -1, Stats.MAX_HP, 0));
break;
case L2Item.SLOT_LEGS:
if (item.getCrystalTypePlus() == CrystalType.R)
{
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTPMCRITATK.getName(), -1, Stats.CRITICAL_RATE, 0));
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTPMCRITATK.getName(), -1, Stats.MCRITICAL_RATE, 0));
break;
}
item.attach(new FuncTemplate(null, null, StatFunction.ENCHANTHP.getName(), -1, Stats.MAX_HP, 0));
break;
case L2Item.SLOT_BACK:
case L2Item.SLOT_FULL_ARMOR:
case L2Item.SLOT_UNDERWEAR:
@ -134,25 +173,27 @@ public class EnchantItemHPBonusData implements IXmlReader
return 0;
}
double blessedArmorBonus = item.isBlessedItem() ? 1.5 : 1;
final int bonus = values.get(Math.min(item.getOlyEnchantLevel(), values.size()) - 1);
if (item.getItem().getBodyPart() == L2Item.SLOT_FULL_ARMOR)
{
return (int) (bonus * FULL_ARMOR_MODIFIER);
return (int) (bonus * FULL_ARMOR_MODIFIER * blessedArmorBonus);
}
return bonus;
}
/**
* Gets the single instance of EnchantHPBonusData.
* @return single instance of EnchantHPBonusData
* Gets the single instance of EnchantBonusData.
* @return single instance of EnchantBonusData
*/
public static final EnchantItemHPBonusData getInstance()
public static final EnchantItemBonusData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final EnchantItemHPBonusData _instance = new EnchantItemHPBonusData();
protected static final EnchantItemBonusData _instance = new EnchantItemBonusData();
}
}

View File

@ -32,7 +32,7 @@ import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemBonusData;
import com.l2jmobius.gameserver.engines.DocumentEngine;
import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.idfactory.IdFactory;
@ -64,6 +64,7 @@ public class ItemTable
private final Map<Integer, L2EtcItem> _etcItems = new HashMap<>();
private final Map<Integer, L2Armor> _armors = new HashMap<>();
private final Map<Integer, L2Weapon> _weapons = new HashMap<>();
static
{
SLOTS.put("shirt", L2Item.SLOT_UNDERWEAR);
@ -380,7 +381,7 @@ public class ItemTable
public void reload()
{
load();
EnchantItemHPBonusData.getInstance().load();
EnchantItemBonusData.getInstance().load();
}
protected static class ResetOwner implements Runnable

View File

@ -247,6 +247,11 @@ public abstract class DocumentBase
case "share":
case "enchant":
case "enchanthp":
case "enchantPAtk":
case "enchantMAtk":
case "enchantRunSpd":
case "enchantAccEvas":
case "enchantPMcritAtk":
{
attachFunc(n, template, name, condition);
}

View File

@ -27,4 +27,5 @@ public class Item
public StatsSet set;
public int currentLevel;
public L2Item item;
public L2Item isBlessedItem;
}

View File

@ -25,6 +25,11 @@ public enum StatFunction
DIV("Div", 20),
ENCHANT("Enchant", 0),
ENCHANTHP("EnchantHp", 40),
ENCHANTACCEVAS("EnchantAccEvas", 30),
ENCHANTPATK("EnchantPAtk", 30),
ENCHANTMATK("EnchantMAtk", 30),
ENCHANTPMCRITATK("EnchantPMCritAtk", 30),
ENCHANTRUNSPD("EnchantRunSpd", 30),
MUL("Mul", 20),
SET("Set", 0),
SHARE("Share", 30),

View File

@ -148,6 +148,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
private final boolean _ex_immediate_effect;
private final int _defaultEnchantLevel;
private final ActionType _defaultAction;
private final boolean _isBlessedItem;
protected int _type1; // needed for item list (inventory)
protected int _type2; // different lists for armor, weapon, etc
@ -208,6 +209,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
_ex_immediate_effect = set.getBoolean("ex_immediate_effect", false);
_defaultAction = set.getEnum("default_action", ActionType.class, ActionType.NONE);
_isBlessedItem = set.getBoolean("isBlessedItem", false);
_useSkillDisTime = set.getInt("useSkillDisTime", 0);
_defaultEnchantLevel = set.getInt("enchanted", 0);
_reuseDelay = set.getInt("reuse_delay", 0);
@ -996,6 +998,14 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
return _defaultAction;
}
/**
* @return {@code true} else item it is blessed (example: ID: 18084)
*/
public boolean isBlessedItem()
{
return _isBlessedItem;
}
public int useSkillDisTime()
{
return _useSkillDisTime;

View File

@ -2141,6 +2141,11 @@ public final class L2ItemInstance extends L2Object
}
}
public boolean isBlessedItem()
{
return getItem().isBlessedItem();
}
@Override
public boolean isItem()
{

View File

@ -0,0 +1,59 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.stats.functions;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Stats;
public class FuncEnchantAccEvas extends AbstractFunction
{
private static final double blessedBonus = 1.5;
public FuncEnchantAccEvas(Stats stat, int order, Object owner, double value, Condition applayCond)
{
super(stat, order, owner, value, applayCond);
}
@Override
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
{
double value = initVal;
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
{
return value;
}
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
if (item.getEnchantLevel() > 3)
{
// Increases Phys.Evasion / Mag. Evasion for helmets
// Increases Phys.Accuracy / Mag.Accuracy for gloves
if (item.getEnchantLevel() == 4)
{
value += (0.2 * blessedBonus);
}
else
{
value += (0.2 * blessedBonus * ((item.getEnchantLevel() * 2) - 9));
}
}
return initVal;
}
}

View File

@ -16,7 +16,7 @@
*/
package com.l2jmobius.gameserver.model.stats.functions;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemHPBonusData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemBonusData;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
@ -44,7 +44,7 @@ public class FuncEnchantHp extends AbstractFunction
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
if (item.getEnchantLevel() > 0)
{
return initVal + EnchantItemHPBonusData.getInstance().getHPBonus(item);
return initVal + EnchantItemBonusData.getInstance().getHPBonus(item);
}
return initVal;
}

View File

@ -0,0 +1,58 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.stats.functions;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Stats;
public class FuncEnchantMAtk extends AbstractFunction
{
private static final double blessedBonus = 1.5;
public FuncEnchantMAtk(Stats stat, int order, Object owner, double value, Condition applayCond)
{
super(stat, order, owner, value, applayCond);
}
@Override
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
{
double value = initVal;
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
{
return value;
}
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
if (item.getEnchantLevel() > 3)
{
// Increases Mag. Atk for chest
if (item.getEnchantLevel() == 4)
{
value += (1.4 * blessedBonus);
}
else
{
value += (1.4 * blessedBonus * ((item.getEnchantLevel() * 2) - 9));
}
}
return initVal;
}
}

View File

@ -0,0 +1,58 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.stats.functions;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Stats;
public class FuncEnchantPAtk extends AbstractFunction
{
private static final double blessedBonus = 1.5;
public FuncEnchantPAtk(Stats stat, int order, Object owner, double value, Condition applayCond)
{
super(stat, order, owner, value, applayCond);
}
@Override
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
{
double value = initVal;
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
{
return value;
}
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
if (item.getEnchantLevel() > 3)
{
// Increases Phys.Atk for chest
if (item.getEnchantLevel() == 4)
{
value += (2 * blessedBonus);
}
else
{
value += (2 * blessedBonus * ((item.getEnchantLevel() * 2) - 9));
}
}
return initVal;
}
}

View File

@ -0,0 +1,58 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.stats.functions;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Stats;
public class FuncEnchantPMCritRate extends AbstractFunction
{
private static final double blessedBonus = 1.5;
public FuncEnchantPMCritRate(Stats stat, int order, Object owner, double value, Condition applayCond)
{
super(stat, order, owner, value, applayCond);
}
@Override
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
{
double value = initVal;
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
{
return value;
}
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
if (item.getEnchantLevel() > 3)
{
// Increases P. Critical Rate / magic damage for legs
if (item.getEnchantLevel() == 4)
{
value += (0.34 * blessedBonus);
}
else
{
value += (0.34 * blessedBonus * ((item.getEnchantLevel() * 2) - 9));
}
}
return initVal;
}
}

View File

@ -0,0 +1,58 @@
/*
* This file is part of the L2J Mobius project.
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.gameserver.model.stats.functions;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.stats.Stats;
public abstract class FuncEnchantRunSpd extends AbstractFunction
{
private static final double blessedBonus = 1.5;
public FuncEnchantRunSpd(Stats stat, int order, Object owner, double value, Condition applayCond)
{
super(stat, order, owner, value, applayCond);
}
@Override
public double calc(L2Character effector, L2Character effected, Skill skill, double initVal)
{
double value = initVal;
if ((getApplayCond() != null) && !getApplayCond().test(effector, effected, skill))
{
return value;
}
final L2ItemInstance item = (L2ItemInstance) getFuncOwner();
if (item.getEnchantLevel() > 3)
{
// Increases speed for feets
if (item.getEnchantLevel() == 4)
{
value += (0.6 * blessedBonus);
}
else
{
value += (0.6 * blessedBonus * ((item.getEnchantLevel() * 2) - 9));
}
}
return initVal;
}
}