Core/Movement: Allow overriding speed for taxi movement generator
Port From (https://github.com/TrinityCore/TrinityCore/commit/038f995ad6ce6a26f71367cae3eb7ae107527a18)
This commit is contained in:
@@ -26,7 +26,6 @@ using Game.Spells;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using static Global;
|
using static Global;
|
||||||
|
|
||||||
namespace Game.Entities
|
namespace Game.Entities
|
||||||
@@ -6907,6 +6906,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
SendMessageToSet(data, true);
|
SendMessageToSet(data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DrunkenState GetDrunkenstateByValue(byte value)
|
public static DrunkenState GetDrunkenstateByValue(byte value)
|
||||||
{
|
{
|
||||||
if (value >= 90)
|
if (value >= 90)
|
||||||
@@ -6919,7 +6919,8 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
public uint GetDeathTimer() { return m_deathTimer; }
|
public uint GetDeathTimer() { return m_deathTimer; }
|
||||||
public bool ActivateTaxiPathTo(List<uint> nodes, Creature npc = null, uint spellid = 0, uint preferredMountDisplay = 0)
|
|
||||||
|
public bool ActivateTaxiPathTo(List<uint> nodes, Creature npc = null, uint spellid = 0, uint preferredMountDisplay = 0, float? speed = null)
|
||||||
{
|
{
|
||||||
if (nodes.Count < 2)
|
if (nodes.Count < 2)
|
||||||
{
|
{
|
||||||
@@ -7096,23 +7097,18 @@ namespace Game.Entities
|
|||||||
ModifyMoney(-firstcost);
|
ModifyMoney(-firstcost);
|
||||||
UpdateCriteria(CriteriaType.MoneySpentOnTaxis, firstcost);
|
UpdateCriteria(CriteriaType.MoneySpentOnTaxis, firstcost);
|
||||||
GetSession().SendActivateTaxiReply();
|
GetSession().SendActivateTaxiReply();
|
||||||
GetSession().SendDoFlight(mount_display_id, sourcepath);
|
StartTaxiMovement(mount_display_id, sourcepath, 0, speed);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ActivateTaxiPathTo(uint taxi_path_id, uint spellid = 0)
|
public bool ActivateTaxiPathTo(uint taxi_path_id, uint spellid = 0, float? speed = null)
|
||||||
{
|
{
|
||||||
var entry = CliDB.TaxiPathStorage.LookupByKey(taxi_path_id);
|
var entry = CliDB.TaxiPathStorage.LookupByKey(taxi_path_id);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
List<uint> nodes = new();
|
return ActivateTaxiPathTo([entry.FromTaxiNode, entry.ToTaxiNode], null, spellid, 0, speed);
|
||||||
|
|
||||||
nodes.Add(entry.FromTaxiNode);
|
|
||||||
nodes.Add(entry.ToTaxiNode);
|
|
||||||
|
|
||||||
return ActivateTaxiPathTo(nodes, null, spellid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FinishTaxiFlight()
|
public void FinishTaxiFlight()
|
||||||
@@ -7178,7 +7174,18 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetSession().SendDoFlight(mountDisplayId, path, startNode);
|
StartTaxiMovement(mountDisplayId, path, startNode, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StartTaxiMovement(uint mountDisplayId, uint path, uint pathNode, float? speed)
|
||||||
|
{
|
||||||
|
// remove fake death
|
||||||
|
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Interacting);
|
||||||
|
|
||||||
|
if (mountDisplayId != 0)
|
||||||
|
Mount(mountDisplayId);
|
||||||
|
|
||||||
|
GetMotionMaster().MoveTaxiFlight(path, pathNode, speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetsRecruitAFriendBonus(bool forXP)
|
public bool GetsRecruitAFriendBonus(bool forXP)
|
||||||
|
|||||||
@@ -112,18 +112,6 @@ namespace Game
|
|||||||
GetPlayer().SetTaxiCheater(lastTaxiCheaterState);
|
GetPlayer().SetTaxiCheater(lastTaxiCheaterState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendDoFlight(uint mountDisplayId, uint path, uint pathNode = 0)
|
|
||||||
{
|
|
||||||
// remove fake death
|
|
||||||
if (GetPlayer().HasUnitState(UnitState.Died))
|
|
||||||
GetPlayer().RemoveAurasByType(AuraType.FeignDeath);
|
|
||||||
|
|
||||||
if (mountDisplayId != 0)
|
|
||||||
GetPlayer().Mount(mountDisplayId);
|
|
||||||
|
|
||||||
GetPlayer().GetMotionMaster().MoveTaxiFlight(path, pathNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SendLearnNewTaxiNode(Creature unit)
|
public bool SendLearnNewTaxiNode(Creature unit)
|
||||||
{
|
{
|
||||||
// find current node
|
// find current node
|
||||||
|
|||||||
@@ -14,8 +14,19 @@ namespace Game.Movement
|
|||||||
{
|
{
|
||||||
public class FlightPathMovementGenerator : MovementGeneratorMedium<Player>
|
public class FlightPathMovementGenerator : MovementGeneratorMedium<Player>
|
||||||
{
|
{
|
||||||
public FlightPathMovementGenerator()
|
float? _speed;
|
||||||
|
float _endGridX; //! X coord of last node location
|
||||||
|
float _endGridY; //! Y coord of last node location
|
||||||
|
uint _endMapId; //! map Id of last node location
|
||||||
|
uint _preloadTargetNode; //! node index where preloading starts
|
||||||
|
|
||||||
|
List<TaxiPathNodeRecord> _path = new();
|
||||||
|
int _currentNode;
|
||||||
|
List<TaxiNodeChangeInfo> _pointsForPathSwitch = new(); //! node indexes and costs where TaxiPath changes
|
||||||
|
|
||||||
|
public FlightPathMovementGenerator(float? speed)
|
||||||
{
|
{
|
||||||
|
_speed = speed;
|
||||||
Mode = MovementGeneratorMode.Default;
|
Mode = MovementGeneratorMode.Default;
|
||||||
Priority = MovementGeneratorPriority.Highest;
|
Priority = MovementGeneratorPriority.Highest;
|
||||||
Flags = MovementGeneratorFlags.InitializationPending;
|
Flags = MovementGeneratorFlags.InitializationPending;
|
||||||
@@ -61,7 +72,7 @@ namespace Game.Movement
|
|||||||
init.SetSmooth();
|
init.SetSmooth();
|
||||||
init.SetUncompressed();
|
init.SetUncompressed();
|
||||||
init.SetWalk(true);
|
init.SetWalk(true);
|
||||||
init.SetVelocity(30.0f);
|
init.SetVelocity(_speed.GetValueOrDefault(30.0f));
|
||||||
init.Launch();
|
init.Launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,15 +323,6 @@ namespace Game.Movement
|
|||||||
|
|
||||||
public uint GetCurrentNode() { return (uint)_currentNode; }
|
public uint GetCurrentNode() { return (uint)_currentNode; }
|
||||||
|
|
||||||
float _endGridX; //! X coord of last node location
|
|
||||||
float _endGridY; //! Y coord of last node location
|
|
||||||
uint _endMapId; //! map Id of last node location
|
|
||||||
uint _preloadTargetNode; //! node index where preloading starts
|
|
||||||
|
|
||||||
List<TaxiPathNodeRecord> _path = new();
|
|
||||||
int _currentNode;
|
|
||||||
List<TaxiNodeChangeInfo> _pointsForPathSwitch = new(); //! node indexes and costs where TaxiPath changes
|
|
||||||
|
|
||||||
class TaxiNodeChangeInfo
|
class TaxiNodeChangeInfo
|
||||||
{
|
{
|
||||||
public TaxiNodeChangeInfo(uint pathIndex, long cost)
|
public TaxiNodeChangeInfo(uint pathIndex, long cost)
|
||||||
|
|||||||
@@ -994,7 +994,7 @@ namespace Game.Movement
|
|||||||
Log.outError(LogFilter.Server, $"MotionMaster::MoveSeekAssistanceDistract: {_owner.GetGUID()} attempted to call distract after assistance");
|
Log.outError(LogFilter.Server, $"MotionMaster::MoveSeekAssistanceDistract: {_owner.GetGUID()} attempted to call distract after assistance");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveTaxiFlight(uint path, uint pathnode)
|
public void MoveTaxiFlight(uint path, uint pathnode, float? speed = null)
|
||||||
{
|
{
|
||||||
if (_owner.IsTypeId(TypeId.Player))
|
if (_owner.IsTypeId(TypeId.Player))
|
||||||
{
|
{
|
||||||
@@ -1006,7 +1006,7 @@ namespace Game.Movement
|
|||||||
bool hasExisting = HasMovementGenerator(gen => gen.GetMovementGeneratorType() == MovementGeneratorType.Flight);
|
bool hasExisting = HasMovementGenerator(gen => gen.GetMovementGeneratorType() == MovementGeneratorType.Flight);
|
||||||
Cypher.Assert(!hasExisting, "Duplicate flight path movement generator");
|
Cypher.Assert(!hasExisting, "Duplicate flight path movement generator");
|
||||||
|
|
||||||
FlightPathMovementGenerator movement = new();
|
FlightPathMovementGenerator movement = new(speed);
|
||||||
movement.LoadPath(_owner.ToPlayer());
|
movement.LoadPath(_owner.ToPlayer());
|
||||||
Add(movement);
|
Add(movement);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user