Skip to content

Commit

Permalink
Core/Auras: Implemented adv flying speed mod auras
Browse files Browse the repository at this point in the history
Co-authored-by: Traesh <[email protected]>
  • Loading branch information
Shauren and Traesh committed Oct 10, 2024
1 parent d329456 commit 6e0b146
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 33 deletions.
60 changes: 43 additions & 17 deletions src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8767,33 +8767,43 @@ void Unit::UpdateAdvFlyingSpeed(AdvFlyingRateTypeSingle speedType, bool clientUp
if (!flightCapabilityEntry)
flightCapabilityEntry = sFlightCapabilityStore.AssertEntry(1);

auto [opcode, newValue] = [&]
auto [opcode, newValue, rateAura] = [&]
{
switch (speedType)
{
case ADV_FLYING_AIR_FRICTION:
return std::pair(SMSG_MOVE_SET_ADV_FLYING_AIR_FRICTION, flightCapabilityEntry->AirFriction);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_AIR_FRICTION, flightCapabilityEntry->AirFriction, SPELL_AURA_MOD_ADV_FLYING_AIR_FRICTION);
case ADV_FLYING_MAX_VEL:
return std::pair(SMSG_MOVE_SET_ADV_FLYING_MAX_VEL, flightCapabilityEntry->MaxVel);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_MAX_VEL, flightCapabilityEntry->MaxVel, SPELL_AURA_MOD_ADV_FLYING_MAX_VEL);
case ADV_FLYING_LIFT_COEFFICIENT:
return std::pair(SMSG_MOVE_SET_ADV_FLYING_LIFT_COEFFICIENT, flightCapabilityEntry->LiftCoefficient);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_LIFT_COEFFICIENT, flightCapabilityEntry->LiftCoefficient, SPELL_AURA_MOD_ADV_FLYING_LIFT_COEF);
case ADV_FLYING_DOUBLE_JUMP_VEL_MOD:
return std::pair(SMSG_MOVE_SET_ADV_FLYING_DOUBLE_JUMP_VEL_MOD, flightCapabilityEntry->DoubleJumpVelMod);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_DOUBLE_JUMP_VEL_MOD, flightCapabilityEntry->DoubleJumpVelMod, SPELL_AURA_NONE);
case ADV_FLYING_GLIDE_START_MIN_HEIGHT:
return std::pair(SMSG_MOVE_SET_ADV_FLYING_GLIDE_START_MIN_HEIGHT, flightCapabilityEntry->GlideStartMinHeight);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_GLIDE_START_MIN_HEIGHT, flightCapabilityEntry->GlideStartMinHeight, SPELL_AURA_NONE);
case ADV_FLYING_ADD_IMPULSE_MAX_SPEED:
return std::pair(SMSG_MOVE_SET_ADV_FLYING_ADD_IMPULSE_MAX_SPEED, flightCapabilityEntry->AddImpulseMaxSpeed);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_ADD_IMPULSE_MAX_SPEED, flightCapabilityEntry->AddImpulseMaxSpeed, SPELL_AURA_MOD_ADV_FLYING_ADD_IMPULSE_MAX_SPEED);
case ADV_FLYING_SURFACE_FRICTION:
return std::pair(SMSG_MOVE_SET_ADV_FLYING_SURFACE_FRICTION, flightCapabilityEntry->SurfaceFriction);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_SURFACE_FRICTION, flightCapabilityEntry->SurfaceFriction, SPELL_AURA_NONE);
case ADV_FLYING_OVER_MAX_DECELERATION:
return std::pair(SMSG_MOVE_SET_ADV_FLYING_OVER_MAX_DECELERATION, flightCapabilityEntry->OverMaxDeceleration);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_OVER_MAX_DECELERATION, flightCapabilityEntry->OverMaxDeceleration, SPELL_AURA_MOD_ADV_FLYING_OVER_MAX_DECELERATION);
case ADV_FLYING_LAUNCH_SPEED_COEFFICIENT:
return std::pair(SMSG_MOVE_SET_ADV_FLYING_LAUNCH_SPEED_COEFFICIENT, flightCapabilityEntry->LaunchSpeedCoefficient);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_LAUNCH_SPEED_COEFFICIENT, flightCapabilityEntry->LaunchSpeedCoefficient, SPELL_AURA_NONE);
default:
return std::pair<OpcodeServer, float>();
return std::tuple<OpcodeServer, float, AuraType>();
}
}();

if (rateAura != SPELL_AURA_NONE)
{
// take only lowest negative and highest positive auras - these effects do not stack
if (int32 neg = GetMaxNegativeAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 0 && mod->GetAmount() < 100; }))
ApplyPct(newValue, neg);

if (int32 pos = GetMaxPositiveAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 100; }))
ApplyPct(newValue, pos);
}

if (m_advFlyingSpeed[speedType] == newValue)
return;

Expand All @@ -8818,23 +8828,39 @@ void Unit::UpdateAdvFlyingSpeed(AdvFlyingRateTypeRange speedType, bool clientUpd
if (!flightCapabilityEntry)
flightCapabilityEntry = sFlightCapabilityStore.AssertEntry(1);

auto [opcode, min, max] = [&]
auto [opcode, min, max, rateAura] = [&]
{
switch (speedType)
{
case ADV_FLYING_BANKING_RATE:
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_BANKING_RATE, flightCapabilityEntry->BankingRateMin, flightCapabilityEntry->BankingRateMax);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_BANKING_RATE, flightCapabilityEntry->BankingRateMin, flightCapabilityEntry->BankingRateMax, SPELL_AURA_MOD_ADV_FLYING_BANKING_RATE);
case ADV_FLYING_PITCHING_RATE_DOWN:
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_PITCHING_RATE_DOWN, flightCapabilityEntry->PitchingRateDownMin, flightCapabilityEntry->PitchingRateDownMax);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_PITCHING_RATE_DOWN, flightCapabilityEntry->PitchingRateDownMin, flightCapabilityEntry->PitchingRateDownMax, SPELL_AURA_MOD_ADV_FLYING_PITCHING_RATE_DOWN);
case ADV_FLYING_PITCHING_RATE_UP:
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_PITCHING_RATE_UP, flightCapabilityEntry->PitchingRateUpMin, flightCapabilityEntry->PitchingRateUpMax);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_PITCHING_RATE_UP, flightCapabilityEntry->PitchingRateUpMin, flightCapabilityEntry->PitchingRateUpMax, SPELL_AURA_MOD_ADV_FLYING_PITCHING_RATE_UP);
case ADV_FLYING_TURN_VELOCITY_THRESHOLD:
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_TURN_VELOCITY_THRESHOLD, flightCapabilityEntry->TurnVelocityThresholdMin, flightCapabilityEntry->TurnVelocityThresholdMax);
return std::tuple(SMSG_MOVE_SET_ADV_FLYING_TURN_VELOCITY_THRESHOLD, flightCapabilityEntry->TurnVelocityThresholdMin, flightCapabilityEntry->TurnVelocityThresholdMax, SPELL_AURA_NONE);
default:
return std::tuple<OpcodeServer, float, float>();
return std::tuple<OpcodeServer, float, float, AuraType>();
}
}();

if (rateAura != SPELL_AURA_NONE)
{
// take only lowest negative and highest positive auras - these effects do not stack
if (int32 neg = GetMaxNegativeAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 0 && mod->GetAmount() < 100; }))
{
ApplyPct(min, neg);
ApplyPct(max, neg);
}

if (int32 pos = GetMaxPositiveAuraModifier(rateAura, [](AuraEffect const* mod) { return mod->GetAmount() > 100; }))
{
ApplyPct(min, pos);
ApplyPct(max, pos);
}
}

if (m_advFlyingSpeed[speedType] == min && m_advFlyingSpeed[speedType + 1] == max)
return;

Expand Down
16 changes: 8 additions & 8 deletions src/server/game/Spells/Auras/SpellAuraDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,18 +604,18 @@ enum AuraType : uint32
SPELL_AURA_MODIFIED_RAID_INSTANCE = 510, // NYI; Related to "Fated" raid affixes
SPELL_AURA_APPLY_PROFESSION_EFFECT = 511, // NYI; MiscValue[0] = ProfessionEffectID
SPELL_AURA_512 = 512,
SPELL_AURA_513 = 513,
SPELL_AURA_514 = 514,
SPELL_AURA_515 = 515,
SPELL_AURA_MOD_ADV_FLYING_AIR_FRICTION = 513,
SPELL_AURA_MOD_ADV_FLYING_MAX_VEL = 514,
SPELL_AURA_MOD_ADV_FLYING_LIFT_COEF = 515,
SPELL_AURA_516 = 516,
SPELL_AURA_517 = 517,
SPELL_AURA_518 = 518,
SPELL_AURA_MOD_ADV_FLYING_ADD_IMPULSE_MAX_SPEED = 518,
SPELL_AURA_MOD_COOLDOWN_RECOVERY_RATE_ALL = 519, // NYI; applies to all spells, not filtered by familyflags or label
SPELL_AURA_520 = 520,
SPELL_AURA_521 = 521,
SPELL_AURA_522 = 522,
SPELL_AURA_MOD_ADV_FLYING_BANKING_RATE = 520,
SPELL_AURA_MOD_ADV_FLYING_PITCHING_RATE_DOWN = 521,
SPELL_AURA_MOD_ADV_FLYING_PITCHING_RATE_UP = 522,
SPELL_AURA_523 = 523,
SPELL_AURA_524 = 524,
SPELL_AURA_MOD_ADV_FLYING_OVER_MAX_DECELERATION = 524,
SPELL_AURA_DISPLAY_PROFESSION_EQUIPMENT = 525, // NYI; MiscValue[0] = Profession (enum, not id)
SPELL_AURA_526 = 526,
SPELL_AURA_527 = 527,
Expand Down
53 changes: 45 additions & 8 deletions src/server/game/Spells/Auras/SpellAuraEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,18 +582,18 @@ NonDefaultConstructible<pAuraEffectHandler> AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNULL, //510 SPELL_AURA_MODIFIED_RAID_INSTANCE
&AuraEffect::HandleNULL, //511 SPELL_AURA_APPLY_PROFESSION_EFFECT
&AuraEffect::HandleNULL, //512
&AuraEffect::HandleNULL, //513
&AuraEffect::HandleNULL, //514
&AuraEffect::HandleNULL, //515
&AuraEffect::HandleAuraModAdvFlyingSpeed, //513 SPELL_AURA_MOD_ADV_FLYING_AIR_FRICTION
&AuraEffect::HandleAuraModAdvFlyingSpeed, //514 SPELL_AURA_MOD_ADV_FLYING_MAX_VEL
&AuraEffect::HandleAuraModAdvFlyingSpeed, //515 SPELL_AURA_MOD_ADV_FLYING_LIFT_COEF
&AuraEffect::HandleNULL, //516
&AuraEffect::HandleNULL, //517
&AuraEffect::HandleNULL, //518
&AuraEffect::HandleAuraModAdvFlyingSpeed, //518 SPELL_AURA_MOD_ADV_FLYING_ADD_IMPULSE_MAX_SPEED
&AuraEffect::HandleNULL, //519 SPELL_AURA_MOD_COOLDOWN_RECOVERY_RATE_ALL
&AuraEffect::HandleNULL, //520
&AuraEffect::HandleNULL, //521
&AuraEffect::HandleNULL, //522
&AuraEffect::HandleAuraModAdvFlyingSpeed, //520 SPELL_AURA_MOD_ADV_FLYING_BANKING_RATE
&AuraEffect::HandleAuraModAdvFlyingSpeed, //521 SPELL_AURA_MOD_ADV_FLYING_PITCHING_RATE_DOWN
&AuraEffect::HandleAuraModAdvFlyingSpeed, //522 SPELL_AURA_MOD_ADV_FLYING_PITCHING_RATE_UP
&AuraEffect::HandleNULL, //523
&AuraEffect::HandleNULL, //524
&AuraEffect::HandleAuraModAdvFlyingSpeed, //524 SPELL_AURA_MOD_ADV_FLYING_OVER_MAX_DECELERATION
&AuraEffect::HandleNULL, //525 SPELL_AURA_DISPLAY_PROFESSION_EQUIPMENT
&AuraEffect::HandleNULL, //526
&AuraEffect::HandleNULL, //527
Expand Down Expand Up @@ -3424,6 +3424,43 @@ void AuraEffect::HandleModMovementForceMagnitude(AuraApplication const* aurApp,
aurApp->GetTarget()->UpdateMovementForcesModMagnitude();
}

void AuraEffect::HandleAuraModAdvFlyingSpeed(AuraApplication const* aurApp, uint8 mode, bool /*apply*/) const
{
if (!(mode & AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK))
return;

Unit* target = aurApp->GetTarget();
switch (GetAuraType())
{
case SPELL_AURA_MOD_ADV_FLYING_AIR_FRICTION:
target->UpdateAdvFlyingSpeed(ADV_FLYING_AIR_FRICTION, true);
break;
case SPELL_AURA_MOD_ADV_FLYING_MAX_VEL:
target->UpdateAdvFlyingSpeed(ADV_FLYING_MAX_VEL, true);
break;
case SPELL_AURA_MOD_ADV_FLYING_LIFT_COEF:
target->UpdateAdvFlyingSpeed(ADV_FLYING_LIFT_COEFFICIENT, true);
break;
case SPELL_AURA_MOD_ADV_FLYING_ADD_IMPULSE_MAX_SPEED:
target->UpdateAdvFlyingSpeed(ADV_FLYING_ADD_IMPULSE_MAX_SPEED, true);
break;
case SPELL_AURA_MOD_ADV_FLYING_BANKING_RATE:
target->UpdateAdvFlyingSpeed(ADV_FLYING_BANKING_RATE, true);
break;
case SPELL_AURA_MOD_ADV_FLYING_PITCHING_RATE_DOWN:
target->UpdateAdvFlyingSpeed(ADV_FLYING_PITCHING_RATE_DOWN, true);
break;
case SPELL_AURA_MOD_ADV_FLYING_PITCHING_RATE_UP:
target->UpdateAdvFlyingSpeed(ADV_FLYING_PITCHING_RATE_UP, true);
break;
case SPELL_AURA_MOD_ADV_FLYING_OVER_MAX_DECELERATION:
target->UpdateAdvFlyingSpeed(ADV_FLYING_OVER_MAX_DECELERATION, true);
break;
default:
break;
}
}

/*********************************************************/
/*** IMMUNITY ***/
/*********************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Spells/Auras/SpellAuraEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class TC_GAME_API AuraEffect
void HandleAuraModUseNormalSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleAuraModMinimumSpeedRate(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleModMovementForceMagnitude(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleAuraModAdvFlyingSpeed(AuraApplication const* aurApp, uint8 mode, bool apply) const;
// immunity
void HandleModMechanicImmunityMask(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleModMechanicImmunity(AuraApplication const* aurApp, uint8 mode, bool apply) const;
Expand Down

0 comments on commit 6e0b146

Please sign in to comment.