fix(Core/Entities): Don't reward quest reputation for factions that are hostile to your player's team. (#24100)
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
@@ -5993,6 +5993,19 @@ void Player::RewardReputation(Unit* victim)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FactionTemplateEntry const* GetAnyFactionTemplateForFaction(uint32 factionId)
|
||||||
|
{
|
||||||
|
for (uint32 i = 0; i < sFactionTemplateStore.GetNumRows(); ++i)
|
||||||
|
{
|
||||||
|
if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(i))
|
||||||
|
{
|
||||||
|
if (factionTemplate->faction == factionId)
|
||||||
|
return factionTemplate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate how many reputation points player gain with the quest
|
// Calculate how many reputation points player gain with the quest
|
||||||
void Player::RewardReputation(Quest const* quest)
|
void Player::RewardReputation(Quest const* quest)
|
||||||
{
|
{
|
||||||
@@ -6046,10 +6059,24 @@ void Player::RewardReputation(Quest const* quest)
|
|||||||
sScriptMgr->OnPlayerGiveReputation(this, quest->RewardFactionId[i], rep, REPUTATION_SOURCE_QUEST);
|
sScriptMgr->OnPlayerGiveReputation(this, quest->RewardFactionId[i], rep, REPUTATION_SOURCE_QUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i]))
|
FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i]);
|
||||||
|
if (!factionEntry)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
FactionTemplateEntry const* templateEntry = GetAnyFactionTemplateForFaction(factionEntry->ID);
|
||||||
|
if (templateEntry)
|
||||||
{
|
{
|
||||||
GetReputationMgr().ModifyReputation(factionEntry, rep, quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_NO_REP_SPILLOVER));
|
bool hostile = (GetTeamId() == TEAM_ALLIANCE) ? templateEntry->IsHostileToAlliancePlayers()
|
||||||
|
: templateEntry->IsHostileToHordePlayers();
|
||||||
|
|
||||||
|
if (hostile)
|
||||||
|
{
|
||||||
|
LOG_DEBUG("sql.sql", "RewardReputation: {} is hostile with player ({}), skipping!", templateEntry->ID, GetGUID().ToString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetReputationMgr().ModifyReputation(factionEntry, rep, quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_NO_REP_SPILLOVER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -979,6 +979,8 @@ struct FactionTemplateEntry
|
|||||||
return (hostileMask & entry.ourMask) != 0;
|
return (hostileMask & entry.ourMask) != 0;
|
||||||
}
|
}
|
||||||
[[nodiscard]] bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) != 0; }
|
[[nodiscard]] bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) != 0; }
|
||||||
|
[[nodiscard]] bool IsHostileToAlliancePlayers() const { return (hostileMask & FACTION_MASK_ALLIANCE) != 0; }
|
||||||
|
[[nodiscard]] bool IsHostileToHordePlayers() const { return (hostileMask & FACTION_MASK_HORDE) != 0; }
|
||||||
[[nodiscard]] bool IsNeutralToAll() const
|
[[nodiscard]] bool IsNeutralToAll() const
|
||||||
{
|
{
|
||||||
for (unsigned int i : enemyFaction)
|
for (unsigned int i : enemyFaction)
|
||||||
|
|||||||
Reference in New Issue
Block a user