Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void EquipItem(ItemUsage itemUsage, GameState client)
- {
- ConquerItem item = null;
- if (itemUsage.dwParam == 17 || itemUsage.dwParam == 9)
- {
- client.Entity.AttackPacket = null;
- if (client.WarDrobe.TryGetItem(itemUsage.UID, out item) && client.Booth == null)
- {
- uint original = (ushort)itemUsage.dwParam;
- if (item.Suspicious) return;
- Positions pos = GetPositionFromID(item.ID);
- if (itemUsage.dwParam > 20 && itemUsage.dwParam < 30 && (ushort)pos < 10)
- {
- pos += 20;
- }
- if ((ushort)pos == 4 && original == 5 || (ushort)pos == 24 && original == 25 || (ushort)pos == 15 && original == 16)
- {
- pos += 1;
- }
- itemUsage.dwParam = (ushort)pos;
- if (pos == Positions.Inventory)
- {
- UseItem(item, client); return;
- }
- if (ItemPosition(item.ID) == ConquerItem.Garment)
- if (client.Entity.Tournament_Signed) return;
- item.Position = (ushort)itemUsage.dwParam;
- if (client.Equipment.Free((byte)itemUsage.dwParam))
- {
- item.Position = (byte)itemUsage.dwParam;
- client.Equipment.Add(item);
- item.Mode = Game.Enums.ItemMode.Update;
- }
- else
- {
- client.Equipment.RemoveWrap((byte)itemUsage.dwParam);
- item.Position = (byte)itemUsage.dwParam;
- client.Equipment.Add(item);
- }
- client.CalculateStatBonus();
- client.CalculateHPBonus();
- client.LoadItemStats();
- ClientEquip equips = new ClientEquip();
- equips.DoEquips(client);
- client.Send(equips);
- Database.ConquerItemTable.UpdateLocation(item, client);
- client.Equipment.UpdateEntityPacket();
- WindowStats Stats = new WindowStats(client);
- client.Send(Stats.ToArray());
- if (item != null)
- {
- if (Database.PerfectionTable.PerfectItems.ContainsKey(item.UID))
- {
- Database.PerfectionTable.PerfectItems[item.UID].Position = item.Position;
- }
- }
- if (client.Team != null)
- {
- client.Team.GetClanShareBp(client);
- }
- }
- return;
- }
- else
- {
- client.Entity.AttackPacket = null;
- if (client.Inventory.TryGetItem(itemUsage.UID, out item) || client.WarDrobe.TryGetItem(itemUsage.UID, out item) && client.Booth == null)
- {
- uint original = (ushort)itemUsage.dwParam;
- if (item.Suspicious) return;
- Positions pos = GetPositionFromID(item.ID);
- if (pos == Positions.Inventory)
- {
- UseItem(item, client); return;
- }
- if (ItemPosition(item.ID) == ConquerItem.Garment)
- if (client.Entity.Tournament_Signed) return;
- if (itemUsage.dwParam > 20 && itemUsage.dwParam < 30 && (ushort)pos < 10)
- {
- pos += 20;
- }
- if ((ushort)pos == 4 && original == 5 || (ushort)pos == 24 && original == 25 || (ushort)pos == 15 && original == 16)
- {
- pos += 1;
- }
- #region Sanity Checks
- bool can2hand = false;
- bool can2wpn = false;
- uint dwExtra = 0;
- if (itemUsage.dwParam > 20)
- dwExtra = 20;
- if (client.Entity.Class >= 10 && client.Entity.Class <= 85)
- can2hand = true;
- if (client.Entity.Class >= 10 && client.Entity.Class <= 15 ||
- client.Entity.Class >= 40 && client.Entity.Class <= 45 ||
- client.Entity.Class >= 50 && client.Entity.Class <= 55 ||
- client.Entity.Class >= 60 && client.Entity.Class <= 65 ||
- client.Entity.Class >= 70 && client.Entity.Class <= 75 ||
- client.Entity.Class >= 80 && client.Entity.Class <= 85)
- can2wpn = true;
- if (client.Entity.Class >= 70 && client.Entity.Class <= 75 ||
- client.Entity.Class >= 40 && client.Entity.Class <= 45)
- can2wpn = true;
- if (client.Entity.Class >= 100 && client.Entity.Class <= 145)
- {
- if (!client.Equipment.Free(4))
- {
- if (IsEpicBacksword(client.Equipment.TryGetItem(4).ID))
- {
- if (IsEpicHossu(item.ID))
- {
- can2wpn = true;
- }
- }
- }
- }
- if (client.Entity.Class >= 20 && client.Entity.Class <= 25)
- {
- can2hand = true;
- can2wpn = true;
- }
- if (client.Entity.Class >= 160 && client.Entity.Class <= 165)
- {
- can2hand = true;
- can2wpn = true;
- }
- if (!Equipable(item, client)) return;
- if (ItemPosition(item.ID) == 5)
- {
- itemUsage.dwParam = 5 + dwExtra;
- if (!can2hand && !can2wpn) return;
- if (client.Equipment.Free(4 + dwExtra) || (client.Equipment.TryGetItem(4 + dwExtra).ID / 1000 != 500 && IsArrow(item.ID)))
- return;
- }
- if (ItemPosition(item.ID) == 4)
- {
- if (itemUsage.dwParam == 5 + dwExtra)
- if (!can2hand || !can2wpn) return;
- }
- if (!((itemUsage.dwParam == 4 + dwExtra || itemUsage.dwParam == 5 + dwExtra) && (ItemPosition(item.ID) == 4 || ItemPosition(item.ID) == 5)))
- {
- if (!IsAccessory(item.ID))
- itemUsage.dwParam = ItemPosition(item.ID) + dwExtra;
- }
- bool twohand = IsTwoHand(item.ID);
- if (!twohand && itemUsage.dwParam == 4 + dwExtra)
- {
- if (!client.Equipment.Free((byte)(5 + dwExtra)))
- {
- if (client.Inventory.Count < 40)
- {
- if (IsArrow(client.Equipment.TryGetItem((byte)(5 + dwExtra)).ID))
- client.Equipment.Remove((byte)(5 + dwExtra));
- else
- {
- if (client.Equipment.TryGetItem((byte)(4 + dwExtra)) != null)
- {
- if (IsTwoHand(client.Equipment.TryGetItem((byte)(4 + dwExtra)).ID))
- client.Equipment.Remove((byte)(4 + dwExtra));
- }
- }
- }
- }
- }
- if ((itemUsage.dwParam - dwExtra) == 5)
- {
- if ((item.ID / 1000) == 421 || IsTwoHand(item.ID)) return;
- var rItem = client.Equipment.TryGetItem((byte)(4 + dwExtra));
- if (rItem != null)
- {
- if (rItem.IsTwoHander())
- {
- if (IsArrow(item.ID))
- {
- if (rItem.ID / 1000 != 500) return;
- }
- else
- {
- if (IsShield(item.ID))
- {
- if ((rItem.ID / 1000) == 421) return;
- if (!client.Spells.ContainsKey(10311) && client.Entity.FirstRebornClass == 25 && client.Entity.SecondRebornClass == 25)//Perseverance
- {
- client.Send(new Message("You need to know Perseverance (Warrior Pure skill) to be able to wear 2-handed weapon and shield.", System.Drawing.Color.Red, Message.Talk));
- return;
- }
- }
- else itemUsage.dwParam = 4 + dwExtra;
- }
- }
- }
- }
- if (itemUsage.dwParam == 4 + dwExtra)
- if (client.Entity.ContainsFlag((ulong)FlagsUpdate.Flags.Fly))
- if (item.ID / 1000 != 500)
- return;
- if (itemUsage.dwParam == 4 + dwExtra)
- if (client.Entity.ContainsFlag3((ulong)FlagsUpdate.Flags3.PathOfShadow))
- if (item.ID / 1000 != 613)
- return;
- if (!(client.Entity.Class >= 50 && client.Entity.Class <= 55))
- if ((item.ID / 1000) == 601)
- if ((itemUsage.dwParam - dwExtra) == 5)
- return;
- #endregion
- if (client.Map.ID == 1039)
- client.Entity.AttackPacket = null;
- item.Position = (ushort)itemUsage.dwParam;
- if (ItemPosition(item.ID) == 5 && !IsArrow(item.ID))
- {
- if (IsTwoHand(client.Equipment.TryGetItem((byte)(4 + dwExtra)).ID))
- {
- if (!client.Spells.ContainsKey(10311))
- {
- client.Send(new Message("You need to know Perseverance (Warrior Pure skill) to be able to wear 2-handed weapon and shield.", System.Drawing.Color.Red, Message.Talk));
- return;
- }
- }
- }
- #region Checks itemType
- uint itemType = item.ID / 1000;
- if (itemType == 421)//Backsword
- {
- if (item.Position == 5 + dwExtra)
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 900)
- {
- if (!(client.Entity.Class >= 20 && client.Entity.Class <= 25))
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 613)//Knife
- {
- if ((client.Entity.Class >= 70 && client.Entity.Class <= 75) || (client.Entity.Class >= 60 && client.Entity.Class <= 65 || (client.Entity.Class >= 10 && client.Entity.Class <= 15 || (client.Entity.Class >= 50 && client.Entity.Class <= 55 || (client.Entity.Class >= 20 && client.Entity.Class <= 25 || (client.Entity.Class >= 142 && client.Entity.Class <= 145 || (client.Entity.Class >= 132 && client.Entity.Class <= 135)))))))
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 511)//Scythe
- {
- if ((client.Entity.Class >= 40 && client.Entity.Class <= 45) || (client.Entity.Class >= 60 && client.Entity.Class <= 65 || (client.Entity.Class >= 10 && client.Entity.Class <= 15 || (client.Entity.Class >= 70 && client.Entity.Class <= 75 || (client.Entity.Class >= 20 && client.Entity.Class <= 25 || (client.Entity.Class >= 142 && client.Entity.Class <= 145 || (client.Entity.Class >= 132 && client.Entity.Class <= 135)))))))
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 601)//Katana
- {
- if ((client.Entity.Class >= 40 && client.Entity.Class <= 45) || (client.Entity.Class >= 60 && client.Entity.Class <= 65 || (client.Entity.Class >= 10 && client.Entity.Class <= 15 || (client.Entity.Class >= 70 && client.Entity.Class <= 75 || (client.Entity.Class >= 20 && client.Entity.Class <= 25 || (client.Entity.Class >= 142 && client.Entity.Class <= 145 || (client.Entity.Class >= 132 && client.Entity.Class <= 135)))))))
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 614)//CrossSaber
- {
- if ((client.Entity.Class >= 40 && client.Entity.Class <= 45) || (client.Entity.Class >= 60 && client.Entity.Class <= 65 || (client.Entity.Class >= 70 && client.Entity.Class <= 75 || (client.Entity.Class >= 20 && client.Entity.Class <= 25 || (client.Entity.Class >= 142 && client.Entity.Class <= 145 || (client.Entity.Class >= 132 && client.Entity.Class <= 135))))))
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 611)//Rapier
- {
- if ((client.Entity.Class >= 40 && client.Entity.Class <= 45) || (client.Entity.Class >= 60 && client.Entity.Class <= 65 || (client.Entity.Class >= 10 && client.Entity.Class <= 15 || (client.Entity.Class >= 50 && client.Entity.Class <= 55 || (client.Entity.Class >= 20 && client.Entity.Class <= 25 || (client.Entity.Class >= 142 && client.Entity.Class <= 145 || (client.Entity.Class >= 132 && client.Entity.Class <= 135)))))))
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 612)//Pistol
- {
- if ((client.Entity.Class >= 40 && client.Entity.Class <= 45) || (client.Entity.Class >= 60 && client.Entity.Class <= 65 || (client.Entity.Class >= 10 && client.Entity.Class <= 15 || (client.Entity.Class >= 50 && client.Entity.Class <= 55 || (client.Entity.Class >= 20 && client.Entity.Class <= 25 || (client.Entity.Class >= 142 && client.Entity.Class <= 145 || (client.Entity.Class >= 132 && client.Entity.Class <= 135)))))))
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 421)//Backsword
- {
- if ((client.Entity.Class >= 40 && client.Entity.Class <= 45) || (client.Entity.Class >= 60 && client.Entity.Class <= 65 || (client.Entity.Class >= 10 && client.Entity.Class <= 15 || (client.Entity.Class >= 50 && client.Entity.Class <= 55 || (client.Entity.Class >= 20 && client.Entity.Class <= 25 || (client.Entity.Class >= 70 && client.Entity.Class <= 75))))))
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 610) // Beads
- {
- if ((client.Entity.Class >= 40 && client.Entity.Class <= 45) || (client.Entity.Class >= 70 && client.Entity.Class <= 75 || (client.Entity.Class >= 10 && client.Entity.Class <= 15 || (client.Entity.Class >= 50 && client.Entity.Class <= 55 || (client.Entity.Class >= 20 && client.Entity.Class <= 25 || (client.Entity.Class >= 142 && client.Entity.Class <= 145 || (client.Entity.Class >= 132 && client.Entity.Class <= 135)))))))
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 131)//warrior armor
- {
- if ((client.Entity.Class >= 40 && client.Entity.Class <= 45) || (client.Entity.Class >= 70 && client.Entity.Class <= 75 || (client.Entity.Class >= 10 && client.Entity.Class <= 15 || (client.Entity.Class >= 60 && client.Entity.Class <= 65 || (client.Entity.Class >= 142 && client.Entity.Class <= 145 || (client.Entity.Class >= 132 && client.Entity.Class <= 135))))))
- {
- item.Position = 0; return;
- }
- }
- if (itemType == 111)//WarriorHelmet
- {
- if ((client.Entity.Class >= 40 && client.Entity.Class <= 45) || (client.Entity.Class >= 70 && client.Entity.Class <= 75 || (client.Entity.Class >= 10 && client.Entity.Class <= 15 || (client.Entity.Class >= 60 && client.Entity.Class <= 65 || (client.Entity.Class >= 142 && client.Entity.Class <= 145 || (client.Entity.Class >= 132 && client.Entity.Class <= 135))))))
- {
- item.Position = 0; return;
- }
- }
- #endregion
- client.Inventory.Remove(item, Game.Enums.ItemUse.Move, true);
- if (client.Equipment.Free((byte)itemUsage.dwParam))
- {
- if (twohand)
- client.Equipment.Remove((byte)(5 + dwExtra));
- item.Position = (byte)itemUsage.dwParam;
- client.Equipment.Add(item);
- item.Mode = Game.Enums.ItemMode.Update;
- item.Send(client);
- }
- else
- {
- if (twohand)
- client.Equipment.Remove((byte)(5 + dwExtra));
- client.Equipment.Remove((byte)itemUsage.dwParam);
- item.Position = (byte)itemUsage.dwParam;
- client.Equipment.Add(item);
- }
- client.CalculateStatBonus();
- client.CalculateHPBonus();
- client.LoadItemStats();
- ClientEquip equips = new ClientEquip();
- equips.DoEquips(client);
- client.Send(equips);
- Database.ConquerItemTable.UpdateLocation(item, client);
- client.Equipment.UpdateEntityPacket();
- WindowStats Stats = new WindowStats(client);
- client.Send(Stats.ToArray());
- if (item != null)
- {
- if (Database.PerfectionTable.PerfectItems.ContainsKey(item.UID))
- {
- Database.PerfectionTable.PerfectItems[item.UID].Position = item.Position;
- }
- }
- if (client.Team != null)
- {
- client.Team.GetClanShareBp(client);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement