• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Eluna Integration with Custom Code

Status
Not open for further replies.

JoshCarter

Respected Member
Hello,

I hope this is the right area to post this question...

I'm using Trinitycore updated as of today 9/23/13.
Also, AHbot ahbot.2013-09-10.9379813.patch from here: http://www.trinitycore.org/f/topic/10-patch-telenpc2-pvpranks-for-trinitycore-2013-09-10-9379813/
And NPCBots patch from here: https://bitbucket.org/trickerer/trinity-bots/wiki/Home

When I merge in Eluna I had conflicts with AHbot, and a problem later with NPCBots... AHbot was an easy fix, just added #include "HookMgr.h" to AuctionHouseBot.h...

However, I'm stumped on the problem I"m having with NPCBots. Since there was no conflict during the merge, and no issue compiling, it's difficult for me to know what's wrong.

With the patch the bots are called through a player command:

Code:
 .npcbot helper

That pulls up a player to player gossip menu pulling info from my Database's:
Code:
locales_gossip_menu_option
table. Since the merge with Eluna, I can pull up the menu, but none of the options do anything when you click to interact. I saw a similar issue here: https://github.com/ElunaLuaEngine/Source/issues/34 , but the user that posted it seemed to not be able to explain himself, and looks to have gotten impatient and then frustrated.

If anyone, can/is willing to, help with this I'd greatly appreciate it. If any additional information is needed that would facilitate said help, please let me know. If this is in-fact the wrong area to ask this question, please move this thread to the proper place... I just wasn't sure, but it seemed the most appropriate area.

{Please reply in the thread here only and not via PM, I cannot check my PM's it says You cannot send PMs because your post count doesn't meet the requirements outlined by the forum administrator.}

Thank you.
 

Rochet2

Moderator / Eluna Dev
You should probably check out the part that handles the gossip select code.

See MiscHandler.cpp
HandleGossipSelectOptionOpcode

Incase its a player or an item you use for gossip, Eluna takes over and returns, thus the other patch's code might never be reached.
 

JoshCarter

Respected Member
You should probably check out the part that handles the gossip select code.

See MiscHandler.cpp
HandleGossipSelectOptionOpcode

Incase its a player or an item you use for gossip, Eluna takes over and returns, thus the other patch's code might never be reached.

Ahh, yes.. it is a player handling it's own gossip to itself, (I think).

Code:
BotHelper::BotHelper(Player* const master) : _master(master) { }
BotHelper::~BotHelper() {}

bool BotHelper::OnGossipSelect(Player* player, uint32 sender, uint32 action)
{
    switch (sender)
    {
        case SENDER_MAIN_PAGE:                          OnGossipHello(player);                              break;

        case SENDER_CREATE_NBOT_MENU:                   SendCreateNPCBotMenu(player, action);               break;
        case SENDER_CREATE_NBOT:                        SendCreateNPCBot(player, action);                   break;
        case SENDER_REMOVE_NBOT_MENU:                   SendRemoveNPCBotMenu(player, action);               break;
        case SENDER_REMOVE_NBOT:                        SendRemoveNPCBot(player, action);                   break;

        case SENDER_INFO_WHISPER:                       SendBotHelpWhisper(player, action);                 break;

        default:
            break;
    }
    return true;
}

bool BotHelper::OnGossipHello(Player* player)
{
    player->PlayerTalkClass->ClearMenus(); //in case of return;

    uint8 count = 0;

    uint8 maxNBcount = player->GetMaxNpcBots();

    bool allowNBots = sConfigMgr->GetBoolDefault("Bot.EnableNpcBots", true) && !player->RestrictBots();

    std::string tempstr;

    if (player->HaveBot())
    {
        count = player->GetNpcBotsCount();
        if (count > 0)
        {
            tempstr = "Abandon my Minion";
            player->PlayerTalkClass->GetGossipMenu().AddMenuItem(4, 0, GetLocaleStringForTextID(tempstr, ABANDON_MINION, player->GetSession()->GetSessionDbLocaleIndex()), SENDER_REMOVE_NBOT_MENU, GOSSIP_ACTION_INFO_DEF + 4, "", 0);
        }
        if (count < maxNBcount && allowNBots)
        {
            tempstr = "Recruit a Minion";
            player->PlayerTalkClass->GetGossipMenu().AddMenuItem(2, 0, GetLocaleStringForTextID(tempstr, RECRUIT_MINION, player->GetSession()->GetSessionDbLocaleIndex()), SENDER_CREATE_NBOT_MENU, GOSSIP_ACTION_INFO_DEF + 2, "", 0);
        }
    }
    else if (allowNBots && maxNBcount != 0)
    {
        tempstr = "Recruit a Minion";
        player->PlayerTalkClass->GetGossipMenu().AddMenuItem(2, 0, GetLocaleStringForTextID(tempstr, RECRUIT_MINION, player->GetSession()->GetSessionDbLocaleIndex()), SENDER_CREATE_NBOT_MENU, GOSSIP_ACTION_INFO_DEF + 2, "", 0);
    }

    tempstr = "Help";
    player->PlayerTalkClass->GetGossipMenu().AddMenuItem(6, 0, GetLocaleStringForTextID(tempstr, HELP_STR, player->GetSession()->GetSessionDbLocaleIndex()), SENDER_INFO_WHISPER, GOSSIP_ACTION_INFO_DEF + 6, "", 0);

    player->PlayerTalkClass->SendGossipMenu(8446, player->GetGUID());
    return true;
}

void BotHelper::SendRemoveNPCBot(Player* player, uint32 action)
{
    int8 x = action - GOSSIP_ACTION_INFO_DEF;
    if (x == 1)
    {
        player->CLOSE_GOSSIP_MENU();
        for (uint8 i = 0; i != player->GetMaxNpcBots(); ++i)
            player->RemoveBot(player->GetBotMap(i)->_Guid(), true);
        return;
    }
    for (uint8 i = 0; i != player->GetMaxNpcBots(); ++i)
    {
        if (!player->GetBotMap(i)->_Cre())
            continue;
        if (x == 2)
        {
            player->RemoveBot(player->GetBotMap(i)->_Guid(), true);
            break;
        }
        --x;
    }
    player->CLOSE_GOSSIP_MENU();
}

void BotHelper::SendRemoveNPCBotMenu(Player* player, uint32 /*action*/)
{
    player->PlayerTalkClass->ClearMenus();
    if (player->GetNpcBotsCount() == 1)
    {
        for (uint8 i = 0; i != player->GetMaxNpcBots(); ++i)
            player->RemoveBot(player->GetBotMap(i)->_Guid(), true);
        player->CLOSE_GOSSIP_MENU();
        return;
    }
    std::string tempstr = "REMOVE ALL";
    player->ADD_GOSSIP_ITEM(9, GetLocaleStringForTextID(tempstr, REMOVE_ALL, player->GetSession()->GetSessionDbLocaleIndex()), SENDER_REMOVE_NBOT, GOSSIP_ACTION_INFO_DEF + 1);

    uint8 x = 2;
    for (uint8 i = 0; i != player->GetMaxNpcBots(); ++i)
    {
        Creature* bot = player->GetBotMap(i)->_Cre();
        if (!bot) continue;
        player->ADD_GOSSIP_ITEM(9, bot->GetName(), SENDER_REMOVE_NBOT, GOSSIP_ACTION_INFO_DEF + x);
        ++x;
    }

    tempstr = "BACK";
    player->ADD_GOSSIP_ITEM(0, GetLocaleStringForTextID(tempstr, BACK_STRING, player->GetSession()->GetSessionDbLocaleIndex()), SENDER_MAIN_PAGE, GOSSIP_ACTION_INFO_DEF + x);

    player->PlayerTalkClass->SendGossipMenu(8446, player->GetGUID());
}

void BotHelper::SendCreateNPCBot(Player* player, uint32 action)
{
    uint8 bot_class = 0;
    if (action == GOSSIP_ACTION_INFO_DEF + 1)//"Back"
    {
        player->CLOSE_GOSSIP_MENU();
        return;
    }
    else if (action == GOSSIP_ACTION_INFO_DEF + 2)
        bot_class = CLASS_WARRIOR;
    else if (action == GOSSIP_ACTION_INFO_DEF + 3)
        bot_class = CLASS_HUNTER;
    else if (action == GOSSIP_ACTION_INFO_DEF + 4)
        bot_class = CLASS_PALADIN;
    else if (action == GOSSIP_ACTION_INFO_DEF + 5)
        bot_class = CLASS_SHAMAN;
    else if (action == GOSSIP_ACTION_INFO_DEF + 6)
        bot_class = CLASS_ROGUE;
    else if (action == GOSSIP_ACTION_INFO_DEF + 7)
        bot_class = CLASS_DRUID;
    else if (action == GOSSIP_ACTION_INFO_DEF + 8)
        bot_class = CLASS_MAGE;
    else if (action == GOSSIP_ACTION_INFO_DEF + 9)
        bot_class = CLASS_PRIEST;
    else if (action == GOSSIP_ACTION_INFO_DEF + 10)
        bot_class = CLASS_WARLOCK;
    //else if (action == GOSSIP_ACTION_INFO_DEF + 11)
    //    bot_class = CLASS_DEATH_KNIGHT;

    if (bot_class != 0)
        player->CreateNPCBot(bot_class);
    player->CLOSE_GOSSIP_MENU();
    return;
}

void BotHelper::SendCreateNPCBotMenu(Player* player, uint32 /*action*/)
{
    std::string cost = player->GetNpcBotCostStr();
    player->PlayerTalkClass->ClearMenus();

    std::string tempstr = "Recruit a Warrior ";
    player->ADD_GOSSIP_ITEM(9, GetLocaleStringForTextID(tempstr, RECRUIT_WARRIOR, player->GetSession()->GetSessionDbLocaleIndex()) + cost, SENDER_CREATE_NBOT, GOSSIP_ACTION_INFO_DEF + 2);
    tempstr = "Recruit a Hunter ";
    player->ADD_GOSSIP_ITEM(9, GetLocaleStringForTextID(tempstr, RECRUIT_HUNTER, player->GetSession()->GetSessionDbLocaleIndex()) + cost, SENDER_CREATE_NBOT, GOSSIP_ACTION_INFO_DEF + 3);
    tempstr = "Recruit a Paladin ";
    player->ADD_GOSSIP_ITEM(9, GetLocaleStringForTextID(tempstr, RECRUIT_PALADIN, player->GetSession()->GetSessionDbLocaleIndex()) + cost, SENDER_CREATE_NBOT, GOSSIP_ACTION_INFO_DEF + 4);
    tempstr = "Recruit a Shaman ";
    player->ADD_GOSSIP_ITEM(9, GetLocaleStringForTextID(tempstr, RECRUIT_SHAMAN, player->GetSession()->GetSessionDbLocaleIndex()) + cost, SENDER_CREATE_NBOT, GOSSIP_ACTION_INFO_DEF + 5);
    tempstr = "Recruit a Rogue ";
    player->ADD_GOSSIP_ITEM(9, GetLocaleStringForTextID(tempstr, RECRUIT_ROGUE, player->GetSession()->GetSessionDbLocaleIndex()) + cost, SENDER_CREATE_NBOT, GOSSIP_ACTION_INFO_DEF + 6);
    tempstr = "Recruit a Druid ";
    player->ADD_GOSSIP_ITEM(3, GetLocaleStringForTextID(tempstr, RECRUIT_DRUID, player->GetSession()->GetSessionDbLocaleIndex()) + cost, SENDER_CREATE_NBOT, GOSSIP_ACTION_INFO_DEF + 7);
    tempstr = "Recruit a Mage ";
    player->ADD_GOSSIP_ITEM(3, GetLocaleStringForTextID(tempstr, RECRUIT_MAGE, player->GetSession()->GetSessionDbLocaleIndex()) + cost, SENDER_CREATE_NBOT, GOSSIP_ACTION_INFO_DEF + 8);
    tempstr = "Recruit a Priest ";
    player->ADD_GOSSIP_ITEM(3, GetLocaleStringForTextID(tempstr, RECRUIT_PRIEST, player->GetSession()->GetSessionDbLocaleIndex()) + cost, SENDER_CREATE_NBOT, GOSSIP_ACTION_INFO_DEF + 9);
    tempstr = "Recruit a Warlock ";
    player->ADD_GOSSIP_ITEM(3, GetLocaleStringForTextID(tempstr, RECRUIT_WARLOCK, player->GetSession()->GetSessionDbLocaleIndex()) + cost, SENDER_CREATE_NBOT, GOSSIP_ACTION_INFO_DEF + 10);
    //tempstr = "Recruit a Death Knight ";
    //player->ADD_GOSSIP_ITEM(9, GetLocaleStringForTextID(tempstr, RECRUIT_DEATH_KNIGHT, player->GetSession()->GetSessionDbLocaleIndex()) + cost, SENDER_CREATE_NBOT, GOSSIP_ACTION_INFO_DEF + 11);

    std::ostringstream buff;
    uint8 bots = player->GetNpcBotsCount();
    uint8 maxNBcount = player->GetMaxNpcBots();
    uint32 freeNBSlots = maxNBcount - bots;

    if (freeNBSlots == 0)
    {
        tempstr = "no more bots available";
        buff << GetLocaleStringForTextID(tempstr, NO_MORE_AVAILABLE, player->GetSession()->GetSessionDbLocaleIndex());
    }
    else
    {
        buff << freeNBSlots;
        buff << ' ';
        if (freeNBSlots == 1)
        {
            if (bots == 0)
            {
                tempstr = "bot available";
                buff << GetLocaleStringForTextID(tempstr, ONE_AVAILABLE, player->GetSession()->GetSessionDbLocaleIndex());
            }
            else
            {
                tempstr = "more bot available";
                buff << GetLocaleStringForTextID(tempstr, ONE_MORE_AVAILABLE, player->GetSession()->GetSessionDbLocaleIndex());
            }
        }
        else
        {
            if (bots == 0)
            {
                tempstr = "bots available";
                buff << GetLocaleStringForTextID(tempstr, SOME_AVAILABLE, player->GetSession()->GetSessionDbLocaleIndex());
            }
            else
            {
                tempstr = "more bots available";
                buff << GetLocaleStringForTextID(tempstr, SOME_MORE_AVAILABLE, player->GetSession()->GetSessionDbLocaleIndex());
            }
        }
    }
    player->ADD_GOSSIP_ITEM(0, buff.str(), SENDER_CREATE_NBOT_MENU, GOSSIP_ACTION_INFO_DEF + 12);

    tempstr = "BACK";
    player->ADD_GOSSIP_ITEM(0, GetLocaleStringForTextID(tempstr, BACK_STRING, player->GetSession()->GetSessionDbLocaleIndex()), SENDER_MAIN_PAGE, GOSSIP_ACTION_INFO_DEF + 13);

    player->PlayerTalkClass->SendGossipMenu(8446, player->GetGUID());
}

void BotHelper::SendBotHelpWhisper(Player* player, uint32 /*action*/)
{
    player->CLOSE_GOSSIP_MENU();
    ChatHandler ch(player->GetSession());
    //Basic
    std::string tempstr = "To see list of available npcbot commands type .npcbot or .npcb";
    std::string msg2 = GetLocaleStringForTextID(tempstr, ABOUT_BASIC_STR2, player->GetSession()->GetSessionDbLocaleIndex());
    tempstr = "You can also use .maintank (or .mt or .main) command on any party member (even npcbot) so your bots will stick to your plan";
    std::string msg3 = GetLocaleStringForTextID(tempstr, ABOUT_BASIC_STR3, player->GetSession()->GetSessionDbLocaleIndex());
    ch.SendSysMessage(msg2.c_str());
    ch.SendSysMessage(msg3.c_str());
    //Heal Icons
    uint8 mask = sConfigMgr->GetIntDefault("Bot.HealTargetIconsMask", 8);
    std::string msg4 = "";
    if (mask == 255)
    {
        tempstr = "If you want your npcbots to heal someone out of your party set any raid target icon on them";
        msg4 = GetLocaleStringForTextID(tempstr, ABOUT_ICONS_STR1, player->GetSession()->GetSessionDbLocaleIndex());
        ch.SendSysMessage(msg4.c_str());
    }
    else if (mask != 0)
    {
        tempstr = "If you want your npcbots to heal someone out of your party set proper raid target icon on them, one of these: ";
        msg4 = GetLocaleStringForTextID(tempstr, ABOUT_ICONS_STR2, player->GetSession()->GetSessionDbLocaleIndex());
        std::string iconrow = "";
        uint8 count = 0;
        for (uint8 i = 0; i != TARGETICONCOUNT; ++i)
        {
            if (mask & GroupIcons[i])
            {
                if (count != 0)
                    iconrow += ", ";
                ++count;
                switch (i)
                {
                    case 0:
                        tempstr = "star";
                        iconrow += GetLocaleStringForTextID(tempstr, ICON_STRING_STAR, player->GetSession()->GetSessionDbLocaleIndex());
                        break;
                    case 1:
                        tempstr = "circle";
                        iconrow += GetLocaleStringForTextID(tempstr, ICON_STRING_CIRCLE, player->GetSession()->GetSessionDbLocaleIndex());
                        break;
                    case 2:
                        tempstr = "diamond";
                        iconrow += GetLocaleStringForTextID(tempstr, ICON_STRING_DIAMOND, player->GetSession()->GetSessionDbLocaleIndex());
                        break;
                    case 3:
                        tempstr = "triangle";
                        iconrow += GetLocaleStringForTextID(tempstr, ICON_STRING_TRIANGLE, player->GetSession()->GetSessionDbLocaleIndex());
                        break;
                    case 4:
                        tempstr = "moon";
                        iconrow += GetLocaleStringForTextID(tempstr, ICON_STRING_MOON, player->GetSession()->GetSessionDbLocaleIndex());
                        break;
                    case 5:
                        tempstr = "square";
                        iconrow += GetLocaleStringForTextID(tempstr, ICON_STRING_SQUARE, player->GetSession()->GetSessionDbLocaleIndex());
                        break;
                    case 6:
                        tempstr = "cross";
                        iconrow += GetLocaleStringForTextID(tempstr, ICON_STRING_CROSS, player->GetSession()->GetSessionDbLocaleIndex());
                        break;
                    case 7:
                        tempstr = "skull";
                        iconrow += GetLocaleStringForTextID(tempstr, ICON_STRING_SKULL, player->GetSession()->GetSessionDbLocaleIndex());
                        break;
                    default:
                        tempstr = "unknown icon";
                        iconrow += GetLocaleStringForTextID(tempstr, ICON_STRING_UNKNOWN, player->GetSession()->GetSessionDbLocaleIndex());
                        break;
                }
            }
        }
        msg4 += iconrow;
        ch.SendSysMessage(msg4.c_str());
    }
}

std::string BotHelper::GetLocaleStringForTextID(std::string& textValue, uint32 textId, int32 localeIdx)
{
    if (textId >= MAX_STRINGS)
    {
        TC_LOG_ERROR(LOG_FILTER_PLAYER, "botgiver:GetLocaleStringForTextID:: unknown text id: %u!", uint32(textId));
        return textValue;
    }

    if (localeIdx == DEFAULT_LOCALE)
        return textValue; //use default

    if (localeIdx < 0)
    {
        TC_LOG_ERROR(LOG_FILTER_PLAYER, "botgiver:GetLocaleStringForTextID:: unknown locale: %i! Sending default locale text...", localeIdx);
        return textValue;
    }

    uint32 idxEntry = MAKE_PAIR32(60000, textId);
    if (GossipMenuItemsLocale const* no = sObjectMgr->GetGossipMenuItemsLocale(idxEntry))
        ObjectMgr::GetLocaleString(no->OptionText, localeIdx, textValue);
    return textValue;
}

The SENDER_MAIN_PAGE still works, just the cases that follow do not... SENDER_CREATE_NBOT_MENU: and below...

Would it have something to do with this then in MiscHandler.cpp

Code:
#ifdef ELUNA
    if (IS_ITEM_GUID(guid) || IS_PLAYER_GUID(guid))
    {
        sHookMgr->HandleGossipSelectOption(GetPlayer(), guid, GetPlayer()->PlayerTalkClass->GetGossipOptionSender(gossipListId), GetPlayer()->PlayerTalkClass->GetGossipOptionAction(gossipListId), code, menuId);
        return;
    }
#endif

I did try Editing the header file and include the hookmgr as well...

Code:
#ifndef _BOTHLP_H
#define _BOTHLP_H

#include "Common.h"
#include "HookMgr.h"

class Player;

class BotHelper
{
    public:
        BotHelper(Player* const master);
        ~BotHelper();

        Player* GetOwner() const { return _master; }

        static bool OnGossipHello(Player* player);
        static bool OnGossipSelect(Player* player, uint32 sender, uint32 action);

    /* private: */
        static void SendRemoveNPCBot(Player* player, uint32 action);
        static void SendRemoveNPCBotMenu(Player* player, uint32 /*action*/);
        static void SendCreateNPCBot(Player* player, uint32 action);
        static void SendCreateNPCBotMenu(Player* player, uint32 /*action*/);


        static void SendBotHelpWhisper(Player* player, uint32 /*action*/);
        static std::string GetLocaleStringForTextID(std::string& textValue, uint32 textId, int32 localeIdx = 0);

        Player* const _master;
};

#endif

That did not help the issue though.
 
Last edited:

Rochet2

Moderator / Eluna Dev
Simply remove the return:

Code:
#ifdef ELUNA
    if (IS_ITEM_GUID(guid) || IS_PLAYER_GUID(guid))
    {
        sHookMgr->HandleGossipSelectOption(GetPlayer(), guid, GetPlayer()->PlayerTalkClass->GetGossipOptionSender(gossipListId), GetPlayer()->PlayerTalkClass->GetGossipOptionAction(gossipListId), code, menuId);
        [COLOR="#FF0000"]return;[/COLOR]
    }
#endif

Not sure if we should also do this on eluna .. hmm
 

Foereaper

Founder
Try removing the return first, if that solves it and subsequently does not break eluna gossip, then we'll remove it from the source. Otherwise we'll have to come up with a different way of handling it
 

JoshCarter

Respected Member
Just compile testing it now... I changed it to this... (posting the snippet that shows both Eluna, and the Custom code in miscHandler.cpp to make sure I didn't mess it up).

Code:
void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)
{
    TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: CMSG_GOSSIP_SELECT_OPTION");

    uint32 gossipListId;
    uint32 menuId;
    uint64 guid;
    std::string code = "";

    recvData >> guid >> menuId >> gossipListId;

    if (_player->PlayerTalkClass->IsGossipOptionCoded(gossipListId))
        recvData >> code;
#ifdef ELUNA
    if (IS_ITEM_GUID(guid) || IS_PLAYER_GUID(guid))
    {
        sHookMgr->HandleGossipSelectOption(GetPlayer(), guid, GetPlayer()->PlayerTalkClass->GetGossipOptionSender(gossipListId), GetPlayer()->PlayerTalkClass->GetGossipOptionAction(gossipListId), code, menuId);
        /*return;*/
    }
#endif

    Creature* unit = NULL;
    GameObject* go = NULL;
    if (IS_CRE_OR_VEH_GUID(guid))
    {
        unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
        if (!unit)
        {
            TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)));
            return;
        }
    }
    //Bot
    else if (IS_PLAYER_GUID(guid))
    {
        if (guid != _player->GetGUID())
        {
            TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - Player (GUID: %u) not found.", uint32(GUID_LOPART(guid)));
            return;
        }
    }
    //end Bot
    else if (IS_GAMEOBJECT_GUID(guid))
    {
        go = _player->GetMap()->GetGameObject(guid);
        if (!go)
        {
            TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - GameObject (GUID: %u) not found.", uint32(GUID_LOPART(guid)));
            return;
        }
    }
    else
    {
        TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for highguid %u. lowpart %u.", uint32(GUID_HIPART(guid)), uint32(GUID_LOPART(guid)));
        return;
    }

    // remove fake death
    if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
        GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);

    if ((unit && unit->GetCreatureTemplate()->ScriptID != unit->LastUsedScriptID) || (go && go->GetGOInfo()->ScriptId != go->LastUsedScriptID))
    {
        TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - Script reloaded while in use, ignoring and set new scipt id");
        if (unit)
            unit->LastUsedScriptID = unit->GetCreatureTemplate()->ScriptID;
        if (go)
            go->LastUsedScriptID = go->GetGOInfo()->ScriptId;
        _player->PlayerTalkClass->SendCloseGossip();
        return;
    }
    if (!code.empty())
    {
        if (unit)
        {
            unit->AI()->sGossipSelectCode(_player, menuId, gossipListId, code.c_str());
            if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str()))
                _player->OnGossipSelect(unit, gossipListId, menuId);
        }
        //Bot
        else if (guid == _player->GetGUID())
        {
            if (!_player->GetBotHelper())
            {
                TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - Player (GUID: %u) do not have a helper on gossip select.", uint32(GUID_LOPART(guid)));
                return;
            }
            //_player->GetBotHelper()->OnCodedGossipSelect(_player, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
        }
        //end Bot
        else
        {
            go->AI()->GossipSelectCode(_player, menuId, gossipListId, code.c_str());
            sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
        }
    }
    else
    {
        if (unit)
        {
            unit->AI()->sGossipSelect(_player, menuId, gossipListId);
            if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
                _player->OnGossipSelect(unit, gossipListId, menuId);
        }
        //Bot
        else if (guid == _player->GetGUID())
        {
            if (!_player->GetBotHelper())
            {
                TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - Player (GUID: %u) do not have a helper on gossip select.", uint32(GUID_LOPART(guid)));
                return;
            }
            _player->GetBotHelper()->OnGossipSelect(_player, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
        }
        //end Bot
        else
        {
            go->AI()->GossipSelect(_player, menuId, gossipListId);
            if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
                _player->OnGossipSelect(go, gossipListId, menuId);
        }
    }
}
 

Tommy

Founder
I honestly don't see why there is a return in the first place, it should've been handled differently instead of like it is now. I blame Rochet. :3
 

JoshCarter

Respected Member
Try removing the return first, if that solves it and subsequently does not break eluna gossip, then we'll remove it from the source. Otherwise we'll have to come up with a different way of handling it

Removing just the return did not fix it unfortunately. I commented out the entire section of code like so...

Code:
//#ifdef ELUNA
  //  if (IS_ITEM_GUID(guid) || IS_PLAYER_GUID(guid))
   // {
     //   sHookMgr->HandleGossipSelectOption(GetPlayer(), guid, GetPlayer()->PlayerTalkClass->GetGossipOptionSender(gossipListId), //GetPlayer()->PlayerTalkClass->GetGossipOptionAction(gossipListId), code, menuId);
  //      return;
    //}
//#endif

and recompiled. That did fix the issue I was having... I realize that isn't a fix by any means, but at least it is confirmation as to where the conflict is.
 

Rochet2

Moderator / Eluna Dev
I honestly don't see why there is a return in the first place
Hey hey!
Its there to prevent crashes if TC gets changed as well as further code to execute since TC hasnt codede those.
Also prevents the debug message .. that could be a bad thing though .. hmm.

it should've been handled differently instead of like it is now. I blame Rochet. :3
How would that be d:
And dont you try smiling at me !

It can be removed since its not really affecting anything.
 

Tommy

Founder
Removing just the return did not fix it unfortunately. I commented out the entire section of code like so...

Code:
//#ifdef ELUNA
  //  if (IS_ITEM_GUID(guid) || IS_PLAYER_GUID(guid))
   // {
     //   sHookMgr->HandleGossipSelectOption(GetPlayer(), guid, GetPlayer()->PlayerTalkClass->GetGossipOptionSender(gossipListId), //GetPlayer()->PlayerTalkClass->GetGossipOptionAction(gossipListId), code, menuId);
  //      return;
    //}
//#endif

and recompiled. That did fix the issue I was having... I realize that isn't a fix by any means, but at least it is confirmation as to where the conflict is.

I see. I'll get on it.

Hey hey!
Its there to prevent crashes if TC gets changed as well as further code to execute since TC hasnt codede those.
Also prevents the debug message .. that could be a bad thing though .. hmm.


How would that be d:
And dont you try smiling at me !

It can be removed since its not really affecting anything.

It's tay! Yeah, I'll change it around since I'm already messing with Eluna.
 

Tommy

Founder
Did an update: https://github.com/ElunaLuaEngine/Source/commit/16a7ed66ef076af6d70d0185c090a34f76005359

Sadly, this will still not resolve your issue. What will resolve it is replacing the MiscHandler.cpp gossip code checking for player is doing this:

Code:
#ifdef ELUNA
        else if (_player->GetGUID() == guid)
        {
[COLOR=#ff0000]           if (_player->GetBotHelper())
           {
               _player->GetBotHelper()->OnGossipSelect(_player, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
              return;
           }[/COLOR]
           
           sHookMgr->HandleGossipSelectOption(GetPlayer(), guid, GetPlayer()->PlayerTalkClass->GetGossipOptionSender(gossipListId), GetPlayer()->PlayerTalkClass->GetGossipOptionAction(gossipListId), code, menuId);
           return;
        }
        else if (item)
        {
            sHookMgr->HandleGossipSelectOption(GetPlayer(), guid, GetPlayer()->PlayerTalkClass->GetGossipOptionSender(gossipListId), GetPlayer()->PlayerTalkClass->GetGossipOptionAction(gossipListId), code, menuId);
            return;
        }
#endif

Basically, this is checking if the player has a bot helper before checking the Eluna code.
 
Status
Not open for further replies.
Top