Core/Movement: Allow overriding speed for taxi movement generator

Port From (https://github.com/TrinityCore/TrinityCore/commit/038f995ad6ce6a26f71367cae3eb7ae107527a18)
This commit is contained in:
Hondacrx
2024-08-04 17:18:56 -04:00
parent 44f1a733e7
commit 22fbfd8360
4 changed files with 33 additions and 36 deletions
+18 -11
View File
@@ -26,7 +26,6 @@ using Game.Spells;
using System;
using System.Collections.Generic;
using System.Linq;
using static Global;
namespace Game.Entities
@@ -6907,6 +6906,7 @@ namespace Game.Entities
SendMessageToSet(data, true);
}
public static DrunkenState GetDrunkenstateByValue(byte value)
{
if (value >= 90)
@@ -6919,7 +6919,8 @@ namespace Game.Entities
}
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)
{
@@ -7096,23 +7097,18 @@ namespace Game.Entities
ModifyMoney(-firstcost);
UpdateCriteria(CriteriaType.MoneySpentOnTaxis, firstcost);
GetSession().SendActivateTaxiReply();
GetSession().SendDoFlight(mount_display_id, sourcepath);
StartTaxiMovement(mount_display_id, sourcepath, 0, speed);
}
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);
if (entry == null)
return false;
List<uint> nodes = new();
nodes.Add(entry.FromTaxiNode);
nodes.Add(entry.ToTaxiNode);
return ActivateTaxiPathTo(nodes, null, spellid);
return ActivateTaxiPathTo([entry.FromTaxiNode, entry.ToTaxiNode], null, spellid, 0, speed);
}
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)
-12
View File
@@ -112,18 +112,6 @@ namespace Game
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)
{
// find current node
@@ -14,8 +14,19 @@ namespace Game.Movement
{
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;
Priority = MovementGeneratorPriority.Highest;
Flags = MovementGeneratorFlags.InitializationPending;
@@ -61,7 +72,7 @@ namespace Game.Movement
init.SetSmooth();
init.SetUncompressed();
init.SetWalk(true);
init.SetVelocity(30.0f);
init.SetVelocity(_speed.GetValueOrDefault(30.0f));
init.Launch();
}
@@ -312,15 +323,6 @@ namespace Game.Movement
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
{
public TaxiNodeChangeInfo(uint pathIndex, long cost)
+2 -2
View File
@@ -994,7 +994,7 @@ namespace Game.Movement
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))
{
@@ -1006,7 +1006,7 @@ namespace Game.Movement
bool hasExisting = HasMovementGenerator(gen => gen.GetMovementGeneratorType() == MovementGeneratorType.Flight);
Cypher.Assert(!hasExisting, "Duplicate flight path movement generator");
FlightPathMovementGenerator movement = new();
FlightPathMovementGenerator movement = new(speed);
movement.LoadPath(_owner.ToPlayer());
Add(movement);
}