mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 19:37:01 +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
|
|
@ -1728,7 +1728,7 @@ void GameObject::SetWorldRotationAngles(float z_rot, float y_rot, float x_rot)
|
|||
bool GameObject::IsHostileTo(Unit const* unit) const
|
||||
{
|
||||
// always non-hostile to GM in GM mode
|
||||
if(unit->GetTypeId()==TYPEID_PLAYER && ((Player const*)unit)->isGameMaster())
|
||||
if (unit->GetTypeId()==TYPEID_PLAYER && ((Player const*)unit)->isGameMaster())
|
||||
return false;
|
||||
|
||||
// test owner instead if have
|
||||
|
|
@ -1739,24 +1739,28 @@ bool GameObject::IsHostileTo(Unit const* unit) const
|
|||
return IsHostileTo(targetOwner);
|
||||
|
||||
// for not set faction case (wild object) use hostile case
|
||||
if(!GetGOInfo()->faction)
|
||||
if (!GetGOInfo()->faction)
|
||||
return true;
|
||||
|
||||
// faction base cases
|
||||
FactionTemplateEntry const*tester_faction = sFactionTemplateStore.LookupEntry(GetGOInfo()->faction);
|
||||
FactionTemplateEntry const*target_faction = unit->getFactionTemplateEntry();
|
||||
if(!tester_faction || !target_faction)
|
||||
if (!tester_faction || !target_faction)
|
||||
return false;
|
||||
|
||||
// GvP forced reaction and reputation case
|
||||
if (unit->GetTypeId()==TYPEID_PLAYER)
|
||||
if (unit->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (tester_faction->faction)
|
||||
{
|
||||
// forced reaction
|
||||
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, true) <= REP_HOSTILE;
|
||||
if (raw_tester_faction && raw_tester_faction->reputationListID >= 0)
|
||||
return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction) <= REP_HOSTILE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1767,7 +1771,7 @@ bool GameObject::IsHostileTo(Unit const* unit) const
|
|||
bool GameObject::IsFriendlyTo(Unit const* unit) const
|
||||
{
|
||||
// always friendly to GM in GM mode
|
||||
if(unit->GetTypeId()==TYPEID_PLAYER && ((Player const*)unit)->isGameMaster())
|
||||
if (unit->GetTypeId()==TYPEID_PLAYER && ((Player const*)unit)->isGameMaster())
|
||||
return true;
|
||||
|
||||
// test owner instead if have
|
||||
|
|
@ -1778,24 +1782,28 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const
|
|||
return IsFriendlyTo(targetOwner);
|
||||
|
||||
// for not set faction case (wild object) use hostile case
|
||||
if(!GetGOInfo()->faction)
|
||||
if (!GetGOInfo()->faction)
|
||||
return false;
|
||||
|
||||
// faction base cases
|
||||
FactionTemplateEntry const*tester_faction = sFactionTemplateStore.LookupEntry(GetGOInfo()->faction);
|
||||
FactionTemplateEntry const*target_faction = unit->getFactionTemplateEntry();
|
||||
if(!tester_faction || !target_faction)
|
||||
if (!tester_faction || !target_faction)
|
||||
return false;
|
||||
|
||||
// GvP forced reaction and reputation case
|
||||
if (unit->GetTypeId()==TYPEID_PLAYER)
|
||||
if (unit->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (tester_faction->faction)
|
||||
{
|
||||
// forced reaction
|
||||
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, true) >= REP_FRIENDLY;
|
||||
if (raw_tester_faction->reputationListID >= 0)
|
||||
return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue