Project update.

This commit is contained in:
MobiusDev
2015-12-31 23:53:41 +00:00
parent e0d681a17e
commit ad2bcd79be
4084 changed files with 83696 additions and 86998 deletions

View File

@ -0,0 +1,91 @@
/*
* 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.multisell;
import java.util.ArrayList;
import java.util.List;
/**
* @author DS
*/
public class Entry
{
protected int _entryId;
protected boolean _stackable = true;
protected List<Ingredient> _products;
protected List<Ingredient> _ingredients;
public Entry(int entryId)
{
_entryId = entryId;
_products = new ArrayList<>();
_ingredients = new ArrayList<>();
}
/**
* This constructor used in PreparedEntry only, ArrayLists not created.
*/
protected Entry()
{
}
public final void setEntryId(int id)
{
_entryId = id;
}
public final int getEntryId()
{
return _entryId;
}
public final void addProduct(Ingredient product)
{
_products.add(product);
if (!product.isStackable())
{
_stackable = false;
}
}
public final List<Ingredient> getProducts()
{
return _products;
}
public final void addIngredient(Ingredient ingredient)
{
_ingredients.add(ingredient);
}
public final List<Ingredient> getIngredients()
{
return _ingredients;
}
public final boolean isStackable()
{
return _stackable;
}
public long getTaxAmount()
{
return 0;
}
}

View File

@ -0,0 +1,151 @@
/*
* 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.multisell;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.model.StatsSet;
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;
/**
* @author DS
*/
public class Ingredient
{
private int _itemId;
private long _itemCount;
private final int _enchantmentLevel;
private boolean _isTaxIngredient;
private boolean _maintainIngredient;
private L2Item _template = null;
private ItemInfo _itemInfo = null;
private final int _chance;
public Ingredient(StatsSet set)
{
this(set.getInt("id"), set.getLong("count"), set.getInt("enchantmentLevel", 0), set.getInt("chance", 0), set.getBoolean("isTaxIngredient", false), set.getBoolean("maintainIngredient", false));
}
public Ingredient(int itemId, long itemCount, int enchantmentLevel, int chance, boolean isTaxIngredient, boolean maintainIngredient)
{
_itemId = itemId;
_itemCount = itemCount;
_enchantmentLevel = enchantmentLevel;
_chance = chance;
_isTaxIngredient = isTaxIngredient;
_maintainIngredient = maintainIngredient;
if (_itemId > 0)
{
_template = ItemTable.getInstance().getTemplate(_itemId);
}
}
/**
* @return a new Ingredient instance with the same values as this.
*/
public Ingredient getCopy()
{
return new Ingredient(_itemId, _itemCount, _enchantmentLevel, _chance, _isTaxIngredient, _maintainIngredient);
}
public final L2Item getTemplate()
{
return _template;
}
public final void setItemInfo(L2ItemInstance item)
{
_itemInfo = new ItemInfo(item);
}
public final void setItemInfo(ItemInfo info)
{
_itemInfo = info;
}
public final ItemInfo getItemInfo()
{
return _itemInfo;
}
public final int getEnchantLevel()
{
return _itemInfo == null ? _enchantmentLevel : _itemInfo.getEnchantLevel();
}
public final void setItemId(int itemId)
{
_itemId = itemId;
}
public final int getItemId()
{
return _itemId;
}
public final void setItemCount(long itemCount)
{
_itemCount = itemCount;
}
public final long getItemCount()
{
return _itemCount;
}
public int getChance()
{
return _chance;
}
public final void setIsTaxIngredient(boolean isTaxIngredient)
{
_isTaxIngredient = isTaxIngredient;
}
public final boolean isTaxIngredient()
{
return _isTaxIngredient;
}
public final void setMaintainIngredient(boolean maintainIngredient)
{
_maintainIngredient = maintainIngredient;
}
public final boolean getMaintainIngredient()
{
return _maintainIngredient;
}
public final boolean isStackable()
{
return _template == null ? true : _template.isStackable();
}
public final boolean isArmorOrWeapon()
{
return _template == null ? false : (_template instanceof L2Armor) || (_template instanceof L2Weapon);
}
public final int getWeight()
{
return _template == null ? 0 : _template.getWeight();
}
}

View File

@ -0,0 +1,84 @@
/*
* 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.multisell;
import com.l2jmobius.gameserver.model.Elementals;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
/**
* @author DS
*/
public class ItemInfo
{
private final int _enchantLevel, _augmentId;
private final byte _elementId;
private final int _elementPower;
private final int[] _elementals = new int[6];
public ItemInfo(L2ItemInstance item)
{
_enchantLevel = item.getEnchantLevel();
_augmentId = item.getAugmentation() != null ? item.getAugmentation().getAugmentationId() : 0;
_elementId = item.getAttackElementType();
_elementPower = item.getAttackElementPower();
_elementals[0] = item.getElementDefAttr(Elementals.FIRE);
_elementals[1] = item.getElementDefAttr(Elementals.WATER);
_elementals[2] = item.getElementDefAttr(Elementals.WIND);
_elementals[3] = item.getElementDefAttr(Elementals.EARTH);
_elementals[4] = item.getElementDefAttr(Elementals.HOLY);
_elementals[5] = item.getElementDefAttr(Elementals.DARK);
}
public ItemInfo(int enchantLevel)
{
_enchantLevel = enchantLevel;
_augmentId = 0;
_elementId = Elementals.NONE;
_elementPower = 0;
_elementals[0] = 0;
_elementals[1] = 0;
_elementals[2] = 0;
_elementals[3] = 0;
_elementals[4] = 0;
_elementals[5] = 0;
}
public final int getEnchantLevel()
{
return _enchantLevel;
}
public final int getAugmentId()
{
return _augmentId;
}
public final byte getElementId()
{
return _elementId;
}
public final int getElementPower()
{
return _elementPower;
}
public final int[] getElementals()
{
return _elementals;
}
}

View File

@ -0,0 +1,123 @@
/*
* 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.multisell;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author DS
*/
public class ListContainer
{
private final int _listId;
private boolean _isNewMultisell = false;
private boolean _applyTaxes = false;
private boolean _maintainEnchantment = false;
private double _useRate = 1.0;
protected List<Entry> _entries = new ArrayList<>();
protected Set<Integer> _npcsAllowed = null;
public ListContainer(int listId)
{
_listId = listId;
}
public ListContainer(ListContainer container)
{
_listId = container.getListId();
_isNewMultisell = container.isNewMultisell();
_maintainEnchantment = container.getMaintainEnchantment();
}
public final List<Entry> getEntries()
{
return _entries;
}
public final int getListId()
{
return _listId;
}
public boolean isNewMultisell()
{
return _isNewMultisell;
}
public void setNewMultisell(boolean isNewMultisell)
{
_isNewMultisell = isNewMultisell;
}
public final void setApplyTaxes(boolean applyTaxes)
{
_applyTaxes = applyTaxes;
}
public final boolean getApplyTaxes()
{
return _applyTaxes;
}
public final void setMaintainEnchantment(boolean maintainEnchantment)
{
_maintainEnchantment = maintainEnchantment;
}
public double getUseRate()
{
return _useRate;
}
/**
* Set this to create multisell with increased products, all product counts will be multiplied by the rate specified.<br>
* <b>NOTE:</b> It affects only parser, it won't change values of already parsed multisell since MultiSells' parseEntry method handles this feature.
* @param rate
*/
public void setUseRate(double rate)
{
_useRate = rate;
}
public final boolean getMaintainEnchantment()
{
return _maintainEnchantment;
}
public void allowNpc(int npcId)
{
if (_npcsAllowed == null)
{
_npcsAllowed = new HashSet<>();
}
_npcsAllowed.add(npcId);
}
public boolean isNpcAllowed(int npcId)
{
return (_npcsAllowed == null) || _npcsAllowed.contains(npcId);
}
public boolean isNpcOnly()
{
return _npcsAllowed != null;
}
}

View File

@ -0,0 +1,113 @@
/*
* 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.multisell;
import static com.l2jmobius.gameserver.model.itemcontainer.Inventory.ADENA_ID;
import java.util.ArrayList;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
/**
* @author DS
*/
public class PreparedEntry extends Entry
{
private long _taxAmount = 0;
public PreparedEntry(Entry template, L2ItemInstance item, boolean applyTaxes, boolean maintainEnchantment, double taxRate)
{
_entryId = template.getEntryId() * 100000;
if (maintainEnchantment && (item != null))
{
_entryId += item.getEnchantLevel();
}
ItemInfo info = null;
long adenaAmount = 0;
_ingredients = new ArrayList<>(template.getIngredients().size());
for (Ingredient ing : template.getIngredients())
{
if (ing.getItemId() == ADENA_ID)
{
// Tax ingredients added only if taxes enabled
if (ing.isTaxIngredient())
{
// if taxes are to be applied, modify/add the adena count based on the template adena/ancient adena count
if (applyTaxes)
{
_taxAmount += Math.round(ing.getItemCount() * taxRate);
}
}
else
{
adenaAmount += ing.getItemCount();
}
// do not yet add this adena amount to the list as non-taxIngredient adena might be entered later (order not guaranteed)
continue;
}
else if (maintainEnchantment && (item != null) && ing.isArmorOrWeapon())
{
info = new ItemInfo(item);
final Ingredient newIngredient = ing.getCopy();
newIngredient.setItemInfo(info);
_ingredients.add(newIngredient);
}
else
{
final Ingredient newIngredient = ing.getCopy();
_ingredients.add(newIngredient);
}
}
// now add the adena, if any.
adenaAmount += _taxAmount; // do not forget tax
if (adenaAmount > 0)
{
_ingredients.add(new Ingredient(ADENA_ID, adenaAmount, 0, 0, false, false));
}
// now copy products
_products = new ArrayList<>(template.getProducts().size());
for (Ingredient ing : template.getProducts())
{
if (!ing.isStackable())
{
_stackable = false;
}
final Ingredient newProduct = ing.getCopy();
if (maintainEnchantment && ing.isArmorOrWeapon())
{
newProduct.setItemInfo(info);
}
else if (ing.isArmorOrWeapon() && (ing.getTemplate().getDefaultEnchantLevel() > 0))
{
info = new ItemInfo(ing.getTemplate().getDefaultEnchantLevel());
newProduct.setItemInfo(info);
}
_products.add(newProduct);
}
}
@Override
public final long getTaxAmount()
{
return _taxAmount;
}
}

View File

@ -0,0 +1,108 @@
/*
* 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.multisell;
import java.util.ArrayList;
import java.util.LinkedList;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.L2Armor;
import com.l2jmobius.gameserver.model.items.L2Weapon;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
public class PreparedListContainer extends ListContainer
{
private int _npcObjectId = 0;
public PreparedListContainer(ListContainer template, boolean inventoryOnly, L2PcInstance player, L2Npc npc)
{
super(template.getListId());
setMaintainEnchantment(template.getMaintainEnchantment());
setApplyTaxes(false);
double taxRate = 0;
if (npc != null)
{
_npcObjectId = npc.getObjectId();
if (template.getApplyTaxes() && npc.getIsInTown() && (npc.getCastle().getOwnerId() > 0))
{
setApplyTaxes(true);
taxRate = npc.getCastle().getTaxRate();
}
}
setNewMultisell(false);
if (template.isNewMultisell())
{
setNewMultisell(true);
}
if (inventoryOnly)
{
if (player == null)
{
return;
}
final L2ItemInstance[] items;
if (getMaintainEnchantment())
{
items = player.getInventory().getUniqueItemsByEnchantLevel(false, false, false);
}
else
{
items = player.getInventory().getUniqueItems(false, false, false);
}
_entries = new LinkedList<>();
for (L2ItemInstance item : items)
{
// only do the match up on equippable items that are not currently equipped
// so for each appropriate item, produce a set of entries for the multisell list.
if (!item.isEquipped() && ((item.getItem() instanceof L2Armor) || (item.getItem() instanceof L2Weapon)))
{
// loop through the entries to see which ones we wish to include
for (Entry ent : template.getEntries())
{
// check ingredients of this entry to see if it's an entry we'd like to include.
for (Ingredient ing : ent.getIngredients())
{
if (item.getId() == ing.getItemId())
{
_entries.add(new PreparedEntry(ent, item, getApplyTaxes(), getMaintainEnchantment(), taxRate));
break; // next entry
}
}
}
}
}
}
else
{
_entries = new ArrayList<>(template.getEntries().size());
for (Entry ent : template.getEntries())
{
_entries.add(new PreparedEntry(ent, null, getApplyTaxes(), false, taxRate));
}
}
}
public final boolean checkNpcObjectId(int npcObjectId)
{
return _npcObjectId != 0 ? _npcObjectId == npcObjectId : true;
}
}