mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[7688] Move Get*IfCanInteractWith to Player including renamed IsGameObjectOfTypeInRange.
This commit is contained in:
parent
82b0ff8b5d
commit
f4adf83cd7
16 changed files with 134 additions and 116 deletions
|
|
@ -46,52 +46,6 @@ INSTANTIATE_CLASS_MUTEX(ObjectAccessor, ZThread::FastMutex);
|
|||
ObjectAccessor::ObjectAccessor() {}
|
||||
ObjectAccessor::~ObjectAccessor() {}
|
||||
|
||||
Creature*
|
||||
ObjectAccessor::GetNPCIfCanInteractWith(Player const &player, uint64 guid, uint32 npcflagmask)
|
||||
{
|
||||
// unit checks
|
||||
if (!guid)
|
||||
return NULL;
|
||||
|
||||
// exist
|
||||
Creature *unit = GetCreature(player, guid);
|
||||
if (!unit)
|
||||
return NULL;
|
||||
|
||||
// player check
|
||||
if(!player.CanInteractWithNPCs(!unit->isSpiritService()))
|
||||
return NULL;
|
||||
|
||||
// appropriate npc type
|
||||
if(npcflagmask && !unit->HasFlag( UNIT_NPC_FLAGS, npcflagmask ))
|
||||
return NULL;
|
||||
|
||||
// alive or spirit healer
|
||||
if(!unit->isAlive() && (!unit->isSpiritService() || player.isAlive() ))
|
||||
return NULL;
|
||||
|
||||
// not allow interaction under control
|
||||
if(unit->GetCharmerOrOwnerGUID())
|
||||
return NULL;
|
||||
|
||||
// not enemy
|
||||
if( unit->IsHostileTo(&player))
|
||||
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 && player.GetReputationMgr().GetRank(faction) <= REP_UNFRIENDLY)
|
||||
return NULL;
|
||||
|
||||
// not too far
|
||||
if(!unit->IsWithinDistInMap(&player,INTERACTION_DISTANCE))
|
||||
return NULL;
|
||||
|
||||
return unit;
|
||||
}
|
||||
|
||||
Creature*
|
||||
ObjectAccessor::GetCreatureOrPetOrVehicle(WorldObject const &u, uint64 guid)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue