Skip to content

Commit

Permalink
Core/Auras: Implemented SPELL_AURA_CAN_TURN_WHILE_FALLING
Browse files Browse the repository at this point in the history
  • Loading branch information
Shauren committed Oct 16, 2016
1 parent 4a0f5ed commit adad691
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23464,6 +23464,9 @@ void Player::SendAurasForTarget(Unit* target) const
if (target->HasAuraType(SPELL_AURA_HOVER))
target->SetHover(true, true);

if (target->HasAuraType(SPELL_AURA_CAN_TURN_WHILE_FALLING))
target->SetCanTurnWhileFalling(true, true);

if (target->HasAura(SPELL_DH_DOUBLE_JUMP))
target->SetDoubleJump(true, true);

Expand Down
38 changes: 36 additions & 2 deletions src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15646,8 +15646,8 @@ bool Unit::SetCanTransitionBetweenSwimAndFly(bool enable)

static OpcodeServer const swimToFlyTransOpcodeTable[2] =
{
SMSG_MOVE_ENABLE_TRANSITION_BETWEEN_SWIM_AND_FLY,
SMSG_MOVE_DISABLE_TRANSITION_BETWEEN_SWIM_AND_FLY
SMSG_MOVE_DISABLE_TRANSITION_BETWEEN_SWIM_AND_FLY,
SMSG_MOVE_ENABLE_TRANSITION_BETWEEN_SWIM_AND_FLY
};

if (Player* playerMover = GetPlayerMover())
Expand All @@ -15665,6 +15665,40 @@ bool Unit::SetCanTransitionBetweenSwimAndFly(bool enable)
return true;
}

bool Unit::SetCanTurnWhileFalling(bool enable, bool packetOnly /*= false*/)
{
if (!packetOnly)
{
if (enable == HasExtraUnitMovementFlag(MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING))
return false;

if (enable)
AddExtraUnitMovementFlag(MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING);
else
RemoveExtraUnitMovementFlag(MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING);
}

static OpcodeServer const canTurnWhileFallingOpcodeTable[2] =
{
SMSG_MOVE_UNSET_CAN_TURN_WHILE_FALLING,
SMSG_MOVE_SET_CAN_TURN_WHILE_FALLING
};

if (Player* playerMover = GetPlayerMover())
{
WorldPackets::Movement::MoveSetFlag packet(canTurnWhileFallingOpcodeTable[enable]);
packet.MoverGUID = GetGUID();
packet.SequenceIndex = m_movementCounter++;
playerMover->SendDirectMessage(packet.Write());

WorldPackets::Movement::MoveUpdate moveUpdate;
moveUpdate.movementInfo = &m_movementInfo;
SendMessageToSet(moveUpdate.Write(), playerMover);
}

return true;
}

bool Unit::SetDoubleJump(bool enable, bool packetOnly /*= false*/)
{
if (!packetOnly)
Expand Down
3 changes: 2 additions & 1 deletion src/server/game/Entities/Unit/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ enum MovementFlags2
MOVEMENTFLAG2_UNK9 = 0x00000200,
MOVEMENTFLAG2_CAN_SWIM_TO_FLY_TRANS = 0x00000400,
MOVEMENTFLAG2_UNK11 = 0x00000800,
MOVEMENTFLAG2_UNK12 = 0x00001000,
MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING = 0x00001000,
MOVEMENTFLAG2_INTERPOLATED_MOVEMENT = 0x00002000,
MOVEMENTFLAG2_INTERPOLATED_TURNING = 0x00004000,
MOVEMENTFLAG2_INTERPOLATED_PITCHING = 0x00008000,
Expand Down Expand Up @@ -1697,6 +1697,7 @@ class TC_GAME_API Unit : public WorldObject
bool SetHover(bool enable, bool packetOnly = false);
bool SetCollision(bool disable);
bool SetCanTransitionBetweenSwimAndFly(bool enable);
bool SetCanTurnWhileFalling(bool enable, bool packetOnly = false);
bool SetDoubleJump(bool enable, bool packetOnly = false);
void SendSetVehicleRecId(uint32 vehicleId);

Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Server/Protocol/Opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MOVE_ROOT, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MOVE_SET_ACTIVE_MOVER, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MOVE_SET_CAN_FLY, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MOVE_SET_CAN_TURN_WHILE_FALLING, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MOVE_SET_CAN_TURN_WHILE_FALLING, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MOVE_SET_COLLISION_HEIGHT, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MOVE_SET_COMPOUND_STATE, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_MOVE_SET_FEATHER_FALL, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Spells/Auras/SpellAuraDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ enum AuraType
SPELL_AURA_406 = 406,
SPELL_AURA_MOD_FEAR_2 = 407, // NYI
SPELL_AURA_408 = 408,
SPELL_AURA_409 = 409,
SPELL_AURA_CAN_TURN_WHILE_FALLING = 409,
SPELL_AURA_410 = 410,
SPELL_AURA_MOD_MAX_CHARGES = 411,
SPELL_AURA_412 = 412,
Expand Down
19 changes: 18 additions & 1 deletion src/server/game/Spells/Auras/SpellAuraEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNULL, //406
&AuraEffect::HandleNULL, //407 SPELL_AURA_MOD_FEAR_2
&AuraEffect::HandleNULL, //408
&AuraEffect::HandleNULL, //409
&AuraEffect::HandleAuraCanTurnWhileFalling, //409 SPELL_AURA_CAN_TURN_WHILE_FALLING
&AuraEffect::HandleNULL, //410
&AuraEffect::HandleNoImmediateEffect, //411 SPELL_AURA_MOD_MAX_CHARGES implemented in SpellHistory::GetMaxCharges
&AuraEffect::HandleNULL, //412
Expand Down Expand Up @@ -2787,6 +2787,23 @@ void AuraEffect::HandleForceMoveForward(AuraApplication const* aurApp, uint8 mod
}
}

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

Unit* target = aurApp->GetTarget();

if (!apply)
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
if (target->HasAuraType(GetAuraType()))
return;
}

target->SetCanTurnWhileFalling(apply);
}

/****************************/
/*** THREAT ***/
/****************************/
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 @@ -182,6 +182,7 @@ class TC_GAME_API AuraEffect
void HandleAuraHover(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleWaterBreathing(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleForceMoveForward(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleAuraCanTurnWhileFalling(AuraApplication const* aurApp, uint8 mode, bool apply) const;
// threat
void HandleModThreat(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleAuraModTotalThreat(AuraApplication const* aurApp, uint8 mode, bool apply) const;
Expand Down

0 comments on commit adad691

Please sign in to comment.