azerothcore / mod-npc-buffer

A NPC that buffs players
http://azerothcore.org/
GNU Affero General Public License v3.0
14 stars 27 forks source link

No longer buffs on right-click #31

Closed ghost closed 2 months ago

ghost commented 3 months ago

Current Behaviour

Right clicking no longer buffs players. Nothing happens. This only started after the most recent module update. It used to work prior.

I also restored the .conf from the .conf.dist to test and still no right-click.

Expected Blizzlike Behaviour

Not blizzlike since it's a custom NPC, but it should cast buffs on players upon right-click.

Steps to reproduce the problem

  1. npc add 601016
  2. right-click new npc
  3. nothing happens

Extra Notes

This used to work prior to the latest update.

AC rev. hash/commit

AzerothCore rev. 099b6ab59a4a 2024-07-08 02:53:58 +0000 (master branch) (Unix, RelWithDebInfo, Static) (worldserver-daemon) ready...

Operating system

Debian 12.6

Custom changes or Modules

parashorea commented 2 months ago

Yes, I encountered this problem too.

parashorea commented 2 months ago

@Helias

Helias commented 2 months ago

I have not enough time to investigate this :(

parashorea commented 2 months ago

@Helias But do you really think hiding will stop me from finding you? It’s pointless! You're such a flamboyant man—no matter where you are, you're like a firefly in the dark—so bright, so outstanding!

entropiccode commented 2 months ago

I'm experiencing this issue with this module as well.

The script seems to be partially working, as toggling the option to announce the module at login does have an effect, however nothing relating to the NPC itself functions.

I tested with custom buffs and the default buffs, and setting "Buff.ByLevel" to 0 and 1 but there was no change in the described behavior regardless of configuration.

The "buff_npc" creaturescript as a whole doesn't seem to be working, as the NPC doesn't whisper the player, nor do they say any phrases or emote.

entropiccode commented 2 months ago

After some testing, I've been able to get a very stripped down version of the bot to work.

I started by stripping out everything in the "buff_npc" class except for checking to see if the module is enabled, storing buff IDs, buffing the player, and having the NPC flex once the buff is applied. At first, this still wasn't working for me, as the NPC would just open the gossip window with the generic "Greetings, \<player name>" behavior seen previously. On a whim, I updated "OnGossipSelect" to "OnGossipHello".

After compiling, the bot began to work without issue. Right clicking the bot does not open a dialogue interface, instead the bot flexes as the configured buffs are added to your character. I tested with the default set of buffs and a set of custom buffs, both configurations worked without issue.

Going back through commits to the project, it looks like the code has been using OnGossipSelect for far longer than this issue has been a problem (I used this module myself 2 years ago and the code from that timeframe used OnGossipSelect), so the issue is either the NPC had gossip options previously that are missing, causing the rest of the OnGossipSelect to fail, or the core itself has adjusted how OnGossipSelect is handled.

For the sake of reference, here is what my buff_npc class looks like. It's a hacky fix at best as I don't program in C and changes I made were based on generalized knowledge of programming based on other languages, but it's a bare-bones demonstration of something I got to work.

class buff_npc : public CreatureScript
{
public:
    buff_npc() : CreatureScript("buff_npc") { }

    bool OnGossipHello(Player* player, Creature* creature) override
    {
        if (!BFEnableModule)
        {
            return false;
        }

        // Store Buff IDs
        std::vector<uint32> vecBuffs = {};
        std::stringstream ss(sConfigMgr->GetOption<std::string>("Buff.Spells", ""));
        for (std::string buff; std::getline(ss, buff, ';');)
        {
            vecBuffs.push_back(stoul(buff));
        }

        for (std::vector<uint32>::const_iterator itr = vecBuffs.begin(); itr != vecBuffs.end(); itr++)
        {
            player->CastSpell(player, *itr, true);
        }

        // Emote and Close
        creature->HandleEmoteCommand(EMOTE_ONESHOT_FLEX);
        CloseGossipMenuFor(player);
        return true;
    }
};
entropiccode commented 2 months ago

Reverted npc_buffer.cpp back to its current state and changed OnGossipSelect to OnGossipHello again, leaving all other functionality. NPC seems to be working after compile, created pull request for my fix.