fix(Core/Entities): Improve interactions between taxis and players regarding PvP flag. (#23681)
This commit is contained in:
@@ -83,29 +83,19 @@ WorldObject* CreatureAI::GetSummoner() const
|
|||||||
inline bool IsValidCombatTarget(Creature* source, Player* target)
|
inline bool IsValidCombatTarget(Creature* source, Player* target)
|
||||||
{
|
{
|
||||||
if (target->IsGameMaster())
|
if (target->IsGameMaster())
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!source->IsInWorld() || !target->IsInWorld())
|
if (!source->IsInWorld() || !target->IsInWorld())
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!source->IsAlive() || !target->IsAlive())
|
if (!source->IsAlive() || !target->IsAlive())
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!source->InSamePhase(target))
|
if (!source->InSamePhase(target))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (source->HasUnitState(UNIT_STATE_IN_FLIGHT) || target->HasUnitState(UNIT_STATE_IN_FLIGHT))
|
if (source->IsInFlight() || target->IsInFlight())
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1439,6 +1439,9 @@ void Player::UpdatePvPState()
|
|||||||
|
|
||||||
if (pvpInfo.IsHostile) // in hostile area
|
if (pvpInfo.IsHostile) // in hostile area
|
||||||
{
|
{
|
||||||
|
if (IsInFlight()) // on taxi
|
||||||
|
return;
|
||||||
|
|
||||||
if (!IsPvP() || pvpInfo.EndTimer != 0)
|
if (!IsPvP() || pvpInfo.EndTimer != 0)
|
||||||
UpdatePvP(true, true);
|
UpdatePvP(true, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1864,7 +1864,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
|
|||||||
|
|
||||||
auto canTakeMeleeDamage = [&]()
|
auto canTakeMeleeDamage = [&]()
|
||||||
{
|
{
|
||||||
return victim->IsAlive() && !victim->HasUnitState(UNIT_STATE_IN_FLIGHT) && (!victim->IsCreature() || !victim->ToCreature()->IsEvadingAttacks());
|
return victim->IsAlive() && !victim->IsInFlight() && (!victim->IsCreature() || !victim->ToCreature()->IsEvadingAttacks());
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!canTakeMeleeDamage())
|
if (!canTakeMeleeDamage())
|
||||||
@@ -18196,10 +18196,8 @@ void Unit::SetControlled(bool apply, UnitState state, Unit* source /*= nullptr*/
|
|||||||
|
|
||||||
void Unit::SetStunned(bool apply)
|
void Unit::SetStunned(bool apply)
|
||||||
{
|
{
|
||||||
if (HasUnitState(UNIT_STATE_IN_FLIGHT))
|
if (IsInFlight())
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (apply)
|
if (apply)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -418,6 +418,7 @@ void FlightPathMovementGenerator::DoFinalize(Player* player)
|
|||||||
player->m_taxi.ClearTaxiDestinations();
|
player->m_taxi.ClearTaxiDestinations();
|
||||||
player->Dismount();
|
player->Dismount();
|
||||||
player->RemoveUnitFlag(UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
|
player->RemoveUnitFlag(UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
|
||||||
|
player->UpdatePvPState(); // to account for cases such as flying into a PvP territory, as it does not flag on the way in
|
||||||
|
|
||||||
if (player->m_taxi.empty())
|
if (player->m_taxi.empty())
|
||||||
{
|
{
|
||||||
@@ -447,6 +448,9 @@ void FlightPathMovementGenerator::DoReset(Player* player)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player->pvpInfo.EndTimer)
|
||||||
|
player->UpdatePvP(false, true); // PvP flag timer immediately ends when starting taxi
|
||||||
|
|
||||||
player->getHostileRefMgr().setOnlineOfflineState(false);
|
player->getHostileRefMgr().setOnlineOfflineState(false);
|
||||||
player->AddUnitState(UNIT_STATE_IN_FLIGHT);
|
player->AddUnitState(UNIT_STATE_IN_FLIGHT);
|
||||||
player->SetUnitFlag(UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
|
player->SetUnitFlag(UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT);
|
||||||
|
|||||||
Reference in New Issue
Block a user