mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 01:29:07 +00:00
feat(Core/Unit): New helpers for UnitFlag and UnitFlag2 (#11227)
This commit is contained in:
@@ -2303,7 +2303,7 @@ void Unit::CalcHealAbsorb(HealInfo& healInfo)
|
||||
|
||||
void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extra)
|
||||
{
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
|
||||
if (HasUnitFlag(UNIT_FLAG_PACIFIED))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -9635,9 +9635,9 @@ ReputationRank Unit::GetReactionTo(Unit const* target, bool checkOriginalFaction
|
||||
return *repRank;
|
||||
}
|
||||
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
if (HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
{
|
||||
if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
if (target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
{
|
||||
if (selfPlayerOwner && targetPlayerOwner)
|
||||
{
|
||||
@@ -9666,7 +9666,7 @@ ReputationRank Unit::GetReactionTo(Unit const* target, bool checkOriginalFaction
|
||||
{
|
||||
if (ReputationRank const* repRank = selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry))
|
||||
return *repRank;
|
||||
if (!selfPlayerOwner->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_IGNORE_REPUTATION))
|
||||
if (!selfPlayerOwner->HasUnitFlag2(UNIT_FLAG2_IGNORE_REPUTATION))
|
||||
{
|
||||
if (FactionEntry const* targetFactionEntry = sFactionStore.LookupEntry(targetFactionTemplateEntry->faction))
|
||||
{
|
||||
@@ -9751,7 +9751,7 @@ ReputationRank Unit::GetFactionReactionTo(FactionTemplateEntry const* factionTem
|
||||
return REP_HOSTILE;
|
||||
if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(factionTemplateEntry))
|
||||
return *repRank;
|
||||
if (!target->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_IGNORE_REPUTATION))
|
||||
if (!target->HasUnitFlag2(UNIT_FLAG2_IGNORE_REPUTATION))
|
||||
{
|
||||
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction))
|
||||
{
|
||||
@@ -9846,7 +9846,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
|
||||
return false;
|
||||
}
|
||||
|
||||
//if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) // pussywizard: why having this flag prevents from entering combat? it should just prevent melee attack
|
||||
//if (HasUnitFlag(UNIT_FLAG_PACIFIED)) // pussywizard: why having this flag prevents from entering combat? it should just prevent melee attack
|
||||
// return false;
|
||||
|
||||
// nobody can attack GM in GM-mode
|
||||
@@ -10229,7 +10229,7 @@ void Unit::SetMinion(Minion* minion, bool apply)
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
minion->m_ControlledByPlayer = true;
|
||||
minion->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
minion->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
}
|
||||
|
||||
// Can only have one pet. If a new one is summoned, dismiss the old one.
|
||||
@@ -10417,7 +10417,7 @@ void Unit::SetCharm(Unit* charm, bool apply)
|
||||
|
||||
charm->m_ControlledByPlayer = true;
|
||||
// TODO: maybe we can use this flag to check if controlled by player
|
||||
charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
charm->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
}
|
||||
else
|
||||
charm->m_ControlledByPlayer = false;
|
||||
@@ -10447,13 +10447,13 @@ void Unit::SetCharm(Unit* charm, bool apply)
|
||||
if (charm->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
charm->m_ControlledByPlayer = true;
|
||||
charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
charm->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
charm->ToPlayer()->UpdatePvPState();
|
||||
}
|
||||
else if (Player* player = charm->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
{
|
||||
charm->m_ControlledByPlayer = true;
|
||||
charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
charm->SetUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, player->GetByteValue(UNIT_FIELD_BYTES_2, 1));
|
||||
|
||||
// Xinef: skip controlled erase if charmed unit is owned by charmer
|
||||
@@ -10463,7 +10463,7 @@ void Unit::SetCharm(Unit* charm, bool apply)
|
||||
else
|
||||
{
|
||||
charm->m_ControlledByPlayer = false;
|
||||
charm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
charm->RemoveUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0);
|
||||
}
|
||||
|
||||
@@ -12840,7 +12840,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
|
||||
if (mount)
|
||||
SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount);
|
||||
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT);
|
||||
SetUnitFlag(UNIT_FLAG_MOUNT);
|
||||
|
||||
if (Player* player = ToPlayer())
|
||||
{
|
||||
@@ -12874,7 +12874,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
|
||||
Battleground* bg = ToPlayer()->GetBattleground();
|
||||
// don't unsummon pet in arena but SetFlag UNIT_FLAG_STUNNED to disable pet's interface
|
||||
if (bg && bg->isArena())
|
||||
pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
pet->SetUnitFlag(UNIT_FLAG_STUNNED);
|
||||
else
|
||||
player->UnsummonPetTemporaryIfAny();
|
||||
}
|
||||
@@ -12882,7 +12882,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
|
||||
// xinef: if we have charmed npc, stun him also
|
||||
if (Unit* charm = player->GetCharm())
|
||||
if (charm->GetTypeId() == TYPEID_UNIT)
|
||||
charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
charm->SetUnitFlag(UNIT_FLAG_STUNNED);
|
||||
|
||||
WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4);
|
||||
data << GetPackGUID();
|
||||
@@ -12900,7 +12900,7 @@ void Unit::Dismount()
|
||||
return;
|
||||
|
||||
SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0);
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT);
|
||||
RemoveUnitFlag(UNIT_FLAG_MOUNT);
|
||||
|
||||
if (Player* thisPlayer = ToPlayer())
|
||||
{
|
||||
@@ -12938,8 +12938,8 @@ void Unit::Dismount()
|
||||
|
||||
if (Pet* pPet = player->GetPet())
|
||||
{
|
||||
if (pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->HasUnitState(UNIT_STATE_STUNNED))
|
||||
pPet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
if (pPet->HasUnitFlag(UNIT_FLAG_STUNNED) && !pPet->HasUnitState(UNIT_STATE_STUNNED))
|
||||
pPet->RemoveUnitFlag(UNIT_FLAG_STUNNED);
|
||||
}
|
||||
else
|
||||
player->ResummonPetTemporaryUnSummonedIfAny();
|
||||
@@ -12947,7 +12947,7 @@ void Unit::Dismount()
|
||||
// xinef: if we have charmed npc, remove stun also
|
||||
if (Unit* charm = player->GetCharm())
|
||||
if (charm->GetTypeId() == TYPEID_UNIT && !charm->HasUnitState(UNIT_STATE_STUNNED))
|
||||
charm->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
charm->RemoveUnitFlag(UNIT_FLAG_STUNNED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13090,13 +13090,13 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration)
|
||||
return;
|
||||
|
||||
// xinef: if we somehow engage in combat (scripts, dunno) with player, remove this flag so he can fight back
|
||||
if (GetTypeId() == TYPEID_UNIT && enemy && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC) && enemy->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); // unit has engaged in combat, remove immunity so players can fight back
|
||||
if (GetTypeId() == TYPEID_UNIT && enemy && HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC) && enemy->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
RemoveUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); // unit has engaged in combat, remove immunity so players can fight back
|
||||
|
||||
if (IsInCombat())
|
||||
return;
|
||||
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
SetUnitFlag(UNIT_FLAG_IN_COMBAT);
|
||||
|
||||
if (Creature* creature = ToCreature())
|
||||
{
|
||||
@@ -13151,13 +13151,13 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy, uint32 duration)
|
||||
void Unit::ClearInCombat()
|
||||
{
|
||||
m_CombatTimer = 0;
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
RemoveUnitFlag(UNIT_FLAG_IN_COMBAT);
|
||||
|
||||
// Player's state will be cleared in Player::UpdateContestedPvP
|
||||
if (Creature* creature = ToCreature())
|
||||
{
|
||||
if (creature->GetCreatureTemplate() && creature->GetCreatureTemplate()->unit_flags & UNIT_FLAG_IMMUNE_TO_PC)
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); // set immunity state to the one from db on evade
|
||||
SetUnitFlag(UNIT_FLAG_IMMUNE_TO_PC); // set immunity state to the one from db on evade
|
||||
|
||||
ClearUnitState(UNIT_STATE_ATTACK_PLAYER);
|
||||
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED))
|
||||
@@ -13185,11 +13185,11 @@ void Unit::ClearInCombat()
|
||||
|
||||
void Unit::ClearInPetCombat()
|
||||
{
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
|
||||
RemoveUnitFlag(UNIT_FLAG_PET_IN_COMBAT);
|
||||
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_LEAVE_COMBAT);
|
||||
if (Unit* owner = GetOwner())
|
||||
{
|
||||
owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
|
||||
owner->RemoveUnitFlag(UNIT_FLAG_PET_IN_COMBAT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13198,10 +13198,10 @@ bool Unit::isTargetableForAttack(bool checkFakeDeath, Unit const* byWho) const
|
||||
if (!IsAlive())
|
||||
return false;
|
||||
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
|
||||
if (HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE))
|
||||
return false;
|
||||
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC) && byWho && byWho->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
if (HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC) && byWho && byWho->GetCharmerOrOwnerPlayerOrPlayerItself())
|
||||
return false;
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->IsGameMaster())
|
||||
@@ -13246,7 +13246,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
|
||||
|
||||
// can't attack untargetable
|
||||
if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE))
|
||||
&& target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
|
||||
&& target->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE))
|
||||
return false;
|
||||
|
||||
if (Player const* playerAttacker = ToPlayer())
|
||||
@@ -13255,16 +13255,16 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
|
||||
return false;
|
||||
}
|
||||
// check flags
|
||||
if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_TAXI_FLIGHT | UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_NON_ATTACKABLE_2)
|
||||
|| (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
|
||||
|| (!target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
|
||||
|| (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))
|
||||
if (target->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_TAXI_FLIGHT | UNIT_FLAG_NOT_ATTACKABLE_1 | UNIT_FLAG_NON_ATTACKABLE_2)
|
||||
|| (!HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && target->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC))
|
||||
|| (!target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && HasUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC))
|
||||
|| (HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && target->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC))
|
||||
// check if this is a world trigger cast - GOs are using world triggers to cast their spells, so we need to ignore their immunity flag here, this is a temp workaround, needs removal when go cast is implemented properly
|
||||
|| ((GetEntry() != WORLD_TRIGGER && (!obj || !obj->isType(TYPEMASK_GAMEOBJECT | TYPEMASK_DYNAMICOBJECT))) && target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC)))
|
||||
|| ((GetEntry() != WORLD_TRIGGER && (!obj || !obj->isType(TYPEMASK_GAMEOBJECT | TYPEMASK_DYNAMICOBJECT))) && target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC)))
|
||||
return false;
|
||||
|
||||
// CvC case - can attack each other only when one of them is hostile
|
||||
if (!HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
if (!HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && !target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
return GetReactionTo(target) <= REP_HOSTILE || target->GetReactionTo(this) <= REP_HOSTILE;
|
||||
|
||||
// PvP, PvC, CvP case
|
||||
@@ -13303,8 +13303,8 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
|
||||
if (creatureAttacker && creatureAttacker->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)
|
||||
return false;
|
||||
|
||||
Player const* playerAffectingAttacker = HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) ? GetAffectingPlayer() : nullptr;
|
||||
Player const* playerAffectingTarget = target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) ? target->GetAffectingPlayer() : nullptr;
|
||||
Player const* playerAffectingAttacker = HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) ? GetAffectingPlayer() : nullptr;
|
||||
Player const* playerAffectingTarget = target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) ? target->GetAffectingPlayer() : nullptr;
|
||||
|
||||
// check duel - before sanctuary checks
|
||||
if (playerAffectingAttacker && playerAffectingTarget)
|
||||
@@ -13313,7 +13313,7 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
|
||||
|
||||
// PvP case - can't attack when attacker or target are in sanctuary
|
||||
// however, 13850 client doesn't allow to attack when one of the unit's has sanctuary flag and is pvp
|
||||
if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && (target->IsInSanctuary() || IsInSanctuary()))
|
||||
if (target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && (target->IsInSanctuary() || IsInSanctuary()))
|
||||
return false;
|
||||
|
||||
// additional checks - only PvP case
|
||||
@@ -13364,23 +13364,23 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
|
||||
|
||||
// can't assist untargetable
|
||||
if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE))
|
||||
&& target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE))
|
||||
&& target->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE))
|
||||
return false;
|
||||
|
||||
if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_ASSIST_IMMUNE_PC))
|
||||
{
|
||||
// xinef: do not allow to assist non attackable units
|
||||
if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE))
|
||||
if (target->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE))
|
||||
return false;
|
||||
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
if (HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
{
|
||||
if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC))
|
||||
if (target->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_PC))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC))
|
||||
if (target->HasUnitFlag(UNIT_FLAG_IMMUNE_TO_NPC))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -13392,10 +13392,10 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
|
||||
return false;
|
||||
|
||||
// PvP case
|
||||
if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
if (target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
{
|
||||
Player const* targetPlayerOwner = target->GetAffectingPlayer();
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
if (HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
|
||||
{
|
||||
Player const* selfPlayerOwner = GetAffectingPlayer();
|
||||
if (selfPlayerOwner && targetPlayerOwner)
|
||||
@@ -13416,8 +13416,8 @@ bool Unit::_IsValidAssistTarget(Unit const* target, SpellInfo const* bySpell) co
|
||||
}
|
||||
}
|
||||
// PvC case - player can assist creature only if has specific type flags
|
||||
// !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) &&
|
||||
else if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)
|
||||
// !target->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) &&
|
||||
else if (HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED)
|
||||
&& (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_ASSIST_IMMUNE_PC))
|
||||
&& !target->IsPvP())
|
||||
{
|
||||
@@ -13818,7 +13818,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced)
|
||||
pet = GetCharm();
|
||||
|
||||
// xinef: do not affect vehicles and possesed pets
|
||||
if (pet && (pet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED) || pet->IsVehicle()))
|
||||
if (pet && (pet->HasUnitFlag(UNIT_FLAG_POSSESSED) || pet->IsVehicle()))
|
||||
pet = nullptr;
|
||||
|
||||
if (pet && pet->GetTypeId() == TYPEID_UNIT && !pet->IsInCombat() && pet->GetMotionMaster()->GetCurrentMovementGeneratorType() == FOLLOW_MOTION_TYPE)
|
||||
@@ -16900,7 +16900,7 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
|
||||
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
pet->ReplaceAllUnitFlags(UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
|
||||
if (!pet->InitStatsForLevel(level))
|
||||
{
|
||||
@@ -17605,7 +17605,7 @@ void Unit::SetStunned(bool apply)
|
||||
if (apply)
|
||||
{
|
||||
SetTarget();
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
SetUnitFlag(UNIT_FLAG_STUNNED);
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
@@ -17626,15 +17626,15 @@ void Unit::SetStunned(bool apply)
|
||||
// don't remove UNIT_FLAG_STUNNED for pet when owner is mounted (disabled pet's interface)
|
||||
Unit* owner = GetOwner();
|
||||
if (!owner || owner->GetTypeId() != TYPEID_PLAYER || !owner->ToPlayer()->IsMounted())
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
RemoveUnitFlag(UNIT_FLAG_STUNNED);
|
||||
|
||||
// Xinef: same for charmed npcs
|
||||
owner = GetCharmer();
|
||||
if (!owner || owner->GetTypeId() != TYPEID_PLAYER || !owner->ToPlayer()->IsMounted())
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
RemoveUnitFlag(UNIT_FLAG_STUNNED);
|
||||
}
|
||||
else
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
RemoveUnitFlag(UNIT_FLAG_STUNNED);
|
||||
|
||||
if (!HasUnitState(UNIT_STATE_ROOT)) // prevent moving if it also has root effect
|
||||
{
|
||||
@@ -17720,9 +17720,9 @@ void Unit::DisableRotate(bool apply)
|
||||
return;
|
||||
|
||||
if (apply)
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
|
||||
SetUnitFlag(UNIT_FLAG_POSSESSED);
|
||||
else if (!HasUnitState(UNIT_STATE_POSSESSED))
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
|
||||
RemoveUnitFlag(UNIT_FLAG_POSSESSED);
|
||||
}
|
||||
|
||||
void Unit::SetFeared(bool apply)
|
||||
@@ -17949,7 +17949,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
||||
switch (type)
|
||||
{
|
||||
case CHARM_TYPE_VEHICLE:
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
|
||||
SetUnitFlag(UNIT_FLAG_POSSESSED);
|
||||
AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
|
||||
playerCharmer->SetClientControl(this, true); // verified
|
||||
playerCharmer->VehicleSpellInitialize();
|
||||
@@ -17957,8 +17957,8 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
||||
case CHARM_TYPE_POSSESS:
|
||||
AddUnitState(UNIT_STATE_POSSESSED);
|
||||
AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
|
||||
charmer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
|
||||
SetUnitFlag(UNIT_FLAG_POSSESSED);
|
||||
charmer->SetUnitFlag(UNIT_FLAG_DISABLE_MOVE);
|
||||
playerCharmer->SetClientControl(this, true); // verified
|
||||
playerCharmer->PossessSpellInitialize();
|
||||
break;
|
||||
@@ -18049,7 +18049,7 @@ void Unit::RemoveCharmedBy(Unit* charmer)
|
||||
|
||||
// xinef: remove stunned flag if owner was mounted
|
||||
if (GetTypeId() == TYPEID_UNIT && !HasUnitState(UNIT_STATE_STUNNED))
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED);
|
||||
RemoveUnitFlag(UNIT_FLAG_STUNNED);
|
||||
|
||||
// If charmer still exists
|
||||
if (!charmer)
|
||||
@@ -18068,14 +18068,14 @@ void Unit::RemoveCharmedBy(Unit* charmer)
|
||||
case CHARM_TYPE_VEHICLE:
|
||||
playerCharmer->SetClientControl(this, false);
|
||||
playerCharmer->SetClientControl(charmer, true); // verified
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
|
||||
RemoveUnitFlag(UNIT_FLAG_POSSESSED);
|
||||
ClearUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
|
||||
break;
|
||||
case CHARM_TYPE_POSSESS:
|
||||
playerCharmer->SetClientControl(this, false);
|
||||
playerCharmer->SetClientControl(charmer, true); // verified
|
||||
charmer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE);
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED);
|
||||
charmer->RemoveUnitFlag(UNIT_FLAG_DISABLE_MOVE);
|
||||
RemoveUnitFlag(UNIT_FLAG_POSSESSED);
|
||||
ClearUnitState(UNIT_STATE_POSSESSED);
|
||||
ClearUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
|
||||
break;
|
||||
@@ -19366,15 +19366,15 @@ bool Unit::IsFalling() const
|
||||
bool Unit::CanSwim() const
|
||||
{
|
||||
// Mirror client behavior, if this method returns false then client will not use swimming animation and for players will apply gravity as if there was no water
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CANNOT_SWIM))
|
||||
if (HasUnitFlag(UNIT_FLAG_CANNOT_SWIM))
|
||||
return false;
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED)) // is player
|
||||
if (HasUnitFlag(UNIT_FLAG_POSSESSED)) // is player
|
||||
return true;
|
||||
if (HasFlag(UNIT_FIELD_FLAGS_2, 0x1000000))
|
||||
if (HasUnitFlag2(UNIT_FLAG2_UNUSED_6))
|
||||
return false;
|
||||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT))
|
||||
if (HasUnitFlag(UNIT_FLAG_PET_IN_COMBAT))
|
||||
return true;
|
||||
return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_RENAME | UNIT_FLAG_SWIMMING);
|
||||
return HasUnitFlag(UNIT_FLAG_RENAME | UNIT_FLAG_SWIMMING);
|
||||
}
|
||||
|
||||
void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool casting /*= false*/, bool vehicleTeleport /*= false*/, bool withPet /*= false*/, bool removeTransport /*= false*/)
|
||||
@@ -20035,12 +20035,12 @@ bool Unit::SetSwim(bool enable)
|
||||
if (enable)
|
||||
{
|
||||
AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SWIMMING);
|
||||
SetUnitFlag(UNIT_FLAG_SWIMMING);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SWIMMING);
|
||||
RemoveUnitFlag(UNIT_FLAG_SWIMMING);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user