mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 13:16:23 +00:00
fix(Core/Movement): Improvements to taxi flight movement generator: (#12347)
Changed multi-segment taxi paths to fly nearby flight masters along the way, not directly through them. Taxi cost on multi-segment paths is now charged per segment when it is started. Properly send taxi node status on login, as well as if the taxi master is out of range. Apply reputation discount to all points in multi-segment paths. Properly clean up list of taxi destinations upon arrival at final node. Teleport players to the destination taxi node location instead of their current ground position. Don't start a spline with just 1 point in FlightPathMovementGenerator Source: TrinityCore.
This commit is contained in:
@@ -20,11 +20,6 @@
|
||||
#include "Tokenize.h"
|
||||
#include "StringConvert.h"
|
||||
|
||||
PlayerTaxi::PlayerTaxi() : _taxiSegment(0)
|
||||
{
|
||||
memset(m_taximask, 0, sizeof(m_taximask));
|
||||
}
|
||||
|
||||
void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level)
|
||||
{
|
||||
// class specific initial known nodes
|
||||
@@ -136,9 +131,25 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, TeamI
|
||||
{
|
||||
ClearTaxiDestinations();
|
||||
|
||||
for (auto const& itr : Acore::Tokenize(values, ' ', false))
|
||||
std::vector<std::string_view> tokens = Acore::Tokenize(values, ' ', false);
|
||||
auto itr = tokens.begin();
|
||||
if (itr != tokens.end())
|
||||
{
|
||||
if (Optional<uint32> node = Acore::StringTo<uint32>(itr))
|
||||
if (Optional<uint32> faction = Acore::StringTo<uint32>(*itr))
|
||||
{
|
||||
m_flightMasterFactionId = *faction;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
while ((++itr) != tokens.end())
|
||||
{
|
||||
if (Optional<uint32> node = Acore::StringTo<uint32>(*itr))
|
||||
{
|
||||
AddTaxiDestination(*node);
|
||||
}
|
||||
@@ -148,26 +159,33 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, TeamI
|
||||
}
|
||||
}
|
||||
|
||||
if (m_TaxiDestinations.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check integrity
|
||||
if (m_TaxiDestinations.size() < 3)
|
||||
if (m_TaxiDestinations.size() < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// xinef: current segment is saved as last destination in db
|
||||
_taxiSegment = m_TaxiDestinations[m_TaxiDestinations.size() - 1];
|
||||
m_TaxiDestinations.pop_back();
|
||||
|
||||
for (size_t i = 0; i < m_TaxiDestinations.size() - 1; ++i)
|
||||
for (size_t i = 1; i < m_TaxiDestinations.size(); ++i)
|
||||
{
|
||||
uint32 cost;
|
||||
uint32 path;
|
||||
sObjectMgr->GetTaxiPath(m_TaxiDestinations[i], m_TaxiDestinations[i + 1], path, cost);
|
||||
sObjectMgr->GetTaxiPath(m_TaxiDestinations[i - 1], m_TaxiDestinations[i], path, cost);
|
||||
if (!path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// can't load taxi path without mount set (quest taxi path?)
|
||||
if (!sObjectMgr->GetTaxiMountDisplayId(GetTaxiSource(), teamId, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -175,26 +193,34 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, TeamI
|
||||
std::string PlayerTaxi::SaveTaxiDestinationsToString()
|
||||
{
|
||||
if (m_TaxiDestinations.empty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
ASSERT(m_TaxiDestinations.size() >= 2);
|
||||
|
||||
std::ostringstream ss;
|
||||
ss << m_flightMasterFactionId << ' ';
|
||||
|
||||
for (size_t i = 0; i < m_TaxiDestinations.size(); ++i)
|
||||
{
|
||||
ss << m_TaxiDestinations[i] << ' ';
|
||||
}
|
||||
|
||||
ss << _taxiSegment << ' ';
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
uint32 PlayerTaxi::GetCurrentTaxiPath() const
|
||||
{
|
||||
if (m_TaxiDestinations.size() < 2 || m_TaxiDestinations.size() <= _taxiSegment + 1)
|
||||
if (m_TaxiDestinations.size() < 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 path;
|
||||
uint32 cost;
|
||||
|
||||
sObjectMgr->GetTaxiPath(m_TaxiDestinations[_taxiSegment], m_TaxiDestinations[_taxiSegment + 1], path, cost);
|
||||
sObjectMgr->GetTaxiPath(m_TaxiDestinations[0], m_TaxiDestinations[1], path, cost);
|
||||
|
||||
return path;
|
||||
}
|
||||
@@ -205,3 +231,8 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
|
||||
ss << taxi.m_taximask[i] << ' ';
|
||||
return ss;
|
||||
}
|
||||
|
||||
FactionTemplateEntry const* PlayerTaxi::GetFlightMasterFactionTemplate() const
|
||||
{
|
||||
return sFactionTemplateStore.LookupEntry(m_flightMasterFactionId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user