void ItemMove(byte fromSlot, byte toSlot, short quantity)
{
#region Move items
try
{
//Get from both slots the item information details
#region Get slot information
Global.slotItem fromItem = GetItem((uint)Character.Information.CharacterID, fromSlot, 0);
Global.slotItem toItem = GetItem((uint)Character.Information.CharacterID, toSlot, 0);
#endregion
//Define (rename for easy usage).
#region Redefine slotnames
fromItem.Slot = fromSlot;
toItem.Slot = toSlot;
#endregion
//Checks
#region Check slots available
//If we unequip a item, and place it on a taken slot
//With this part if unequipping a item, we just use toslot , because it will be changed here.
if (fromSlot < 13 && toItem.ID != 0)
{
//We get our next free available slot.
toSlot = GetFreeSlot();
//Though if our free slots is to low, we return.
if (toSlot <= 12) return;
}
#endregion
//Job slot handling
#region Job slot
//When equipping a job suit, we cannot equip another (Switch them out).
if (toSlot == 8 && toItem.ID == 0)//So our to slot must be empty
{
//If item is not a hunter suit but character job is hunter , stop
if (Character.Job.type == 1 && Data.ItemBase[fromItem.ID].Type != Global.item_database.ArmorType.HUNTER) return;
//If item is not a thief suit but character job is thief , stop
if (Character.Job.type == 2 && Data.ItemBase[fromItem.ID].Type != Global.item_database.ArmorType.THIEF) return;
//TODO: Find out more about trader job specifications
//If no job
if (Character.Job.type == 0) return;
}
//If we unequip from our job slot
if (fromSlot == 8 && fromItem.ID != 0)
{
ItemUnEquiped(fromItem);
}
#endregion
//If we equip to slot 7 (Shield / Arrow slot) Completed.
#region Shield / Arrow slot
if (toSlot == 7)
{
//We get more information about the items
Global.slotItem shieldItem = GetItem((uint)Character.Information.CharacterID, 7, 0);
Global.slotItem weaponItem = GetItem((uint)Character.Information.CharacterID, 6, 0);
//First we check if our level is high enough.
if (!CheckItemLevel(Character.Information.Level, fromItem.ID))
{
client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_HIGHER_LEVEL_REQUIRED));
return;
}
//Then we check the race the item belongs to EU / CH.
else if (!CheckRace(Character.Information.Model, fromItem.ID))
{
client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_COUNTRY_MISMATCH));
return;
}
//If we allready have a weapon equipped
if (weaponItem.ID != 0)
{
//If we allready have a shield equipped
if (shieldItem.ID != 0)
{
//We compare what item we are going to equip first. (If this is a shield).
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.CH_SHIELD || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SHIELD)
{
//Now we check if the weapon we are holding is not two handed, so we dont need to unequip the weapon item first.
if (Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.SWORD ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.BLADE ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_STAFF)
{
#region Done
//Equip new shield
ItemEquiped(fromItem, 7);
//Visually update
GetUpdateSlot(fromItem, 7, 0, 1);
//Now we update the database information of the item to the new slot.
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
//If the user is holding a two handed weapon.
else
{
#region Done
byte new_slot = GetFreeSlot();
//We start to unequip the two handed weapon before we equip our weapon.
ItemUnEquiped(weaponItem);
//Unequip our arrows
ItemUnEquiped(shieldItem);
//Equip new shield
ItemEquiped(fromItem, 7);
//Global info
//Set the amount of arrows globally
Character.Information.Item.sAmount = 0;
Character.Information.Item.sID = 0;
//Visually update
GetUpdateSlot(fromItem, 7, 0, 1);
//Visually update
GetUpdateSlot(weaponItem, new_slot, 0, 1);
//Database update
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + new_slot + "',slot='" + new_slot + "' WHERE id='" + weaponItem.dbID + "'");
//Database update
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + fromItem.dbID + "'");
//Database update
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + shieldItem.dbID + "'");
#endregion
}
}
//If the user wants to equip arrows
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BOLT || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.ARROW)
{
//We firstly check if the user has a bow equiped
if (Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
#region Done
//If the user has a bow equip we begin equipping our arrow / bolt item
GetUpdateSlot(shieldItem, fromItem.Slot, 0, shieldItem.Amount);
//We update the database with the old equipped slot item to new freeslot information
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + shieldItem.dbID + "'");
//We set the item amount to global information
Character.Information.Item.sAmount = fromItem.Amount;
Character.Information.Item.sID = fromItem.ID;
//And finally set new database information for the new equipped item
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
//If the user wants to equip arrows, and is not holding a bow
else
{
//Return with no action taken
return;
}
}
}
//If the player does not have a shield equipped yet. but has a weapon equiped
else
{
//We check if the player is equipping a new shield.
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.CH_SHIELD || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SHIELD)
{
//Then we check if the player weapon type can have a shield or not.
if (Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.SWORD || Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.BLADE || Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF || Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_STAFF || Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_SWORD)
{
#region Done
//We begin equipping the item
ItemEquiped(fromItem, 7);
//Now we update the remaining information
client.Send(Packet.MoveItem(0, fromSlot, toSlot, quantity, 0, "MOVE_INSIDE_INVENTORY"));
//Then we update the item information in the database with the new slot.
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
else
{
#region Done
//Get free slot for unequiping the weapon
byte new_slot = GetFreeSlot();
//If not enough slots
if (new_slot <= 12) return;
//We start to unequip the two handed weapon before we equip our shield.
ItemUnEquiped(weaponItem);
//Now we update the old slot (or freeslot), to new info.
ItemEquiped(fromItem, 7);
//Update visually the shielditem info
GetUpdateSlot(fromItem, 7, 0, 1);
//Update weapon
GetUpdateSlot(weaponItem, new_slot, 0, 1);
//Now we update the database information of the item to the new slot.
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + fromItem.dbID + "'");
//And then we update the old item to the new freeslot information
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + new_slot + "',slot='" + new_slot + "' WHERE id='" + weaponItem.dbID + "'");
#endregion
}
}
//Again if the player wants to equip an arrow type, while holding a weapon
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BOLT || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.ARROW)
{
//We check if the player has a bow or not.
if (Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
#region Done
//Set the amount of arrows globally
Character.Information.Item.sAmount = fromItem.Amount;
Character.Information.Item.sID = fromItem.ID;
//Now we update the remaining information
GetUpdateSlot(fromItem, 7, 0, fromItem.Amount);
//Update the slot information in database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
}
}
}
else
//If the user is not holding a weapon
{
//We check if the user is holding a shield.
if (shieldItem.ID != 0)
{
//If the user has a shield equipped.
if (Data.ItemBase[shieldItem.ID].Itemtype == Global.item_database.ItemType.CH_SHIELD || Data.ItemBase[shieldItem.ID].Itemtype == Global.item_database.ItemType.EU_SHIELD)
{
//We check if the user wants to equip another shield type.
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.CH_SHIELD || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SHIELD)
{
#region Done
//If the weapon is one handed and not a bow related item we start unequipping our shield.
ItemUnEquiped(shieldItem);
//Now we update the old slot (or freeslot), to new info.
ItemEquiped(fromItem, 7);
//Now we update the remaining information
client.Send(Packet.MoveItem(0, fromSlot, 7, quantity, 0, "MOVE_INSIDE_INVENTORY"));
//Now we update the database information of the item to the new slot.
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + fromItem.dbID + "'");
//And then we update the old item to the new freeslot information
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + shieldItem.dbID + "'");
#endregion
}
else return;
}
else return;
}
//If there's no shield or weapon equiped.
else
{
//We check if the user wants to equip a shield
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.CH_SHIELD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SHIELD)
{
#region Done
//Now we update the old slot (or freeslot), to new info.
ItemEquiped(fromItem, 7);
//Now we update the remaining information
client.Send(Packet.MoveItem(0, fromSlot, 7, 1, 0, "MOVE_INSIDE_INVENTORY"));
//Now we update the database information of the item to the new slot.
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
else return;
}
}
}
#endregion
//Weapon slot Completed.
#region Weapon slot
if (toSlot == 6)
{
//Get global item information
Global.slotItem shieldItem = GetItem((uint)Character.Information.CharacterID, 7, 0);
Global.slotItem weaponItem = GetItem((uint)Character.Information.CharacterID, 6, 0);
//First we check if our level is high enough.
if (!CheckItemLevel(Character.Information.Level, fromItem.ID))
{
client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_HIGHER_LEVEL_REQUIRED));
return;
}
//Then we check the race the item belongs to EU / CH.
else if (!CheckRace(Character.Information.Model, fromItem.ID))
{
client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_COUNTRY_MISMATCH));
return;
}
//If the player has a weapon equipped
if (weaponItem.ID != 0)
{
//If the player has a 1 handed weapon equipped
if (Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.SWORD ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.BLADE ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_STAFF ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_SWORD)
{
//If the player is holding a shield item
if (shieldItem.ID != 0)
{
//If the shield item is a shield
if (Data.ItemBase[shieldItem.ID].Itemtype == Global.item_database.ItemType.CH_SHIELD || Data.ItemBase[shieldItem.ID].Itemtype == Global.item_database.ItemType.EU_SHIELD)
{
//if the player wants to equip a bow
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
#region Done
byte new_slot = GetFreeSlot();
//If freeslots to low
if (new_slot <= 12) return;
//Unequip the current weapon
ItemUnEquiped(weaponItem);
//Equip new bow
ItemEquiped(fromItem, 6);
//Unequip shield
ItemUnEquiped(shieldItem);
//Visually update
GetUpdateSlot(fromItem, 6, 0, 1);
//Check if player has arrows equiped
byte ammoslot = GetAmmoSlot(Character);
//We check if the slot is not empty allready has arrows equipped.
if (ammoslot != 0)
{
//Get the arrow information
Global.slotItem AmmoItem = GetItem((uint)Character.Information.CharacterID, ammoslot, 0);
//Set the amount of arrows globally
Character.Information.Item.sAmount = AmmoItem.Amount;
Character.Information.Item.sID = AmmoItem.ID;
//Now we update the remaining information
GetUpdateSlot(AmmoItem, 7, 0, AmmoItem.Amount);
//Update the slot information in database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + AmmoItem.dbID + "'");
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + ammoslot + "',slot='" + ammoslot + "' WHERE id='" + shieldItem.dbID + "'");
}
else
{
//Visual update
GetUpdateSlot(shieldItem, new_slot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + new_slot + "',slot='" + new_slot + "' WHERE id='" + shieldItem.dbID + "'");
}
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
//If the player wants to equip an other type two handed
#region Done
else if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SPEAR ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.GLAVIE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_AXE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_HARP ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSWORD)
{
byte freeslot = GetFreeSlot();
//Unequip the current shield
ItemUnEquiped(shieldItem);
//Unequip the current weapon
ItemUnEquiped(weaponItem);
//Equip new weapon
ItemEquiped(fromItem, 6);
//Visual update weapon slot
GetUpdateSlot(fromItem, 6, 0, 1);
//Visual update shield slot
GetUpdateSlot(shieldItem, freeslot, 0, 1);
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + freeslot + "',slot='" + freeslot + "' WHERE id='" + shieldItem.dbID + "'");
}
#endregion
//If player wants to equip 1 handed item, we can keep the shield equiped
else if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SWORD || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BLADE || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SWORD || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_STAFF || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF)
{
#region Done
//Unequip Weapon
ItemUnEquiped(weaponItem);
//Update visually
GetUpdateSlot(weaponItem, fromItem.Slot, 0, 1);
//Equip new weapon
ItemEquiped(fromItem, 6);
//Update Database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
}
else
return;
}
//If no shield is equiped
else
{
//if player wants to equip bow
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
#region Done
//Unequip the current weapon
ItemUnEquiped(weaponItem);
//Equip new bow
ItemEquiped(fromItem, 6);
//Visually update
GetUpdateSlot(weaponItem, fromSlot, 0, 1);
//Check if player has arrows equiped
byte ammoslot = GetAmmoSlot(Character);
//We check if the slot is not empty allready has arrows equipped.
if (ammoslot != 0)
{
//Get the arrow information
Global.slotItem AmmoItem = GetItem((uint)Character.Information.CharacterID, ammoslot, 0);
//Set the amount of arrows globally
Character.Information.Item.sAmount = AmmoItem.Amount;
Character.Information.Item.sID = AmmoItem.ID;
//Now we update the remaining information
GetUpdateSlot(AmmoItem, 7, 0, AmmoItem.Amount);
//Update the slot information in database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + AmmoItem.dbID + "'");
}
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
//If player wants to equip other weapon type
#region Done
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SPEAR ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.GLAVIE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BLADE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_AXE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_HARP ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_STAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSWORD)
{
//Unequip our weapon
ItemUnEquiped(weaponItem);
//Equip new weapon
ItemEquiped(fromItem, 6);
//Visually update
GetUpdateSlot(fromItem, 6, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
}
#endregion
}
}
//If player has a 2 handed weapon equiped
else if (Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.GLAVIE ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.SPEAR ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_TSWORD ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_HARP ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_AXE)
{
//If player wants to equip a bow
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
#region Done
//Unequip the current weapon
ItemUnEquiped(weaponItem);
//Equip new bow
ItemEquiped(fromItem, 6);
//Visually update
GetUpdateSlot(weaponItem, fromSlot, 0, 1);
//Check if player has arrows equiped
byte ammoslot = GetAmmoSlot(Character);
//We check if the slot is not empty allready has arrows equipped.
if (ammoslot != 0)
{
//Get the arrow information
Global.slotItem AmmoItem = GetItem((uint)Character.Information.CharacterID, ammoslot, 0);
//Set the amount of arrows globally
Character.Information.Item.sAmount = AmmoItem.Amount;
Character.Information.Item.sID = AmmoItem.ID;
//Now we update the remaining information
GetUpdateSlot(AmmoItem, 7, 0, AmmoItem.Amount);
//Update the slot information in database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + AmmoItem.dbID + "'");
}
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
//If player wants to equip other weapon types
#region Done
else if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SPEAR ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.GLAVIE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BLADE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_AXE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_HARP ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_STAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSWORD)
{
//Unequip our weapon
ItemUnEquiped(weaponItem);
//Equip new weapon
ItemEquiped(fromItem, 6);
//Visually update
GetUpdateSlot(fromItem, 6, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
}
#endregion
}
//If player has a bow equiped
else if (Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[weaponItem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
//If arrows are equiped
if (shieldItem.ID != 0)
{
//Check to make sure its a arrow
if (Data.ItemBase[shieldItem.ID].Itemtype == Global.item_database.ItemType.ARROW || Data.ItemBase[shieldItem.ID].Itemtype == Global.item_database.ItemType.BOLT)
{
//Check what we are equipping
#region Done
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SPEAR ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.GLAVIE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BLADE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_AXE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_HARP ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_STAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSWORD)
{
//Get free slot to move to
byte freeslot = GetFreeSlot();
//If slots free is to low
if (freeslot <= 12) return;
//Unequip our bow
ItemUnEquiped(weaponItem);
//Unequip arrow
ItemUnEquiped(shieldItem);
//Equip new weapon
ItemEquiped(fromItem, 6);
//Visual update
GetUpdateSlot(weaponItem, fromItem.Slot, 0, 1);
//Visual update
GetUpdateSlot(shieldItem, freeslot, 0, 1);
//Set global info
Character.Information.Item.sAmount = 0;
Character.Information.Item.sID = 0;
//Update Database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update Database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + freeslot + "',slot='" + freeslot + "' WHERE id='" + shieldItem.dbID + "'");
//Update Database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
}
#endregion
//If player wants to equip another bow
#region Done
else if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
//Unequip current bow
ItemUnEquiped(weaponItem);
//Equip new bow
ItemEquiped(fromItem, 6);
//Visually update
GetUpdateSlot(fromItem, 6, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
}
#endregion
}
}
//If no arrow item is equiped
else
{
//If player wants to equip another bow
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
#region Done
//Unequip weapon
ItemUnEquiped(weaponItem);
//Equip new bow
ItemEquiped(fromItem, 6);
//Visualy update
GetUpdateSlot(fromItem, 6, 0, 1);
//Check if user has arrows
byte ammoslot = GetAmmoSlot(Character);
//If the user has arrows
if (ammoslot != 0)
{
//Get the arrow information
Global.slotItem AmmoItem = GetItem((uint)Character.Information.CharacterID, ammoslot, 0);
//Set the amount of arrows globally
Character.Information.Item.sAmount = AmmoItem.Amount;
Character.Information.Item.sID = AmmoItem.ID;
//Now we update the remaining information
GetUpdateSlot(AmmoItem, 7, 0, AmmoItem.Amount);
//Update the slot information in database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + AmmoItem.dbID + "'");
}
//Update database info
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update database info
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
//If player wants to equip another weapon type
#region Done
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SPEAR ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.GLAVIE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BLADE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_AXE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_HARP ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_STAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSWORD)
{
//Unequip our bow
ItemUnEquiped(weaponItem);
//Equip new weapon
ItemEquiped(fromItem, 6);
//Visual update
GetUpdateSlot(fromItem, 6, 0, 1);
//Update Database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + weaponItem.dbID + "'");
//Update Database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
}
#endregion
}
}
}
//If no weapon is equiped
else
{
//If shield has been equipped.
if (shieldItem.ID != 0)
{
//If player wants to equip a bow
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BOW ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
#region Done
//Equip the bow
ItemEquiped(fromItem, 6);
//Unequip shield item
ItemUnEquiped(shieldItem);
//Send visual equip bow
GetUpdateSlot(fromItem, 6, 0, 1);
//Get arrows in inventory
byte ammoslot = GetAmmoSlot(Character);
//If player has arrows
if (ammoslot != 0)
{
//Get the arrow information
Global.slotItem AmmoItem = GetItem((uint)Character.Information.CharacterID, ammoslot, 0);
//Set the amount of arrows globally
Character.Information.Item.sAmount = AmmoItem.Amount;
Character.Information.Item.sID = AmmoItem.ID;
//Now we update the remaining information
GetUpdateSlot(AmmoItem, 7, 0, AmmoItem.Amount);
//Update the slot information in database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + AmmoItem.dbID + "'");
//Update in database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + ammoslot + "',slot='" + ammoslot + "' WHERE id='" + shieldItem.dbID + "'");
}
else
{
GetUpdateSlot(shieldItem, fromSlot, 0, 1);
//Update in database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + shieldItem.dbID + "'");
}
//Update in database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
#endregion
}
//If 2 handed weapon
#region Done
else if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SPEAR ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.GLAVIE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_AXE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_HARP ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_STAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSWORD)
{
//Unequip old item
ItemUnEquiped(shieldItem);
//Equip the item
ItemEquiped(fromItem, 6);
//Visual update
GetUpdateSlot(fromItem, 6, 0, 1);
//Visual update
GetUpdateSlot(shieldItem, fromSlot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + shieldItem.dbID + "'");
//Update database information
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
}
#endregion
//If one handed weapon
#region Done
else if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BLADE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SWORD)
{
//Equip the item
ItemEquiped(fromItem, 6);
//Visually update the inventory
GetUpdateSlot(fromItem, 6, 0, 1);
//Update database information
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
}
#endregion
}
//Nothing equipped
else
{
//If player wants to equip bow
#region Done
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
//Equip the bow
ItemEquiped(fromItem, 6);
//Visually update
GetUpdateSlot(fromItem, 6, 0, 1);
//Updat database information
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
//Check if player has arrows in equipment
byte ammoslot = GetAmmoSlot(Character);
//If the player has arrows
if (ammoslot != 0)
{
//Get arrow information
Global.slotItem AmmoItem = GetItem((uint)Character.Information.CharacterID, ammoslot, 0);
//Equip the arrows
ItemEquiped(fromItem, 7);
//Set global information
Character.Information.Item.sAmount = AmmoItem.Amount;
Character.Information.Item.sID = AmmoItem.ID;
//Visually show changes
GetUpdateSlot(AmmoItem, 7, 0, AmmoItem.Amount);
//Update database information
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE id='" + AmmoItem.dbID + "'");
}
}
#endregion
//If player wants to equip other weapons
#region Equip other items (done)
else if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SPEAR ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.GLAVIE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BLADE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_AXE ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_HARP ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_STAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_SWORD ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.EU_TSWORD)
{
//Equip the item
ItemEquiped(fromItem, 6);
//Show visual changes
GetUpdateSlot(fromItem, 6, 0, 1);
//Update database information
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 6 + "',slot='" + 6 + "' WHERE id='" + fromItem.dbID + "'");
}
#endregion
}
}
}
#endregion
//Clothing items (Armor / Jewelry).
#region Clothing items
//Check if our item is a none weapon type and clothing type
if (Data.ItemBase[fromItem.ID].Class_D == 1 && toSlot != 6 && toSlot != 7 && toSlot < 13)
{
if (toSlot < 13)
{
//First we check if our level is high enough.
if (!CheckItemLevel(Character.Information.Level, fromItem.ID))
{
client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_HIGHER_LEVEL_REQUIRED));
return;
}
//Then we check if the gender is the same as ours.
else if (!CheckGender(Character.Information.Model, fromItem.ID))
{
client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_GENDER_MISMATCH));
return;
}
//Then we check the race the item belongs to EU / CH.
else if (!CheckRace(Character.Information.Model, fromItem.ID))
{
client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_COUNTRY_MISMATCH));
return;
}
//Then we check if armor type equals the current equipped ones.
else if (!CheckArmorType(fromItem.ID, Character.Information.CharacterID))
{
client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UITT_MSG_CUSTOM_ARMOR_TYPE_WRONG));
return;
}
//All checks ok we equip the item
else
{
if (toItem.ID != 0)
{
//Unequip item
ItemUnEquiped(toItem);
//Equip the new item
ItemEquiped(fromItem, toSlot);
//Update visual
GetUpdateSlot(fromItem, toSlot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + toItem.dbID + "'");
}
else
{
//Equip the new item
ItemEquiped(fromItem, toSlot);
GetUpdateSlot(fromItem, toSlot, 0, 1);
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
}
}
}
else if (fromSlot < 13)
{
if (toItem.ID != 0)
{
byte new_slot = GetFreeSlot();
ItemUnEquiped(fromItem);
GetUpdateSlot(fromItem, new_slot, 0, 1);
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + new_slot + "',slot='" + new_slot + "' WHERE id='" + fromItem.dbID + "'");
}
else
{
ItemUnEquiped(fromItem);
GetUpdateSlot(fromItem, toSlot, 0, 1);
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
}
}
else
{
if (toItem.ID != 0)
{
byte new_slot = GetFreeSlot();
ItemUnEquiped(fromItem);
GetUpdateSlot(fromItem, new_slot, 0, 1);
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + new_slot + "',slot='" + new_slot + "' WHERE id='" + fromItem.dbID + "'");
}
else
{
ItemUnEquiped(fromItem);
GetUpdateSlot(fromItem, toSlot, 0, 1);
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
}
}
}
#endregion
//Normal item movement non equpping inside inventory
#region Normal inventory movement
short newquantity = 0;
short fromquantity = 0;
if (fromSlot >= 13 && toSlot >= 13)
{
if (toItem.ID != 0)
{
if (toItem.ID == fromItem.ID)
{
if (Data.ItemBase[fromItem.ID].Class_D == 3 && Data.ItemBase[toItem.ID].Class_D == 3)
{
if (Data.ItemBase[fromItem.ID].Max_Stack > 1)
{
newquantity = (short)(fromItem.Amount + toItem.Amount);
if (newquantity > Data.ItemBase[fromItem.ID].Max_Stack)
{
GetUpdateSlot(fromItem, toSlot, 0, fromItem.Amount);
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + toItem.dbID + "'");
}
else if (newquantity <= Data.ItemBase[fromItem.ID].Max_Stack)
{
MsSQL.InsertData("delete from char_items where id='" + fromItem.dbID + "'");
MsSQL.InsertData("UPDATE char_items SET quantity='" + newquantity + "' WHERE id='" + toItem.dbID + "'");
GetUpdateSlot(fromItem, toSlot, 0, newquantity);
}
else
{
fromquantity = (short)(newquantity % Data.ItemBase[fromItem.ID].Max_Stack);
newquantity -= fromquantity;
MsSQL.InsertData("UPDATE char_items SET quantity='" + fromquantity + "' WHERE id='" + fromItem.dbID + "'");
MsSQL.InsertData("UPDATE char_items SET quantity='" + newquantity + "' WHERE id='" + toItem.dbID + "'");
}
}
}
else
{
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + toItem.dbID + "'");
}
}
else
{
GetUpdateSlot(fromItem, toSlot, 0, quantity);
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + toItem.dbID + "'");
}
}
else
{
if (fromItem.Amount != quantity && Data.ItemBase[fromItem.ID].Class_D == 3)
{
AddItem(fromItem.ID, quantity, toSlot, Character.Information.CharacterID, 0);
int calc = (fromItem.Amount - quantity);
if (calc < 1) calc = 1;
GetUpdateSlot(fromItem, toSlot,0, quantity);
MsSQL.InsertData("UPDATE char_items SET quantity='" + calc + "' WHERE id='" + fromItem.dbID + "'");
}
else if (toItem.ID != 0)
{
GetUpdateSlot(fromItem, toSlot, 0, quantity);
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE id='" + toItem.dbID + "'");
}
else
{
GetUpdateSlot(fromItem, toSlot, 0, quantity);
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
}
}
}
#endregion
//Unequip from slot
#region Unequip items
if (fromSlot < 13 && toSlot > 13)
{
#region From slot 6
Global.slotItem weaponitem = GetItem((uint)Character.Information.CharacterID, 6, 0);
Global.slotItem shieldslotitem = GetItem((uint)Character.Information.CharacterID, 7, 0);
//If we unequip a bow or other item
if (fromSlot == 6 && shieldslotitem.ID != 0)
{
//if we unequip a bow
if (Data.ItemBase[weaponitem.ID].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[weaponitem.ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW)
{
//If we drag it to a none free slot
if (toItem.ID != 0)
{
//Free arrow slot
byte freeweaponslot = GetFreeSlot();
//Unequip the arrows
ItemUnEquiped(shieldslotitem);
//Update visually arrow
GetUpdateSlot(shieldslotitem, freeweaponslot, 0, quantity);
//Update database bow
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + freeweaponslot + "',slot='" + freeweaponslot + "' WHERE id='" + shieldslotitem.dbID + "'");
//Free weapon slot
byte freearrowslot = GetFreeSlot();
//Unequip the weapon
ItemUnEquiped(fromItem);
//Update visually bow
GetUpdateSlot(fromItem, freearrowslot, 0, 1);
//Update global information
Character.Information.Item.sAmount = 0;
Character.Information.Item.sID = 0;
//Update database arrow
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + freearrowslot + "',slot='" + freearrowslot + "' WHERE id='" + fromItem.dbID + "'");
}
//If we drag to free slot
else
{
//Unequip the arrow
ItemUnEquiped(fromItem);
//Unequip the weapon
ItemUnEquiped(shieldslotitem);
//Update visually bow
GetUpdateSlot(fromItem, toSlot, 0, 1);
//Update bow database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
//Free weapon slot
byte newslot = GetFreeSlot();
//Update visually arrows
GetUpdateSlot(shieldslotitem, newslot, 0, quantity);
//Update global information
Character.Information.Item.sAmount = 0;
Character.Information.Item.sID = 0;
//Update arrow in database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + newslot + "',slot='" + newslot + "' WHERE id='" + shieldslotitem.dbID + "'");
}
}
//If we unequip another weapon type and shield is equiped we keep the shield.
else
{
if (toItem.ID != 0)
{
//Free weapon slot
byte weaponslot = GetFreeSlot();
ItemUnEquiped(fromItem);
//Update visually
GetUpdateSlot(fromItem, weaponslot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + weaponslot + "',slot='" + weaponslot + "' WHERE id='" + fromItem.dbID + "'");
}
else
{
ItemUnEquiped(fromItem);
//Update visually
GetUpdateSlot(fromItem, toSlot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
}
}
}
//If no shield item has been equiped
else if (fromSlot == 6 && shieldslotitem.ID == 0)
{
if (toItem.ID != 0)
{
//Free weapon slot
byte weaponslot = GetFreeSlot();
//Unequip our weapon
ItemUnEquiped(fromItem);
//Update visually
GetUpdateSlot(fromItem, weaponslot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + weaponslot + "',slot='" + weaponslot + "' WHERE id='" + fromItem.dbID + "'");
}
else
{
ItemUnEquiped(fromItem);
//Update visually
GetUpdateSlot(fromItem, toSlot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
}
}
#endregion
//It we unequip a shield or arrows
#region From slot 7
else if (fromSlot == 7)
{
//if we unequip arrows
if (Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.ARROW || Data.ItemBase[fromItem.ID].Itemtype == Global.item_database.ItemType.BOLT)
{
if (toItem.ID != 0)
{
//Free arrow slot
byte arrowslot = GetFreeSlot();
//Unequip our arrows
ItemUnEquiped(fromItem);
//Update visually
GetUpdateSlot(fromItem, arrowslot, 0, quantity);
//Set global data
Character.Information.Item.sAmount = 0;
Character.Information.Item.sID = 0;
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + arrowslot + "',slot='" + arrowslot + "' WHERE id='" + fromItem.dbID + "'");
}
else
{
ItemUnEquiped(fromItem);
//Update visually
GetUpdateSlot(fromItem, toSlot, 0, quantity);
//Set global data
Character.Information.Item.sAmount = 0;
Character.Information.Item.sID = 0;
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
}
}
//If we unequip shields
else
{
if (toItem.ID != 0)
{
//Free weapon slot
byte newshieldslot = GetFreeSlot();
//Unequip our weapon
ItemUnEquiped(fromItem);
//Update visually
GetUpdateSlot(fromItem, newshieldslot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + newshieldslot + "',slot='" + newshieldslot + "' WHERE id='" + fromItem.dbID + "'");
}
else
{
ItemUnEquiped(fromItem);
//Update visually
GetUpdateSlot(fromItem, toSlot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
}
}
}
#endregion
//Other slots
#region Other from slots
else
{
if (toItem.ID != 0)
{
//Free weapon slot
byte newunequipslot = GetFreeSlot();
//Unequip our weapon
ItemUnEquiped(fromItem);
//Update visually
GetUpdateSlot(fromItem, newunequipslot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + newunequipslot + "',slot='" + newunequipslot + "' WHERE id='" + fromItem.dbID + "'");
}
else
{
ItemUnEquiped(fromItem);
//Update visually
GetUpdateSlot(fromItem, toSlot, 0, 1);
//Update database
MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE id='" + fromItem.dbID + "'");
}
}
#endregion
}
#endregion
//Save player information
SavePlayerInfo();
#endregion
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}