Likes: 0
Results 1 to 3 of 3
-
07-07-09, 02:30 AM #1
[C++] Create A Custom Teleporter NPC
Register to remove this adwell this is fully done in notepad for me cause the computer i do my programming and stuff is broken and i gotta buy a new copy of windows
for it but hey alteast im trying here
ok
type this into your notepad or visual c++ or what ever your gonna use
Code:Code:#include "StdAfx.h" #include "Setup.h" #ifdef WIN32 #pragma warning(disable:4305) #endif
that is your opening text
Next type this under that
Code:Code:class SCRIPT_DECL GlobalNPC : public GossipScript { public: void GossipHello(Object * pObject, Player* Plr, bool AutoSend); void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code); void GossipEnd(Object * pObject, Player* Plr); void Destroy() { delete this; } };
Code:Code:void GlobalNPC::GossipHello(Object * pObject, Player* Plr, bool AutoSend) { GossipMenu *Menu; objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
"i got bored of old color so i went to red"
Code:Code:if(Plr->getRace()== 10||Plr->getRace()== 2||Plr->getRace()== 6||Plr->getRace()== 8||Plr->getRace()== 5)
Code:Code:{Menu->AddItem(0, "Horde Cities", 1);}else{Menu->AddItem(1, "Alliance Cities", 2);}
Code:Code:Menu->AddItem(2, "Global Locations", 80);
lets break it down
Menu- its stating that its part of the menu obvious right
->pointing to the command i guess lol thats my easy description
AddItem - This is what will add this to be selectable on the menu as a port or another menu with more ports
the 2 is just a number for the icon that will be next to it i usually put 0 for it cuase im cool like that
"Global Locations" - that is the name of the menu or port
then 80 - that is the case that that menu links to
ok lets create our own little custom one here just so we understand it
now do what ever you want for yours dont scroll down past the line below til you finish your menu peice
_
ok for my creation i got
Menu->AddItem(4, "ZOMG this guide is awesome", 20);
weird eh,
but if your menu is kind like mine then Good job
now before we go any further let me mention the case thing i said earlier
on my example i put the case as 20
so somewhere in my script will be
Code:Code:case 20: //Magers guide
but if you dont well then your screwed lol j/k
the case is what the link will send you to
if the case is a teleport it will port you to where its supposed to
if its a menu you get to go to another menu again
do you kinda understand??
anyway after you made all the menu items you want for the first thing
(btw dont make the Case the same as others or else it will do the same thing)
after your done with your main menu type
Code:Code:if(AutoSend) Menu->SendTo(Plr); } void GlobalNPC::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code) { Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL; if(pCreature==NULL) return; GossipMenu * Menu; switch(IntId) {
Code:if(Plr->getRace()== 10||Plr->getRace()== 2||Plr->getRace()== 6||Plr->getRace()== 8||Plr->getRace()== 5) {Menu->AddItem(0, "Horde Cities", 1);}else{Menu->AddItem(1, "Alliance Cities", 2);} Menu->AddItem(3, "Azeroth Instances", 30); Menu->AddItem(4, "Outland Instances", 50); Menu->AddItem(5, "Shattrath", 20); Menu->AddItem(6, "Gurubashi Arena", 21); Menu->AddItem(8, "Buff me up, baby!", 96); Menu->AddItem(7, "Make This Place Your Home", 95); Menu->AddItem(9, "Remove Resurrection Sickness", 97); if(AutoSend) Menu->SendTo(Plr); } void GlobalNPC::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code) { Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL; if(pCreature==NULL) return; GossipMenu * Menu; switch(IntId) {
time for Case 0:
Code:Code:case 0: GossipHello(pObject, Plr, true); break;
now we go to case 1
now one of your menu items that you made should have started with case 1 if not change it or just do a different case its all the same thing
now if you want the case to send you to another menu just make it look like this a bit
Code:Code:case 1: { objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); Menu->AddItem(5, "Silvermoon", 4); Menu->AddItem(5, "Orgrimmar", 5); Menu->AddItem(5, "Thunder Bluff", 6); Menu->AddItem(5, "Undercity", 7); Menu->SendTo(Plr); } break;
I taught the Menu items so i dont need to describe that again
and the Menu->SendTo(Plr);
just make it to where it shows up
all you need to know now is to make it port
that would be a simple command
so lets base off of Menu->AddItem(5, "Thunder Bluff", 6);
so now we will put
Code:case 6://ThunderBluff { Plr->EventTeleport(1, -1304.569946, 205.285004, 68.681396); } break;
Plr->EventTeleport - that is innitiating that the Plr or Player is going have the event teleport used on him/her
then the coords are where you end up at
now just type this at the bottom of this and your done
Code:void GlobalNPC::GossipEnd(Object * pObject, Player* Plr) { GossipScript::GossipEnd(pObject, Plr); } void SetupGlobalNPC(ScriptMgr * mgr) { GossipScript * gs = (GossipScript*) new GlobalNPC(); mgr->register_gossip_script(NPC ID) }
if you need help compiling look to another guide please
Well Guys i hoped you liked it and please leave feed back
i wanna know what you guys think
› See More: [C++] Create A Custom Teleporter NPCLast edited by Apple; 16-02-10 at 10:46 PM.
-
09-09-09, 12:32 PM #2
-
14-11-09, 04:10 PM #3
Register to remove this adi will try this now. But i have to say the colors you used to make this tutorial are so ugly !