Jump to content

Easy Custom Portal system


Guest Lunera

Recommended Posts

* 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.

Link to comment
Share on other sites

maybe a message can done with Source->GetSession()->SendNotification("Your Level is too low");

if you want to improve you patch further: move the mysql-query somewhere at the startup-loads (at the place where all gameobjects are loaded).. cause else this query will be called at every gameobject use, which is maybe to much for a larger server..

so just do at the beginning a query, give a variable in gameobject-class the teleportid (or whatever is needed - haven't looked close)

and then you just check at gameobject-use if teleportid is present or not..

but i believe this patch couldn't be applied to mangos.. i think such custom-features are not very welcome (also ahbot, jail couldn't get to mangos)

ps: also it would be great if you make 4spaces instead of tabs ;)

Link to comment
Share on other sites

The only reason I have done it this way, is because I've used it before, so I know it works. It's a slightly modified ArcScript.

Now what I wonder is, wasn't there something in place at some point to use the mini-game gameobject type? That is 27 I believe. That method, from what I understand used the data fields for coordinates. If THOSE are cached at launch, then I could implement that method.

Does anybody have any info on this?

I'm not expecting this to make it into the master branch, or any branch even, I'm just doing this for the fun of the coding and seeing how things work.

Link to comment
Share on other sites

ah i thought you want it to master, cause you used this formal title-design :)

i don't know about minigame-gameobjects (i even haven't heared, such exist^^)

i have done a quite similar thing for gameobjects, where i wanted that some gameobjects have extra-information

http://github.com/balrok/mangos/commit/2a61e79ce005732dcc13cb9654f43314e4bb2f3c

instead of adding this function to battlegroundmanger, you can add it to objmgr

and then, from inside gameobject::use you'll also have access to the objmgr and can ask if the gameobject has this special attribute

edit maybe this table is supposed to do such things - but i don't know anything about it :x

http://wiki.udbforums.org/index.php/Gameobject_scripts

Link to comment
Share on other sites

  • 4 weeks later...

Well hopefully you understand how the patch works. The "-" means to remove that line and "+" to add. So those are the changes. The lines that don't have those symbols are just for locating where to make the changes. In a text editor (I recommend Notepad++ for Windows) do a Find(Control+F) search of a line that isn't modified like "

Player* player = (Player*)user;" and then when you find it, press Enter a few times and copy + paste all the lines with the "+" to add them. Remember to delete the little plus signs though.

That's how you can manually add them. Works great when there's problems patching if it's small.

Link to comment
Share on other sites

  • 2 weeks later...
  • 7 months later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use