Replaced Augmentation with Variation data.

Adapted from: L2jUnity free files.
This commit is contained in:
MobiusDev
2018-02-17 13:39:22 +00:00
parent 164b4fe686
commit c112d243be
280 changed files with 150683 additions and 272178 deletions

View File

@ -89,7 +89,7 @@ import com.l2jmobius.gameserver.data.xml.impl.SpawnsData;
import com.l2jmobius.gameserver.data.xml.impl.StaticObjectData;
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.data.xml.impl.VariationData;
import com.l2jmobius.gameserver.datatables.BotReportTable;
import com.l2jmobius.gameserver.datatables.EventDroplist;
import com.l2jmobius.gameserver.datatables.ItemTable;
@ -222,7 +222,7 @@ public class GameServer
EnchantItemOptionsData.getInstance();
ItemCrystallizationData.getInstance();
OptionData.getInstance();
AugmentationData.getInstance();
VariationData.getInstance();
EnchantItemHPBonusData.getInstance();
BuyListData.getInstance();
MultisellData.getInstance();

View File

@ -0,0 +1,270 @@
/*
* 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.data.xml.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import org.w3c.dom.Document;
import com.l2jmobius.commons.util.IGameXmlReader;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.options.OptionDataCategory;
import com.l2jmobius.gameserver.model.options.OptionDataGroup;
import com.l2jmobius.gameserver.model.options.Options;
import com.l2jmobius.gameserver.model.options.Variation;
import com.l2jmobius.gameserver.model.options.VariationFee;
import com.l2jmobius.gameserver.model.options.VariationWeaponType;
/**
* @author Pere
*/
public class VariationData implements IGameXmlReader
{
private static final Logger LOGGER = Logger.getLogger(VariationData.class.getSimpleName());
private final Map<Integer, Variation> _variations = new HashMap<>();
private final Map<Integer, Map<Integer, VariationFee>> _fees = new HashMap<>();
protected VariationData()
{
load();
}
@Override
public void load()
{
_variations.clear();
_fees.clear();
parseDatapackFile("data/stats/augmentation/Variations.xml");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _variations.size() + " Variations.");
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _fees.size() + " Fees.");
}
@Override
public void parseDocument(Document doc, File f)
{
forEach(doc, "list", listNode ->
{
forEach(listNode, "variations", variationsNode ->
{
forEach(variationsNode, "variation", variationNode ->
{
final int mineralId = parseInteger(variationNode.getAttributes(), "mineralId");
if (ItemTable.getInstance().getTemplate(mineralId) == null)
{
LOGGER.warning(getClass().getSimpleName() + ": Mineral with item id " + mineralId + " was not found.");
}
final Variation variation = new Variation(mineralId);
forEach(variationNode, "optionGroup", groupNode ->
{
final String weaponTypeString = parseString(groupNode.getAttributes(), "weaponType").toUpperCase();
final VariationWeaponType weaponType = VariationWeaponType.valueOf(weaponTypeString);
final int order = parseInteger(groupNode.getAttributes(), "order");
final List<OptionDataCategory> sets = new ArrayList<>();
forEach(groupNode, "optionCategory", categoryNode ->
{
final double chance = parseDouble(categoryNode.getAttributes(), "chance");
final Map<Options, Double> options = new HashMap<>();
forEach(categoryNode, "option", optionNode ->
{
final double optionChance = parseDouble(optionNode.getAttributes(), "chance");
final int optionId = parseInteger(optionNode.getAttributes(), "id");
final Options opt = OptionData.getInstance().getOptions(optionId);
if (opt == null)
{
LOGGER.warning(getClass().getSimpleName() + ": Null option for id " + optionId);
return;
}
options.put(opt, optionChance);
});
forEach(categoryNode, "optionRange", optionNode ->
{
final double optionChance = parseDouble(optionNode.getAttributes(), "chance");
final int fromId = parseInteger(optionNode.getAttributes(), "from");
final int toId = parseInteger(optionNode.getAttributes(), "to");
for (int id = fromId; id <= toId; id++)
{
final Options op = OptionData.getInstance().getOptions(id);
if (op == null)
{
LOGGER.warning(getClass().getSimpleName() + ": Null option for id " + id);
return;
}
options.put(op, optionChance);
}
});
sets.add(new OptionDataCategory(options, chance));
});
variation.setEffectGroup(weaponType, order, new OptionDataGroup(sets));
});
_variations.put(mineralId, variation);
});
});
final Map<Integer, List<Integer>> itemGroups = new HashMap<>();
forEach(listNode, "itemGroups", variationsNode ->
{
forEach(variationsNode, "itemGroup", variationNode ->
{
final int id = parseInteger(variationNode.getAttributes(), "id");
final List<Integer> items = new ArrayList<>();
forEach(variationNode, "item", itemNode ->
{
final int itemId = parseInteger(itemNode.getAttributes(), "id");
if (ItemTable.getInstance().getTemplate(itemId) == null)
{
LOGGER.warning(getClass().getSimpleName() + ": Item with id " + itemId + " was not found.");
}
items.add(itemId);
});
itemGroups.put(id, items);
});
});
forEach(listNode, "fees", variationNode ->
{
forEach(variationNode, "fee", feeNode ->
{
final int itemGroupId = parseInteger(feeNode.getAttributes(), "itemGroup");
final List<Integer> itemGroup = itemGroups.get(itemGroupId);
final int itemId = parseInteger(feeNode.getAttributes(), "itemId");
final int itemCount = parseInteger(feeNode.getAttributes(), "itemCount");
final int cancelFee = parseInteger(feeNode.getAttributes(), "cancelFee");
if (ItemTable.getInstance().getTemplate(itemId) == null)
{
LOGGER.warning(getClass().getSimpleName() + ": Item with id " + itemId + " was not found.");
}
final VariationFee fee = new VariationFee(itemId, itemCount, cancelFee);
final Map<Integer, VariationFee> feeByMinerals = new HashMap<>();
forEach(feeNode, "mineral", mineralNode ->
{
final int mId = parseInteger(mineralNode.getAttributes(), "id");
feeByMinerals.put(mId, fee);
});
forEach(feeNode, "mineralRange", mineralNode ->
{
final int fromId = parseInteger(mineralNode.getAttributes(), "from");
final int toId = parseInteger(mineralNode.getAttributes(), "to");
for (int id = fromId; id <= toId; id++)
{
feeByMinerals.put(id, fee);
}
});
for (int item : itemGroup)
{
Map<Integer, VariationFee> fees = _fees.computeIfAbsent(item, k -> new HashMap<>());
fees.putAll(feeByMinerals);
}
});
});
});
}
public int getVariationCount()
{
return _variations.size();
}
public int getFeeCount()
{
return _fees.size();
}
/**
* Generate a new random variation instance
* @param variation The variation template to generate the variation instance from
* @param targetItem The item on which the variation will be applied
* @return VariationInstance
*/
public VariationInstance generateRandomVariation(Variation variation, L2ItemInstance targetItem)
{
final VariationWeaponType weaponType = ((targetItem.getWeaponItem() != null) && targetItem.getWeaponItem().isMagicWeapon()) ? VariationWeaponType.MAGE : VariationWeaponType.WARRIOR;
return generateRandomVariation(variation, weaponType);
}
private VariationInstance generateRandomVariation(Variation variation, VariationWeaponType weaponType)
{
Options option1 = variation.getRandomEffect(weaponType, 0);
Options option2 = variation.getRandomEffect(weaponType, 1);
return ((option1 != null) && (option2 != null)) ? new VariationInstance(variation.getMineralId(), option1, option2) : null;
}
public final Variation getVariation(int mineralId)
{
return _variations.get(mineralId);
}
public final VariationFee getFee(int itemId, int mineralId)
{
return _fees.getOrDefault(itemId, Collections.emptyMap()).get(mineralId);
}
public final long getCancelFee(int itemId, int mineralId)
{
final Map<Integer, VariationFee> fees = _fees.get(itemId);
if (fees == null)
{
return -1;
}
VariationFee fee = fees.get(mineralId);
if (fee == null)
{
// FIXME This will happen when the data is pre-rework or when augments were manually given, but still that's a cheap solution
LOGGER.warning(getClass().getSimpleName() + ": Cancellation fee not found for item [" + itemId + "] and mineral [" + mineralId + "]");
fee = fees.values().iterator().next();
if (fee == null)
{
return -1;
}
}
return fee.getCancelFee();
}
public final boolean hasFeeData(int itemId)
{
Map<Integer, VariationFee> itemFees = _fees.get(itemId);
return (itemFees != null) && !itemFees.isEmpty();
}
public static VariationData getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final VariationData _instance = new VariationData();
}
}

View File

@ -195,7 +195,7 @@ public abstract class IdFactory
cleanCount += stmt.executeUpdate("DELETE FROM items WHERE items.owner_id NOT IN (SELECT charId FROM characters) AND items.owner_id NOT IN (SELECT clan_id FROM clan_data) AND items.owner_id != -1;");
cleanCount += stmt.executeUpdate("DELETE FROM items WHERE items.owner_id = -1 AND loc LIKE 'MAIL' AND loc_data NOT IN (SELECT messageId FROM messages WHERE senderId = -1);");
cleanCount += stmt.executeUpdate("DELETE FROM item_auction_bid WHERE item_auction_bid.playerObjId NOT IN (SELECT charId FROM characters);");
cleanCount += stmt.executeUpdate("DELETE FROM item_attributes WHERE item_attributes.itemId NOT IN (SELECT object_id FROM items);");
cleanCount += stmt.executeUpdate("DELETE FROM item_variations WHERE item_variations.itemId NOT IN (SELECT object_id FROM items);");
cleanCount += stmt.executeUpdate("DELETE FROM item_elementals WHERE item_elementals.itemId NOT IN (SELECT object_id FROM items);");
cleanCount += stmt.executeUpdate("DELETE FROM item_special_abilities WHERE item_special_abilities.objectId NOT IN (SELECT object_id FROM items);");
cleanCount += stmt.executeUpdate("DELETE FROM item_variables WHERE item_variables.id NOT IN (SELECT object_id FROM items);");

View File

@ -1,101 +0,0 @@
/*
* 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;
import java.util.logging.Logger;
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.options.Options;
/**
* Used to store an augmentation and its bonuses.
* @author durgus, UnAfraid
*/
public final class Augmentation
{
private static final Logger LOGGER = Logger.getLogger(Augmentation.class.getName());
private final Options[] _options;
private final int _id;
public Augmentation(int id)
{
_id = id;
final int[] stats = new int[2];
stats[0] = 0x0000FFFF & id;
stats[1] = (id >> 16);
_options = new Options[stats.length];
for (int i = 0; i < stats.length; i++)
{
final Options op = OptionData.getInstance().getOptions(stats[i]);
if (op != null)
{
_options[i] = op;
}
else
{
LOGGER.warning(getClass().getSimpleName() + ": Couldn't find option: " + stats[i]);
}
}
}
/**
* Get the augmentation "id" used in serverpackets.
* @return augmentationId
*/
public int getId()
{
return _id;
}
public Options[] getOptions()
{
return _options;
}
public int getOptionId(int index)
{
if ((index >= 0) && (index < _options.length) && (_options[index] != null))
{
return _options[index].getId();
}
return 0;
}
public void applyBonus(L2PcInstance player)
{
for (Options op : _options)
{
if (op != null)
{
op.apply(player);
}
}
}
public void removeBonus(L2PcInstance player)
{
for (Options op : _options)
{
if (op != null)
{
op.remove(player);
}
}
}
}

View File

@ -50,7 +50,7 @@ public class CharSelectInfoPackage
private int _reputation = 0;
private int _pkKills = 0;
private int _pvpKills = 0;
private Augmentation _augmentation;
private VariationInstance _augmentation;
private int _x = 0;
private int _y = 0;
private int _z = 0;
@ -336,12 +336,12 @@ public class CharSelectInfoPackage
return _reputation;
}
public void setAugmentation(Augmentation augmentation)
public void setAugmentation(VariationInstance augmentation)
{
_augmentation = augmentation;
}
public Augmentation getAugmentation()
public VariationInstance getAugmentation()
{
return _augmentation;
}

View File

@ -39,7 +39,7 @@ public class ItemInfo
private int _enchantLevel;
/** The augmentation of the item */
private Augmentation _augmentation;
private VariationInstance _augmentation;
/** The quantity of L2ItemInstance */
private long _count;
@ -168,7 +168,10 @@ public class ItemInfo
_enchantLevel = item.getEnchant();
// Get the augmentation bonus
_augmentation = item.getAugmentation();
if ((item.getAugmentationOption1() >= 0) && (item.getAugmentationOption2() >= 0))
{
_augmentation = new VariationInstance(0, item.getAugmentationOption1(), item.getAugmentationOption2());
}
// Get the quantity of the L2ItemInstance
_count = item.getCount();
@ -297,7 +300,7 @@ public class ItemInfo
return _enchantLevel;
}
public Augmentation getAugmentation()
public VariationInstance getAugmentation()
{
return _augmentation;
}
@ -376,4 +379,10 @@ public class ItemInfo
{
return _visualExpiration;
}
@Override
public String toString()
{
return String.valueOf(_item) + "[objId: " + _objectId + ", count: " + _count + "]";
}
}

View File

@ -46,7 +46,8 @@ public class TradeItem
};
private final int[] _enchantOptions;
private int _visualId;
private Augmentation _augmentation;
private int _augmentationOption1 = -1;
private int _augmentationOption2 = -1;
public TradeItem(L2ItemInstance item, long count, long price)
{
@ -67,7 +68,12 @@ public class TradeItem
}
_enchantOptions = item.getEnchantOptions();
_visualId = item.getVisualId();
_augmentation = item.getAugmentation();
if (item.getAugmentation() != null)
{
_augmentationOption1 = item.getAugmentation().getOption1Id();
_augmentationOption1 = item.getAugmentation().getOption2Id();
}
}
public TradeItem(L2Item item, long count, long price)
@ -194,9 +200,20 @@ public class TradeItem
return _enchantOptions;
}
public Augmentation getAugmentation()
public void setAugmentation(int option1, int option2)
{
return _augmentation;
_augmentationOption1 = option1;
_augmentationOption2 = option2;
}
public int getAugmentationOption1()
{
return _augmentationOption1;
}
public int getAugmentationOption2()
{
return _augmentationOption2;
}
public int getVisualId()

View File

@ -0,0 +1,82 @@
/*
* 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;
import java.util.Objects;
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.options.Options;
/**
* Used to store an augmentation and its bonuses.
* @author durgus, UnAfraid, Pere
*/
public final class VariationInstance
{
private final int _mineralId;
private final Options _option1;
private final Options _option2;
public VariationInstance(int mineralId, int option1Id, int option2Id)
{
_mineralId = mineralId;
_option1 = OptionData.getInstance().getOptions(option1Id);
_option2 = OptionData.getInstance().getOptions(option2Id);
if ((_option1 == null) || (_option2 == null))
{
throw new IllegalArgumentException("Couldn't find option for id: " + option1Id + " or id: " + option1Id);
}
}
public VariationInstance(int mineralId, Options op1, Options op2)
{
Objects.requireNonNull(op1);
Objects.requireNonNull(op2);
_mineralId = mineralId;
_option1 = op1;
_option2 = op2;
}
public int getMineralId()
{
return _mineralId;
}
public int getOption1Id()
{
return _option1.getId();
}
public int getOption2Id()
{
return _option2.getId();
}
public void applyBonus(L2PcInstance player)
{
_option1.apply(player);
_option2.apply(player);
}
public void removeBonus(L2PcInstance player)
{
_option1.remove(player);
_option2.remove(player);
}
}

View File

@ -16,7 +16,7 @@
*/
package com.l2jmobius.gameserver.model.events.impl.character.player;
import com.l2jmobius.gameserver.model.Augmentation;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.events.EventType;
import com.l2jmobius.gameserver.model.events.impl.IBaseEvent;
@ -29,10 +29,10 @@ public class OnPlayerAugment implements IBaseEvent
{
private final L2PcInstance _activeChar;
private final L2ItemInstance _item;
private final Augmentation _augmentation;
private final VariationInstance _augmentation;
private final boolean _isAugment; // true = is being augmented // false = augment is being removed
public OnPlayerAugment(L2PcInstance activeChar, L2ItemInstance item, Augmentation augment, boolean isAugment)
public OnPlayerAugment(L2PcInstance activeChar, L2ItemInstance item, VariationInstance augment, boolean isAugment)
{
_activeChar = activeChar;
_item = item;
@ -50,7 +50,7 @@ public class OnPlayerAugment implements IBaseEvent
return _item;
}
public Augmentation getAugmentation()
public VariationInstance getAugmentation()
{
return _augmentation;
}

View File

@ -16,10 +16,8 @@
*/
package com.l2jmobius.gameserver.model.itemauction;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.model.Augmentation;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
@ -35,6 +33,7 @@ public final class AuctionItem
private final int _itemId;
private final long _itemCount;
@SuppressWarnings("unused")
private final StatsSet _itemExtra;
public AuctionItem(int auctionItemId, int auctionLength, long auctionInitBid, int itemId, long itemCount, StatsSet itemExtra)
@ -84,11 +83,6 @@ public final class AuctionItem
L2World.getInstance().storeObject(item);
item.setCount(_itemCount);
item.setEnchantLevel(item.getItem().getDefaultEnchantLevel());
final Augmentation augmentation = AugmentationData.getInstance().getAugmentation(_itemExtra.getInt("augmentation_id", 0));
if (augmentation != null)
{
item.setAugmentation(augmentation, false);
}
return item;
}
}

View File

@ -42,10 +42,10 @@ import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.enums.ItemSkillType;
import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.model.Augmentation;
import com.l2jmobius.gameserver.model.L2ArmorSet;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.ArmorsetSkillHolder;
import com.l2jmobius.gameserver.model.items.L2Item;
@ -992,7 +992,7 @@ public abstract class Inventory extends ItemContainer
return (item != null) ? item.getVisualId() : 0;
}
public Augmentation getPaperdollAugmentation(int slot)
public VariationInstance getPaperdollAugmentation(int slot)
{
final L2ItemInstance item = _paperdoll[slot];
return (item != null) ? item.getAugmentation() : null;

View File

@ -19,7 +19,7 @@ package com.l2jmobius.gameserver.model.items;
import java.util.Objects;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.Augmentation;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
import com.l2jmobius.gameserver.model.items.type.ItemType;
@ -43,7 +43,7 @@ public class L2WarehouseItem
private final int _locationSlot;
private final int _enchant;
private final CrystalType _grade;
private final Augmentation _augmentation;
private final VariationInstance _augmentation;
private final int _customType1;
private final int _customType2;
private final int _mana;
@ -221,7 +221,7 @@ public class L2WarehouseItem
/**
* @return the augmentation If.
*/
public Augmentation getAugmentation()
public VariationInstance getAugmentation()
{
return _augmentation;
}

View File

@ -39,7 +39,6 @@ import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.data.xml.impl.AppearanceItemData;
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemOptionsData;
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.enums.InstanceType;
@ -51,12 +50,12 @@ import com.l2jmobius.gameserver.idfactory.IdFactory;
import com.l2jmobius.gameserver.instancemanager.CastleManager;
import com.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager;
import com.l2jmobius.gameserver.instancemanager.SiegeGuardManager;
import com.l2jmobius.gameserver.model.Augmentation;
import com.l2jmobius.gameserver.model.DropProtection;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.L2WorldRegion;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@ -132,7 +131,7 @@ public final class L2ItemInstance extends L2Object
private boolean _wear;
/** Augmented Item */
private Augmentation _augmentation = null;
private VariationInstance _augmentation = null;
/** Shadow item */
private int _mana = -1;
@ -942,7 +941,7 @@ public final class L2ItemInstance extends L2Object
* Returns the augmentation object for this item
* @return augmentation
*/
public Augmentation getAugmentation()
public VariationInstance getAugmentation()
{
return _augmentation;
}
@ -953,7 +952,7 @@ public final class L2ItemInstance extends L2Object
* @param updateDatabase
* @return return true if successfully
*/
public boolean setAugmentation(Augmentation augmentation, boolean updateDatabase)
public boolean setAugmentation(VariationInstance augmentation, boolean updateDatabase)
{
// there shall be no previous augmentation..
if (_augmentation != null)
@ -982,11 +981,11 @@ public final class L2ItemInstance extends L2Object
}
// Copy augmentation before removing it.
final Augmentation augment = _augmentation;
final VariationInstance augment = _augmentation;
_augmentation = null;
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM item_attributes WHERE itemId = ?"))
PreparedStatement ps = con.prepareStatement("DELETE FROM item_variations WHERE itemId = ?"))
{
ps.setInt(1, getObjectId());
ps.executeUpdate();
@ -1003,7 +1002,7 @@ public final class L2ItemInstance extends L2Object
public void restoreAttributes()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps1 = con.prepareStatement("SELECT augAttributes FROM item_attributes WHERE itemId=?");
PreparedStatement ps1 = con.prepareStatement("SELECT mineralId,option1,option2 FROM item_variations WHERE itemId=?");
PreparedStatement ps2 = con.prepareStatement("SELECT elemType,elemValue FROM item_elementals WHERE itemId=?"))
{
ps1.setInt(1, getObjectId());
@ -1011,10 +1010,12 @@ public final class L2ItemInstance extends L2Object
{
if (rs.next())
{
final int aug_attributes = rs.getInt(1);
if (aug_attributes != -1)
int mineralId = rs.getInt("mineralId");
int option1 = rs.getInt("option1");
int option2 = rs.getInt("option2");
if ((option1 != -1) && (option2 != -1))
{
_augmentation = AugmentationData.getInstance().getAugmentation(rs.getInt("augAttributes"));
_augmentation = new VariationInstance(mineralId, option1, option2);
}
}
}
@ -1053,10 +1054,12 @@ public final class L2ItemInstance extends L2Object
private void updateItemOptions(Connection con)
{
try (PreparedStatement ps = con.prepareStatement("REPLACE INTO item_attributes VALUES(?,?)"))
try (PreparedStatement ps = con.prepareStatement("REPLACE INTO item_variations VALUES(?,?,?,?)"))
{
ps.setInt(1, getObjectId());
ps.setInt(2, _augmentation != null ? _augmentation.getId() : -1);
ps.setInt(2, _augmentation != null ? _augmentation.getMineralId() : 0);
ps.setInt(3, _augmentation != null ? _augmentation.getOption1Id() : -1);
ps.setInt(4, _augmentation != null ? _augmentation.getOption2Id() : -1);
ps.executeUpdate();
}
catch (SQLException e)
@ -1691,7 +1694,7 @@ public final class L2ItemInstance extends L2Object
ps.executeUpdate();
}
try (PreparedStatement ps = con.prepareStatement("DELETE FROM item_attributes WHERE itemId = ?"))
try (PreparedStatement ps = con.prepareStatement("DELETE FROM item_variations WHERE itemId = ?"))
{
ps.setInt(1, getObjectId());
ps.executeUpdate();

View File

@ -0,0 +1,63 @@
/*
* 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.options;
import java.util.Map;
import com.l2jmobius.commons.util.Rnd;
/**
* @author Pere
*/
public final class OptionDataCategory
{
private final Map<Options, Double> _options;
private final double _chance;
public OptionDataCategory(Map<Options, Double> options, double chance)
{
_options = options;
_chance = chance;
}
Options getRandomOptions()
{
Options result = null;
do
{
double random = Rnd.get() * 100.0;
for (Map.Entry<Options, Double> entry : _options.entrySet())
{
if (entry.getValue() >= random)
{
result = entry.getKey();
break;
}
random -= entry.getValue();
}
}
while (result == null);
return result;
}
public double getChance()
{
return _chance;
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.options;
import java.util.List;
import com.l2jmobius.commons.util.Rnd;
/**
* @author Pere
*/
public final class OptionDataGroup
{
private final List<OptionDataCategory> _categories;
public OptionDataGroup(List<OptionDataCategory> categories)
{
_categories = categories;
}
Options getRandomEffect()
{
Options result = null;
do
{
double random = Rnd.get() * 100.0;
for (OptionDataCategory category : _categories)
{
if (category.getChance() >= random)
{
result = category.getRandomOptions();
break;
}
random -= category.getChance();
}
}
while (result == null);
// Should never get there
return result;
}
}

View File

@ -0,0 +1,60 @@
/*
* 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.options;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
/**
* @author Pere
*/
public final class Variation
{
private static final Logger LOGGER = Logger.getLogger(Variation.class.getSimpleName());
private final int _mineralId;
private final Map<VariationWeaponType, OptionDataGroup[]> _effects = new HashMap<>();
public Variation(int mineralId)
{
_mineralId = mineralId;
}
public int getMineralId()
{
return _mineralId;
}
public void setEffectGroup(VariationWeaponType type, int order, OptionDataGroup group)
{
final OptionDataGroup[] effects = _effects.computeIfAbsent(type, k -> new OptionDataGroup[2]);
effects[order] = group;
}
public Options getRandomEffect(VariationWeaponType type, int order)
{
OptionDataGroup[] effects = _effects.get(type);
if ((effects == null) || (effects[order] == null))
{
LOGGER.warning("Null effect: " + type + ", " + order);
return null;
}
return effects[order].getRandomEffect();
}
}

View File

@ -0,0 +1,49 @@
/*
* 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.options;
/**
* @author Pere
*/
public final class VariationFee
{
private final int _itemId;
private final long _itemCount;
private final long _cancelFee;
public VariationFee(int itemId, long itemCount, long cancelFee)
{
_itemId = itemId;
_itemCount = itemCount;
_cancelFee = cancelFee;
}
public int getItemId()
{
return _itemId;
}
public long getItemCount()
{
return _itemCount;
}
public long getCancelFee()
{
return _cancelFee;
}
}

View File

@ -0,0 +1,26 @@
/*
* 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.options;
/**
* @author Pere
*/
public enum VariationWeaponType
{
WARRIOR,
MAGE
}

View File

@ -495,7 +495,7 @@ public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
ps.execute();
}
try (PreparedStatement ps = con.prepareStatement("DELETE FROM item_attributes WHERE itemId IN (SELECT object_id FROM items WHERE items.owner_id=?)"))
try (PreparedStatement ps = con.prepareStatement("DELETE FROM item_variations WHERE itemId IN (SELECT object_id FROM items WHERE items.owner_id=?)"))
{
ps.setInt(1, objid);
ps.execute();

View File

@ -17,8 +17,6 @@
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.enums.ItemLocation;
@ -27,278 +25,53 @@ import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.request.EnchantItemAttributeRequest;
import com.l2jmobius.gameserver.model.actor.request.EnchantItemRequest;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Item;
import com.l2jmobius.gameserver.model.items.L2Weapon;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
import com.l2jmobius.gameserver.model.options.VariationFee;
import com.l2jmobius.gameserver.model.skills.AbnormalType;
import com.l2jmobius.gameserver.network.SystemMessageId;
public abstract class AbstractRefinePacket implements IClientIncomingPacket
{
public static final int GRADE_NONE = 0;
public static final int GRADE_MID = 1;
public static final int GRADE_HIGH = 2;
public static final int GRADE_TOP = 3;
public static final int GRADE_ACC = 4; // Accessory LS
public static final int GRADE_FORGOTTEN = 5; // Forgotten
protected static final int[] GEMSTONE_D = new int[]
{
2130
};
protected static final int[] GEMSTONE_C = new int[]
{
2131,
36719
};
protected static final int[] GEMSTONE_B = new int[]
{
2132
};
protected static final int[] GEMSTONE_A = new int[]
{
2133
};
protected static final int[] GEMSTONE_S = new int[]
{
2134
};
protected static final int[] GEMSTONE_R = new int[]
{
19440
};
private static final Map<Integer, LifeStone> _lifeStones = new HashMap<>();
protected static final class LifeStone
{
// lifestone level to player level table
private static final int[] LEVELS =
{
46,
49,
52,
55,
58,
61,
64,
67,
70,
76,
80,
82,
84,
85,
95,
99
};
private final int _grade;
private final int _level;
public LifeStone(int grade, int level)
{
_grade = grade;
_level = level;
}
public final int getLevel()
{
return _level;
}
public final int getGrade()
{
return _grade;
}
public final int getPlayerLevel()
{
return LEVELS[_level];
}
}
static
{
// itemId, (LS grade, LS level)
_lifeStones.put(36718, new LifeStone(GRADE_NONE, 0));
_lifeStones.put(8723, new LifeStone(GRADE_NONE, 0));
_lifeStones.put(8724, new LifeStone(GRADE_NONE, 1));
_lifeStones.put(8725, new LifeStone(GRADE_NONE, 2));
_lifeStones.put(8726, new LifeStone(GRADE_NONE, 3));
_lifeStones.put(8727, new LifeStone(GRADE_NONE, 4));
_lifeStones.put(8728, new LifeStone(GRADE_NONE, 5));
_lifeStones.put(8729, new LifeStone(GRADE_NONE, 6));
_lifeStones.put(8730, new LifeStone(GRADE_NONE, 7));
_lifeStones.put(8731, new LifeStone(GRADE_NONE, 8));
_lifeStones.put(8732, new LifeStone(GRADE_NONE, 9));
_lifeStones.put(8733, new LifeStone(GRADE_MID, 0));
_lifeStones.put(8734, new LifeStone(GRADE_MID, 1));
_lifeStones.put(8735, new LifeStone(GRADE_MID, 2));
_lifeStones.put(8736, new LifeStone(GRADE_MID, 3));
_lifeStones.put(8737, new LifeStone(GRADE_MID, 4));
_lifeStones.put(8738, new LifeStone(GRADE_MID, 5));
_lifeStones.put(8739, new LifeStone(GRADE_MID, 6));
_lifeStones.put(8740, new LifeStone(GRADE_MID, 7));
_lifeStones.put(8741, new LifeStone(GRADE_MID, 8));
_lifeStones.put(8742, new LifeStone(GRADE_MID, 9));
_lifeStones.put(8743, new LifeStone(GRADE_HIGH, 0));
_lifeStones.put(8744, new LifeStone(GRADE_HIGH, 1));
_lifeStones.put(8745, new LifeStone(GRADE_HIGH, 2));
_lifeStones.put(8746, new LifeStone(GRADE_HIGH, 3));
_lifeStones.put(8747, new LifeStone(GRADE_HIGH, 4));
_lifeStones.put(8748, new LifeStone(GRADE_HIGH, 5));
_lifeStones.put(8749, new LifeStone(GRADE_HIGH, 6));
_lifeStones.put(8750, new LifeStone(GRADE_HIGH, 7));
_lifeStones.put(8751, new LifeStone(GRADE_HIGH, 8));
_lifeStones.put(8752, new LifeStone(GRADE_HIGH, 9));
_lifeStones.put(8753, new LifeStone(GRADE_TOP, 0));
_lifeStones.put(8754, new LifeStone(GRADE_TOP, 1));
_lifeStones.put(8755, new LifeStone(GRADE_TOP, 2));
_lifeStones.put(8756, new LifeStone(GRADE_TOP, 3));
_lifeStones.put(8757, new LifeStone(GRADE_TOP, 4));
_lifeStones.put(8758, new LifeStone(GRADE_TOP, 5));
_lifeStones.put(8759, new LifeStone(GRADE_TOP, 6));
_lifeStones.put(8760, new LifeStone(GRADE_TOP, 7));
_lifeStones.put(8761, new LifeStone(GRADE_TOP, 8));
_lifeStones.put(8762, new LifeStone(GRADE_TOP, 9));
_lifeStones.put(9573, new LifeStone(GRADE_NONE, 10));
_lifeStones.put(9574, new LifeStone(GRADE_MID, 10));
_lifeStones.put(9575, new LifeStone(GRADE_HIGH, 10));
_lifeStones.put(9576, new LifeStone(GRADE_TOP, 10));
_lifeStones.put(10483, new LifeStone(GRADE_NONE, 11));
_lifeStones.put(10484, new LifeStone(GRADE_MID, 11));
_lifeStones.put(10485, new LifeStone(GRADE_HIGH, 11));
_lifeStones.put(10486, new LifeStone(GRADE_TOP, 11));
_lifeStones.put(12754, new LifeStone(GRADE_ACC, 0));
_lifeStones.put(12755, new LifeStone(GRADE_ACC, 1));
_lifeStones.put(12756, new LifeStone(GRADE_ACC, 2));
_lifeStones.put(12757, new LifeStone(GRADE_ACC, 3));
_lifeStones.put(12758, new LifeStone(GRADE_ACC, 4));
_lifeStones.put(12759, new LifeStone(GRADE_ACC, 5));
_lifeStones.put(12760, new LifeStone(GRADE_ACC, 6));
_lifeStones.put(12761, new LifeStone(GRADE_ACC, 7));
_lifeStones.put(12762, new LifeStone(GRADE_ACC, 8));
_lifeStones.put(12763, new LifeStone(GRADE_ACC, 9));
_lifeStones.put(12821, new LifeStone(GRADE_ACC, 10));
_lifeStones.put(12822, new LifeStone(GRADE_ACC, 11));
_lifeStones.put(12840, new LifeStone(GRADE_ACC, 0));
_lifeStones.put(12841, new LifeStone(GRADE_ACC, 1));
_lifeStones.put(12842, new LifeStone(GRADE_ACC, 2));
_lifeStones.put(12843, new LifeStone(GRADE_ACC, 3));
_lifeStones.put(12844, new LifeStone(GRADE_ACC, 4));
_lifeStones.put(12845, new LifeStone(GRADE_ACC, 5));
_lifeStones.put(12846, new LifeStone(GRADE_ACC, 6));
_lifeStones.put(12847, new LifeStone(GRADE_ACC, 7));
_lifeStones.put(12848, new LifeStone(GRADE_ACC, 8));
_lifeStones.put(12849, new LifeStone(GRADE_ACC, 9));
_lifeStones.put(12850, new LifeStone(GRADE_ACC, 10));
_lifeStones.put(12851, new LifeStone(GRADE_ACC, 11));
_lifeStones.put(14008, new LifeStone(GRADE_ACC, 12));
_lifeStones.put(14166, new LifeStone(GRADE_NONE, 12));
_lifeStones.put(14167, new LifeStone(GRADE_MID, 12));
_lifeStones.put(14168, new LifeStone(GRADE_HIGH, 12));
_lifeStones.put(14169, new LifeStone(GRADE_TOP, 12));
_lifeStones.put(16160, new LifeStone(GRADE_NONE, 13));
_lifeStones.put(16161, new LifeStone(GRADE_MID, 13));
_lifeStones.put(16162, new LifeStone(GRADE_HIGH, 13));
_lifeStones.put(16163, new LifeStone(GRADE_TOP, 13));
_lifeStones.put(16177, new LifeStone(GRADE_ACC, 13));
_lifeStones.put(16164, new LifeStone(GRADE_NONE, 13));
_lifeStones.put(16165, new LifeStone(GRADE_MID, 13));
_lifeStones.put(16166, new LifeStone(GRADE_HIGH, 13));
_lifeStones.put(16167, new LifeStone(GRADE_TOP, 13));
_lifeStones.put(16178, new LifeStone(GRADE_ACC, 13));
_lifeStones.put(18563, new LifeStone(GRADE_NONE, 13));
_lifeStones.put(18564, new LifeStone(GRADE_MID, 13));
_lifeStones.put(18565, new LifeStone(GRADE_HIGH, 13));
_lifeStones.put(18566, new LifeStone(GRADE_TOP, 13));
_lifeStones.put(18567, new LifeStone(GRADE_FORGOTTEN, 13));
_lifeStones.put(19166, new LifeStone(GRADE_ACC, 13));
_lifeStones.put(18568, new LifeStone(GRADE_NONE, 14));
_lifeStones.put(18569, new LifeStone(GRADE_MID, 14));
_lifeStones.put(18570, new LifeStone(GRADE_HIGH, 14));
_lifeStones.put(18571, new LifeStone(GRADE_TOP, 14));
_lifeStones.put(18572, new LifeStone(GRADE_FORGOTTEN, 14));
_lifeStones.put(19167, new LifeStone(GRADE_ACC, 14));
_lifeStones.put(18573, new LifeStone(GRADE_NONE, 15));
_lifeStones.put(18574, new LifeStone(GRADE_MID, 15));
_lifeStones.put(18575, new LifeStone(GRADE_HIGH, 15));
_lifeStones.put(18576, new LifeStone(GRADE_TOP, 15));
_lifeStones.put(18577, new LifeStone(GRADE_FORGOTTEN, 15));
_lifeStones.put(19168, new LifeStone(GRADE_ACC, 15));
_lifeStones.put(36731, new LifeStone(GRADE_NONE, 13));
_lifeStones.put(38571, new LifeStone(GRADE_ACC, 0));
}
protected static LifeStone getLifeStone(int itemId)
{
return _lifeStones.get(itemId);
}
/**
* Checks player, source item, lifestone and gemstone validity for augmentation process
* @param player
* @param item
* @param refinerItem
* @param gemStones
* @param mineralItem
* @param feeItem
* @param fee
* @return
*/
protected static boolean isValid(L2PcInstance player, L2ItemInstance item, L2ItemInstance refinerItem, L2ItemInstance gemStones)
protected static boolean isValid(L2PcInstance player, L2ItemInstance item, L2ItemInstance mineralItem, L2ItemInstance feeItem, VariationFee fee)
{
if (!isValid(player, item, refinerItem))
if (fee == null)
{
return false;
}
if (!isValid(player, item, mineralItem))
{
return false;
}
// GemStones must belong to owner
if (gemStones.getOwnerId() != player.getObjectId())
if (feeItem.getOwnerId() != player.getObjectId())
{
return false;
}
// .. and located in inventory
if (gemStones.getItemLocation() != ItemLocation.INVENTORY)
if (feeItem.getItemLocation() != ItemLocation.INVENTORY)
{
return false;
}
final CrystalType grade = item.getItem().getCrystalType();
final LifeStone ls = _lifeStones.get(refinerItem.getId());
// Check for item id
boolean gemIdFinded = false;
for (int id : getGemStoneId(grade))
{
if (gemStones.getId() == id)
{
gemIdFinded = true;
}
}
if (!gemIdFinded)
if (fee.getItemId() != feeItem.getId())
{
return false;
}
// Count must be greater or equal of required number
if (getGemStoneCount(grade, ls.getGrade()) > gemStones.getCount())
if (fee.getItemCount() > feeItem.getCount())
{
return false;
}
@ -310,10 +83,10 @@ public abstract class AbstractRefinePacket implements IClientIncomingPacket
* Checks player, source item and lifestone validity for augmentation process
* @param player
* @param item
* @param refinerItem
* @param mineralItem
* @return
*/
protected static boolean isValid(L2PcInstance player, L2ItemInstance item, L2ItemInstance refinerItem)
protected static boolean isValid(L2PcInstance player, L2ItemInstance item, L2ItemInstance mineralItem)
{
if (!isValid(player, item))
{
@ -321,33 +94,12 @@ public abstract class AbstractRefinePacket implements IClientIncomingPacket
}
// Item must belong to owner
if (refinerItem.getOwnerId() != player.getObjectId())
if (mineralItem.getOwnerId() != player.getObjectId())
{
return false;
}
// Lifestone must be located in inventory
if (refinerItem.getItemLocation() != ItemLocation.INVENTORY)
{
return false;
}
final LifeStone ls = _lifeStones.get(refinerItem.getId());
if (ls == null)
{
return false;
}
// weapons can't be augmented with accessory ls
if ((item.getItem() instanceof L2Weapon) && (ls.getGrade() == GRADE_ACC))
{
return false;
}
// and accessory can't be augmented with weapon ls
if ((item.getItem() instanceof L2Armor) && (ls.getGrade() != GRADE_ACC))
{
return false;
}
// check for level of the lifestone
if (player.getLevel() < ls.getPlayerLevel())
if (mineralItem.getItemLocation() != ItemLocation.INVENTORY)
{
return false;
}
@ -401,10 +153,6 @@ public abstract class AbstractRefinePacket implements IClientIncomingPacket
{
return false;
}
if (item.getItem().getCrystalType().isLesser(CrystalType.C))
{
return false;
}
// Source item can be equipped or in inventory
switch (item.getItemLocation())
@ -420,39 +168,7 @@ public abstract class AbstractRefinePacket implements IClientIncomingPacket
}
}
if (item.getItem() instanceof L2Weapon)
{
switch (((L2Weapon) item.getItem()).getItemType())
{
case NONE:
case FISHINGROD:
{
return false;
}
default:
{
break;
}
}
}
else if (item.getItem() instanceof L2Armor)
{
// only accessories can be augmented
switch (item.getItem().getBodyPart())
{
case L2Item.SLOT_LR_FINGER:
case L2Item.SLOT_LR_EAR:
case L2Item.SLOT_NECK:
{
break;
}
default:
{
return false;
}
}
}
else
if (!(item.getItem() instanceof L2Weapon) && !(item.getItem() instanceof L2Armor))
{
return false; // neither weapon nor armor ?
}
@ -514,115 +230,4 @@ public abstract class AbstractRefinePacket implements IClientIncomingPacket
return true;
}
/**
* @param itemGrade
* @return GemStone itemId based on item grade
*/
protected static int[] getGemStoneId(CrystalType itemGrade)
{
switch (itemGrade)
{
case C:
case B:
case A:
case S:
case S80:
case S84:
{
return GEMSTONE_B;
}
case R:
{
return GEMSTONE_A;
}
case R95:
{
return GEMSTONE_S;
}
case R99:
{
return GEMSTONE_R;
}
default:
{
return null;
}
}
}
/**
* Different for weapon and accessory augmentation.
* @param itemGrade
* @param lifeStoneGrade
* @return GemStone count based on item grade and life stone grade
*/
protected static int getGemStoneCount(CrystalType itemGrade, int lifeStoneGrade)
{
switch (lifeStoneGrade)
{
case GRADE_ACC:
{
switch (itemGrade)
{
case C:
case B:
case A:
case S:
case S80:
case S84:
{
return 125;
}
case R:
{
return 30;
}
case R95:
{
return 18;
}
case R99:
{
return 8;
}
default:
{
return 0;
}
}
}
default:
{
switch (itemGrade)
{
case C:
case B:
case A:
case S:
case S80:
case S84:
{
return 25;
}
case R:
{
return 20;
}
case R95:
{
return 12;
}
case R99:
{
return 5;
}
default:
{
return 0;
}
}
}
}
}
}

View File

@ -159,7 +159,7 @@ public class MultiSellChoose implements IClientIncomingPacket
|| (itemEnchantment.getAttributeDefence(AttributeType.HOLY) != _holyDefence)
|| (itemEnchantment.getAttributeDefence(AttributeType.DARK) != _darkDefence)
|| ((itemEnchantment.getAugmentation() == null) && ((_augmentOption1 != 0) || (_augmentOption2 != 0)))
|| ((itemEnchantment.getAugmentation() != null) && ((itemEnchantment.getAugmentation().getOptionId(0) != _augmentOption1) || (itemEnchantment.getAugmentation().getOptionId(1) != _augmentOption2)))
|| ((itemEnchantment.getAugmentation() != null) && ((itemEnchantment.getAugmentation().getOption1Id() != _augmentOption1) || (itemEnchantment.getAugmentation().getOption2Id() != _augmentOption2)))
))
//@formatter:on
{

View File

@ -18,6 +18,7 @@ package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.VariationData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
@ -72,105 +73,11 @@ public final class RequestConfirmCancelItem implements IClientIncomingPacket
return;
}
int price = 0;
switch (item.getItem().getCrystalType())
final long price = VariationData.getInstance().getCancelFee(item.getId(), item.getAugmentation().getMineralId());
if (price < 0)
{
case C:
{
if (item.getCrystalCount() < 1720)
{
price = 95000;
}
else if (item.getCrystalCount() < 2452)
{
price = 150000;
}
else
{
price = 210000;
}
break;
}
case B:
{
if (item.getCrystalCount() < 1746)
{
price = 240000;
}
else
{
price = 270000;
}
break;
}
case A:
{
if (item.getCrystalCount() < 2160)
{
price = 330000;
}
else if (item.getCrystalCount() < 2824)
{
price = 390000;
}
else
{
price = 420000;
}
break;
}
case S:
{
if (item.getCrystalCount() <= 2052)
{
price = 480000;
}
else
{
price = 920000;
}
break;
}
case S80:
case S84:
{
if (item.getCrystalCount() <= 4965)
{
price = 920000;
}
else if (item.getCrystalCount() <= 7050)
{
price = 2800000;
}
else if (item.getCrystalCount() <= 8233)
{
price = 2800000;
}
else
{
price = 3200000;
}
break;
}
case R:
{
price = 3492800;
break;
}
case R95:
{
price = 2943200;
break;
}
case R99:
{
price = 6485800;
break;
}
default:
{
return;
}
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
return;
}
activeChar.sendPacket(new ExPutItemResultForVariationCancel(item, price));

View File

@ -17,8 +17,10 @@
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.VariationData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.options.VariationFee;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExPutCommissionResultForVariationMake;
@ -30,17 +32,17 @@ import com.l2jmobius.gameserver.network.serverpackets.ExPutCommissionResultForVa
public final class RequestConfirmGemStone extends AbstractRefinePacket
{
private int _targetItemObjId;
private int _refinerItemObjId;
private int _gemstoneItemObjId;
private long _gemStoneCount;
private int _mineralItemObjId;
private int _feeItemObjId;
private long _feeCount;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_targetItemObjId = packet.readD();
_refinerItemObjId = packet.readD();
_gemstoneItemObjId = packet.readD();
_gemStoneCount = packet.readQ();
_mineralItemObjId = packet.readD();
_feeItemObjId = packet.readD();
_feeCount = packet.readQ();
return true;
}
@ -52,42 +54,39 @@ public final class RequestConfirmGemStone extends AbstractRefinePacket
{
return;
}
final L2ItemInstance targetItem = activeChar.getInventory().getItemByObjectId(_targetItemObjId);
if (targetItem == null)
{
return;
}
final L2ItemInstance refinerItem = activeChar.getInventory().getItemByObjectId(_refinerItemObjId);
final L2ItemInstance refinerItem = activeChar.getInventory().getItemByObjectId(_mineralItemObjId);
if (refinerItem == null)
{
return;
}
final L2ItemInstance gemStoneItem = activeChar.getInventory().getItemByObjectId(_gemstoneItemObjId);
final L2ItemInstance gemStoneItem = activeChar.getInventory().getItemByObjectId(_feeItemObjId);
if (gemStoneItem == null)
{
return;
}
// Make sure the item is a gemstone
if (!isValid(activeChar, targetItem, refinerItem, gemStoneItem))
final VariationFee fee = VariationData.getInstance().getFee(targetItem.getId(), refinerItem.getId());
if (!isValid(activeChar, targetItem, refinerItem, gemStoneItem, fee))
{
client.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
return;
}
// Check for gemstone count
final LifeStone ls = getLifeStone(refinerItem.getId());
if (ls == null)
{
return;
}
if (_gemStoneCount != getGemStoneCount(targetItem.getItem().getCrystalType(), ls.getGrade()))
// Check for fee count
if (_feeCount != fee.getItemCount())
{
client.sendPacket(SystemMessageId.GEMSTONE_QUANTITY_IS_INCORRECT);
return;
}
client.sendPacket(new ExPutCommissionResultForVariationMake(_gemstoneItemObjId, _gemStoneCount, gemStoneItem.getId()));
client.sendPacket(new ExPutCommissionResultForVariationMake(_feeItemObjId, _feeCount, gemStoneItem.getId()));
}
}

View File

@ -17,10 +17,10 @@
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.data.xml.impl.VariationData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.items.type.CrystalType;
import com.l2jmobius.gameserver.model.options.VariationFee;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExPutIntensiveResultForVariationMake;
@ -63,33 +63,13 @@ public class RequestConfirmRefinerItem extends AbstractRefinePacket
return;
}
if (!AugmentationData.getInstance().isAugmentaionStoneValid(refinerItem.getId()))
{
activeChar.sendMessage("This is not a proper life stone."); // need to update retailchances.xml with this item
return;
}
if (!isValid(activeChar, targetItem, refinerItem))
final VariationFee fee = VariationData.getInstance().getFee(targetItem.getId(), refinerItem.getId());
if ((fee == null) || !isValid(activeChar, targetItem, refinerItem))
{
activeChar.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
return;
}
final int refinerItemId = refinerItem.getItem().getId();
final CrystalType grade = targetItem.getItem().getCrystalType();
final LifeStone ls = getLifeStone(refinerItemId);
int gemStoneId = 0;
if (getGemStoneId(grade) != null)
{
for (int id : getGemStoneId(grade))
{
if (activeChar.getInventory().getAllItemsByItemId(id) != null)
{
gemStoneId = id;
break;
}
}
}
activeChar.sendPacket(new ExPutIntensiveResultForVariationMake(_refinerItemObjId, refinerItemId, gemStoneId, getGemStoneCount(grade, ls.getGrade())));
activeChar.sendPacket(new ExPutIntensiveResultForVariationMake(_refinerItemObjId, refinerItem.getId(), fee.getItemId(), fee.getItemCount()));
}
}

View File

@ -17,6 +17,7 @@
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.VariationData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
@ -53,6 +54,12 @@ public final class RequestConfirmTargetItem extends AbstractRefinePacket
return;
}
if (!VariationData.getInstance().hasFeeData(item.getId()))
{
client.sendPacket(SystemMessageId.THIS_IS_NOT_A_SUITABLE_ITEM);
return;
}
if (!isValid(activeChar, item))
{
// Different system message here

View File

@ -17,10 +17,12 @@
package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.model.Augmentation;
import com.l2jmobius.gameserver.data.xml.impl.VariationData;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.options.Variation;
import com.l2jmobius.gameserver.model.options.VariationFee;
import com.l2jmobius.gameserver.network.L2GameClient;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ExVariationResult;
@ -33,17 +35,17 @@ import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
public final class RequestRefine extends AbstractRefinePacket
{
private int _targetItemObjId;
private int _refinerItemObjId;
private int _gemStoneItemObjId;
private long _gemStoneCount;
private int _mineralItemObjId;
private int _feeItemObjId;
private long _feeCount;
@Override
public boolean read(L2GameClient client, PacketReader packet)
{
_targetItemObjId = packet.readD();
_refinerItemObjId = packet.readD();
_gemStoneItemObjId = packet.readD();
_gemStoneCount = packet.readQ();
_mineralItemObjId = packet.readD();
_feeItemObjId = packet.readD();
_feeCount = packet.readQ();
return true;
}
@ -55,77 +57,82 @@ public final class RequestRefine extends AbstractRefinePacket
{
return;
}
final L2ItemInstance targetItem = activeChar.getInventory().getItemByObjectId(_targetItemObjId);
if (targetItem == null)
{
return;
}
final L2ItemInstance refinerItem = activeChar.getInventory().getItemByObjectId(_refinerItemObjId);
if (refinerItem == null)
{
return;
}
final L2ItemInstance gemStoneItem = activeChar.getInventory().getItemByObjectId(_gemStoneItemObjId);
if (gemStoneItem == null)
final L2ItemInstance mineralItem = activeChar.getInventory().getItemByObjectId(_mineralItemObjId);
if (mineralItem == null)
{
return;
}
if (!isValid(activeChar, targetItem, refinerItem, gemStoneItem))
final L2ItemInstance feeItem = activeChar.getInventory().getItemByObjectId(_feeItemObjId);
if (feeItem == null)
{
activeChar.sendPacket(new ExVariationResult(0, 0, 0));
return;
}
final VariationFee fee = VariationData.getInstance().getFee(targetItem.getId(), mineralItem.getId());
if (!isValid(activeChar, targetItem, mineralItem, feeItem, fee))
{
activeChar.sendPacket(new ExVariationResult(0, 0, false));
activeChar.sendPacket(SystemMessageId.AUGMENTATION_FAILED_DUE_TO_INAPPROPRIATE_CONDITIONS);
return;
}
final LifeStone ls = getLifeStone(refinerItem.getId());
if (ls == null)
if (_feeCount != fee.getItemCount())
{
activeChar.sendPacket(new ExVariationResult(0, 0, false));
activeChar.sendPacket(SystemMessageId.AUGMENTATION_FAILED_DUE_TO_INAPPROPRIATE_CONDITIONS);
return;
}
final int lifeStoneLevel = ls.getLevel();
final int lifeStoneGrade = ls.getGrade();
if (_gemStoneCount != getGemStoneCount(targetItem.getItem().getCrystalType(), lifeStoneGrade))
final Variation variation = VariationData.getInstance().getVariation(mineralItem.getId());
if (variation == null)
{
activeChar.sendPacket(new ExVariationResult(0, 0, 0));
activeChar.sendPacket(SystemMessageId.AUGMENTATION_FAILED_DUE_TO_INAPPROPRIATE_CONDITIONS);
activeChar.sendPacket(new ExVariationResult(0, 0, false));
return;
}
final VariationInstance augment = VariationData.getInstance().generateRandomVariation(variation, targetItem);
if (augment == null)
{
activeChar.sendPacket(new ExVariationResult(0, 0, false));
return;
}
// unequip item
final InventoryUpdate iu = new InventoryUpdate();
if (targetItem.isEquipped())
{
final L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot());
final InventoryUpdate iu = new InventoryUpdate();
L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(targetItem.getLocationSlot());
for (L2ItemInstance itm : unequiped)
{
iu.addModifiedItem(itm);
}
activeChar.sendInventoryUpdate(iu);
activeChar.broadcastUserInfo();
}
// consume the life stone
if (!activeChar.destroyItem("RequestRefine", refinerItem, 1, null, false))
if (!activeChar.destroyItem("RequestRefine", mineralItem, 1, null, false))
{
return;
}
// consume the gemstones
if (!activeChar.destroyItem("RequestRefine", gemStoneItem, _gemStoneCount, null, false))
if (!activeChar.destroyItem("RequestRefine", feeItem, _feeCount, null, false))
{
return;
}
final Augmentation aug = AugmentationData.getInstance().generateRandomAugmentation(lifeStoneLevel, lifeStoneGrade, targetItem.getItem().getBodyPart(), refinerItem.getId(), targetItem);
targetItem.setAugmentation(aug, true);
targetItem.setAugmentation(augment, true);
activeChar.sendPacket(new ExVariationResult(augment.getOption1Id(), augment.getOption2Id(), true));
activeChar.sendPacket(new ExVariationResult(aug.getOptionId(0), aug.getOptionId(1), 1));
final InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(targetItem);
activeChar.sendInventoryUpdate(iu);
}
}

View File

@ -18,6 +18,7 @@ package com.l2jmobius.gameserver.network.clientpackets;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketReader;
import com.l2jmobius.gameserver.data.xml.impl.VariationData;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.network.L2GameClient;
@ -53,108 +54,36 @@ public final class RequestRefineCancel implements IClientIncomingPacket
final L2ItemInstance targetItem = activeChar.getInventory().getItemByObjectId(_targetItemObjId);
if (targetItem == null)
{
client.sendPacket(new ExVariationCancelResult(0));
client.sendPacket(ExVariationCancelResult.STATIC_PACKET_FAILURE);
return;
}
if (targetItem.getOwnerId() != activeChar.getObjectId())
{
Util.handleIllegalPlayerAction(client.getActiveChar(), "Warning!! Character " + client.getActiveChar().getName() + " of account " + client.getActiveChar().getAccountName() + " tryied to augment item that doesn't own.", Config.DEFAULT_PUNISH);
return;
}
// cannot remove augmentation from a not augmented item
if (!targetItem.isAugmented())
{
client.sendPacket(SystemMessageId.AUGMENTATION_REMOVAL_CAN_ONLY_BE_DONE_ON_AN_AUGMENTED_ITEM);
client.sendPacket(new ExVariationCancelResult(0));
client.sendPacket(ExVariationCancelResult.STATIC_PACKET_FAILURE);
return;
}
// get the price
int price = 0;
switch (targetItem.getItem().getCrystalType())
final long price = VariationData.getInstance().getCancelFee(targetItem.getId(), targetItem.getAugmentation().getMineralId());
if (price < 0)
{
case C:
{
if (targetItem.getCrystalCount() < 1720)
{
price = 95000;
}
else if (targetItem.getCrystalCount() < 2452)
{
price = 150000;
}
else
{
price = 210000;
}
break;
}
case B:
{
if (targetItem.getCrystalCount() < 1746)
{
price = 240000;
}
else
{
price = 270000;
}
break;
}
case A:
{
if (targetItem.getCrystalCount() < 2160)
{
price = 330000;
}
else if (targetItem.getCrystalCount() < 2824)
{
price = 390000;
}
else
{
price = 420000;
}
break;
}
case S:
{
price = 480000;
break;
}
case S80:
case S84:
{
price = 920000;
break;
}
case R:
{
price = 1560000;
break;
}
case R95:
{
price = 5400000;
break;
}
case R99:
{
price = 14160000;
break;
}
// any other item type is not augmentable
default:
{
client.sendPacket(new ExVariationCancelResult(0));
return;
}
client.sendPacket(ExVariationCancelResult.STATIC_PACKET_FAILURE);
return;
}
// try to reduce the players adena
if (!activeChar.reduceAdena("RequestRefineCancel", price, null, true))
if (!activeChar.reduceAdena("RequestRefineCancel", price, targetItem, true))
{
client.sendPacket(new ExVariationCancelResult(0));
client.sendPacket(ExVariationCancelResult.STATIC_PACKET_FAILURE);
client.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
return;
}
@ -169,10 +98,10 @@ public final class RequestRefineCancel implements IClientIncomingPacket
targetItem.removeAugmentation();
// send ExVariationCancelResult
client.sendPacket(new ExVariationCancelResult(1));
client.sendPacket(ExVariationCancelResult.STATIC_PACKET_SUCCESS);
// send inventory update
final InventoryUpdate iu = new InventoryUpdate();
InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(targetItem);
activeChar.sendInventoryUpdate(iu);
}

View File

@ -133,8 +133,8 @@ public abstract class AbstractItemPacket extends AbstractMaskPacket<ItemListType
{
if ((item != null) && (item.getAugmentation() != null))
{
packet.writeH(item.getAugmentation().getOptionId(0));
packet.writeH(item.getAugmentation().getOptionId(1));
packet.writeH(item.getAugmentation().getOption1Id());
packet.writeH(item.getAugmentation().getOption2Id());
}
else
{

View File

@ -21,7 +21,7 @@ import java.util.Set;
import com.l2jmobius.Config;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jmobius.gameserver.model.Augmentation;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2DecoyInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.ceremonyofchaos.CeremonyOfChaosEvent;
@ -134,9 +134,10 @@ public class CharInfo implements IClientOutgoingPacket
for (int slot : getPaperdollOrderAugument())
{
final Augmentation augment = _activeChar.getInventory().getPaperdollAugmentation(slot);
packet.writeD(augment != null ? augment.getOptionId(0) : 0); // Confirmed
// packet.writeD(augment != null ? augment.getOptionId(1) : 0); // Confirmed
final VariationInstance augment = _activeChar.getInventory().getPaperdollAugmentation(slot);
packet.writeD(augment != null ? augment.getOption1Id() : 0); // Confirmed
// Mobius: Maybe use 2x writeH ?
// packet.writeD(augment != null ? augment.getOption2Id() : 0); // Confirmed
}
packet.writeC(_armorEnchant);

View File

@ -29,9 +29,9 @@ import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
import com.l2jmobius.gameserver.datatables.AugmentationData;
import com.l2jmobius.gameserver.model.CharSelectInfoPackage;
import com.l2jmobius.gameserver.model.L2Clan;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.entity.Hero;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.network.L2GameClient;
@ -190,8 +190,9 @@ public class CharSelectionInfo implements IClientOutgoingPacket
packet.writeD(i == _activeId ? 1 : 0);
packet.writeC(charInfoPackage.getEnchantEffect() > 127 ? 127 : charInfoPackage.getEnchantEffect());
packet.writeD(charInfoPackage.getAugmentation() != null ? charInfoPackage.getAugmentation().getOptionId(0) : 0);
// packet.writeD(charInfoPackage.getAugmentation() != null ? charInfoPackage.getAugmentation().getOptionId(1) : 0);
packet.writeD(charInfoPackage.getAugmentation() != null ? charInfoPackage.getAugmentation().getOption1Id() : 0);
// Mobius: Maybe use 2x writeH?
// packet.writeD(charInfoPackage.getAugmentation() != null ? charInfoPackage.getAugmentation().getOption2Id() : 0);
// packet.writeD(charInfoPackage.getTransformId()); // Used to display Transformations
packet.writeD(0x00); // Currently on retail when you are on character select you don't see your transformation.
@ -357,17 +358,19 @@ public class CharSelectionInfo implements IClientOutgoingPacket
if (weaponObjId > 0)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT augAttributes FROM item_attributes WHERE itemId=?"))
PreparedStatement statement = con.prepareStatement("SELECT mineralId,option1,option2 FROM item_variations WHERE itemId=?"))
{
statement.setInt(1, weaponObjId);
try (ResultSet result = statement.executeQuery())
{
if (result.next())
{
final int augment = result.getInt("augAttributes");
if (augment > 0)
int mineralId = result.getInt("mineralId");
int option1 = result.getInt("option1");
int option2 = result.getInt("option2");
if ((option1 != -1) && (option2 != -1))
{
charInfopackage.setAugmentation(AugmentationData.getInstance().getAugmentation(augment));
charInfopackage.setAugmentation(new VariationInstance(mineralId, option1, option2));
}
}
}

View File

@ -24,10 +24,10 @@ public class ExPutIntensiveResultForVariationMake implements IClientOutgoingPack
private final int _refinerItemObjId;
private final int _lifestoneItemId;
private final int _gemstoneItemId;
private final int _gemstoneCount;
private final long _gemstoneCount;
private final int _unk2;
public ExPutIntensiveResultForVariationMake(int refinerItemObjId, int lifeStoneId, int gemstoneItemId, int gemstoneCount)
public ExPutIntensiveResultForVariationMake(int refinerItemObjId, int lifeStoneId, int gemstoneItemId, long gemstoneCount)
{
_refinerItemObjId = refinerItemObjId;
_lifestoneItemId = lifeStoneId;

View File

@ -33,8 +33,8 @@ public class ExPutItemResultForVariationCancel implements IClientOutgoingPacket
_itemObjId = item.getObjectId();
_itemId = item.getDisplayId();
_price = price;
_itemAug1 = item.getAugmentation().getOptionId(0);
_itemAug2 = item.getAugmentation().getOptionId(1);
_itemAug1 = item.getAugmentation().getOption1Id();
_itemAug2 = item.getAugmentation().getOption2Id();
}
@Override

View File

@ -18,7 +18,7 @@ package com.l2jmobius.gameserver.network.serverpackets;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.enums.InventorySlot;
import com.l2jmobius.gameserver.model.Augmentation;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
import com.l2jmobius.gameserver.network.OutgoingPackets;
@ -74,12 +74,13 @@ public class ExUserInfoEquipSlot extends AbstractMaskPacket<InventorySlot>
{
if (containsMask(slot))
{
final Augmentation augment = inventory.getPaperdollAugmentation(slot.getSlot());
final VariationInstance augment = inventory.getPaperdollAugmentation(slot.getSlot());
packet.writeH(18); // 2 + 4 * 4
packet.writeD(inventory.getPaperdollObjectId(slot.getSlot()));
packet.writeD(inventory.getPaperdollItemId(slot.getSlot()));
packet.writeD(augment != null ? augment.getOptionId(0) : 0);
// packet.writeD(augment != null ? augment.getOptionId(1) : 0);
packet.writeD(augment != null ? augment.getOption1Id() : 0);
// Mobius: Maybe use 2x writeH?
// packet.writeD(augment != null ? augment.getOption2Id() : 0);
packet.writeD(inventory.getPaperdollItemVisualId(slot.getSlot()));
}
}

View File

@ -21,9 +21,12 @@ import com.l2jmobius.gameserver.network.OutgoingPackets;
public class ExVariationCancelResult implements IClientOutgoingPacket
{
public static final ExVariationCancelResult STATIC_PACKET_SUCCESS = new ExVariationCancelResult(1);
public static final ExVariationCancelResult STATIC_PACKET_FAILURE = new ExVariationCancelResult(0);
private final int _result;
public ExVariationCancelResult(int result)
private ExVariationCancelResult(int result)
{
_result = result;
}

View File

@ -24,15 +24,15 @@ import com.l2jmobius.gameserver.network.OutgoingPackets;
*/
public class ExVariationResult implements IClientOutgoingPacket
{
private final int _stat12;
private final int _stat34;
private final int _unk3;
private final int _option1;
private final int _option2;
private final int _success;
public ExVariationResult(int unk1, int unk2, int unk3)
public ExVariationResult(int option1, int option2, boolean success)
{
_stat12 = unk1;
_stat34 = unk2;
_unk3 = unk3;
_option1 = option1;
_option2 = option2;
_success = success ? 0x01 : 0x00;
}
@Override
@ -40,9 +40,9 @@ public class ExVariationResult implements IClientOutgoingPacket
{
OutgoingPackets.EX_VARIATION_RESULT.writeId(packet);
packet.writeD(_stat12);
packet.writeD(_stat34);
packet.writeD(_unk3);
packet.writeD(_option1);
packet.writeD(_option2);
packet.writeD(_success);
return true;
}
}

View File

@ -19,7 +19,7 @@ package com.l2jmobius.gameserver.network.serverpackets;
import com.l2jmobius.commons.network.PacketWriter;
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.model.Augmentation;
import com.l2jmobius.gameserver.model.VariationInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.OutgoingPackets;
@ -89,9 +89,10 @@ public class GMViewCharacterInfo implements IClientOutgoingPacket
for (int slot : getPaperdollOrder())
{
final Augmentation augment = _activeChar.getInventory().getPaperdollAugmentation(slot);
packet.writeD(augment != null ? augment.getOptionId(0) : 0); // Confirmed
// packet.writeD(augment != null ? augment.getOptionId(1) : 0); // Confirmed
final VariationInstance augment = _activeChar.getInventory().getPaperdollAugmentation(slot);
packet.writeD(augment != null ? augment.getOption1Id() : 0); // Confirmed
// Mobius: Maybe use 2x writeH?
// packet.writeD(augment != null ? augment.getOption2Id() : 0); // Confirmed
}
packet.writeD(0x00);
packet.writeD(0x00);