public void AlchemyCreateStone()
{
try
{
//Open packet reader
PacketReader reader = new PacketReader(PacketInformation.buffer);
byte type = reader.Byte();
byte type1 = reader.Byte();
byte type2 = reader.Byte();
byte tabletslot = reader.Byte();
byte elementslot1 = reader.Byte();
byte elementslot2 = reader.Byte();
byte elementslot3 = reader.Byte();
byte elementslot4 = reader.Byte();
reader.Close();
//Tablet information
Global.slotItem tabletslotitem = GetItem((uint)Character.Information.CharacterID, tabletslot, 0);
//Get stone information equaly to the tablet
int stone = GetStoneFromTablet(tabletslotitem.ID);
//Earth element information
Global.slotItem element1slotitem = GetItem((uint)Character.Information.CharacterID, elementslot1, 0);
//Water element information
Global.slotItem element2slotitem = GetItem((uint)Character.Information.CharacterID, elementslot2, 0);
//Fire element information
Global.slotItem element3slotitem = GetItem((uint)Character.Information.CharacterID, elementslot3, 0);
//Wind element information
Global.slotItem element4slotitem = GetItem((uint)Character.Information.CharacterID, elementslot4, 0);
//Check if the requirements are ok (Extra check amount).
if (element1slotitem.Amount < Data.ItemBase[tabletslotitem.ID].EARTH_ELEMENTS_AMOUNT_REQ) return;
if (element2slotitem.Amount < Data.ItemBase[tabletslotitem.ID].WATER_ELEMENTS_AMOUNT_REQ) return;
if (element3slotitem.Amount < Data.ItemBase[tabletslotitem.ID].FIRE_ELEMENTS_AMOUNT_REQ) return;
if (element2slotitem.Amount < Data.ItemBase[tabletslotitem.ID].WIND_ELEMENTS_AMOUNT_REQ) return;
//Check if the requirements are ok (Extra check element name).
if (Data.ItemBase[element1slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].EARTH_ELEMENTS_NAME) return;
if (Data.ItemBase[element2slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].WATER_ELEMENTS_NAME) return;
if (Data.ItemBase[element3slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].FIRE_ELEMENTS_NAME) return;
if (Data.ItemBase[element4slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].WIND_ELEMENTS_NAME) return;
//Update amount of elements
element1slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].EARTH_ELEMENTS_AMOUNT_REQ;
element2slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].WATER_ELEMENTS_AMOUNT_REQ;
element3slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].FIRE_ELEMENTS_AMOUNT_REQ;
element4slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].WIND_ELEMENTS_AMOUNT_REQ;
ItemUpdateAmount(element1slotitem, Character.Information.CharacterID);
ItemUpdateAmount(element2slotitem, Character.Information.CharacterID);
ItemUpdateAmount(element3slotitem, Character.Information.CharacterID);
ItemUpdateAmount(element4slotitem, Character.Information.CharacterID);
//Update amount of tablet
tabletslotitem.Amount -= 1;
ItemUpdateAmount(tabletslotitem, Character.Information.CharacterID);
//Send alchemy packet
client.Send(Packet.StoneCreation(tabletslot));
//Check for new free slots in inventory
byte freeslot = GetFreeSlot();
//Update database and insert new item
AddItem(stone, 1, freeslot, Character.Information.CharacterID, 0);
//Send visual packet add stone (creation works, just need to check why it sends 2x same packet).
client.Send(Packet.GainElements(freeslot, stone, 1));
}
catch (Exception ex)
{
Console.WriteLine("Stone creation error {0}", ex);
Systems.Debugger.Write(ex);
}
}