mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Entities: don't allow client control if player is still affected by any lose of control state
This commit is contained in:
@@ -821,7 +821,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)
|
||||
|
||||
@@ -12072,45 +12072,46 @@ 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) || GetVehicle())
|
||||
return;
|
||||
|
||||
ClearUnitState(state);
|
||||
SetRooted(false);
|
||||
break;
|
||||
case UNIT_STATE_CONFUSED:
|
||||
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))
|
||||
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))
|
||||
SetRooted(true);
|
||||
|
||||
if (HasAuraType(SPELL_AURA_MOD_CONFUSE))
|
||||
SetConfused(true);
|
||||
|
||||
if (HasAuraType(SPELL_AURA_MOD_FEAR))
|
||||
SetFeared(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12237,8 +12238,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)
|
||||
@@ -12260,8 +12265,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)
|
||||
@@ -12528,7 +12537,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);
|
||||
|
||||
@@ -248,7 +248,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,
|
||||
|
||||
Reference in New Issue
Block a user