ArcEmu: [c++] Simple Teleportitem/teleportnpc - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to join channel #arcemu /server /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[c++] Simple Teleportitem/teleportnpc

#1 User is offline   sleinzelmann 

  • Member
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 24-September 10
  • Gender:Male

Posted 17 April 2011 - 02:51 PM

Hi Everyone

Today I'm gonna Teach you, how to script a TeleportItem or a TeleportNPC in C++.

What u need to complete this Tutorial?

- The Will to understand my Crappy English;
- Some basic idea about C++;
- Time

Let's Start

What we need to do first:
(This is done in Microsoft Visual Studio)
We need to create a new c++ File.
We go into arcGossipScript and then to scripts. We right-click Scripts and choose Add -> New Item.
Create a new cpp file in \src\scripts\src\GossipScripts.

Now we can start with the code.

First we need to write

#include "Setup.h"

at the top of the Script.
This includes the header file Setup.h, need to do this everytime making a gossip script.

now We Create a new Class. If you dont know what a class is, then use Google ^^

class GossipPortNpc: public Arcemu::Gossip::Script[code]

What this does? Its simple. Create a class with Name GossipPortNpc, you can change that into what you wanna have it. The Public Arcemu::Gossip::Script means, that our Class learn the methods from Arcemu::Gossip::Script. This is Important to use things as Teleport the Player.

[code]void OnHello(Object* pObject, Player* Plr)

		Arcemu::Gossip::Menu menu(pObject->GetGUID(), 1);
		menu.AddItem( Arcemu::Gossip::ICON_CHAT, "Playertreff", 1);
		menu.AddItem( Arcemu::Gossip::ICON_CHAT, "Cities", 2);
		menu.AddItem( Arcemu::Gossip::ICON_INTERACT_1, "Wiederbelebungsnachwirkungen entfernen",3);
		menu.AddItem( Arcemu::Gossip::ICON_BATTLE, "Heilen", 4);
		menu.AddItem( Arcemu::Gossip::ICON_INTERACT_2, "Buffen", 5);

Damn, what does this **** mean?

Okey i'll explain you :D

void OnHello ==> if you speak with the NPC or rightclick an item, then whats inside the OnHello will happen.

(Object* pObject, Player* Plr) dont know how to explain in english sorry. But I think its not really important to know that at this point ^^

Arcemu::Gossip::Menu menu(pObject->GetGUID(), 1); ==> This creates a Menu. The Name of the Menu is menu. The Numer 1 means TextID 1. Just use 1 for it.

menu.AddItem( Arcemu::Gossip::ICON_CHAT, "Playertreff", 1); ==> This adds a Line into our Menu. Text is Playertreff, and the Icon standing infront of the Text is the white Chat Icon. The Number (in this example 1) is usefull to let the computer know what to do if the player clicks on the first option.

menu.Send(plr) ==> sends the created Menu to the Player.

void OnSelectOption(Obejct* pObject, Player* Plr, uint32 Id, const char * Entered Code)
case 1:
{ Plr->SafeTeleport( 1, 0, -11821.4f, -4760.38f, 7.011f, 2.3f);
case 2:
Arcemu::Gossip::Menu menu1(pObject->GetGUID(), 1);
			if (Plr->getRace() == 1 || Plr->getRace() == 3 || Plr->getRace() == 4 || Plr->getRace() == 7 || Plr->getRace() == 11)
			{	Arcemu::Gossip::Menu menu1(pObject->GetGUID(), 1);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Sturmwind", 50);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Eisenschmiede", 51);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Darnassus", 52);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Exodar", 53);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Shattrath", 54);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Dalaran", 55);

			if (Plr->getRace() == 2 || Plr->getRace() == 5 || Plr->getRace() == 6 || Plr->getRace() == 8 || Plr->getRace() == 10)
			{	Arcemu::Gossip::Menu menu1(pObject->GetGUID(), 1);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Orgrimmar", 56);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Donnerfels", 57);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Unterstadt", 58);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Silbermond", 59);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Shattrath", 54);
				menu1.AddItem( Arcemu::Gossip::ICON_CHAT, "Dalaran", 55);
case 3:
			Plr->removeSpell(15007, false, false, 0);
case 4:
case 5:
                        Plr->CooldownCheat = true;
			Plr->CastTimeCheat = true;
			Plr->CastSpell(Plr, 56520, false);
                        Plr->CastSpell(Plr, 48161, false);
			Plr->CooldownCheat = false;
			Plr->CastTimeCheat = false;

//Here you would have to write the Case 50-60 for the Cities Teleport, same thing as Case 1, just different Coordinates.


Hmm So what that this thing mean? I'll explain you with my Crappy English.

void OnSelectOption(Obejct* pObject, Player* Plr, uint32 Id, const char * Entered Code) ==> If you click on a Option in the Menu we created.

Plr->SafeTeleport( 1, 0, -11821.4f, -4760.38f, 7.011f, 2.3f); ==> Teleports the Player ( Map ID, ZoneID, XPosition, YPosition, ZPosition, Rotation) You can get the Numbers through .gps command ingame.
Arcemu::Gossip::Menu::Complete(Plr); ==> Close The Menu

case 2:

} ==> Look if the Player is Alliance or Horde, to create a new Menu with the Cities.

Plr->addSpell(15007); ==> Learns a spell
Plr->removeSpell(15007, false, false, 0); ==> Unlearn a Spell. This code is to remove Rebirth Debuff.

case 4:
} ==> Heal the Player. Set the Health to 100 Percent.

case 5:
Plr->CooldownCheat = true; ==> Player can cast Spells without Cooldown
Plr->CastTimeCheat = true; ==> Player can Cast Instant
Plr->CastSpell(Plr, 56520, false); ==> Player casts a Buff on himself
Plr->CastSpell(Plr, 48161, false); ==> Same
Plr->CooldownCheat = false; ==> Deactivate The CooldownCheat
Plr->CastTimeCheat = false; ==> Deactivate The CastTimeCheat

Next thing to add is:
void Destroy() { delete this; }

Dont know what this means in English, but has something to do with Pointers.

Lets move on

//For a Teleport NPC
void SetupPortNPC(ScriptMgr * mgr)
	mgr->register_creature_gossip(50130, new SameNameAsClass);		// PortNPC
//For an Item

void SetupPortItem(ScriptMgr * mgr)
	mgr->register_item_gossip(85666, new SameNameAsClass);		// PortItem

This Is To Register The Script. Choose the one you need. register_item_gossip for an Teleportitem or register_creature_gossip for a TeleportNPC

Now we finished The Main Code.

We just need to go into Setup.h and Setup.cpp
setup.h we add the following Code:

void SetupPortNPC(ScriptMgr *mgr);

setup.cpp we add this code line:


void SetupPortNPC must be the same name as you used in the last Void function we did.

Thats all...

I did a little bit more in my own scripts.

Here the Links:
Teleportitem :
TeleportNPC :

Hope I gave you a little Idea how to Script a TeleportItem/TeleportNPC

Greetings Sleinzel

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users