Обратите внимание, что данный пользователь заблокирован! Не совершайте с ним никаких сделок! Перейдите в его профиль, чтобы узнать причину блокировки.
помогите поправить 1 деталь чет не пойму.
на сервере выдает такой бред
Где тут в коде эта фигня чет не могу понять почему выводит 9 а должно выводить 3.
Код:
public class RequestAlchemyTryMixCube extends L2GameClientPacket
{
private final static int AIR_STONE = 39461;
private final static int ELCYUM_CRYSTAL = 36514;
private final Map<Integer, Long> _items = new HashMap<>();
public RequestAlchemyTryMixCube()
{
_items.clear();
}
@Override
protected void readImpl()
{
final int count = readD();
for (int i = 0; i < count; ++i)
{
final int itemObjectId = readD();
final long itemCount = readQ();
_items.put(itemObjectId, itemCount);
}
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if ((_items == null) || _items.isEmpty())
{
activeChar.sendPacket(ExTryMixCube.FAIL);
return;
}
if (activeChar.isInCombat())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_DURING_BATTLE);
activeChar.sendPacket(ExTryMixCube.FAIL);
return;
}
if (activeChar.isInStoreMode() || activeChar.isInStoreMode())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_TRADING_OR_USING_A_PRIVATE_STORE_OR_SHOP);
activeChar.sendPacket(ExTryMixCube.FAIL);
return;
}
if (activeChar.isDead())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_DEAD);
activeChar.sendPacket(ExTryMixCube.FAIL);
return;
}
if (activeChar.isMovementDisabled())
{
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_ALCHEMY_WHILE_IMMOBILE);
activeChar.sendPacket(ExTryMixCube.FAIL);
return;
}
long totalPrice = 0;
long count = 0;
for (int itemId : _items.keySet())
{
final int itemObjectId = itemId;
final long itemCount = _items.get(itemId);
final L2ItemInstance item = activeChar.getInventory().getItemByObjectId(itemObjectId);
if (item != null)
{
if (item.getCount() < itemCount)
{
continue;
}
if (!item.isDestroyable())
{
continue;
}
if (item.getEnchantLevel() > 0)
{
continue;
}
if (item.isAugmented())
{
continue;
}
if (item.isShadowItem())
{
continue;
}
if (item.getId() == ELCYUM_CRYSTAL)
{
if (_items.size() <= 3)
{
continue;
}
count = itemCount;
}
else
{
final long price = item.getId() == Inventory.ADENA_ID ? itemCount : item.getReferencePrice();
if (price <= 0)
{
continue;
}
totalPrice += price;
}
activeChar.destroyItem("AlchemyMixCube", itemObjectId, itemCount, activeChar, true);
}
}
long stoneCount = 0;
if (totalPrice > 0)
{
if (_items.size() >= 3)
{
stoneCount = totalPrice / 10000;
stoneCount += count * 1000;
}
else if ((totalPrice >= 20000) && (totalPrice < 35000))
{
stoneCount = 1;
}
else if ((totalPrice >= 35000) && (totalPrice < 50000))
{
stoneCount = 2;
}
else if (totalPrice >= 50000)
{
stoneCount = (long) Math.floor(totalPrice / 16666.666666666668);
}
}
if (stoneCount > 0)
{
activeChar.addItem("AlchemyMixCube", AIR_STONE, stoneCount, activeChar, true);
}
activeChar.sendPacket(new ExTryMixCube(AIR_STONE, stoneCount));
}
@Override
public String getType()
{
return getClass().getSimpleName();
}
}
Код:
public class RequestAlchemySkillList extends L2GameClientPacket
{
@Override
protected void readImpl()
{
// Nothing to read
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getActiveChar();
if ((activeChar == null) || (activeChar.getRace() != Race.ERTHEIA))
{
return;
}
activeChar.sendPacket(new ExAlchemySkillList(activeChar));
}
@Override
public String getType()
{
return getClass().getSimpleName();
}
}
Код:
public class RequestAlchemyConversion extends L2GameClientPacket
{
@SuppressWarnings("unused")
private int _unk;
private int _skillId;
private int _skillLevel;
private int _skillUseCount;
private long _resultItemCount = 0;
private long _resultFailCount = 0;
@Override
protected void readImpl()
{
_skillUseCount = readD();
_unk = readH(); // Unk = 10;
_skillId = readD();
_skillLevel = readD();
readB(new byte[28]);
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
final Skill skill = SkillData.getInstance().getSkill(_skillId, _skillLevel);
final L2AlchemySkill alchemySkill = skill.getAlchemySkill();
if ((activeChar == null) || (activeChar.getRace() != Race.ERTHEIA) || (_skillUseCount < 0))
{
return;
}
boolean hasIngidients = true;
for (ItemHolder item : alchemySkill.getIngridientItems())
{
if ((activeChar.getInventory().getInventoryItemCount(item.getId(), -1) * _skillUseCount) < (item.getCount() * _skillUseCount))
{
hasIngidients = false;
break;
}
}
if (!hasIngidients)
{
activeChar.sendPacket(SystemMessageId.PLEASE_ENTER_THE_COMBINATION_INGREDIENTS);
return;
}
for (int i = 0; i < _skillUseCount; i++)
{
if (Rnd.get(1, 100) < 90) // 90% ?
{
_resultItemCount += alchemySkill.getTransmutedItem().getCount();
}
else
{
_resultFailCount++;
}
alchemySkill.getIngridientItems().forEach(holder -> activeChar.getInventory().destroyItemByItemId("Alchemy", holder.getId(), holder.getCount(), activeChar, null));
}
if (_resultItemCount > 0)
{
activeChar.addItem("Alchemy", alchemySkill.getTransmutedItem(), activeChar, true);
}
if (_resultFailCount > 0)
{
for (ItemHolder item : alchemySkill.getIngridientItems())
{
activeChar.getInventory().destroyItemByItemId("Alchemy", item.getId(), _resultFailCount, activeChar, null);
break; // FIXME: Takes only 1st ingredient (client has specific item and quantity).
}
activeChar.sendPacket(SystemMessageId.FAILURE_TO_TRANSMUTE_WILL_DESTROY_SOME_INGREDIENTS);
}
activeChar.sendPacket(new ExAlchemyConversion((int) _resultItemCount, (int) _resultFailCount));
activeChar.sendPacket(new ItemList(activeChar, false));
}
@Override
public String getType()
{
return getClass().getSimpleName();
}
}
Код:
public class ExAlchemyConversion extends L2GameServerPacket
{
private final int _itemCount;
private final int _failCount;
public ExAlchemyConversion(int itemCount, int failCount)
{
_itemCount = itemCount;
_failCount = failCount;
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0x176);
writeC(0x00);
writeD(_itemCount);
writeD(_failCount);
}
}
Код:
public class ExAlchemySkillList extends L2GameServerPacket
{
private final static int ALCHEMY_CUBE_SKILL = 17943;
private final List<Skill> _skills = new ArrayList<>();
public ExAlchemySkillList(L2PcInstance player)
{
for (Skill skill : player.getAllSkills())
{
// Make sure its alchemy skill.
if (SkillTreesData.getInstance().getAlchemySkill(skill.getId(), skill.getLevel()) != null)
{
_skills.add(skill);
}
}
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0x174);
writeD(_skills.size());
for (Skill skill : _skills)
{
writeD(skill.getId());
writeD(skill.getLevel());
writeQ(0x00); // Always 0 on Naia, SP i guess?
writeC(skill.getId() == ALCHEMY_CUBE_SKILL ? 0x00 : 0x01);
}
}
}
Код:
public class ExTryMixCube extends L2GameServerPacket
{
public static final L2GameServerPacket FAIL = new ExTryMixCube(6);
private final int _result;
private final int _itemId;
private final long _itemCount;
public ExTryMixCube(int result)
{
_result = result;
_itemId = 0;
_itemCount = 0;
}
public ExTryMixCube(int itemId, long itemCount)
{
_result = 0;
_itemId = itemId;
_itemCount = itemCount;
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0x175);
writeC(_result);
writeC(0x01);
writeD(0x00); // 1=show bonus card, but cant't understand bonus count
writeD(_itemId);
writeQ(_itemCount);
}
}
Где тут в коде эта фигня чет не могу понять почему выводит 9 а должно выводить 3.
Последнее редактирование: