diff options
-rw-r--r-- | src/server/game/Battlegrounds/Battleground.cpp | 3 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 43 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 2 |
3 files changed, 30 insertions, 18 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index e492847827a..25a9f200606 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -860,7 +860,8 @@ uint32 Battleground::GetBonusHonorFromKill(uint32 kills) const void Battleground::BlockMovement(Player* player) { - player->SetClientControl(player, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave() + // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave() + player->SetClientControl(player, false); } void Battleground::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool SendPacket) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 280ecf86d33..8902b480c90 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -11672,12 +11672,14 @@ void Unit::SetControlled(bool apply, UnitState state) if (HasAuraType(SPELL_AURA_MOD_STUN)) return; + ClearUnitState(state); SetStunned(false); break; case UNIT_STATE_ROOT: if (HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOT_2) || GetVehicle()) return; + ClearUnitState(state); if (!HasUnitState(UNIT_STATE_STUNNED)) SetRooted(false); break; @@ -11685,33 +11687,32 @@ void Unit::SetControlled(bool apply, UnitState state) if (HasAuraType(SPELL_AURA_MOD_CONFUSE)) return; + ClearUnitState(state); SetConfused(false); break; case UNIT_STATE_FLEEING: if (HasAuraType(SPELL_AURA_MOD_FEAR)) return; + ClearUnitState(state); SetFeared(false); break; default: return; } - ClearUnitState(state); - // Unit States might have been already cleared but auras still present. I need to check with HasAuraType if (HasAuraType(SPELL_AURA_MOD_STUN)) SetStunned(true); - else - { - if (HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOT_2)) - SetRooted(true); - if (HasAuraType(SPELL_AURA_MOD_CONFUSE)) - SetConfused(true); - else if (HasAuraType(SPELL_AURA_MOD_FEAR)) - SetFeared(true); - } + if (HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOT_2)) + SetRooted(true); + + if (HasAuraType(SPELL_AURA_MOD_CONFUSE)) + SetConfused(true); + + if (HasAuraType(SPELL_AURA_MOD_FEAR)) + SetFeared(true); } } @@ -11815,8 +11816,12 @@ void Unit::SetFeared(bool apply) } if (Player* player = ToPlayer()) - if (!player->HasUnitState(UNIT_STATE_POSSESSED)) - player->SetClientControl(this, !apply); + { + if (apply) + player->SetClientControl(this, false); + else if (!HasUnitState(UNIT_STATE_LOST_CONTROL)) + player->SetClientControl(this, true); + } } void Unit::SetConfused(bool apply) @@ -11838,8 +11843,12 @@ void Unit::SetConfused(bool apply) } if (Player* player = ToPlayer()) - if (!player->HasUnitState(UNIT_STATE_POSSESSED)) - player->SetClientControl(this, !apply); + { + if (apply) + player->SetClientControl(this, false); + else if (!HasUnitState(UNIT_STATE_LOST_CONTROL)) + player->SetClientControl(this, true); + } } bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* aurApp) @@ -12106,7 +12115,9 @@ void Unit::RemoveCharmedBy(Unit* charmer) NeedChangeAI = true; IsAIEnabled = false; } - player->SetClientControl(this, true); + + if (!HasUnitState(UNIT_STATE_LOST_CONTROL)) + player->SetClientControl(this, true); } EngageWithTarget(charmer); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index f1948da6223..9dc7b800b02 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -281,7 +281,7 @@ enum UnitState : uint32 UNIT_STATE_UNATTACKABLE = UNIT_STATE_IN_FLIGHT, UNIT_STATE_MOVING = UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE | UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE, UNIT_STATE_CONTROLLED = UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING, - UNIT_STATE_LOST_CONTROL = UNIT_STATE_CONTROLLED | UNIT_STATE_JUMPING | UNIT_STATE_CHARGING, + UNIT_STATE_LOST_CONTROL = UNIT_STATE_CONTROLLED | UNIT_STATE_POSSESSED | UNIT_STATE_JUMPING | UNIT_STATE_CHARGING, UNIT_STATE_SIGHTLESS = UNIT_STATE_LOST_CONTROL | UNIT_STATE_EVADE, UNIT_STATE_CANNOT_AUTOATTACK = UNIT_STATE_LOST_CONTROL | UNIT_STATE_CASTING, UNIT_STATE_CANNOT_TURN = UNIT_STATE_LOST_CONTROL | UNIT_STATE_ROTATING, |