fix: DragonSoul Timer

This commit is contained in:
rtw1x1
2026-01-21 23:18:10 +00:00
parent 735b0e8748
commit 7c2f4e17a3
2 changed files with 77 additions and 7 deletions

View File

@@ -206,10 +206,12 @@ class DragonSoulWindow(ui.ScriptWindow):
self.inventoryTab[(page+3)%5].SetUp()
self.inventoryTab[(page+4)%5].SetUp()
self.RefreshBagSlotWindow()
def SetItemToolTip(self, tooltipItem):
self.tooltipItem = tooltipItem
if tooltipItem:
tooltipItem.SetDragonSoulWindow(self)
def RefreshItemSlot(self):
self.RefreshBagSlotWindow()
self.RefreshEquipSlotWindow()

View File

@@ -499,10 +499,18 @@ class ItemToolTip(ToolTip):
# When displaying item tooltip, if the current character cannot equip the item, force it to use Disable Color (already works this way but needed ability to turn it off)
self.bCannotUseItemForceSetDisableColor = True
self._curItemWindowType = None
self._curItemSlotIndex = -1
self._wearTimerCache = {}
self._dragonSoulWindow = None
def __del__(self):
ToolTip.__del__(self)
self.metinSlot = None
def SetDragonSoulWindow(self, wnd):
self._dragonSoulWindow = wnd
def SetCannotUseItemForceSetDisableColor(self, enable):
self.bCannotUseItemForceSetDisableColor = enable
@@ -568,6 +576,10 @@ class ItemToolTip(ToolTip):
def ClearToolTip(self):
self.isShopItem = False
self.toolTipWidth = self.TOOL_TIP_WIDTH
self._curItemWindowType = None
self._curItemSlotIndex = -1
ToolTip.ClearToolTip(self)
def SetInventoryItem(self, slotIndex, window_type = player.INVENTORY):
@@ -584,6 +596,8 @@ class ItemToolTip(ToolTip):
metinSlot = [player.GetItemMetinSocket(window_type, slotIndex, i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
attrSlot = [player.GetItemAttribute(window_type, slotIndex, i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
self._curItemWindowType = window_type
self._curItemSlotIndex = slotIndex
self.AddItemData(itemVnum, metinSlot, attrSlot)
def SetShopItem(self, slotIndex):
@@ -593,6 +607,8 @@ class ItemToolTip(ToolTip):
price = shop.GetItemPrice(slotIndex)
self.ClearToolTip()
self._curItemWindowType = None
self._curItemSlotIndex = slotIndex
self.isShopItem = True
metinSlot = []
@@ -612,6 +628,8 @@ class ItemToolTip(ToolTip):
price = shop.GetItemPrice(slotIndex)
self.ClearToolTip()
self._curItemWindowType = None
self._curItemSlotIndex = slotIndex
self.isShopItem = True
metinSlot = []
@@ -630,6 +648,8 @@ class ItemToolTip(ToolTip):
return
self.ClearToolTip()
self._curItemWindowType = None
self._curItemSlotIndex = slotIndex
metinSlot = []
for i in xrange(player.METIN_SOCKET_MAX_NUM):
@@ -645,6 +665,8 @@ class ItemToolTip(ToolTip):
return
self.ClearToolTip()
self._curItemWindowType = None
self._curItemSlotIndex = slotIndex
metinSlot = []
for i in xrange(player.METIN_SOCKET_MAX_NUM):
@@ -661,6 +683,8 @@ class ItemToolTip(ToolTip):
item.SelectItem(itemVnum)
self.ClearToolTip()
self._curItemWindowType = None
self._curItemSlotIndex = privateShopSlotIndex
self.AppendSellingPrice(shop.GetPrivateShopItemPrice(invenType, invenPos))
metinSlot = []
@@ -678,6 +702,8 @@ class ItemToolTip(ToolTip):
return
self.ClearToolTip()
self._curItemWindowType = None
self._curItemSlotIndex = slotIndex
metinSlot = []
for i in xrange(player.METIN_SOCKET_MAX_NUM):
metinSlot.append(safebox.GetItemMetinSocket(slotIndex, i))
@@ -693,6 +719,8 @@ class ItemToolTip(ToolTip):
return
self.ClearToolTip()
self._curItemWindowType = None
self._curItemSlotIndex = slotIndex
metinSlot = []
for i in xrange(player.METIN_SOCKET_MAX_NUM):
metinSlot.append(safebox.GetMallItemMetinSocket(slotIndex, i))
@@ -1263,7 +1291,7 @@ class ItemToolTip(ToolTip):
self.AppendRealTimeStartFirstUseLastTime(item, metinSlot, i, limitValue2)
elif item.LIMIT_TIMER_BASED_ON_WEAR == limitType:
self.AppendTimerBasedOnWearLastTime(metinSlot)
self.AppendTimerBasedOnWearLastTime(metinSlot, limitValue2)
self.ShowToolTip()
@@ -1886,13 +1914,53 @@ class ItemToolTip(ToolTip):
return timeTextLine
def AppendTimerBasedOnWearLastTime(self, metinSlot):
if 0 == metinSlot[0]:
def AppendTimerBasedOnWearLastTime(self, metinSlot, getLimit):
remainSec = metinSlot[0]
if 0 == remainSec:
self.AppendSpace(5)
self.AppendTextLine(localeInfo.CANNOT_USE, self.DISABLE_COLOR)
return
# For Dragon Soul items, the timer only ticks when:
# 1. The item is EQUIPPED on a deck (window_type == player.INVENTORY for DS equip slots)
# 2. AND the deck is ACTIVATED
# Items in DS inventory bag (window_type == player.DRAGON_SOUL_INVENTORY) never tick.
item.SelectItem(self.itemVnum)
isDragonSoulItem = item.GetItemType() == item.ITEM_TYPE_DS
if isDragonSoulItem:
isTimerActive = False
windowType = getattr(self, "_curItemWindowType", None)
# Only equipped DS items (in INVENTORY window, not DRAGON_SOUL_INVENTORY) can have active timers
isEquippedOnDeck = (windowType == player.INVENTORY)
if isEquippedOnDeck and self._dragonSoulWindow and getattr(self._dragonSoulWindow, "isActivated", False):
isTimerActive = True
else:
endTime = app.GetGlobalTimeStamp() + metinSlot[0]
self.AppendMallItemLastTime(endTime, getLimit)
# Non-dragon soul items with LIMIT_TIMER_BASED_ON_WEAR
# Timer is active when equipped (this function is only called for such items)
isTimerActive = True
# Not active -> show STATIC remaining time (no ticking)
if not isTimerActive:
self.AppendSpace(5)
self.AppendTextLine(localeInfo.LEFT_TIME + ": " + localeInfo.RTSecondToDHMS(remainSec), self.NORMAL_COLOR)
return
# Active -> show real-time countdown
# Cache maintains stable display across re-hovers (server updates remainSec periodically)
now = app.GetGlobalTimeStamp()
slotIndex = getattr(self, "_curItemSlotIndex", -1)
key = (self.itemVnum, slotIndex)
cache = self._wearTimerCache.get(key)
if cache and cache.get("remainSec") == remainSec:
endTime = cache["endTime"]
else:
endTime = now + remainSec
self._wearTimerCache[key] = {"remainSec": remainSec, "endTime": endTime}
self.AppendMallItemLastTime(endTime, getLimit)
def AppendRealTimeStartFirstUseLastTime(self, item, metinSlot, limitIndex, getLimit):
useCount = metinSlot[1]