In this tutorial I try to show you how to make a custom taxipath (flightmaster with custom path).


1. How does it work?
A TaxiPath (tp) includes a lot of TaxiPathNodes (tpn) which will be served consecutively. We create a new TaxiPath and the core will include this after the taxipaths from dbc files.



Code:
// A new TaxiPath
TaxiPath* tp = new TaxiPath();

tp->AddPathNode(0, tpn1); // First TaxiPathNode in the TaxiPath starts with "0", and the tpn number. In this case it is "tpn1"
tp->AddPathNode(1, tpn2);
tp->AddPathNode(2, tpn3);

Every tpn includes the following information: position x, position y, position z and the map.
Code:
// First TaxiPathNode
TaxiPathNode* tpn1 = new TaxiPathNode();
tpn1->x = 4636,960;
tpn1->y = -3805,252;
tpn1->z = 942,384;
tpn1->mapid = 1;

// Second TaxiPathNode
TaxiPathNode* tpn2 = new TaxiPathNode();
tpn2->x = 4686,888;
tpn2->y = -3707,108;
tpn2->z = 995,145;
tpn2->mapid = 1;

// Third TaxiPathNode
TaxiPathNode* tpn3 = new TaxiPathNode();
tpn3->x = 4660,425;
tpn3->y = -3656,121;
tpn3->z = 1017,829;
tpn3->mapid = 1;

2. Create your flightmaster:
This tutorial is not about "how to create a creature". Make sure your npcflags is set to: 8193 (flymaster = 8192 + gossip = 1 = 8193).


3. Start with a new .cpp file:
Code:
#include "StdAfx.h"

class SCRIPT_DECL flightmaster : public GossipScript
{

    void Destroy()
    {
        delete [] this;
    }
     
    void GossipHello(Object* pObject, Player* Plr, bool AutoSend)
    {
        GossipMenu* menu;
        objmgr.CreateGossipMenuForPlayer(&menu, pObject->GetGUID(), 32101, Plr);
        menu->AddItem(2, "Testflight", 1); // (Icon, menu name, gossip select id). If you need more flightpath copy and paste this line over "menu->SendTo(Plr)"
        menu->SendTo(Plr);
    }
     
    void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char* EnteredCode)
    {
        switch(IntId)
        {
            case 0:
            {
                Plr->Gossip_Complete();
            break;
            }
            case 1: // first case, if you need more custom path add case 2: and so on...
            {
                TaxiPathNode* tpn1 = new TaxiPathNode();
                tpn1->x = 4636,960;
                tpn1->y = -3805,252;
                tpn1->z = 942,384;
                tpn1->mapid = 1;

                TaxiPathNode* tpn2 = new TaxiPathNode();
                tpn2->x = 4686,888;
                tpn2->y = -3707,108;
                tpn2->z = 995,145;
                tpn2->mapid = 1;

                TaxiPathNode* tpn3 = new TaxiPathNode();
                tpn3->x = 4660,425;
                tpn3->y = -3656,121;
                tpn3->z = 1017,829;
                tpn3->mapid = 1;
     
                TaxiPath* tp = new TaxiPath();
                tp->AddPathNode(0, tpn1);
                tp->AddPathNode(1, tpn2);
                tp->AddPathNode(2, tpn3);

                // tp->SetPrice(10); this is optional, see tutorial
     
                Plr->TaxiStart(tp, 32101, 0); // start this flight
                Plr->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 17765); // (mount the player, mount id)
     
                sChatHandler.RedSystemMessageToPlr(Plr, "Testflight one"); // The flightmaster say this in chat
                Plr->Gossip_Complete(); // close the gossip
                break;
            }
        break;
        }  
    }
};

//Register the script to script mgr. Dont forget to add the script to script.h and script.cpp!     
void FlightScript(ScriptMgr * mgr)
{
    mgr->register_gossip_script(32101, (GossipScript*)new flightmaster()); //(CRETUREID, our script)
}

4. SetPrice (if you lost all your money, follow these instructions)

4.1 Add "tp->SetPrice(PriceInCopper)" to your custom taxipath

4.2 Go to TaxiMgr.h (in project world) and add:
Code:
void SetPrice(uint32 m_price) { price = m_price; }
under:
Code:
void AddPathNode(uint32 index, TaxiPathNode* pn) { m_pathNodes[index] = pn; }
finish :-)


Known problems:
[Q-01] "the path is very jerky"
[A-01] "The path between the tpns is calculated by the core, please delete some of your points and give the core some space to calculate"

[Q-02] "I thought this is illegal?!?"
[A-02] "You didn't modifie the dbc, it is serverside. Arcemu provides this function serverside :-) "

All questions about compiling and general scripting will not be answered in this tutorial.

Best wishes
Tulba


› See More: Custom Flightmaster