[8688] proper implementation of creatures ghost-flags

this reverts 8676 (9c50d9e70314b0cd9eb0fe3bac8040d64a9965a5)
the new flag is from wdb-files so your database should be
already alright

also i've dropped the function Player::CanInteractWithNPCs
cause it was used only in one place and didn't seem to make anything
easier

NOTE for this flag:
it just means that the creature can be seen by ghost-players
too..
so they are still visible for alive players.. unless a special
aura or ther unitflag (spiritguide/healer) disables this..
(see next commit for it)
This commit is contained in:
balrok 2009-10-19 20:25:02 +02:00
parent 58139610eb
commit e990d5c509
12 changed files with 24 additions and 36 deletions

View file

@ -2072,24 +2072,10 @@ void Player::RegenerateHealth(uint32 diff)
ModifyHealth(int32(addvalue));
}
bool Player::CanInteractWithNPCs(bool alive) const
{
if(alive && !isAlive())
return false;
if(isInFlight())
return false;
return true;
}
Creature*
Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
{
// unit checks
if (!guid)
return NULL;
if(!IsInWorld())
if (!guid || !IsInWorld() || isInFlight())
return NULL;
// exist (we need look pets also for some interaction (quest/etc)
@ -2097,23 +2083,20 @@ Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
if (!unit)
return NULL;
// player check
if(!CanInteractWithNPCs(!(unit->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_GHOST)))
return NULL;
// appropriate npc type
if(npcflagmask && !unit->HasFlag( UNIT_NPC_FLAGS, npcflagmask ))
if (npcflagmask && !unit->HasFlag( UNIT_NPC_FLAGS, npcflagmask ))
return NULL;
if (isAlive() && !unit->isAlive())
// if a dead unit should be able to talk - the creature must be alive and have special flags
if (!unit->isAlive())
return NULL;
// not allow interaction under control, but allow with own pets
if(unit->GetCharmerGUID())
if (unit->GetCharmerGUID())
return NULL;
// not enemy
if( unit->IsHostileTo(this))
if (unit->IsHostileTo(this))
return NULL;
// not unfriendly