Merge pull request #7644 from e000/master
[Unit::SetCharm] Restore original walking state when removing charm. Fixes mind control + walk bug.
This commit is contained in:
@@ -9978,7 +9978,8 @@ void Unit::SetCharm(Unit* charm, bool apply)
|
|||||||
if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
|
if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
|
||||||
sLog->outFatal(LOG_FILTER_UNITS, "Unit %u is being charmed, but it already has a charmer " UI64FMTD "", charm->GetEntry(), charm->GetCharmerGUID());
|
sLog->outFatal(LOG_FILTER_UNITS, "Unit %u is being charmed, but it already has a charmer " UI64FMTD "", charm->GetEntry(), charm->GetCharmerGUID());
|
||||||
|
|
||||||
if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
|
_isWalkingBeforeCharm = charm->IsWalking();
|
||||||
|
if (_isWalkingBeforeCharm)
|
||||||
{
|
{
|
||||||
charm->SetWalk(false);
|
charm->SetWalk(false);
|
||||||
charm->SendMovementFlagUpdate();
|
charm->SendMovementFlagUpdate();
|
||||||
@@ -10015,6 +10016,12 @@ void Unit::SetCharm(Unit* charm, bool apply)
|
|||||||
charm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
|
charm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
|
||||||
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0);
|
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (charm->IsWalking() != _isWalkingBeforeCharm)
|
||||||
|
{
|
||||||
|
charm->SetWalk(_isWalkingBeforeCharm);
|
||||||
|
charm->SendMovementFlagUpdate(true); // send packet to self, to update movement state on player.
|
||||||
|
}
|
||||||
|
|
||||||
if (charm->GetTypeId() == TYPEID_PLAYER
|
if (charm->GetTypeId() == TYPEID_PLAYER
|
||||||
|| !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION)
|
|| !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION)
|
||||||
@@ -14763,11 +14770,11 @@ void Unit::StopMoving()
|
|||||||
init.Launch();
|
init.Launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::SendMovementFlagUpdate()
|
void Unit::SendMovementFlagUpdate(bool self /* = false */)
|
||||||
{
|
{
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
BuildHeartBeatMsg(&data);
|
BuildHeartBeatMsg(&data);
|
||||||
SendMessageToSet(&data, false);
|
SendMessageToSet(&data, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unit::IsSitState() const
|
bool Unit::IsSitState() const
|
||||||
|
|||||||
@@ -1606,7 +1606,7 @@ class Unit : public WorldObject
|
|||||||
void MonsterMoveWithSpeed(float x, float y, float z, float speed);
|
void MonsterMoveWithSpeed(float x, float y, float z, float speed);
|
||||||
//void SetFacing(float ori, WorldObject* obj = NULL);
|
//void SetFacing(float ori, WorldObject* obj = NULL);
|
||||||
//void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL);
|
//void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL);
|
||||||
void SendMovementFlagUpdate();
|
void SendMovementFlagUpdate(bool self = false);
|
||||||
|
|
||||||
/*! These methods send the same packet to the client in apply and unapply case.
|
/*! These methods send the same packet to the client in apply and unapply case.
|
||||||
The client-side interpretation of this packet depends on the presence of relevant movementflags
|
The client-side interpretation of this packet depends on the presence of relevant movementflags
|
||||||
@@ -2356,6 +2356,7 @@ class Unit : public WorldObject
|
|||||||
|
|
||||||
Spell const* _focusSpell;
|
Spell const* _focusSpell;
|
||||||
bool _targetLocked; // locks the target during spell cast for proper facing
|
bool _targetLocked; // locks the target during spell cast for proper facing
|
||||||
|
bool _isWalkingBeforeCharm; // Are we walking before we were charmed?
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Trinity
|
namespace Trinity
|
||||||
|
|||||||
Reference in New Issue
Block a user