Hello & Welcome to our community. Is this your first visit? Register
Follow us on
Follow us on Facebook Follow us on Twitter Watch us on YouTube


MMOCoin

Likes Likes:  0
Results 1 to 1 of 1
  1. #1
    Graphics Guru

    Join Date
    Feb 2009
    Posts
    1,377
    Post Thanks / Like
    Rep Power
    22
    Reputation
    382

    Player Waypoints (Custom Flightpaths, etc.)


    Register to remove this ad
    Player Waypoints (Custom Flightpaths, etc.)
    Tested on 3.3.3a revision of tc (8330)

    Description

    • C++ class, that allows forced movement of player on predefined path
    • I bring this script to you as it is, I know its got its bugs, but it wasnt intended for this usage. Take it or let it be.
    • Possible usage
      • Custom flightpaths (even in Azeroth)
      • Ground "flight paths" (just an idea :-))
      • Ingame "movies"

    • Script is little bit buggy, but nothing serious id say. It wasnt originaly written to serve this prupose, i just wanted something that would allow me to do "ingame animation" for some quest
    • Bugs (known):
      • If player (mounted by this script) dispells mount (by right clicking on its icon), spell renews itself (icon), but mount is not shown (your just swimming in air). I dont understand why, if anybody knows, be sure to tell me
      • At higher speeds (mainly fly mode) it not exactly accurate. With higher speed, theres bigger chance to not land exactly on waypoint, but for example 20 yards away from it (final waypoint land is okay). Script is able to detect such sitation and skips to next waypoint, but it might be a bit messy if waypoints placed badly. Its good not to put waypoints too close to each other (again, mainly for fly mode, walkmode should be ok) and not put them too close to buildings. Walking, running is fine (you end up within 5 yards away from destination in db).
      • Porting flying player may cause some mess, but relog should fix it



    Example of player waypoint movement


    What you have to do




    Kód


    Script for npc (Just example of how to use the main class)



    Code:
     #include "ScriptedPch.h"
    
    bool GossipHello_npc_player_wp(Player *player, Creature *_creature)
    {
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "TEST FLY", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 20);
        player->SEND_GOSSIP_MENU(1, _creature->GetGUID());
        return true;
    }
    
    bool GossipSelect_npc_player_wp(Player *player, Creature *_creature, uint32 sender, uint32 action )
    {
        if (sender != GOSSIP_SENDER_MAIN)
            return false;
    
        if (action == GOSSIP_ACTION_INFO_DEF + 20)
        {
            player->playerControlledMovement = new PlayerControlledMovement(player);
            player->Unmount();
            player->SetPosition(_creature->GetPositionX(), _creature->GetPositionY(), _creature->GetPositionZ(), _creature->GetOrientation(), true);
            player->PlayerTalkClass->CloseGossip();
            player->playerControlledMovement->LoadPath(3); // this is important, number in brackets is number of waypoint path in db
            player->PlayerControlledMovementEnabled = true;
        }
        
        return true;
    }
    
    
    void AddSC_npc_player_wp()
    {
        Script *newscript;
        newscript = new Script;
        newscript->Name = "npc_player_wp";
        newscript->pGossipHello = &GossipHello_npc_player_wp;
        newscript->pGossipSelect = &GossipSelect_npc_player_wp;
        newscript->RegisterSelf();
    }
    PlayerControlledMovement.h - put it in src/game

    Code:
    #pragma once
    
    class Node{
    public:
        Node();
    float x;
    float y;
    float z;
    int mount;
    int move;
    int mode;
    int part;
    };
    
    typedef std::list<Node *> Nodes;
    
    class PlayerControlledMovement
    {
    protected:
        Player * me;
    public:
        int flyAnimTimer;
        int failedUpdatesCounter;
        bool finish;
        float oldPosX;
        float oldPosY;
        float oldPosZ;
        void Finish();
        int part;
        Nodes nodes;
        Node * activeNode;
        int nodesLenght;
        PlayerControlledMovement(Player *p);
        void MoveToPoint(Node * n, bool forceSlow);
        void Update(uint32 diff);
        void LoadPath(int pathid);
        Node * GetNextNode(Node * n);
    };
    PlayerControlledMovement.cpp - put it in src/game


    Edit this file: Player.h
    (lines marked with + are supposed to be added, without that +)

    Code:
      #include "ReputationMgr.h"
      #include "BattleGround.h"
      #include "DBCEnums.h"
      #include "LFG.h"
    + #include "PlayerControlledMovement.h"
    
      #include<string>
      #include<vector>
    Code:
     class Player : public Unit, public GridObject<Player>
    {
        friend class WorldSession;
        friend void Item::AddToUpdateQueueOf(Player *player);
        friend void Item::RemoveFromUpdateQueueOf(Player *player);
        public:
            explicit Player (WorldSession *session);
            ~Player ();
    
    +        PlayerControlledMovement * playerControlledMovement;
    +        bool PlayerControlledMovementEnabled;
    
        void CleanupsBeforeDelete(bool finalCleanup = true);
    
        static UpdateMask updateVisualBits;
        static void InitVisibleBits();
    
        void AddToWorld();
    Edit this file: Player.cpp
    (lines marked with + are supposed to be added, without that +)
    Code:
    Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputationMgr(this)
    {
    +      PlayerControlledMovementEnabled = false;
    
        m_speakTime = 0;
        m_speakCount = 0;
    
        m_objectType |= TYPEMASK_PLAYER;
        m_objectTypeId = TYPEID_PLAYER;
    
        m_valuesCount = PLAYER_END;
    Code:
    void Player::Update(uint32 p_time)
    {
        if (!IsInWorld())
            return;
    
    +      if (PlayerControlledMovementEnabled == true)
    +          playerControlledMovement->Update(p_time);
    
        // undelivered mail
        if (m_nextMailDelivereTime && m_nextMailDelivereTime <= time(NULL))
        {
            SendNewMail();
            ++unReadMails;
    
            // It will be recalculate at mailbox open (for unReadMails important non-0 until mailbox open, it also will be recalculated)
            m_nextMailDelivereTime = 0;
        }
    SQL - import into world DB

    Code:
      -- ----------------------------
    -- Table structure for `custom_character_movepaths`
    -- ----------------------------
    DROP TABLE IF EXISTS `custom_character_movepaths`;
    CREATE TABLE `custom_character_movepaths` (
      `PathID` int(11) NOT NULL default '0',
      `TravelOrder` int(11) NOT NULL default '0',
      `x` float default NULL,
      `y` float default NULL,
      `z` float default NULL,
      `mount` int(11) default NULL,
      `move` tinyint(4) default NULL,
      `spawn` int(11) default NULL,
      `mode` smallint(6) default NULL,
      `emote` int(11) default NULL,
      `wait` int(11) default NULL,
      PRIMARY KEY  (`PathID`,`TravelOrder`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    Few words to that table - There are some unused fields, mainly because it was (and still is) intended to be used in a bit different way. What youv got is like a developement version of my unfinished script a bit edited to serve like title says.
    Whats important:
    • PathID, which is used in npc gossip scripts to make player moving
    • TravelOrder - number waypoints. Waypoints will follow after each other depending on this order (they are ordered by this field when loading from db)
    • mount - is ID of mount spell player should have on this waypoint
    • move - nut sure what this was for, leave it 0
    • spawn, emote, wait - not yet used, leave blank
    • mode - speed on given node
      • 1 - bullettime
      • 2 - walk
      • 3 - run
      • 4 - slow ground mount
      • 5 - fast ground mount
      • 6 - fast fly





    Credits : Hkarta


    › See More: Player Waypoints (Custom Flightpaths, etc.)
    Last edited by Wise; 31-07-13 at 08:54 PM.



  2. Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread

 

 

Visitors found this page by searching for:

Nobody landed on this page from a search engine, yet!
SEO Blog

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -5. The time now is 11:00 AM.
Powered by vBulletin® Copyright ©2000-2024, Jelsoft Enterprises Ltd.
See More links by ForumSetup.net. Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
vBulletin Licensed to: MMOPro.org