mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 20:56:23 +00:00
fix(Core/Creature): Implement respond to call for help faction flag. (#21959)
This commit is contained in:
@@ -1937,17 +1937,8 @@ bool Creature::CanStartAttack(Unit const* who) const
|
||||
if (!_IsTargetAcceptable(who))
|
||||
return false;
|
||||
|
||||
// pussywizard: at this point we are either hostile to who or friendly to who->getAttackerForHelper()
|
||||
// pussywizard: if who is in combat and has an attacker, help him if the distance is right (help because who is hostile or help because attacker is friendly)
|
||||
bool assist = false;
|
||||
if (who->IsEngaged() && IsWithinDist(who, ATTACK_DISTANCE))
|
||||
if (Unit* victim = who->getAttackerForHelper())
|
||||
if (IsWithinDistInMap(victim, sWorld->getFloatConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS)))
|
||||
assist = true;
|
||||
|
||||
if (!assist)
|
||||
if (IsNeutralToAll() || !IsWithinDistInMap(who, GetAggroRange(who) + m_CombatDistance, true, false)) // pussywizard: +m_combatDistance for turrets and similar
|
||||
return false;
|
||||
if (IsNeutralToAll() || !IsWithinDistInMap(who, GetAggroRange(who) + m_CombatDistance, true, false)) // pussywizard: +m_combatDistance for turrets and similar
|
||||
return false;
|
||||
|
||||
if (!CanCreatureAttack(who))
|
||||
return false;
|
||||
@@ -1955,6 +1946,9 @@ bool Creature::CanStartAttack(Unit const* who) const
|
||||
if (HasUnitState(UNIT_STATE_STUNNED))
|
||||
return false;
|
||||
|
||||
if (!IsHostileTo(who))
|
||||
return false;
|
||||
|
||||
return IsWithinLOSInMap(who);
|
||||
}
|
||||
|
||||
@@ -2537,6 +2531,9 @@ bool Creature::CanAssistTo(Unit const* u, Unit const* enemy, bool checkfaction /
|
||||
{
|
||||
if (GetFaction() != u->GetFaction())
|
||||
return false;
|
||||
|
||||
if (!RespondsToCallForHelp())
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -986,6 +986,13 @@ public:
|
||||
|
||||
return false;
|
||||
}
|
||||
[[nodiscard]] bool RespondsToCallForHelp() const
|
||||
{
|
||||
if (FactionTemplateEntry const* entry = GetFactionTemplateEntry())
|
||||
return entry->FactionRespondsToCallForHelp();
|
||||
|
||||
return false;
|
||||
}
|
||||
[[nodiscard]] bool IsInSanctuary() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SANCTUARY); }
|
||||
[[nodiscard]] bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); }
|
||||
[[nodiscard]] bool IsFFAPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); }
|
||||
|
||||
@@ -986,6 +986,7 @@ struct FactionTemplateEntry
|
||||
return hostileMask == 0 && friendlyMask == 0;
|
||||
}
|
||||
[[nodiscard]] bool IsContestedGuardFaction() const { return (factionFlags & FACTION_TEMPLATE_FLAG_ATTACK_PVP_ACTIVE_PLAYERS) != 0; }
|
||||
[[nodiscard]] bool FactionRespondsToCallForHelp() const { return (factionFlags & FACTION_TEMPLATE_FLAG_RESPOND_TO_CALL_FOR_HELP) != 0; }
|
||||
};
|
||||
|
||||
struct GameObjectArtKitEntry
|
||||
|
||||
Reference in New Issue
Block a user