Welcome to AC Web.
Results 1 to 13 of 13
  1. #1

    Gossip script action


    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    Hey there,
    Im trying to code a NPC buffer,
    I'm getting error

    It's supposed that action gets last id from AddGossipItemFor, but it is not.
    I gets the id in order from the list (in-game) as its shown in the npc gossip menu.

    So, my gossip hello, adds gossip item as action id 1, but it's taken as 0, because it's the first in the list in-game

    Any idea how to fix this?

    Code:
    class npc_custom : public CreatureScript
    {
    public:
        npc_custom() : CreatureScript("npc_custom"){}
    
        struct npc_customAI : public ScriptedAI
        {
            npc_customAI(Creature* creature) : ScriptedAI(creature){}
    
    
            bool GossipHello(Player *player)
            {
                AddGossipItemFor(player, GOSSIP_ICON_CHAT, "I'd like to browse your buffs!", GOSSIP_SENDER_MAIN, 1);
                SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, me->GetGUID());
                return true;
            }
    
            bool GossipSelect(Player *player, uint32 sender, uint32 action)
            {
                    ClearGossipMenuFor(player);
                switch (action)
                {
                case 1:
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Buff 1", GOSSIP_SENDER_MAIN, 2;
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Buff 2", GOSSIP_SENDER_MAIN, 3);
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Buff 3", GOSSIP_SENDER_MAIN, 4);
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Return to Main Menu", GOSSIP_SENDER_MAIN, 5);
                    SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, me->GetGUID());
                    break;
                case 2:
                    printf("\nPlayer got buff 1");
                    break;
                case 3:
                    printf("\nPlayer got buff 2");
                    break;
                case 4:
                    printf("\nPlayer got buff 3");
                    break;
                case 5:
                    printf("Main menu");
                    break;
                default:
                    CloseGossipMenuFor(player);
                    break;
                }
                return true;
            }
        };
    
        CreatureAI* GetAI(Creature* creature) const
        {
            return new npc_customAI(creature);
        }
    };
    
    void AddSC_npc_custom()
    {
        new npc_custom();
    }

  2. #2
    args are not sender, action in GossipSelect

    they are menuid, gossiplistid

    so change

    bool GossipSelect(Player *player, uint32 sender, uint32 action)
    to


    bool GossipSelect(Player *player, uint32 menuId, uint32 gossipListId)

    then

    uint32 action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);

    before ClearGossipMenuFor(player);

  3. #3

  4. #4
    Quote Originally Posted by Ckabot View Post
    args are not sender, action in GossipSelect

    they are menuid, gossiplistid

    so change

    bool GossipSelect(Player *player, uint32 sender, uint32 action)
    to


    bool GossipSelect(Player *player, uint32 menuId, uint32 gossipListId)

    then

    uint32 action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);

    before ClearGossipMenuFor(player);
    Well argument names does not care at all, you can name them "my_var",
    Visual Studio ain't giving me the function "GossipSelect", I don't know why, I mean, I wrote it and did not appear like I could use it, still did not show up any error (???)
    GossipListId is always = 0 if I click the first item on the gossip menu

    Code:
    Greetings $N
    
    * Click here to get some buffs >>> First item on gossip menu always gossipid = 0 (Does not care if I send it as ID = 10000 in C++, it gets auto = to 0)
    * Click here to get some items > Id = 1 (second item on list)
    So lets says I click on get some buffs, a new menu pops up

    Code:
    * Blessing of Kings >>> I set this ID = 10002 of course, 10000-10001 are used in Main menu, still is sent as ID = 0 because is the first in the list
    * Blessing of Wisdom >>> ID = 10003, sent as ID = 1, second in the gossip list
    I've readed it's the ScriptedAI error, you gotta take functions out of it, but I tried and does not work, GossipHello is not getting called outside the ScriptedAI struct.

    Now Going to your solution it fixed my index (ID) problem, but, lets say my "get your buff" gossip has ICON = CHAT, when it gets into sub_menu my 'blessing of kings' has ICON = BAG (example) and it shows the 'get your buff' ICON
    how to fix that?

    Thank you very much

    Quote Originally Posted by sexipriest View Post
    + missing overrides
    I don't find it any necessary, tried it, does not make any changes.
    What's its function, why should I implement that?

    - - - Updated - - -

    Well Ckabot your fix worked,
    but ICONS are bug af, any way to fix this?

    If I talk to another npc, then talk to this one, ICONS are from the other NPC lol

  5. #5


    Join Date
    Nov 2015
    Location
    Library of Elchea
    Posts
    675
    Quote Originally Posted by sexipriest View Post
    + missing overrides
    Keyword override tells the compiler and the reader that the function where it is used is overriding a method from its base class.
    While it is helpful for detecting errors before and during compiling, it won't change the way this script behaves.


    Quote Originally Posted by molinita View Post
    Well argument names does not care at all, you can name them "my_var",
    It is true that you can assign whatever names you see fit to arguments, however in large projects such as TC, it is good practice to use the pre-assigned argument names when defining a function. This will help your code look cleaner, more organized and easier to read as most developers are used to the already existing argument naming such as sender, action, menuId, gossipListId etc.

    To follow up on what CKabot wrote, your GossipSelect method should look like something like this

    Code:
    bool GossipSelect(Player *player, uint32 menuId, uint32 gossipListId)
    {
        ClearGossipMenuFor(player);
        uint32 sender = player->PlayerTalkClass->GetGossipOptionSender(gossipListId);
        uint32 action = player->PlayerTalkClass->GetGossipOptionAction(gossipListId);
    
         switch (action)
         {
                case 1:
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Buff 1", GOSSIP_SENDER_MAIN, 2;
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Buff 2", GOSSIP_SENDER_MAIN, 3);
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Buff 3", GOSSIP_SENDER_MAIN, 4);
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Return to Main Menu", GOSSIP_SENDER_MAIN, 5);
                    SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, me->GetGUID());
                    break;
                case 2:
                    printf("\nPlayer got buff 1");
                    break;
                case 3:
                    printf("\nPlayer got buff 2");
                    break;
                case 4:
                    printf("\nPlayer got buff 3");
                    break;
                case 5:
                    printf("Main menu");
                    break;
                default:
                    CloseGossipMenuFor(player);
                    break;
                }
                return true;
            }
    Last edited by Loud21; 12-11-2019 at 08:23 PM.

  6. #6
    ClearGossipMenuFor must be after you make action variable, otherwise GetGossipOptionAction will always return 0

  7. #7


    Join Date
    Nov 2015
    Location
    Library of Elchea
    Posts
    675
    Quote Originally Posted by Ckabot View Post
    ClearGossipMenuFor must be after you make action variable, otherwise GetGossipOptionAction will always return 0
    Thank you for the correction, king!

    Edit:
    This was my 666th post.
    Last edited by Loud21; 12-12-2019 at 03:32 PM.

  8. #8
    My code is working, but ICONS are bug as fuck.

    I mean having this gossip menu:

    Code:
    Greetings $N
    * I want to buy some buffs >>> With ICON_CHAT
    Opens a sub_menu

    Code:
    > Blessing of Kings >> Coded as ICON_BAG but shown as CHAT (because of first one "I want to buy some buffs")
    > Blessing of Wisdom >> Coded as ICON_BAG, shown correctly (but if got another menu down "I want some buffs" then gets bug too)
    I hope you guys get what I mean

  9. #9
    Post latest script

  10. #10
    Here,

    Gossip ID 0 (buffs) has ICON = CHAT
    Gossip ID's 1-3 and 9999 has ICON = DOT

    Once I click ID 0 (Buffs), submenu with ID's 1-3 and 9999 appear, they all ICON = DOT but first one (ID 1 = Buff 1) Has ICON = CHAT (gets same one as ID 0 (buffs)

    Code:
    void Gossip_MainMenu(Player *player)
            {
                AddGossipItemFor(player, GOSSIP_ICON_CHAT, "I'd like to browse your buffs!", GOSSIP_SENDER_MAIN, 0);
                SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, me->GetGUID());
            }
    
            bool GossipHello(Player *player)
            {
                Gossip_MainMenu(player);
    
                return true;
            }
    
            bool GossipSelect(Player *player, uint32 sender, uint32 action)
            {
                switch (player->PlayerTalkClass->GetGossipOptionAction(action))
                {
                case 0:
                    ClearGossipMenuFor(player);
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Buff 1", GOSSIP_SENDER_MAIN, 1, POPUP_TEXT, BASIC_BUFFS_COST, false);
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Buff 2", GOSSIP_SENDER_MAIN, 2, POPUP_TEXT, BASIC_BUFFS_COST, false);
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Buff 3", GOSSIP_SENDER_MAIN, 3, POPUP_TEXT, BASIC_BUFFS_COST, false);
                    AddGossipItemFor(player, GOSSIP_ICON_DOT, "Return to Main Menu", GOSSIP_SENDER_MAIN, 9999);
                    SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, me->GetGUID());
                    break;
                case 1:
                    printf("Buff 1");
                    CloseGossipMenuFor(player);
                    break;
                case 2:
                    printf("Buff 2");
                    CloseGossipMenuFor(player);
                    break;
                case 3:
                    printf("Buff 3");
                    CloseGossipMenuFor(player);
                    break;
                case 9999:
                    ClearGossipMenuFor(player);
                    Gossip_MainMenu(player);
                    break;
                default:
                    CloseGossipMenuFor(player);
                    break;
                }
                return true;

  11. #11
    apparently GOSSIP_ICON_DOT gives client issues https://github.com/azerothcore/azero...tlk/issues/618

    so it's not a core issue, client issue

  12. #12
    Quote Originally Posted by Ckabot View Post
    apparently GOSSIP_ICON_DOT gives client issues https://github.com/azerothcore/azero...tlk/issues/618

    so it's not a core issue, client issue
    Okay I will try to change that ICON and see what happens!
    thank you

    Oh, do you know how to int2string?
    Tried to #include <string.h> and ToString() but does not show

  13. #13

    REGISTER! (FREE)
    Registered members see less ads
    and also gain access to other great features.
    Quote Originally Posted by molinita View Post
    Okay I will try to change that ICON and see what happens!
    thank you

    Oh, do you know how to int2string?
    Tried to #include <string.h> and ToString() but does not show
    you were answered in your other thread but

    std::to_string(intVar); ///< converts intVar to an std::string

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •