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:
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)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; } } };
Now- Explaining it!
This is explaining the basic properties of the item, making it a public gossip script and naming it "Warper"Code:class SCRIPT_DECL Warper : public GossipScript { public: void GossipHello(Object* pObject, Player * Plr, bool AutoSend)
The next part:
This just says when you right click on the "magic" item it will give 2 options: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);
Teleport or use the (broken) flying mounts.
Whenever you add an item do the following:
is always used so it works ;pCode:Menu->AddItem
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.Code:(0, "name here", case # here);
TAKE A 3 MIN BREAK :P
Now this just well..in an understandable term means you can start the options (or case) nextCode:void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code) { GossipMenu * Menu; switch(IntId) {
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:
putwhere everything else looks like that. it abbreviates the code and lets you register itCode:GossipScript * item = (GossipScript*) new Warper();
this registers the script as the item and 90005 means what the item ID is and item is what you put in above.Code:mgr->register_item_gossip_script(90005,item);