mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[11890] Fix Player::GetNPCIfCanInteractWith to consider forced reactions
This will fix ie quest 9410 A Spirit Guide Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
parent
0fe4f21b6a
commit
3e552fc739
8 changed files with 35 additions and 45 deletions
|
|
@ -1751,16 +1751,12 @@ bool GameObject::IsHostileTo(Unit const* unit) const
|
|||
// GvP forced reaction and reputation case
|
||||
if (unit->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
// forced reaction
|
||||
if (tester_faction->faction)
|
||||
{
|
||||
if(ReputationRank const* force = ((Player*)unit)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
|
||||
return *force <= REP_HOSTILE;
|
||||
|
||||
// apply reputation state
|
||||
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
|
||||
if (raw_tester_faction && raw_tester_faction->reputationListID >=0 )
|
||||
return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction) <= REP_HOSTILE;
|
||||
return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction, true) <= REP_HOSTILE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1794,16 +1790,12 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const
|
|||
// GvP forced reaction and reputation case
|
||||
if (unit->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
// forced reaction
|
||||
if (tester_faction->faction)
|
||||
{
|
||||
if(ReputationRank const* force =((Player*)unit)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
|
||||
return *force >= REP_FRIENDLY;
|
||||
|
||||
// apply reputation state
|
||||
if (FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
|
||||
if (raw_tester_faction->reputationListID >=0 )
|
||||
return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY;
|
||||
return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction, true) >= REP_FRIENDLY;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1361,7 +1361,7 @@ void ChatHandler::ShowFactionListHelper( FactionEntry const * factionEntry, Loca
|
|||
|
||||
if (repState) // and then target!=NULL also
|
||||
{
|
||||
ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
|
||||
ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry, false);
|
||||
std::string rankName = GetMangosString(ReputationRankStrIndex[rank]);
|
||||
|
||||
ss << " " << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ")";
|
||||
|
|
|
|||
|
|
@ -7482,7 +7482,7 @@ bool PlayerCondition::Meets(Player const * player) const
|
|||
case CONDITION_REPUTATION_RANK:
|
||||
{
|
||||
FactionEntry const* faction = sFactionStore.LookupEntry(value1);
|
||||
return faction && player->GetReputationMgr().GetRank(faction) >= ReputationRank(value2);
|
||||
return faction && player->GetReputationMgr().GetRank(faction, false) >= ReputationRank(value2);
|
||||
}
|
||||
case CONDITION_TEAM:
|
||||
return uint32(player->GetTeam()) == value1;
|
||||
|
|
|
|||
|
|
@ -2184,7 +2184,7 @@ Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask)
|
|||
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) <= REP_UNFRIENDLY)
|
||||
if(faction->reputationListID >= 0 && GetReputationMgr().GetRank(faction, true) <= REP_UNFRIENDLY)
|
||||
return NULL;
|
||||
|
||||
// not too far
|
||||
|
|
@ -6229,7 +6229,7 @@ void Player::setFactionForRace(uint8 race)
|
|||
ReputationRank Player::GetReputationRank(uint32 faction) const
|
||||
{
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction);
|
||||
return GetReputationMgr().GetRank(factionEntry);
|
||||
return GetReputationMgr().GetRank(factionEntry, false);
|
||||
}
|
||||
|
||||
//Calculate total reputation percent player gain with quest/creature level
|
||||
|
|
@ -6310,7 +6310,7 @@ void Player::RewardReputation(Unit *pVictim, float rate)
|
|||
int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue1, Rep->repfaction1, pVictim->getLevel());
|
||||
donerep1 = int32(donerep1*rate);
|
||||
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1);
|
||||
uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
|
||||
uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1, false);
|
||||
if (factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
|
||||
GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
|
||||
|
||||
|
|
@ -6328,7 +6328,7 @@ void Player::RewardReputation(Unit *pVictim, float rate)
|
|||
int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue2, Rep->repfaction2, pVictim->getLevel());
|
||||
donerep2 = int32(donerep2*rate);
|
||||
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2);
|
||||
uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
|
||||
uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2, false);
|
||||
if (factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
|
||||
GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,8 +74,14 @@ int32 ReputationMgr::GetReputation(FactionEntry const* factionEntry) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
ReputationRank ReputationMgr::GetRank(FactionEntry const* factionEntry) const
|
||||
ReputationRank ReputationMgr::GetRank(FactionEntry const* factionEntry, bool withForcedReaction) const
|
||||
{
|
||||
if (withForcedReaction)
|
||||
{
|
||||
ForcedReactions::const_iterator find = m_forcedReactions.find(factionEntry->ID);
|
||||
if (find != m_forcedReactions.end())
|
||||
return find->second;
|
||||
}
|
||||
int32 reputation = GetReputation(factionEntry);
|
||||
return ReputationToRank(reputation);
|
||||
}
|
||||
|
|
@ -280,7 +286,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi
|
|||
{
|
||||
if (FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr))
|
||||
{
|
||||
if (factionEntryCalc == factionEntry || GetRank(factionEntryCalc) > ReputationRank(factionEntryCalc->spilloverMaxRankIn))
|
||||
if (factionEntryCalc == factionEntry || GetRank(factionEntryCalc, false) > ReputationRank(factionEntryCalc->spilloverMaxRankIn))
|
||||
continue;
|
||||
int32 spilloverRep = int32(spillOverRepOut * factionEntryCalc->spilloverRateIn);
|
||||
if (spilloverRep != 0 || !incremental)
|
||||
|
|
@ -486,7 +492,7 @@ void ReputationMgr::LoadFromDB(QueryResult *result)
|
|||
}
|
||||
|
||||
// set atWar for hostile
|
||||
if(GetRank(factionEntry) <= REP_HOSTILE)
|
||||
if(GetRank(factionEntry, true) <= REP_HOSTILE)
|
||||
SetAtWar(faction,true);
|
||||
|
||||
// reset changed flag if values similar to saved in DB
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class ReputationMgr
|
|||
int32 GetReputation(FactionEntry const* factionEntry) const;
|
||||
int32 GetBaseReputation(FactionEntry const* factionEntry) const;
|
||||
|
||||
ReputationRank GetRank(FactionEntry const* factionEntry) const;
|
||||
ReputationRank GetRank(FactionEntry const* factionEntry, bool withForcedReaction) const;
|
||||
ReputationRank GetBaseRank(FactionEntry const* factionEntry) const;
|
||||
|
||||
ReputationRank const* GetForcedRankIfAny(FactionTemplateEntry const* factionTemplateEntry) const
|
||||
|
|
|
|||
|
|
@ -5445,16 +5445,12 @@ bool Unit::IsHostileTo(Unit const* unit) const
|
|||
// CvP forced reaction and reputation case
|
||||
else if (target->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
// forced reaction
|
||||
if (tester_faction->faction)
|
||||
{
|
||||
if(ReputationRank const* force = ((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
|
||||
return *force <= REP_HOSTILE;
|
||||
|
||||
// apply reputation state
|
||||
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
|
||||
if (raw_tester_faction && raw_tester_faction->reputationListID >=0 )
|
||||
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) <= REP_HOSTILE;
|
||||
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction, true) <= REP_HOSTILE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5557,16 +5553,12 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
|
|||
// CvP forced reaction and reputation case
|
||||
else if (target->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
// forced reaction
|
||||
if (tester_faction->faction)
|
||||
{
|
||||
if(ReputationRank const* force =((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
|
||||
return *force >= REP_FRIENDLY;
|
||||
|
||||
// apply reputation state
|
||||
if (FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
|
||||
if (raw_tester_faction->reputationListID >=0 )
|
||||
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY;
|
||||
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction, true) >= REP_FRIENDLY;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11889"
|
||||
#define REVISION_NR "11890"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue