Core/Movement: Store adv flying speeds instead of hardcoding them in SMSG_UPDATE_OBJECT and enable packets modifying them
Port From (https://github.com/TrinityCore/TrinityCore/commit/43c7965d6b97a919ddd7e97a1f6e3f5750553f09)
This commit is contained in:
@@ -112,6 +112,28 @@ namespace Framework.Constants
|
||||
End
|
||||
}
|
||||
|
||||
public enum AdvFlyingRateTypeSingle
|
||||
{
|
||||
AirFriction = 0,
|
||||
MaxVel = 1,
|
||||
LiftCoefficient = 2,
|
||||
DoubleJumpVelMod = 3,
|
||||
GlideStartMinHeight = 4,
|
||||
AddImpulseMaxSpeed = 5,
|
||||
SurfaceFriction = 14,
|
||||
OverMaxDeceleration = 15,
|
||||
LaunchSpeedCoefficient = 16,
|
||||
Max = 17
|
||||
}
|
||||
|
||||
public enum AdvFlyingRateTypeRange
|
||||
{
|
||||
BankingRate = 6,
|
||||
PitchingRateDown = 8,
|
||||
PitchingRateUp = 10,
|
||||
TurnVelocityThreshold = 12
|
||||
}
|
||||
|
||||
public enum DamageEffectType
|
||||
{
|
||||
Direct = 0, // used for normal weapon damage (not for class abilities or spells)
|
||||
|
||||
@@ -355,23 +355,23 @@ namespace Game.Entities
|
||||
data.WriteFloat(1.0f); // MovementForcesModMagnitude
|
||||
}
|
||||
|
||||
data.WriteFloat(2.0f); // advFlyingAirFriction
|
||||
data.WriteFloat(65.0f); // advFlyingMaxVel
|
||||
data.WriteFloat(1.0f); // advFlyingLiftCoefficient
|
||||
data.WriteFloat(3.0f); // advFlyingDoubleJumpVelMod
|
||||
data.WriteFloat(10.0f); // advFlyingGlideStartMinHeight
|
||||
data.WriteFloat(100.0f); // advFlyingAddImpulseMaxSpeed
|
||||
data.WriteFloat(90.0f); // advFlyingMinBankingRate
|
||||
data.WriteFloat(140.0f); // advFlyingMaxBankingRate
|
||||
data.WriteFloat(180.0f); // advFlyingMinPitchingRateDown
|
||||
data.WriteFloat(360.0f); // advFlyingMaxPitchingRateDown
|
||||
data.WriteFloat(90.0f); // advFlyingMinPitchingRateUp
|
||||
data.WriteFloat(270.0f); // advFlyingMaxPitchingRateUp
|
||||
data.WriteFloat(30.0f); // advFlyingMinTurnVelocityThreshold
|
||||
data.WriteFloat(80.0f); // advFlyingMaxTurnVelocityThreshold
|
||||
data.WriteFloat(2.75f); // advFlyingSurfaceFriction
|
||||
data.WriteFloat(7.0f); // advFlyingOverMaxDeceleration
|
||||
data.WriteFloat(0.4f); // advFlyingLaunchSpeedCoefficient
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeed(AdvFlyingRateTypeSingle.AirFriction));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeed(AdvFlyingRateTypeSingle.MaxVel));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeed(AdvFlyingRateTypeSingle.LiftCoefficient));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeed(AdvFlyingRateTypeSingle.DoubleJumpVelMod));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeed(AdvFlyingRateTypeSingle.GlideStartMinHeight));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeed(AdvFlyingRateTypeSingle.AddImpulseMaxSpeed));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeedMin(AdvFlyingRateTypeRange.BankingRate));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeedMax(AdvFlyingRateTypeRange.BankingRate));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeedMin(AdvFlyingRateTypeRange.PitchingRateDown));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeedMax(AdvFlyingRateTypeRange.PitchingRateDown));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeedMin(AdvFlyingRateTypeRange.PitchingRateUp));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeedMax(AdvFlyingRateTypeRange.PitchingRateUp));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeedMin(AdvFlyingRateTypeRange.TurnVelocityThreshold));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeedMax(AdvFlyingRateTypeRange.TurnVelocityThreshold));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeed(AdvFlyingRateTypeSingle.SurfaceFriction));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeed(AdvFlyingRateTypeSingle.OverMaxDeceleration));
|
||||
data.WriteFloat(unit.GetAdvFlyingSpeed(AdvFlyingRateTypeSingle.LaunchSpeedCoefficient));
|
||||
|
||||
data.WriteBit(HasSpline);
|
||||
data.FlushBits();
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Game.Entities
|
||||
|
||||
//Movement
|
||||
protected float[] m_speed_rate = new float[(int)UnitMoveType.Max];
|
||||
float[] m_advFlyingSpeed = new float[(int)AdvFlyingRateTypeSingle.Max];
|
||||
List<AbstractFollower> m_followingMe = new();
|
||||
public MoveSpline MoveSpline { get; set; }
|
||||
MotionMaster i_motionMaster;
|
||||
|
||||
@@ -154,6 +154,111 @@ namespace Game.Entities
|
||||
|
||||
public float GetSpeedRate(UnitMoveType mtype) { return m_speed_rate[(int)mtype]; }
|
||||
|
||||
void SetFlightCapabilityID(int flightCapabilityId, bool clientUpdate)
|
||||
{
|
||||
if (flightCapabilityId != 0 && !CliDB.FlightCapabilityStorage.HasRecord((uint)flightCapabilityId))
|
||||
return;
|
||||
|
||||
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.FlightCapabilityID), flightCapabilityId);
|
||||
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.AirFriction, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.MaxVel, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.LiftCoefficient, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.DoubleJumpVelMod, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.GlideStartMinHeight, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.AddImpulseMaxSpeed, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange.BankingRate, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange.PitchingRateDown, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange.PitchingRateUp, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange.TurnVelocityThreshold, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.SurfaceFriction, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.OverMaxDeceleration, clientUpdate);
|
||||
UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.LaunchSpeedCoefficient, clientUpdate);
|
||||
}
|
||||
|
||||
void UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle speedType, bool clientUpdate)
|
||||
{
|
||||
FlightCapabilityRecord flightCapabilityEntry = CliDB.FlightCapabilityStorage.LookupByKey(GetFlightCapabilityID());
|
||||
if (flightCapabilityEntry == null)
|
||||
flightCapabilityEntry = CliDB.FlightCapabilityStorage.LookupByKey(1);
|
||||
|
||||
(ServerOpcodes opcode, float newValue) = speedType switch
|
||||
{
|
||||
AdvFlyingRateTypeSingle.AirFriction => (ServerOpcodes.MoveSetAdvFlyingAirFriction, flightCapabilityEntry.AirFriction),
|
||||
AdvFlyingRateTypeSingle.MaxVel => (ServerOpcodes.MoveSetAdvFlyingMaxVel, flightCapabilityEntry.MaxVel),
|
||||
AdvFlyingRateTypeSingle.LiftCoefficient => (ServerOpcodes.MoveSetAdvFlyingLiftCoefficient, flightCapabilityEntry.LiftCoefficient),
|
||||
AdvFlyingRateTypeSingle.DoubleJumpVelMod => (ServerOpcodes.MoveSetAdvFlyingDoubleJumpVelMod, flightCapabilityEntry.DoubleJumpVelMod),
|
||||
AdvFlyingRateTypeSingle.GlideStartMinHeight => (ServerOpcodes.MoveSetAdvFlyingGlideStartMinHeight, flightCapabilityEntry.GlideStartMinHeight),
|
||||
AdvFlyingRateTypeSingle.AddImpulseMaxSpeed => (ServerOpcodes.MoveSetAdvFlyingAddImpulseMaxSpeed, flightCapabilityEntry.AddImpulseMaxSpeed),
|
||||
AdvFlyingRateTypeSingle.SurfaceFriction => (ServerOpcodes.MoveSetAdvFlyingSurfaceFriction, flightCapabilityEntry.SurfaceFriction),
|
||||
AdvFlyingRateTypeSingle.OverMaxDeceleration => (ServerOpcodes.MoveSetAdvFlyingOverMaxDeceleration, flightCapabilityEntry.OverMaxDeceleration),
|
||||
AdvFlyingRateTypeSingle.LaunchSpeedCoefficient => (ServerOpcodes.MoveSetAdvFlyingLaunchSpeedCoefficient, flightCapabilityEntry.LaunchSpeedCoefficient),
|
||||
_ => (ServerOpcodes.Max, 0)
|
||||
};
|
||||
|
||||
if (m_advFlyingSpeed[(int)speedType] == newValue)
|
||||
return;
|
||||
|
||||
m_advFlyingSpeed[(int)speedType] = newValue;
|
||||
|
||||
if (!clientUpdate)
|
||||
return;
|
||||
|
||||
Player playerMover = GetUnitBeingMoved()?.ToPlayer();
|
||||
if (playerMover != null)
|
||||
{
|
||||
SetAdvFlyingSpeed selfpacket = new(opcode);
|
||||
selfpacket.MoverGUID = GetGUID();
|
||||
selfpacket.SequenceIndex = m_movementCounter++;
|
||||
selfpacket.Speed = newValue;
|
||||
playerMover.GetSession().SendPacket(selfpacket);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange speedType, bool clientUpdate)
|
||||
{
|
||||
FlightCapabilityRecord flightCapabilityEntry = CliDB.FlightCapabilityStorage.LookupByKey(GetFlightCapabilityID());
|
||||
if (flightCapabilityEntry == null)
|
||||
flightCapabilityEntry = CliDB.FlightCapabilityStorage.LookupByKey(1);
|
||||
|
||||
(ServerOpcodes opcode, float min, float max) = speedType switch
|
||||
{
|
||||
AdvFlyingRateTypeRange.BankingRate => (ServerOpcodes.MoveSetAdvFlyingBankingRate, flightCapabilityEntry.BankingRateMin, flightCapabilityEntry.BankingRateMax),
|
||||
AdvFlyingRateTypeRange.PitchingRateDown => (ServerOpcodes.MoveSetAdvFlyingPitchingRateDown, flightCapabilityEntry.PitchingRateDownMin, flightCapabilityEntry.PitchingRateDownMax),
|
||||
AdvFlyingRateTypeRange.PitchingRateUp => (ServerOpcodes.MoveSetAdvFlyingPitchingRateUp, flightCapabilityEntry.PitchingRateUpMin, flightCapabilityEntry.PitchingRateUpMax),
|
||||
AdvFlyingRateTypeRange.TurnVelocityThreshold => (ServerOpcodes.MoveSetAdvFlyingTurnVelocityThreshold, flightCapabilityEntry.TurnVelocityThresholdMin, flightCapabilityEntry.TurnVelocityThresholdMax),
|
||||
_ => (ServerOpcodes.Max, 0, 0)
|
||||
};
|
||||
|
||||
if (m_advFlyingSpeed[(int)speedType] == min && m_advFlyingSpeed[(int)speedType + 1] == max)
|
||||
return;
|
||||
|
||||
m_advFlyingSpeed[(int)speedType] = min;
|
||||
m_advFlyingSpeed[(int)speedType + 1] = max;
|
||||
|
||||
if (!clientUpdate)
|
||||
return;
|
||||
|
||||
Player playerMover = GetUnitBeingMoved()?.ToPlayer();
|
||||
if (playerMover != null)
|
||||
{
|
||||
SetAdvFlyingSpeedRange selfpacket = new(opcode);
|
||||
selfpacket.MoverGUID = GetGUID();
|
||||
selfpacket.SequenceIndex = m_movementCounter++;
|
||||
selfpacket.SpeedMin = min;
|
||||
selfpacket.SpeedMax = max;
|
||||
playerMover.GetSession().SendPacket(selfpacket);
|
||||
}
|
||||
}
|
||||
|
||||
int GetFlightCapabilityID() { return m_unitData.FlightCapabilityID; }
|
||||
|
||||
public float GetAdvFlyingSpeed(AdvFlyingRateTypeSingle speedType) { return m_advFlyingSpeed[(int)speedType]; }
|
||||
|
||||
public float GetAdvFlyingSpeedMin(AdvFlyingRateTypeRange speedType) { return m_advFlyingSpeed[(int)speedType]; }
|
||||
|
||||
public float GetAdvFlyingSpeedMax(AdvFlyingRateTypeRange speedType) { return m_advFlyingSpeed[(int)speedType + 1]; }
|
||||
|
||||
public virtual MovementGeneratorType GetDefaultMovementType()
|
||||
{
|
||||
return MovementGeneratorType.Idle;
|
||||
@@ -254,7 +359,7 @@ namespace Game.Entities
|
||||
init.DisableTransportPathTransformations(); // It makes no sense to target global orientation
|
||||
init.SetFacing(point.GetPositionX(), point.GetPositionY(), point.GetPositionZ());
|
||||
|
||||
//GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_FACE, MOTION_PRIORITY_HIGHEST);
|
||||
//GetMotionMaster().LaunchMoveSpline(std::move(init), EVENT_FACE, MOTION_PRIORITY_HIGHEST);
|
||||
UpdateSplineMovement((uint)init.Launch());
|
||||
Creature creature = ToCreature();
|
||||
if (creature != null)
|
||||
|
||||
@@ -68,6 +68,8 @@ namespace Game.Entities
|
||||
for (byte i = 0; i < (int)UnitMoveType.Max; ++i)
|
||||
m_speed_rate[i] = 1.0f;
|
||||
|
||||
SetFlightCapabilityID(0, false);
|
||||
|
||||
m_serverSideVisibility.SetValue(ServerSideVisibilityType.Ghost, GhostVisibilityType.Alive);
|
||||
|
||||
m_unitData = new UnitData();
|
||||
|
||||
@@ -607,6 +607,29 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingAddImpulseMaxSpeedAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingAirFrictionAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingDoubleJumpVelModAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingGlideStartMinHeightAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingLaunchSpeedCoefficientAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingLiftCoefficientAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingMaxVelAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingOverMaxDecelerationAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingSurfaceFrictionAck)]
|
||||
void HandleSetAdvFlyingSpeedAck(MovementSpeedAck speedAck)
|
||||
{
|
||||
GetPlayer().ValidateMovementInfo(speedAck.Ack.Status);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingBankingRateAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingPitchingRateDownAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingPitchingRateUpAck)]
|
||||
[WorldPacketHandler(ClientOpcodes.MoveSetAdvFlyingTurnVelocityThresholdAck)]
|
||||
void HandleSetAdvFlyingSpeedRangeAck(MovementSpeedRangeAck speedRangeAck)
|
||||
{
|
||||
GetPlayer().ValidateMovementInfo(speedRangeAck.Ack.Status);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.SetActiveMover)]
|
||||
void HandleSetActiveMover(SetActiveMover packet)
|
||||
{
|
||||
|
||||
@@ -532,6 +532,40 @@ namespace Game.Networking.Packets
|
||||
public float Speed = 1.0f;
|
||||
}
|
||||
|
||||
class SetAdvFlyingSpeed : ServerPacket
|
||||
{
|
||||
public ObjectGuid MoverGUID;
|
||||
public uint SequenceIndex;
|
||||
public float Speed = 1.0f;
|
||||
|
||||
public SetAdvFlyingSpeed(ServerOpcodes opcode) : base(opcode) { }
|
||||
|
||||
public override void Write()
|
||||
{
|
||||
_worldPacket.WritePackedGuid(MoverGUID);
|
||||
_worldPacket.WriteUInt32(SequenceIndex);
|
||||
_worldPacket.WriteFloat(Speed);
|
||||
}
|
||||
}
|
||||
|
||||
class SetAdvFlyingSpeedRange : ServerPacket
|
||||
{
|
||||
public ObjectGuid MoverGUID;
|
||||
public uint SequenceIndex;
|
||||
public float SpeedMin = 1.0f;
|
||||
public float SpeedMax = 1.0f;
|
||||
|
||||
public SetAdvFlyingSpeedRange(ServerOpcodes opcode) : base(opcode) { }
|
||||
|
||||
public override void Write()
|
||||
{
|
||||
_worldPacket.WritePackedGuid(MoverGUID);
|
||||
_worldPacket.WriteUInt32(SequenceIndex);
|
||||
_worldPacket.WriteFloat(SpeedMin);
|
||||
_worldPacket.WriteFloat(SpeedMax);
|
||||
}
|
||||
}
|
||||
|
||||
public class MoveSplineSetFlag : ServerPacket
|
||||
{
|
||||
public MoveSplineSetFlag(ServerOpcodes opcode) : base(opcode, ConnectionType.Instance) { }
|
||||
@@ -840,8 +874,8 @@ namespace Game.Networking.Packets
|
||||
}
|
||||
|
||||
public ObjectGuid MoverGUID;
|
||||
int AckIndex;
|
||||
int MoveTime;
|
||||
public int AckIndex;
|
||||
public int MoveTime;
|
||||
}
|
||||
|
||||
public class MovementAckMessage : ClientPacket
|
||||
@@ -870,6 +904,22 @@ namespace Game.Networking.Packets
|
||||
public float Speed;
|
||||
}
|
||||
|
||||
class MovementSpeedRangeAck : ClientPacket
|
||||
{
|
||||
public MovementAck Ack;
|
||||
public float SpeedMin = 1.0f;
|
||||
public float SpeedMax = 1.0f;
|
||||
|
||||
public MovementSpeedRangeAck(WorldPacket packet) : base(packet) { }
|
||||
|
||||
public override void Read()
|
||||
{
|
||||
Ack.Read(_worldPacket);
|
||||
SpeedMin = _worldPacket.ReadFloat();
|
||||
SpeedMax = _worldPacket.ReadFloat();
|
||||
}
|
||||
}
|
||||
|
||||
public class SetActiveMover : ClientPacket
|
||||
{
|
||||
public ObjectGuid ActiveMover;
|
||||
|
||||
Reference in New Issue
Block a user