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

[SOLVED] Item Gossip

Status
Not open for further replies.

Mookz

Epic Member
Item Gossip error when trying to apply

Says error corrupt at line 132 or 130

I tried adding a space the at end and tried Tommys diff that he posted in thread.

Would be nice if somebody could tell me how xD
 

Tommy

Founder
Honestly, it isn't very hard to add everything manually.

Under GameObject* go = NULL; add inside "void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)"

Code:
Item* item = NULL;

MiscHandler.cpp, search for "void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)" (Line 89 - Latest TC). Once you found it, you should already see "if (IS_CRE_OR_VEH_GUID(guid))" (Line 105 - 127 - Latest TC). After "if (IS_CRE_OR_VEH_GUID(guid))", put:

Code:
     else if (IS_PLAYER_GUID(guid))
     {
         if(_player->GetGUID() == guid && _player->PlayerTalkClass->GetGossipMenu().GetMenuId() == menuId)
         {
             if(code.empty())
                 sScriptMgr->OnGossipSelect(_player, menuId, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
             else
                 sScriptMgr->OnGossipSelectCode(_player, menuId, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
         }
         return;
     }
     else if(IS_ITEM_GUID(guid))
     {
         if(Item* item = _player->GetItemByGuid(guid))
         {
             if(code.empty())
                 sScriptMgr->OnGossipSelect(_player, item, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
             else
                 sScriptMgr->OnGossipSelectCode(_player, item, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
         }
         return;
     }

So now it should look like:

Code:
    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;
        }
    }

[COLOR=#00ff00]     else if (IS_PLAYER_GUID(guid))
     {
         if(_player->GetGUID() == guid && _player->PlayerTalkClass->GetGossipMenu().GetMenuId() == menuId)
         {
             if(code.empty())
                 sScriptMgr->OnGossipSelect(_player, menuId, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
             else
                 sScriptMgr->OnGossipSelectCode(_player, menuId, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
         }
         return;
     }
     else if(IS_ITEM_GUID(guid))
     {
         if(Item* item = _player->GetItemByGuid(guid))
         {
             if(code.empty())
                 sScriptMgr->OnGossipSelect(_player, item, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId));
             else
                 sScriptMgr->OnGossipSelectCode(_player, item, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str());
         }
         return;
     }[/COLOR]


    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;
    }


In ScriptMgr.h on line (369 - LatestTC -- is ItemScript that holds virtual functions). Under line 389 (Latest TC), add:

Code:
        virtual void OnGossipSelect(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/) { }
        virtual void OnGossipSelectCode(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }

After that, we still need to do one more thing in ScriptMgr.h. Go to line 914 (Latest TC) and you should see "public: /* ItemScript */". Below line 919 (Latest TC) add:

Code:
        void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action);
        void OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code);


After you have done that, we need to edit ScriptMgr.cpp (Last one) - Go to line 680 (Latest TC) and at the end of that function put:

Code:
void ScriptMgr::OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action)
{
    ASSERT(player);
    ASSERT(item);

    FOREACH_SCRIPT(ItemScript)->OnGossipSelect(player, item, sender, action);
}

void ScriptMgr::OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code)
{
    ASSERT(player);
    ASSERT(item);

    FOREACH_SCRIPT(ItemScript)->OnGossipSelectCode(player, item, sender, action, code);
}

In ScriptMgr.h, Add this on line 687 or below:

Code:
    // Called when a player selects an option in a player gossip window
    virtual void OnGossipSelect(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/) { }

    // Called when a player selects an option in a player gossip window
    virtual void OnGossipSelectCode(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }

Last one in ScriptMgr.h, on line 1020 or below, add:

Code:
    void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action);
    void OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code);

Add this in ScriptMgr.cpp:

Code:
void ScriptMgr::OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action)
{
    ASSERT(player);

	FOREACH_SCRIPT(PlayerScript)->OnGossipSelect(player, menu_id, sender, action);
}

void ScriptMgr::OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code)
{
    ASSERT(player);

    FOREACH_SCRIPT(PlayerScript)->OnGossipSelectCode(player, menu_id, sender, action, code);
}

Alright, you should be done! However, if you need help with the lines, I have something below for you to click on to see the exact line:

MiscHandler.cpp - "void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recvData)" (Line 89 - Latest TC):

https://github.com/TrinityCore/TrinityCore/blob/master/src/server/game/Handlers/MiscHandler.cpp#L89

MiscHandler.cpp - if (IS_CRE_OR_VEH_GUID(guid))" (Line 105 - 127 - Latest TC)

https://github.com/TrinityCore/Trin...erver/game/Handlers/MiscHandler.cpp#L105-L127

MiscHandler.cpp - Under Line (113) Add the Item code:

https://github.com/TrinityCore/TrinityCore/blob/master/src/server/game/Handlers/MiscHandler.cpp#L113

ScriptMgr.h - Go to line 914 (Latest TC) and you should see "public: /* ItemScript */"

https://github.com/TrinityCore/TrinityCore/blob/master/src/server/game/Scripting/ScriptMgr.h#L914

ScriptMgr.h - on line (369 - LatestTC -- is ItemScript that holds virtual functions).

https://github.com/TrinityCore/TrinityCore/blob/master/src/server/game/Scripting/ScriptMgr.h#L369

ScriptMgr.h - Under line 389 (Latest TC), add:

https://github.com/TrinityCore/TrinityCore/blob/master/src/server/game/Scripting/ScriptMgr.h#L389

ScriptMgr.cpp - Go to line 680 (Latest TC) and at the end of that function put:

https://github.com/TrinityCore/TrinityCore/blob/master/src/server/game/Scripting/ScriptMgr.cpp#L680

END OF FUNCTION:

https://github.com/TrinityCore/TrinityCore/blob/master/src/server/game/Scripting/ScriptMgr.cpp#L687


I added the code from the Item Gossip thread, so if there's an issue don't hate on me. :3
 
Last edited:

ToxicDev

Banned
The item gossip script original originated from rochet. I made a modifcation of it and gave it to reloac who then released it here. So yeh its very possible its not coded correctly and might have issues. However i have not ran into any but i think rochet said it disables eluna's item gossip.
 

Tommy

Founder
The item gossip script original originated from rochet. I made a modifcation of it and gave it to reloac who then released it here. So yeh its very possible its not coded correctly and might have issues. However i have not ran into any but i think rochet said it disables eluna's item gossip.

Well, I don't think he's using Eluna -- so that isn't a big deal. The item gossip thread in the C++ section, the diff needs to be fixed up because it has Eluna stuff in it, when it doesn't need that in there. Anyway, with the new changes I did to Eluna on Item/Player gossip, you can easily add this without it disrupting Eluna's stuff (If added correctly)..
 

Tommy

Founder
I don't see how you added these wrong. >.>

Line 369+:

RED = WRONG/ERROR:

Code:
class ItemScript : public ScriptObject
[COLOR=#ff0000]        virtual void OnGossipSelect(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/) { }
        virtual void OnGossipSelectCode(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }
{[/COLOR]
    protected:
 
        ItemScript(const char* name);
 
    public:
 
        bool IsDatabaseBound() const FINAL { return true; }
 
        // Called when a dummy spell effect is triggered on the item.
        virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Item* /*target*/) { return false; }
 
        // Called when a player accepts a quest from the item.
        virtual bool OnQuestAccept(Player* /*player*/, Item* /*item*/, Quest const* /*quest*/) { return false; }
 
        // Called when a player uses the item.
        virtual bool OnUse(Player* /*player*/, Item* /*item*/, SpellCastTargets const& /*targets*/) { return false; }
 
        // Called when the item expires (is destroyed).
        virtual bool OnExpire(Player* /*player*/, ItemTemplate const* /*proto*/) { return false; }
};

Lime = Correct:

Code:
class ItemScript : public ScriptObject
{
protected:
    ItemScript(const char* name);
public:
    bool IsDatabaseBound() const FINAL { return true; }
 
     // Called when a dummy spell effect is triggered on the item.
    virtual bool OnDummyEffect(Unit* /*caster*/, uint32 /*spellId*/, SpellEffIndex /*effIndex*/, Item* /*target*/) { return false; }
 
    // Called when a player accepts a quest from the item.
    virtual bool OnQuestAccept(Player* /*player*/, Item* /*item*/, Quest const* /*quest*/) { return false; }
 
    // Called when a player uses the item.
    virtual bool OnUse(Player* /*player*/, Item* /*item*/, SpellCastTargets const& /*targets*/) { return false; }
 
    // Called when the item expires (is destroyed).
    virtual bool OnExpire(Player* /*player*/, ItemTemplate const* /*proto*/) { return false; }
    
[COLOR=#00ff00]    virtual void OnGossipSelect(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/) { }
    virtual void OnGossipSelectCode(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { }[/COLOR]
};
 

Mookz

Epic Member
This time I get:

Code:
Linking...
LINK : fatal error LNK1181: cannot open input file '..\game\Release\game.lib'
Build log was saved at "file://c:\Trinity\Build\src\server\worldserver\worldserver.dir\Release\BuildLog.htm"
worldserver - 1 error(s), 0 warning(s)
 

Tommy

Founder
This time I get:

Code:
Linking...
LINK : fatal error LNK1181: cannot open input file '..\game\Release\game.lib'
Build log was saved at "file://c:\Trinity\Build\src\server\worldserver\worldserver.dir\Release\BuildLog.htm"
worldserver - 1 error(s), 0 warning(s)

That's because you still have error(s) in the game solution so there isn't a game.lib for the worldserver to compile with.
 

Mookz

Epic Member
Code:
..\..\..\..\Source\src\server\game\Handlers\MiscHandler.cpp(119) : error C2664: 'void ScriptMgr::OnGossipSelect(Player *,Item *,uint32,uint32)' : cannot convert parameter 2 from 'uint32' to 'Item *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\..\..\..\Source\src\server\game\Handlers\MiscHandler.cpp(121) : error C2664: 'void ScriptMgr::OnGossipSelectCode(Player *,Item *,uint32,uint32,const char *)' : cannot convert parameter 2 from 'uint32' to 'Item *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

Mischandler.cpp
http://pastebin.com/4hVBRCqK

Now transmog sucks dick

http://pastebin.com/RFBA7kti

Just going to reapply transmog.
 

Tommy

Founder
Code:
..\..\..\..\Source\src\server\game\Handlers\MiscHandler.cpp(119) : error C2664: 'void ScriptMgr::OnGossipSelect(Player *,Item *,uint32,uint32)' : cannot convert parameter 2 from 'uint32' to 'Item *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
..\..\..\..\Source\src\server\game\Handlers\MiscHandler.cpp(121) : error C2664: 'void ScriptMgr::OnGossipSelectCode(Player *,Item *,uint32,uint32,const char *)' : cannot convert parameter 2 from 'uint32' to 'Item *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

Mischandler.cpp
http://pastebin.com/4hVBRCqK

Now transmog sucks dick

http://pastebin.com/RFBA7kti

Just going to reapply transmog.

No point in reapplying it just because of a few configuration errors. If you want do, I'll fix these the first thing when I get up tomorrow. It is getting late now, so leave it like it is at the moment.
 
Status
Not open for further replies.
Top