Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Issue with "Can cure Debuff" function always returning false

Featured Replies

 

Hello Wrobot community,

I'm having an issue with the CanPurify function in my code, and I was hoping someone could help me figure out what's going on. Currently, no matter what, the function always returns false, even when the player has a debuff that should be able to be purified.

Here is the current code for the function:

    public bool CanPurify(string playerName)
    {
        var lua = $@"
    canPurify = false
    for i = 1, 40 do
        local name, _, _, debuffAuraType, _, _, _, _, _ = UnitDebuff(""{playerName}"", i);
        if (name and debuffAuraType) and (debuffAuraType == 'Magic' or debuffAuraType == 'Disease' or debuffAuraType == 'Poison') then
            canPurify = true
            break
        end
    end
    return canPurify
";
        Logging.Write($"Checking if {playerName} can be purified...");
        bool result = Lua.LuaDoString<bool>(lua);
        Logging.Write($"Result: {result}");
        return result;

 

If anyone has any idea what might be causing this issue, or any suggestions for how I can fix it, I would really appreciate it. Thank you in advance for your help!

Best regards,

Hello,

In "playerName" argument you should pass arguments like "player", "target", "focus", "party1", "raid1" (if you pass real player/unit name that will no work).

Your code should look like that if you want to use playerName (not tested) :

    public bool CanPurify(string playerName)
    {
        var units = ObjectManager.GetObjectWoWUnit();
        units.AddRange(ObjectManager.GetObjectWoWPlayer());

        var unitsByName = ObjectManager.GetWoWUnitByName(units, playerName);

        return CanPurify(unitsByName.FirstOrDefault());
    }
    public bool CanPurify(WoWUnit wowUnit)
    {
        if (wowUnit == null || !wowUnit.IsValid)
            return false;

        string unit;
        long currentFocus;
        if (wowUnit.IsLocalPlayer)
            unit = "player";
        else if (wowUnit.IsMyTarget)
            unit = "target";
        else
        {
            currentFocus = ObjectManager.Me.FocusGuid;
            ObjectManager.Me.FocusGuid = wowUnit.Guid;
            unit = "focus";
        }

        var lua = $@"
    canPurify = false
    for i = 1, 40 do
        local name, _, _, debuffAuraType, _, _, _, _, _ = UnitDebuff(""{unit}"", i);
        if (name and debuffAuraType) and (debuffAuraType == 'Magic' or debuffAuraType == 'Disease' or debuffAuraType == 'Poison') then
            canPurify = true
            break
        end
    end
    return canPurify
";

        if (unit == "focus")
            ObjectManager.Me.FocusGuid = currentFocus;

        Logging.Write($"Checking if {wowUnit} can be purified...");
        bool result = Lua.LuaDoString<bool>(lua);
        Logging.Write($"Result: {result}");
        return result;
    }

 

  • Author

Thank you very much! I will try your code later.

Regarding your code, my fightclass already has a priority list established based on the people in my party or raid. So, I will not use the first part of your code, as I understand it is trying to find a wowUnit to dispel.

Instead, I will pass a Wowunit player to the second function, rather than just the pseudo.

Thanks!

  • Author

Hello Droidz,

Unfortunately, the code is not working. I am playing on WoW 3.3.5a.

At the moment, I have added some print statements:

 
csharp
 
var lua = $@" canPurify = false for i = 1, 40 do local name, _, _, debuffAuraType, _, _, _, _, _ = UnitDebuff(""{unit}"", i); print(""{unit}"") print(name) print(debuffAuraType) if (name and debuffAuraType) and (debuffAuraType == 'Magic' or debuffAuraType == 'Disease' or debuffAuraType == 'Poison') then canPurify = true break end end return canPurify ";

 

Here is the output:

image.png.905de3bd6c53cec0b4d01e1e2a1d6cdf.png

Thank you.

 
  • Author

I would like to thank the Wholsome Discord for their help. It turns out that my debuffAuraType was in the third position, when it should have been in the fourth position in UnitDebuff.

Here is the modified code:

 

public bool CanPurify(string playerName)
{
    var lua = $@"
canPurify = false
for i = 1, 40 do
    local name, _, _, _, debuffAuraType, _, _, _, _ = UnitDebuff(""{playerName}"", i);
    print(""{playerName}"")
    print(name)
    print(debuffAuraType)
    if (name and debuffAuraType) and (debuffAuraType == 'Magic' or debuffAuraType == 'Disease' or debuffAuraType == 'Poison') then
        canPurify = true
        break
    end
end
return canPurify
";
    Logging.Write($"Checking if {playerName} can be purified...");
    bool result = Lua.LuaDoString<bool>(lua);
    Logging.Write($"Result: {result}");
    return result;
}

public void Purify(WoWUnit p)
{
    while (CanPurify(p.Name) && CastHeal(Cleanse, p, 100))
    {
        SpellManager.CastSpellByNameOn("Holy Light", p.Name);
    }
}

 

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.