Core/Auras: Implemented adv flying speed mod auras

Port From (https://github.com/TrinityCore/TrinityCore/commit/6e0b146f1d6df817714595995632e2514e5869a8)
This commit is contained in:
Hondacrx
2024-11-10 22:13:41 -05:00
parent f14a77d33f
commit 3a4eec6ebd
3 changed files with 100 additions and 27 deletions
@@ -520,18 +520,18 @@ namespace Framework.Constants
ModifiedRaidInstance = 510, // NYI; Related to "Fated" raid affixes
ApplyProfessionEffect = 511, // Nyi; Miscvalue[0] = Professioneffectid
Unk512 = 512,
Unk513 = 513,
Unk514 = 514,
Unk515 = 515,
ModAdvFlyingAirFriction = 513,
ModAdvFlyingMaxVel = 514,
ModAdvFlyingLiftCoef = 515,
Unk516 = 516,
Unk517 = 517,
Unk518 = 518,
ModAdvFlyingAddImpulseMaxSpeed = 518,
ModCooldownRecoveryRateAll = 519, // Nyi; Applies To All Spells, Not Filtered By Familyflags Or Label
Unk520 = 520,
Unk521 = 521,
Unk522 = 522,
ModAdvFlyingBankingRate = 520,
ModAdvFlyingPitchingRateDown = 521,
ModAdvFlyingPitchingRateUp = 522,
Unk523 = 523,
Unk524 = 524,
ModAdvFlyingOverMaxDeceleration = 524,
DisplayProfessionEquipment = 525, // Nyi; Miscvalue[0] = Profession (Enum, Not Id)
Unk526 = 526,
Unk527 = 527,
+49 -19
View File
@@ -176,26 +176,38 @@ namespace Game.Entities
UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.LaunchSpeedCoefficient, clientUpdate);
}
void UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle speedType, bool clientUpdate)
public 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
(ServerOpcodes opcode, float newValue, AuraType rateAura) = 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)
AdvFlyingRateTypeSingle.AirFriction => (ServerOpcodes.MoveSetAdvFlyingAirFriction, flightCapabilityEntry.AirFriction, AuraType.ModAdvFlyingAirFriction),
AdvFlyingRateTypeSingle.MaxVel => (ServerOpcodes.MoveSetAdvFlyingMaxVel, flightCapabilityEntry.MaxVel, AuraType.ModAdvFlyingMaxVel),
AdvFlyingRateTypeSingle.LiftCoefficient => (ServerOpcodes.MoveSetAdvFlyingLiftCoefficient, flightCapabilityEntry.LiftCoefficient, AuraType.ModAdvFlyingLiftCoef),
AdvFlyingRateTypeSingle.DoubleJumpVelMod => (ServerOpcodes.MoveSetAdvFlyingDoubleJumpVelMod, flightCapabilityEntry.DoubleJumpVelMod, AuraType.None),
AdvFlyingRateTypeSingle.GlideStartMinHeight => (ServerOpcodes.MoveSetAdvFlyingGlideStartMinHeight, flightCapabilityEntry.GlideStartMinHeight, AuraType.None),
AdvFlyingRateTypeSingle.AddImpulseMaxSpeed => (ServerOpcodes.MoveSetAdvFlyingAddImpulseMaxSpeed, flightCapabilityEntry.AddImpulseMaxSpeed, AuraType.ModAdvFlyingAddImpulseMaxSpeed),
AdvFlyingRateTypeSingle.SurfaceFriction => (ServerOpcodes.MoveSetAdvFlyingSurfaceFriction, flightCapabilityEntry.SurfaceFriction, AuraType.None),
AdvFlyingRateTypeSingle.OverMaxDeceleration => (ServerOpcodes.MoveSetAdvFlyingOverMaxDeceleration, flightCapabilityEntry.OverMaxDeceleration, AuraType.ModAdvFlyingOverMaxDeceleration),
AdvFlyingRateTypeSingle.LaunchSpeedCoefficient => (ServerOpcodes.MoveSetAdvFlyingLaunchSpeedCoefficient, flightCapabilityEntry.LaunchSpeedCoefficient, AuraType.None),
_ => (ServerOpcodes.Max, 0, AuraType.None)
};
if (rateAura != AuraType.None)
{
// take only lowest negative and highest positive auras - these effects do not stack
int neg = GetMaxNegativeAuraModifier(rateAura, mod => mod.GetAmount() > 0 && mod.GetAmount() < 100);
if (neg != 0)
MathFunctions.ApplyPct(ref newValue, neg);
int pos = GetMaxPositiveAuraModifier(rateAura, mod => mod.GetAmount() > 100);
if (pos != 0)
MathFunctions.ApplyPct(ref newValue, pos);
}
if (m_advFlyingSpeed[(int)speedType] == newValue)
return;
@@ -215,21 +227,39 @@ namespace Game.Entities
}
}
void UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange speedType, bool clientUpdate)
public 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
(ServerOpcodes opcode, float min, float max, AuraType rateAura) = 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)
AdvFlyingRateTypeRange.BankingRate => (ServerOpcodes.MoveSetAdvFlyingBankingRate, flightCapabilityEntry.BankingRateMin, flightCapabilityEntry.BankingRateMax, AuraType.ModAdvFlyingBankingRate),
AdvFlyingRateTypeRange.PitchingRateDown => (ServerOpcodes.MoveSetAdvFlyingPitchingRateDown, flightCapabilityEntry.PitchingRateDownMin, flightCapabilityEntry.PitchingRateDownMax, AuraType.ModAdvFlyingPitchingRateDown),
AdvFlyingRateTypeRange.PitchingRateUp => (ServerOpcodes.MoveSetAdvFlyingPitchingRateUp, flightCapabilityEntry.PitchingRateUpMin, flightCapabilityEntry.PitchingRateUpMax, AuraType.ModAdvFlyingPitchingRateUp),
AdvFlyingRateTypeRange.TurnVelocityThreshold => (ServerOpcodes.MoveSetAdvFlyingTurnVelocityThreshold, flightCapabilityEntry.TurnVelocityThresholdMin, flightCapabilityEntry.TurnVelocityThresholdMax, AuraType.None),
_ => (ServerOpcodes.Max, 0, 0, AuraType.None)
};
if (rateAura != AuraType.None)
{
// take only lowest negative and highest positive auras - these effects do not stack
int neg = GetMaxNegativeAuraModifier(rateAura, mod => mod.GetAmount() > 0 && mod.GetAmount() < 100);
if (neg != 0)
{
MathFunctions.ApplyPct(ref min, neg);
MathFunctions.ApplyPct(ref max, neg);
}
int pos = GetMaxPositiveAuraModifier(rateAura, mod => mod.GetAmount() > 100);
if (pos != 0)
{
MathFunctions.ApplyPct(ref min, pos);
MathFunctions.ApplyPct(ref max, pos);
}
}
if (m_advFlyingSpeed[(int)speedType] == min && m_advFlyingSpeed[(int)speedType + 1] == max)
return;
+43
View File
@@ -2888,6 +2888,49 @@ namespace Game.Spells
aurApp.GetTarget().UpdateMovementForcesModMagnitude();
}
[AuraEffectHandler(AuraType.ModAdvFlyingAirFriction)]
[AuraEffectHandler(AuraType.ModAdvFlyingMaxVel)]
[AuraEffectHandler(AuraType.ModAdvFlyingLiftCoef)]
[AuraEffectHandler(AuraType.ModAdvFlyingAddImpulseMaxSpeed)]
[AuraEffectHandler(AuraType.ModAdvFlyingBankingRate)]
[AuraEffectHandler(AuraType.ModAdvFlyingPitchingRateDown)]
[AuraEffectHandler(AuraType.ModAdvFlyingPitchingRateUp)]
[AuraEffectHandler(AuraType.ModAdvFlyingOverMaxDeceleration)]
void HandleAuraModAdvFlyingSpeed(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply)
{
if (!mode.HasAnyFlag(AuraEffectHandleModes.ChangeAmountMask))
return;
Unit target = aurApp.GetTarget();
switch (GetAuraType())
{
case AuraType.ModAdvFlyingAirFriction:
target.UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.AirFriction, true);
break;
case AuraType.ModAdvFlyingMaxVel:
target.UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.MaxVel, true);
break;
case AuraType.ModAdvFlyingLiftCoef:
target.UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.LiftCoefficient, true);
break;
case AuraType.ModAdvFlyingAddImpulseMaxSpeed:
target.UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.AddImpulseMaxSpeed, true);
break;
case AuraType.ModAdvFlyingBankingRate:
target.UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange.BankingRate, true);
break;
case AuraType.ModAdvFlyingPitchingRateDown:
target.UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange.PitchingRateDown, true);
break;
case AuraType.ModAdvFlyingPitchingRateUp:
target.UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange.PitchingRateUp, true);
break;
case AuraType.ModAdvFlyingOverMaxDeceleration:
target.UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle.OverMaxDeceleration, true);
break;
}
}
/*********************************************************/
/*** IMMUNITY ***/
/*********************************************************/