root/trunk/src/game/DestinationHolder.h @ 52

Revision 44, 2.8 kB (checked in by yumileroy, 17 years ago)

[svn] * Merge Temp dev SVN with Assembla.
* Changes include:

  • Implementation of w12x's Outdoor PvP and Game Event Systems.
  • Temporary removal of IRC Chat Bot (until infinite loop when disabled is fixed).
  • All mangos -> trinity (to convert your mangos_string table, please run mangos_string_to_trinity_string.sql).
  • Improved Config cleanup.
  • And many more changes.

Original author: Seline
Date: 2008-10-14 11:57:03-05:00

Line 
1/*
2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
3 *
4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef TRINITY_DESTINATION_HOLDER_H
22#define TRINITY_DESTINATION_HOLDER_H
23
24#include "Platform/Define.h"
25#include "Timer.h"
26
27class WorldObject;
28
29#define TRAVELLER_UPDATE_INTERVAL  300
30
31template<typename TRAVELLER>
32class TRINITY_DLL_DECL DestinationHolder
33{
34    TimeTrackerSmall i_tracker;
35    uint32 i_totalTravelTime;
36    uint32 i_timeElapsed;
37    bool i_destSet;
38    float i_fromX, i_fromY, i_fromZ;
39    float i_destX, i_destY, i_destZ;
40
41    public:
42        DestinationHolder() : i_tracker(TRAVELLER_UPDATE_INTERVAL), i_totalTravelTime(0), i_timeElapsed(0),
43            i_destSet(false), i_fromX(0), i_fromY(0), i_fromZ(0), i_destX(0), i_destY(0), i_destZ(0) {}
44
45        uint32 SetDestination(TRAVELLER &traveller, float dest_x, float dest_y, float dest_z, bool sendMove = true);
46        void GetDestination(float &x, float &y, float &z) const { x = i_destX; y = i_destY; z = i_destZ; }
47        bool UpdateExpired(void) const { return i_tracker.Passed(); }
48        void ResetUpdate(uint32 t = TRAVELLER_UPDATE_INTERVAL) { i_tracker.Reset(t); }
49        uint32 GetTotalTravelTime(void) const { return i_totalTravelTime; }
50        void IncreaseTravelTime(uint32 increment) { i_totalTravelTime += increment; }
51        bool HasDestination(void) const { return i_destSet; }
52        float GetDestinationDiff(float x, float y, float z) const;
53        bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); }
54        bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update=false, bool micro_movement=false);
55        uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true);
56        void GetLocationNow(uint32 mapid, float &x, float &y, float &z, bool is3D = false) const;
57        void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement
58        float GetDistance2dFromDestSq(const WorldObject &obj) const;
59
60    private:
61        void _findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y);
62
63};
64#endif
Note: See TracBrowser for help on using the browser.