Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void AddDamageProtection(WorldSession client, uint mainGuid, IReadOnlyList<uint> minorGuids)
- {
- Item mainItem;
- if (client.Character.GetItem(mainGuid, out mainItem) && mainItem.Protection < 7)
- {
- if (!mainItem.IsBlessEnable)
- throw new SevereViolation($"Attempted to add protection to {mainItem}");
- var remove = 0;
- while (remove < minorGuids.Count)
- {
- Item minorItem;
- if (!client.Character.TryRemoveItem(minorGuids[remove], out minorItem))
- break;
- if (minorItem.Base.Sort != ItemSort.Gem ||
- minorItem.Base.Class != ItemClass.SuperTortoiseGem)
- throw new SevereViolation($"Attempted add protection to {mainItem} using {minorItem}");
- remove++;
- }
- switch (mainItem.Protection)
- {
- case 0:
- if (remove == 5)
- mainItem.Protection = 1;
- break;
- case 1:
- if (remove == 1)
- mainItem.Protection = 3;
- break;
- case 3:
- if (remove == 3)
- mainItem.Protection = 5;
- break;
- case 5:
- if (remove == 5)
- mainItem.Protection = 7;
- break;
- }
- }
- client.Send(new ItemInformation(mainItem, ItemInformation.Mode.Update));
- }
- private static void CreateEquipmentSocket(WorldSession client, uint mainGuid, IReadOnlyList<uint> minorGuids)
- {
- if (minorGuids.Count < 1)
- throw new SevereViolation("Attempt to create item socket with no minor items.");
- Item mainItem;
- if (!client.Character.GetItem(mainGuid, out mainItem))
- throw new MildViolation($"Expected to find the main item on {client.Character.Name}, but did not.");
- if (!mainItem.IsSocketEnable)
- // should never reach this case if the item is socketless.
- throw new SevereViolation($"Opening sockets in a socketless item. {mainItem}");
- if (mainItem.Base.Sort == ItemSort.Artifact)
- // the main item should never be an artifact in this case.
- throw new SevereViolation($"Attempt to socket an artifact using the equipment socket method. {mainItem}");
- if (mainItem.SecondSocket == SocketIdentifier.None)
- {
- var remove = 0;
- while (remove < minorGuids.Count)
- {
- Item minorItem;
- if (!client.Character.TryRemoveItem(minorGuids[remove], out minorItem))
- continue;
- remove++;
- if (mainItem.IsArmor || mainItem.IsShield)
- {
- if (mainItem.FirstSocket == SocketIdentifier.None)
- {
- if (minorGuids.Count != 12)
- throw new SevereViolation(
- $"The requirement to open the first armor socket was not met. {minorItem} was lost.");
- if (minorItem.Base.Id != 1088000)
- throw new ModerateViolation(
- $"{minorItem} was lost while using it to open the first armor socket.");
- if (remove < 12)
- continue;
- mainItem.FirstSocket = SocketIdentifier.EmptySocket;
- break;
- }
- if (minorItem.Base.Sort != ItemSort.PremiumExpendable)
- throw new ModerateViolation(
- $"{minorItem} was lost while using it to open the second armor socket.");
- if (minorItem.Base.Class == ItemClass.ToughDrill)
- if (!RNGProvider.Chance(WorldServer.Configuration.World.ArmorSecondSocketRate))
- {
- client.Character.Inventory.Add(ItemManager.Instance.CreateItem(client.Character, 1200006));
- break;
- }
- if (minorItem.Base.Class == ItemClass.StarDrill)
- if (remove < 7)
- continue;
- mainItem.SecondSocket = SocketIdentifier.EmptySocket;
- break;
- }
- if (mainItem.IsWeapon)
- {
- if (minorItem.Base.Id != 1088000)
- throw new ModerateViolation(
- $"{minorItem} was lost while using it to open a weapon socket.");
- if (mainItem.FirstSocket == SocketIdentifier.None)
- {
- mainItem.FirstSocket = SocketIdentifier.EmptySocket;
- break;
- }
- if (remove < 5)
- continue;
- mainItem.SecondSocket = SocketIdentifier.EmptySocket;
- break;
- }
- }
- }
- client.Send(new ItemInformation(mainItem, ItemInformation.Mode.Update));
- }
- private static void CreateTalismanSocket(WorldSession client, uint mainGuid, IReadOnlyList<uint> minorGuids)
- {
- Item mainItem;
- if (!client.Character.GetItem(mainGuid, out mainItem))
- throw new MildViolation(
- $"Expected to find the main item on {client.Character.Name}, but did not.");
- if (!mainItem.IsSocketEnable || mainItem.Base.Sort != ItemSort.Artifact)
- throw new SevereViolation(
- $"Invalid item received when using talisman socket function. {mainItem}");
- if (mainItem.SecondSocket == SocketIdentifier.None)
- {
- var remove = 0;
- while (remove < minorGuids.Count)
- {
- Item minorItem;
- if (!client.Character.TryRemoveItem(minorGuids[remove], out minorItem))
- // more than one or two of these and it *could be* an attempt to cheat the system.
- // a few scenarios would make this an acceptable occurrence
- throw new MildViolation("A minor item was expected to be removable, but was not.");
- remove++;
- //initialize progress value based on how many points are added by a minor's craft level.
- var progressAdded =
- ItemManager.ArtifactSocketPoints[minorItem.CraftLevel > 9 ? 9 : minorItem.CraftLevel];
- //increase progress per minor quality.
- switch (minorItem.Quality)
- {
- case ItemQuality.Refined:
- progressAdded += 5;
- break;
- case ItemQuality.Unique:
- progressAdded += 10;
- break;
- case ItemQuality.Elite:
- progressAdded += 40;
- break;
- case ItemQuality.Super:
- progressAdded += 1000;
- break;
- }
- if (minorItem.IsArmor || minorItem.IsShield)
- {
- if (minorItem.FirstSocket != SocketIdentifier.None)
- progressAdded += 2000;
- if (minorItem.SecondSocket != SocketIdentifier.None)
- progressAdded += 6000;
- }
- else if (minorItem.IsWeapon)
- {
- if (minorItem.FirstSocket != SocketIdentifier.None)
- progressAdded += 160;
- if (minorItem.SecondSocket != SocketIdentifier.None)
- progressAdded += 800;
- }
- mainItem.SocketProgress += progressAdded;
- }
- if (mainItem.FirstSocket == SocketIdentifier.None && mainItem.SocketProgress >= 8000)
- {
- mainItem.SocketProgress -= 8000;
- mainItem.FirstSocket = SocketIdentifier.EmptySocket;
- }
- if (mainItem.SocketProgress >= 20000)
- {
- mainItem.SocketProgress = 0;
- mainItem.SecondSocket = SocketIdentifier.EmptySocket;
- }
- }
- client.Send(new ItemInformation(mainItem, ItemInformation.Mode.Update));
- }
- private static void PurchaseTalismanSocket(WorldSession client, uint itemGuid)
- {
- Item item;
- if (!client.Character.GetItem(itemGuid, out item))
- throw new MildViolation(
- $"Expected to find the main item on {client.Character.Name}, but did not.");
- if (item.SecondSocket != SocketIdentifier.None)
- return;
- var progressRequired = item.FirstSocket == SocketIdentifier.None ? 8000 : 20000;
- var socketProgressPercentage = MathUtils.Percentage(item.SocketProgress, progressRequired);
- if (socketProgressPercentage < 30)
- throw new SevereViolation(
- $"Attempt to buy talisman socket below 30% progress. {item} available progress: {socketProgressPercentage}");
- var eMoneyPrice = (int) ((progressRequired - item.SocketProgress)*0.7);
- if (client.Character.EMoney >= eMoneyPrice)
- {
- client.Character.EMoney -= eMoneyPrice;
- if (progressRequired == 8000)
- item.FirstSocket = SocketIdentifier.EmptySocket;
- if (progressRequired == 20000)
- item.SecondSocket = SocketIdentifier.EmptySocket;
- item.SocketProgress = 0;
- }
- client.Send(new ItemInformation(item, ItemInformation.Mode.Update));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement