mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[11892] Really fix [11890]. This basicly reverts commit 11890
Remove the actually not required faction check in Player::GetNPCIfCanInteractWith - this is done by IsHostileTo a line before Improve the Player-login AtWar selection to also consider forced reactions Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
85309aa3c1
commit
6aab5c1022
8 changed files with 70 additions and 61 deletions
|
|
@ -1753,10 +1753,14 @@ bool GameObject::IsHostileTo(Unit const* unit) const
|
||||||
{
|
{
|
||||||
if (tester_faction->faction)
|
if (tester_faction->faction)
|
||||||
{
|
{
|
||||||
|
// forced reaction
|
||||||
|
if (ReputationRank const* force = ((Player*)unit)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
|
||||||
|
return *force <= REP_HOSTILE;
|
||||||
|
|
||||||
// apply reputation state
|
// apply reputation state
|
||||||
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
|
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
|
||||||
if (raw_tester_faction && raw_tester_faction->reputationListID >= 0)
|
if (raw_tester_faction && raw_tester_faction->reputationListID >= 0)
|
||||||
return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction, true) <= REP_HOSTILE;
|
return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction) <= REP_HOSTILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1792,10 +1796,14 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const
|
||||||
{
|
{
|
||||||
if (tester_faction->faction)
|
if (tester_faction->faction)
|
||||||
{
|
{
|
||||||
|
// forced reaction
|
||||||
|
if (ReputationRank const* force =((Player*)unit)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
|
||||||
|
return *force >= REP_FRIENDLY;
|
||||||
|
|
||||||
// apply reputation state
|
// apply reputation state
|
||||||
if (FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
|
if (FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
|
||||||
if (raw_tester_faction->reputationListID >= 0)
|
if (raw_tester_faction->reputationListID >= 0)
|
||||||
return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction, true) >= REP_FRIENDLY;
|
return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1361,7 +1361,7 @@ void ChatHandler::ShowFactionListHelper( FactionEntry const * factionEntry, Loca
|
||||||
|
|
||||||
if (repState) // and then target!=NULL also
|
if (repState) // and then target!=NULL also
|
||||||
{
|
{
|
||||||
ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry, false);
|
ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
|
||||||
std::string rankName = GetMangosString(ReputationRankStrIndex[rank]);
|
std::string rankName = GetMangosString(ReputationRankStrIndex[rank]);
|
||||||
|
|
||||||
ss << " " << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ")";
|
ss << " " << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ")";
|
||||||
|
|
|
||||||
|
|
@ -7482,7 +7482,7 @@ bool PlayerCondition::Meets(Player const * player) const
|
||||||
case CONDITION_REPUTATION_RANK:
|
case CONDITION_REPUTATION_RANK:
|
||||||
{
|
{
|
||||||
FactionEntry const* faction = sFactionStore.LookupEntry(value1);
|
FactionEntry const* faction = sFactionStore.LookupEntry(value1);
|
||||||
return faction && player->GetReputationMgr().GetRank(faction, false) >= ReputationRank(value2);
|
return faction && player->GetReputationMgr().GetRank(faction) >= ReputationRank(value2);
|
||||||
}
|
}
|
||||||
case CONDITION_TEAM:
|
case CONDITION_TEAM:
|
||||||
return uint32(player->GetTeam()) == value1;
|
return uint32(player->GetTeam()) == value1;
|
||||||
|
|
|
||||||
|
|
@ -2180,13 +2180,6 @@ Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask)
|
||||||
if (unit->IsHostileTo(this))
|
if (unit->IsHostileTo(this))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// not unfriendly
|
|
||||||
if(FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(unit->getFaction()))
|
|
||||||
if(factionTemplate->faction)
|
|
||||||
if(FactionEntry const* faction = sFactionStore.LookupEntry(factionTemplate->faction))
|
|
||||||
if(faction->reputationListID >= 0 && GetReputationMgr().GetRank(faction, true) <= REP_UNFRIENDLY)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
// not too far
|
// not too far
|
||||||
if (!unit->IsWithinDistInMap(this, INTERACTION_DISTANCE))
|
if (!unit->IsWithinDistInMap(this, INTERACTION_DISTANCE))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -6229,7 +6222,7 @@ void Player::setFactionForRace(uint8 race)
|
||||||
ReputationRank Player::GetReputationRank(uint32 faction) const
|
ReputationRank Player::GetReputationRank(uint32 faction) const
|
||||||
{
|
{
|
||||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction);
|
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction);
|
||||||
return GetReputationMgr().GetRank(factionEntry, false);
|
return GetReputationMgr().GetRank(factionEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculate total reputation percent player gain with quest/creature level
|
//Calculate total reputation percent player gain with quest/creature level
|
||||||
|
|
@ -6310,7 +6303,7 @@ void Player::RewardReputation(Unit *pVictim, float rate)
|
||||||
int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue1, Rep->repfaction1, pVictim->getLevel());
|
int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue1, Rep->repfaction1, pVictim->getLevel());
|
||||||
donerep1 = int32(donerep1*rate);
|
donerep1 = int32(donerep1*rate);
|
||||||
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1);
|
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1);
|
||||||
uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1, false);
|
uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
|
||||||
if (factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
|
if (factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
|
||||||
GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
|
GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
|
||||||
|
|
||||||
|
|
@ -6328,7 +6321,7 @@ void Player::RewardReputation(Unit *pVictim, float rate)
|
||||||
int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue2, Rep->repfaction2, pVictim->getLevel());
|
int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue2, Rep->repfaction2, pVictim->getLevel());
|
||||||
donerep2 = int32(donerep2*rate);
|
donerep2 = int32(donerep2*rate);
|
||||||
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2);
|
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2);
|
||||||
uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2, false);
|
uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
|
||||||
if (factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
|
if (factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
|
||||||
GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
|
GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,14 +74,8 @@ int32 ReputationMgr::GetReputation(FactionEntry const* factionEntry) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReputationRank ReputationMgr::GetRank(FactionEntry const* factionEntry, bool withForcedReaction) const
|
ReputationRank ReputationMgr::GetRank(FactionEntry const* factionEntry) const
|
||||||
{
|
{
|
||||||
if (withForcedReaction)
|
|
||||||
{
|
|
||||||
ForcedReactions::const_iterator find = m_forcedReactions.find(factionEntry->ID);
|
|
||||||
if (find != m_forcedReactions.end())
|
|
||||||
return find->second;
|
|
||||||
}
|
|
||||||
int32 reputation = GetReputation(factionEntry);
|
int32 reputation = GetReputation(factionEntry);
|
||||||
return ReputationToRank(reputation);
|
return ReputationToRank(reputation);
|
||||||
}
|
}
|
||||||
|
|
@ -286,7 +280,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
|
||||||
{
|
{
|
||||||
if (FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr))
|
if (FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr))
|
||||||
{
|
{
|
||||||
if (factionEntryCalc == factionEntry || GetRank(factionEntryCalc, false) > ReputationRank(factionEntryCalc->spilloverMaxRankIn))
|
if (factionEntryCalc == factionEntry || GetRank(factionEntryCalc) > ReputationRank(factionEntryCalc->spilloverMaxRankIn))
|
||||||
continue;
|
continue;
|
||||||
int32 spilloverRep = int32(spillOverRepOut * factionEntryCalc->spilloverRateIn);
|
int32 spilloverRep = int32(spillOverRepOut * factionEntryCalc->spilloverRateIn);
|
||||||
if (spilloverRep != 0 || !incremental)
|
if (spilloverRep != 0 || !incremental)
|
||||||
|
|
@ -492,7 +486,13 @@ void ReputationMgr::LoadFromDB(QueryResult *result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// set atWar for hostile
|
// set atWar for hostile
|
||||||
if(GetRank(factionEntry, true) <= REP_HOSTILE)
|
ForcedReactions::const_iterator forceItr = m_forcedReactions.find(factionEntry->ID);
|
||||||
|
if (forceItr != m_forcedReactions.end())
|
||||||
|
{
|
||||||
|
if (forceItr->second <= REP_HOSTILE)
|
||||||
|
SetAtWar(faction, true);
|
||||||
|
}
|
||||||
|
else if (GetRank(factionEntry) <= REP_HOSTILE)
|
||||||
SetAtWar(faction, true);
|
SetAtWar(faction, true);
|
||||||
|
|
||||||
// reset changed flag if values similar to saved in DB
|
// reset changed flag if values similar to saved in DB
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ class ReputationMgr
|
||||||
int32 GetReputation(FactionEntry const* factionEntry) const;
|
int32 GetReputation(FactionEntry const* factionEntry) const;
|
||||||
int32 GetBaseReputation(FactionEntry const* factionEntry) const;
|
int32 GetBaseReputation(FactionEntry const* factionEntry) const;
|
||||||
|
|
||||||
ReputationRank GetRank(FactionEntry const* factionEntry, bool withForcedReaction) const;
|
ReputationRank GetRank(FactionEntry const* factionEntry) const;
|
||||||
ReputationRank GetBaseRank(FactionEntry const* factionEntry) const;
|
ReputationRank GetBaseRank(FactionEntry const* factionEntry) const;
|
||||||
|
|
||||||
ReputationRank const* GetForcedRankIfAny(FactionTemplateEntry const* factionTemplateEntry) const
|
ReputationRank const* GetForcedRankIfAny(FactionTemplateEntry const* factionTemplateEntry) const
|
||||||
|
|
|
||||||
|
|
@ -5430,9 +5430,9 @@ bool Unit::IsHostileTo(Unit const* unit) const
|
||||||
// PvC forced reaction and reputation case
|
// PvC forced reaction and reputation case
|
||||||
if (tester->GetTypeId() == TYPEID_PLAYER)
|
if (tester->GetTypeId() == TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
// forced reaction
|
|
||||||
if (target_faction->faction)
|
if (target_faction->faction)
|
||||||
{
|
{
|
||||||
|
// forced reaction
|
||||||
if (ReputationRank const* force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction))
|
if (ReputationRank const* force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction))
|
||||||
return *force <= REP_HOSTILE;
|
return *force <= REP_HOSTILE;
|
||||||
|
|
||||||
|
|
@ -5447,10 +5447,14 @@ bool Unit::IsHostileTo(Unit const* unit) const
|
||||||
{
|
{
|
||||||
if (tester_faction->faction)
|
if (tester_faction->faction)
|
||||||
{
|
{
|
||||||
|
// forced reaction
|
||||||
|
if (ReputationRank const* force = ((Player*)unit)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
|
||||||
|
return *force <= REP_HOSTILE;
|
||||||
|
|
||||||
// apply reputation state
|
// apply reputation state
|
||||||
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
|
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
|
||||||
if (raw_tester_faction && raw_tester_faction->reputationListID >= 0)
|
if (raw_tester_faction && raw_tester_faction->reputationListID >= 0)
|
||||||
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction, true) <= REP_HOSTILE;
|
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) <= REP_HOSTILE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5538,9 +5542,9 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
|
||||||
// PvC forced reaction and reputation case
|
// PvC forced reaction and reputation case
|
||||||
if (tester->GetTypeId() == TYPEID_PLAYER)
|
if (tester->GetTypeId() == TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
// forced reaction
|
|
||||||
if (target_faction->faction)
|
if (target_faction->faction)
|
||||||
{
|
{
|
||||||
|
// forced reaction
|
||||||
if (ReputationRank const* force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction))
|
if (ReputationRank const* force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction))
|
||||||
return *force >= REP_FRIENDLY;
|
return *force >= REP_FRIENDLY;
|
||||||
|
|
||||||
|
|
@ -5555,10 +5559,14 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
|
||||||
{
|
{
|
||||||
if (tester_faction->faction)
|
if (tester_faction->faction)
|
||||||
{
|
{
|
||||||
|
// forced reaction
|
||||||
|
if (ReputationRank const* force =((Player*)unit)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
|
||||||
|
return *force >= REP_FRIENDLY;
|
||||||
|
|
||||||
// apply reputation state
|
// apply reputation state
|
||||||
if (FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
|
if (FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
|
||||||
if (raw_tester_faction->reputationListID >=0 )
|
if (raw_tester_faction->reputationListID >=0 )
|
||||||
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction, true) >= REP_FRIENDLY;
|
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11891"
|
#define REVISION_NR "11892"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue