* What bug does the patch fix? What features does the patch add?
Makes for easy custom portals
* For which repository revision was the patch created?
8171
* Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.
no
* Who has been writing this patch? Please include either forum user names or email addresses.
Lunera(me)
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 56a5d06..50a0ed6 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -35,6 +35,9 @@
#include "InstanceData.h"
#include "BattleGround.h"
#include "Util.h"
+
GameObject::GameObject() : WorldObject()
{
@@ -966,7 +969,36 @@ void GameObject::Use(Unit* user)
if(user->GetTypeId()==TYPEID_PLAYER)
{
Player* player = (Player*)user;
-
+// Probably not doing this right -- Lunera
+ float xt,yt,zt,orientationt;
+ uint32 mapidt;
+
+ QueryResult *result = NULL;
+ std::ostringstream qry;
+ qry << "SELECT * FROM gameobject_teleports WHERE entry = " << info->id;
+ result = WorldDatabase.Query(qry.str( ).c_str( ));
+ if(result != NULL)
+ {
+ Field *fields = result->Fetch();
+ uint32 required_level = fields[6].GetInt32();
+
+ if ((required_level == 0) || (required_level <= player->getLevel()))
+ {
+ mapidt = fields[1].GetInt32();
+ xt = fields[2].GetFloat();
+ yt = fields[3].GetFloat();
+ zt = fields[4].GetFloat();
+ orientationt = fields[5].GetFloat();
+
+ player->TeleportTo(mapidt, xt, yt, zt, orientationt, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);
+ }
+ else if (required_level != 0)
+ {
+ }
+ delete result;
+ }
+ //I'm done here -- Lunera
// show page
if(info->goober.pageId)
{
This was inspired by another (open source)cores method. Okay, more like copypasta, but I had to change some of it to work with MaNGOS. I'm not taking any credit for anything other than the edits.
There is also some SQL to make it work.
# Table structure for table 'gameobject_teleports'
#
CREATE TABLE "gameobject_teleports" (
"entry" int(10) unsigned NOT NULL AUTO_INCREMENT,
"mapid" int(10) unsigned NOT NULL,
"x_pos" float NOT NULL,
"y_pos" float NOT NULL,
"z_pos" float NOT NULL,
"orientation" float NOT NULL,
"required_level" int(10) unsigned NOT NULL,
PRIMARY KEY ("entry")
) AUTO_INCREMENT=800213 /*!40100 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC COMMENT='Optional table to create custom portals'*/;
To implement this, make a gameobject with a type of 10 (goober), and make a matching entry in the gameobject_teleports table with entry being the id of the gameobject. The other coloumns are the destination and required level to use the portal. This can work with any gameobject display. If there is no entry in the gameobject_teleport table, the rest of the goober handler executes. There is no need to reload the table as it is accesed as needed so all changes made in the DB are immediate.
-still to work on: Returning a message to the player if their level is too low.