Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add itemInRange condition support to Equipment Slot triggers #5639

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

its-riece
Copy link

@its-riece its-riece commented Jan 27, 2025

Description

This PR adds the Item in Range conditional used by Cooldown Progress (Item) triggers to Cooldown Progress (Slot) triggers.

The motivation for the change is that many item slots in Classic for which you'd care about the cooldown can also have range limitations. Examples include:

  • Goblin Rocket Helmet
  • Gnomish Net-o-Matic Projector
  • Tidal Charm
  • (etc, there's so many)

Fixes #5638

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested

I created a new WeakAura with a Cooldown Progress (Slot) trigger and used the added Item in Range conditional. I was able to verify its behavior for both the Helmet and Trinket 1 slots. Here is an export of that WeakAura:

!WA:2!DrvZUTTrqylRc4cv0wB1udK2CWWaniTOWiXaXaT3evOsCGSKkjDTtViTKCi5wtTlZUlLS8HceDkN1JGa6TEspc(jGqOOpa(qVx)e0zxr58Jbm183oZ33SZovAvFy9W6HV9rZPbCMlpxeapydXLDJIKGQYcs4VNlvq4jKl38Dku2MIj3fcliHl6XPmLFt7oE2old480q(yM7yAgm461Q2HXqIGeOOCM8ihPIiu1SOmQQMFe(JmP2uLGghdc5x8qrP4)yPMKbwufm8gzUpmcyk38Oi6Ll63SHRxFxVgoEz7KlH(Xade0a3e(4USbl)a15s8NgPJjtKomYqqw7A9r051nLRgmDT03ovMbPPhh(Er0bpWG7kFpbGL3XTND72w5i(9ZsjtaHJXB2(nlj8E9e8ybiL79i7xNtZgIE3txIVFEi4JCWdzM4f2T71602ZYzLmUw2o6M0iWBL(j8q4V24wSbdcgj9xX2d2b)ZBYkZ(QRTF4bBS5mjKgzUkk2clHKOYfefKmhrUdeR77)8UfBVev9jbxel45SW3EVS6k4svFzcbr95LxSz33y08jIlgsWakfSyCgm7o37)DYSTFVm0KNYfVSsLkvVzL11GYQXPEDZ(kJrsUIJPIgCgnuLy1avVDvTOxcHgJVz5QzRxvIORn(1ZG0OjibfCfsop0OvNUDSl2wG8shZCtGbgyuf)BwjjW7MTBjOxT3VKtcXgdzppVpG7RR0sJTXCr4zcs20ZkfwbGruj1pfNRxHU(zAQLTZXD6y703QRNx3tCo(5VWB5Dv1LEfC)sYC(hucTxZqq3t9AFCh7)DzCkFClb86CGfmP3N84do8PRiM2X16pptFNIxLvNQ10NEPFUsXzDhbcCoCU2CBGfRs(6fA51SAMwP5DDf9W9ZxBjXe5AWzPvsmX7gqsHQgy5LqdUGHdCvnEAtr5DmvZcBqGiXpbOXjQ3yLYjHTSKiT31zyEQIwZcFtfSBXVvZjiLiLAjFfMzMslMTnILgLRxmBBs(ytuwYCHze2ZSoaxx5J)hrJRnJWOdnTKJk(SwfBxCW1arcUkHPjS1YWYowF9MeHeWZfkNQJrNRIdSgsOmZblc3QakIkIrXp)JTmD9ISb3Ebazn0us5OZCYsCCgVC7Mz2TvZ6koFyfN3nboxXdgT6D7N(J)3(0qh8LJuD7QzIwcC9Igk(UnDST74qsZsivDgBEfKvh7eRxPG7cWkcdomNgU40Z7CO6jbrTB)kbLPZpKSisNmK744D1S7TgY6xjpJkj4GByYCDdGAG638qNGei4IJk(YQthreuDel0R8oM5qyXGZisAoureKO1W4l(JxwfFApf3(Gnt1KIHlOSv7fWewRGmOU0)Ph8KF6GhxF0FF())d

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

I duplicated code from Cooldown Progress (Equipment Slot) nearly 1:1 as I was not familiar enough with the structure of the file to avoid doing that. If there's something smarter to do here I'm happy to fix my implementation.

local itemSlot = state.trigger.itemSlot
local item = GetInventoryItemID("player", itemSlot or 0)
local itemName = item and C_Item.GetItemInfo(item) or nil
return C_Item.IsItemInRange(itemName, 'target') == (needle == 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the itemId stored in state.itemId, and also need to handle it being nil.

Copy link
Author

@its-riece its-riece Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@InfusOnWoW can you point me to where that state is constructed? I am not seeing itemId in there at all. I did find state.name which appears to be the item name (I'm just DevTools_Dumping and scrolling around like a noob)-- should I use that instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed f9c6fd5 which swaps to state.name but it feels a bit spooky to use something generically called name, I don't mind refactoring to something smarter just not sure where I ought to be looking as a reference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding it too all triggers that have an itemId might be nice, although it's also a bit more involved. I wouldn't require that for a PR.

As to the item id, it's not saved in that trigger's state, but we should use the item id, not the name for checking:

Adding

      {
        name = "itemId",
        display = L["ItemId"],
        hidden = true,
        init = "item",
        test = "true",
        store = true,
        conditionType = "number",
        operator_types = "only_equal",
      },

In that trigger's data should be enough to add it to the state.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@InfusOnWoW yeah seemed to work-- refactored accordingly. I tried to refactor Cooldown Progress (Item) similarly but adding the itemId block you gave me in the same way didn't give me access to state.itemId. Is that just a misunderstanding on my part? Feels weird to leave that one checking state.itemname.

@mrbuds
Copy link
Contributor

mrbuds commented Jan 28, 2025

It would make sense to automatically add this condition for all triggers with the field hasItemID = true

@its-riece
Copy link
Author

its-riece commented Jan 28, 2025

@mrbuds I agree, could you clarify if that's something you'd like done before merging this? If so unfortunately may be out of my depth. This is the first time I've looked at the codebase-- I'd be down to try with some nudging though.

@its-riece its-riece requested a review from InfusOnWoW January 31, 2025 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Item in Range conditional support for Cooldown Progress (Slot) triggers
3 participants