Gossip scripting guide! menu

User Tag List

Results 1 to 4 of 4
  1. #1
    Le Froid's Avatar Contributor
    Reputation
    172
    Join Date
    Mar 2007
    Posts
    1,327
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Gossip scripting guide!

    I know what you must be thinking..."WHAT THE HELL IS GOSSIP SCRIPTING AND WHY AM I HERE"

    Well...gossip scripting does um..stuff.

    I will show a code and break it down, then explain how to compile it and stuff.

    Take a look at this:

    Code:
    class SCRIPT_DECL Warper : public GossipScript
    {
    public:
        void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
        {
            GossipMenu *Menu;
            objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
            Menu->AddItem(0, "Teleport Locations", 0);
            Menu->AddItem(0, "Flying Mounts", 13);
                Menu->SendTo(Plr);
        }
    
    
    
    void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
        {
            GossipMenu * Menu;
            switch(IntId)
            {
                         
                 case 0: //Teleport Locations
                          objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
            Menu->AddItem(0, "Stormwind", 1); 
            Menu->AddItem(0, "Ironforge", 2); 
            Menu->AddItem(0, "Exodar", 3); 
            Menu->AddItem(0, "Darnassus", 4);  
            Menu->AddItem(0, "Orgrimmar", 5);
            Menu->AddItem(0, "Thunder Bluff", 6);
            Menu->AddItem(0, "Silvermoon City", 7);
            Menu->AddItem(0, "Undercity", 8);
            Menu->AddItem(0, "Misc", 9);
            Menu->AddItem(0, "[Back]", 12);
            Menu->SendTo(Plr);
            break;
            
                 case 1:  //stormwind
                 {
                     Plr->SafeTeleport(0, 0, -8831.61, 622.666, 93.7787, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 2:  //ironforge
                 {
                     Plr->SafeTeleport(0, 0, -4804.45, -1101.14, 498.807, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 3:  //exodar
                 {
                     Plr->SafeTeleport(530, 0, -3796.24, -11710.9, -105.45, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 4:  //darnassus
                 {
                     Plr->SafeTeleport(1, 0, 9952.07, 2278.46, 1341.39, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 5:  //orgrimmar
                 {
                     Plr->SafeTeleport(1, 0, 1499.55, -4406.91, 23.1642, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 6:  //TB
                 {
                     Plr->SafeTeleport(1, 0, -1195.88, -56.5582, 160.034, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 7:  //silvermoon
                 {
                     Plr->SafeTeleport(530, 0, 9492.45, -7279.12, 14.3036, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 8:  //undercity
                 {
                     Plr->SafeTeleport(0, 0, 1615.1, 239.786, -62.0774, 0);
                     Plr->Gossip_Complete();
                 }break;
                 
             case 9:  //misc
                  {
                    objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
                    
                    Menu->AddItem(0, "Shopping Mall", 10);
                    Menu->AddItem(0, "Leveling Road", 11);
                    Menu->AddItem(0, "[Back]", 12);
                    Menu->SendTo(Plr);
                    }
               break;
               
               case 10:  //mall
                    {
                     Plr->SafeTeleport(1, 0, 16222.6, 16265.9, 14.2085, 0);
                     Plr->Gossip_Complete();
                     }
                     break;
                     
               case 11:  //leveling road
                    {
                     Plr->SafeTeleport(0, 0, -4086.36, -2610.95, 47.0143, 0);
                     Plr->Gossip_Complete();
                     }
                     break;
               
               case 12:  // [back]
                         GossipHello(pObject, Plr, true);
                         break;
               
               case 13:  // mounts
                         {
                           objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
                           Menu->AddItem(0, "Swift Gryphon", 14);
                           Menu->AddItem(0, "Swift Broom", 15);
                           Menu->AddItem(0, "Netherwing Drake", 16);
                           Menu->AddItem(0, "[Back]", 12);
                           Menu->SendTo(Plr);
                           }
                     break;
                     
               case 14: //gryphon         
                       {
                      // Does Unit::castSpell(32292,0,0,0) work?this part and   
                                     objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
                        Plr->addSpell(32292);  //cast spell?
                        Plr->removeSpell(32292,0,0,0);  //remove spell?
                       Menu->AddItem(0, "[Back]", 12);
                       Menu->SendTo(Plr);
                       }
                       break;                        // beyond is semi broken
    
    
                       }
                       break;
                       
               case 15: // Broom
                     {
                        objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
                        Plr->addSpell(42668);  //cast spell?
                        Plr->removeSpell(42668,0,0,0);  //remove spell?
                       Menu->AddItem(0, "[Back]", 12);
                       Menu->SendTo(Plr);
                       }
                       break;
                       
               case 16: // nd
               {
                        objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
                        Plr->addSpell(41513);  //cast spell?
                        Plr->removeSpell(41513,0,0,0);  //remove spell?
                       Menu->AddItem(0, "[Back]", 12);
                       Menu->SendTo(Plr);
                       }
                       break;
                       
    
         
    
    
    }
    }
    };
    This is a simple item that when you right click on it, it can teleport you OR add flying mounts (last part is 1/2 working, I picked a random script I'm working on)

    Now- Explaining it!

    Code:
    class SCRIPT_DECL Warper : public GossipScript
    {
    public:
        void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
    This is explaining the basic properties of the item, making it a public gossip script and naming it "Warper"

    The next part:
    Code:
       GossipMenu *Menu;
            objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
            Menu->AddItem(0, "Teleport Locations", 0);
            Menu->AddItem(0, "Flying Mounts", 13);
                Menu->SendTo(Plr);
    This just says when you right click on the "magic" item it will give 2 options:
    Teleport or use the (broken) flying mounts.
    Whenever you add an item do the following:

    Code:
    Menu->AddItem
    is always used so it works ;p
    Code:
    (0, "name here", case # here);
    now this can get confusing.. the first number you see is the icon next to the item. 0 means it is a chat bubble. Experiment a little! The "name here" is what you want the menu item to be called. Now..the case # can be from 1-9999999. It simply identifies where your code is and what to do.


    TAKE A 3 MIN BREAK :P


    Code:
    
    void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
        {
            GossipMenu * Menu;
            switch(IntId)
            {
                         
    Now this just well..in an understandable term means you can start the options (or case) next


    Code:
    case 0: //Teleport Locations
                          objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
            Menu->AddItem(0, "Stormwind", 1); 
            Menu->AddItem(0, "Ironforge", 2); 
            Menu->AddItem(0, "Exodar", 3); 
            Menu->AddItem(0, "Darnassus", 4);  
            Menu->AddItem(0, "Orgrimmar", 5);
            Menu->AddItem(0, "Thunder Bluff", 6);
            Menu->AddItem(0, "Silvermoon City", 7);
            Menu->AddItem(0, "Undercity", 8);
            Menu->AddItem(0, "Misc", 9);
            Menu->AddItem(0, "[Back]", 12);
            Menu->SendTo(Plr);
            break;


    The first part (
    case 0: //Teleport Locations objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr)

    Means when you click on case 0: (teleport locations) you will see a new menu.

    The rest is what you will see next and what I already explained

    Code:
    
                 case 1:  //stormwind
                 {
                     Plr->SafeTeleport(0, 0, -8831.61, 622.666, 93.7787, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 2:  //ironforge
                 {
                     Plr->SafeTeleport(0, 0, -4804.45, -1101.14, 498.807, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 3:  //exodar
                 {
                     Plr->SafeTeleport(530, 0, -3796.24, -11710.9, -105.45, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 4:  //darnassus
                 {
                     Plr->SafeTeleport(1, 0, 9952.07, 2278.46, 1341.39, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 5:  //orgrimmar
                 {
                     Plr->SafeTeleport(1, 0, 1499.55, -4406.91, 23.1642, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 6:  //TB
                 {
                     Plr->SafeTeleport(1, 0, -1195.88, -56.5582, 160.034, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 7:  //silvermoon
                 {
                     Plr->SafeTeleport(530, 0, 9492.45, -7279.12, 14.3036, 0);
                     Plr->Gossip_Complete();
                 }break;
    
             case 8:  //undercity
                 {
                     Plr->SafeTeleport(0, 0, 1615.1, 239.786, -62.0774, 0);
                     Plr->Gossip_Complete();
                 }break;
                 
             case 9:  //misc
                  {
                    objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
                    
                    Menu->AddItem(0, "Shopping Mall", 10);
                    Menu->AddItem(0, "Leveling Road", 11);
                    Menu->AddItem(0, "[Back]", 12);
                    Menu->SendTo(Plr);
                    }
               break;
               
               case 10:  //mall
                    {
                     Plr->SafeTeleport(1, 0, 16222.6, 16265.9, 14.2085, 0);
                     Plr->Gossip_Complete();
                     }
                     break;
                     
               case 11:  //leveling road
                    {
                     Plr->SafeTeleport(0, 0, -4086.36, -2610.95, 47.0143, 0);
                     Plr->Gossip_Complete();
                     }
                     break;
               
               case 12:  // [back]
                         GossipHello(pObject, Plr, true);
                         break;
               


    Simply says what each teleport will do. case 12 is different though. what gossiphello (bla bla bla) does is sends you back to the first option-teleport or mount.

    Everything else there like Plr->SafeTeleport(0, 0, -4086, -2610, 47, 0);
    Plr->Gossip_Complete();

    means The plr (player who clicked it) will teleport, and the menu will disappear

    ONE MORE BREAK :P


    Code:
     case 13:  // mounts
                         {
                           objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
                           Menu->AddItem(0, "Swift Gryphon", 14);
                           Menu->AddItem(0, "Swift Broom", 15);
                           Menu->AddItem(0, "Netherwing Drake", 16);
                           Menu->AddItem(0, "[Back]", 12);
                           Menu->SendTo(Plr);
                           }
                     break;
                     
               case 14: //gryphon         
                       {
                      // Does Unit::castSpell(32292,0,0,0) work?this part and   
                                     objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
                        Plr->addSpell(32292);  //cast spell?
                        Plr->removeSpell(32292,0,0,0);  //remove spell?
                       Menu->AddItem(0, "[Back]", 12);
                       Menu->SendTo(Plr);
                       }
                       break;                        // beyond is semi broken
    
    
                       }
                       break;
                       
               case 15: // Broom
                     {
                        objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
                        Plr->addSpell(42668);  //cast spell?
                        Plr->removeSpell(42668,0,0,0);  //remove spell?
                       Menu->AddItem(0, "[Back]", 12);
                       Menu->SendTo(Plr);
                       }
                       break;
                       
               case 16: // nd
               {
                        objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr);
                        Plr->addSpell(41513);  //cast spell?
                        Plr->removeSpell(41513,0,0,0);  //remove spell?
                       Menu->AddItem(0, "[Back]", 12);
                       Menu->SendTo(Plr);
                       }
                       break;
                       
    
         
    
    
    }
    }
    };


    the first case is the menu for the item.

    Everything else is unorganised and (for now) just teaches you the spell for the mount without casting, then unlearning it. if you saw the //Unit::spell bla bla bla that means Soon when i find out that code I can work with it :P



    After this.... I put the code in GuardGossip.cpp in the ascent svn (src/scripts/src/gossipscripts) because I am too lazy to add it into its own .dll

    Then I compile ascent as normal and when you MAKE the item, right click on it, then you will see the code

    For all the item stats...put everything as "0" except name and stuff you want to edit there too.

    WILL EDIT

    EDIT after 30 seconds :|

    How to register the script:

    put
    Code:
    GossipScript * item = (GossipScript*) new Warper();
    where everything else looks like that. it abbreviates the code and lets you register it


    Code:
    mgr->register_item_gossip_script(90005,item);
    this registers the script as the item and 90005 means what the item ID is and item is what you put in above.
    Last edited by Le Froid; 12-11-2007 at 09:39 PM.

    Gossip scripting guide!
  2. #2
    TripZone's Avatar Active Member
    Reputation
    44
    Join Date
    Sep 2007
    Posts
    70
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ty for this awsome post woot!

  3. #3
    Le Froid's Avatar Contributor
    Reputation
    172
    Join Date
    Mar 2007
    Posts
    1,327
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry for wall of text btw :P

  4. #4
    killaor's Avatar Member
    Reputation
    1
    Join Date
    Nov 2007
    Posts
    79
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thnx, looks like it's gret

Similar Threads

  1. [C++] Gossip Example Script/Guide
    By AzolexX in forum WoW EMU Guides & Tutorials
    Replies: 2
    Last Post: 05-24-2009, 07:45 AM
  2. [Guide] Lua Scripting Guide is here [Updating]
    By Illidan1 in forum WoW EMU Guides & Tutorials
    Replies: 93
    Last Post: 11-04-2008, 06:56 PM
  3. Basic SQL Scripting Guide
    By R0flz0r in forum WoW EMU Guides & Tutorials
    Replies: 7
    Last Post: 04-17-2008, 06:34 PM
  4. LuA SCRIPTING (guide)
    By Dee2001 in forum WoW EMU Guides & Tutorials
    Replies: 5
    Last Post: 03-05-2008, 11:43 AM
  5. GM Scripting Guides by me (there is alot of Scripting guides by me in here)
    By Illidan1 in forum WoW EMU Guides & Tutorials
    Replies: 26
    Last Post: 11-27-2007, 04:46 PM
All times are GMT -5. The time now is 10:41 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search