From 5e7f1bbf1f3fdf1e52283abad7c0d7fe730711aa Mon Sep 17 00:00:00 2001 From: Denis Kamenskikh Date: Fri, 8 Jan 2021 15:09:11 +0300 Subject: [PATCH] Legendary fix --- states/Equipment.lua | 35 ++++++++++++++++++++++++++++++++++- states/runeforge.lua | 4 ++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/states/Equipment.lua b/states/Equipment.lua index af2d0ac..9d0514a 100644 --- a/states/Equipment.lua +++ b/states/Equipment.lua @@ -86,6 +86,8 @@ __exports.OvaleEquipmentClass = __class(nil, { self.ready = false self.equippedItemById = {} self.equippedItemBySlot = {} + self.equippedLegendaryById = {} + self.equippedLegendaryBySlot = {} self.mainHandDPS = 0 self.offHandDPS = 0 self.armorSetCount = {} @@ -161,6 +163,18 @@ __exports.OvaleEquipmentClass = __class(nil, { end return ReturnBoolean(boolean) end + self.hasEquippedLegendary = function(positionalParams, namedParams, atTime) + local legendaryId = positionalParams[1] + local boolean = false + local slotId + if type(legendaryId) == "number" then + slotId = self:HasEquippedLegendary(legendaryId) + if slotId then + boolean = true + end + end + return ReturnBoolean(boolean) + end self.hasShield = function(positionalParams, namedParams, atTime) local boolean = self:HasShield() return ReturnBoolean(boolean) @@ -268,6 +282,8 @@ __exports.OvaleEquipmentClass = __class(nil, { end, registerConditions = function(self, ovaleCondition) ovaleCondition:RegisterCondition("hasequippeditem", false, self.hasEquippedItem) + ovaleCondition:RegisterCondition("equippedruneforge", false, self.hasEquippedLegendary) + ovaleCondition:RegisterCondition("runeforge", false, self.hasEquippedLegendary) ovaleCondition:RegisterCondition("hasshield", false, self.hasShield) ovaleCondition:RegisterCondition("hastrinket", false, self.hasTrinket) ovaleCondition:RegisterCondition("itemcooldown", false, self.ItemCooldown) @@ -325,6 +341,9 @@ __exports.OvaleEquipmentClass = __class(nil, { HasEquippedItem = function(self, itemId) return (self.equippedItemById[itemId] and true) or false end, + HasEquippedLegendary = function(self, legendaryId) + return (self.equippedLegendaryById[legendaryId] and true) or false + end, HasMainHandWeapon = function(self, handedness) if not self.mainHandItemType then return false @@ -387,10 +406,23 @@ __exports.OvaleEquipmentClass = __class(nil, { if prevItemId then self.equippedItemById[prevItemId] = nil end + local prevLegendaryId = self.equippedLegendaryBySlot[slotId] + if prevLegendaryId then + self.equippedLegendaryById[prevLegendaryId] = nil + end local newItemId = GetInventoryItemID("player", slotId) + local newLegendaryId = nil if newItemId then self.equippedItemById[newItemId] = slotId self.equippedItemBySlot[slotId] = newItemId + if GetInventoryItemQuality("player", slotId) == 5 then + local newItemLink = string.match(GetInventoryItemLink("player", slotId), "item:([%-?%d:]+)") + newLegendaryId = tonumber(string.match(newItemLink, "%d*:%d*:%d*:%d*:%d*:%d*:%d*:%d*:%d*:%d*:%d*:%d*:%d*:(%d*):")) + self.equippedLegendaryById[newLegendaryId] = slotId + self.equippedLegendaryBySlot[slotId] = newLegendaryId + else + self.equippedLegendaryBySlot[slotId] = nil + end if slotId == OVALE_SLOTID_BY_SLOTNAME["mainhandslot"] then local itemEquipLoc, dps = self:UpdateWeapons(slotId, newItemId) self.mainHandItemType = itemEquipLoc @@ -402,6 +434,7 @@ __exports.OvaleEquipmentClass = __class(nil, { end else self.equippedItemBySlot[slotId] = nil + self.equippedLegendaryBySlot[slotId] = nil if slotId == OVALE_SLOTID_BY_SLOTNAME["mainhandslot"] then self.mainHandItemType = nil self.mainHandDPS = 0 @@ -410,7 +443,7 @@ __exports.OvaleEquipmentClass = __class(nil, { self.offHandDPS = 0 end end - if prevItemId ~= newItemId then + if prevItemId ~= newItemId or prevLegendaryId ~= newLegendaryId then return true end return false diff --git a/states/runeforge.lua b/states/runeforge.lua index a68b994..7cfd6a2 100644 --- a/states/runeforge.lua +++ b/states/runeforge.lua @@ -49,7 +49,7 @@ __exports.Runeforge = __class(nil, { debug.defaultOptions.args["runeforge"] = self.debugOptions end, registerConditions = function(self, condition) - condition:RegisterCondition("equippedruneforge", false, self.equippedRuneforge) - condition:RegisterCondition("runeforge", false, self.equippedRuneforge) +-- condition:RegisterCondition("equippedruneforge", false, self.equippedRuneforge) +-- condition:RegisterCondition("runeforge", false, self.equippedRuneforge) end, }) -- 2.21.0.windows.1