mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[8689] implement function Unit::isInvisibleForAlive
with that i've implemented all known auras which makes units invisible for alive.. but that's currently quite hacky i think best would be if we could set a unit-flag after those auras getting applied
This commit is contained in:
parent
e990d5c509
commit
46389e4e1c
9 changed files with 31 additions and 12 deletions
|
|
@ -49,7 +49,7 @@ AggressorAI::MoveInLineOfSight(Unit *u)
|
|||
|
||||
if (!m_creature->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED) && u->isTargetableForAttack() &&
|
||||
( m_creature->IsHostileTo( u ) /*|| u->getVictim() && m_creature->IsFriendlyTo( u->getVictim() )*/ ) &&
|
||||
u->isInAccessablePlaceFor(m_creature) )
|
||||
u->isInAccessablePlaceFor(m_creature) && !u->isInvisibleForAlive())
|
||||
{
|
||||
float attackRadius = m_creature->GetAttackDistance(u);
|
||||
if(m_creature->IsWithinDistInMap(u, attackRadius) && m_creature->IsWithinLOSInMap(u) )
|
||||
|
|
|
|||
|
|
@ -1746,11 +1746,12 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
|
|||
if(pl->isGameMaster())
|
||||
return true;
|
||||
|
||||
if (GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INVISIBLE)
|
||||
return false;
|
||||
|
||||
// Live player (or with not release body see live creatures or death creatures with corpse disappearing time > 0
|
||||
if(pl->isAlive() || pl->GetDeathTimer() > 0)
|
||||
{
|
||||
if (GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INVISIBLE)
|
||||
return false;
|
||||
return (isAlive() || m_deathTimer > 0 || (m_isDeadByDefault && m_deathState == CORPSE));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -995,7 +995,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who)
|
|||
return;
|
||||
|
||||
if (!m_creature->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED) && who->isTargetableForAttack() &&
|
||||
m_creature->IsHostileTo(who) && who->isInAccessablePlaceFor(m_creature))
|
||||
m_creature->IsHostileTo(who) && who->isInAccessablePlaceFor(m_creature) && !who->isInvisibleForAlive())
|
||||
{
|
||||
if (!m_creature->canFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ void GuardAI::MoveInLineOfSight(Unit *u)
|
|||
|
||||
if (!m_creature->getVictim() && u->isTargetableForAttack() &&
|
||||
( u->IsHostileToPlayers() || m_creature->IsHostileTo(u) /*|| u->getVictim() && m_creature->IsFriendlyTo(u->getVictim())*/ ) &&
|
||||
u->isInAccessablePlaceFor(m_creature))
|
||||
u->isInAccessablePlaceFor(m_creature) && !u->isInvisibleForAlive())
|
||||
{
|
||||
float attackRadius = m_creature->GetAttackDistance(u);
|
||||
if (m_creature->IsWithinDistInMap(u,attackRadius))
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ void PetAI::MoveInLineOfSight(Unit *u)
|
|||
if( !m_creature->getVictim() && m_creature->GetCharmInfo() &&
|
||||
m_creature->GetCharmInfo()->HasReactState(REACT_AGGRESSIVE) &&
|
||||
u->isTargetableForAttack() && m_creature->IsHostileTo( u ) &&
|
||||
u->isInAccessablePlaceFor(m_creature))
|
||||
u->isInAccessablePlaceFor(m_creature) && !u->isInvisibleForAlive())
|
||||
{
|
||||
float attackRadius = m_creature->GetAttackDistance(u);
|
||||
if(m_creature->IsWithinDistInMap(u, attackRadius) && m_creature->GetDistanceZ(u) <= CREATURE_Z_ATTACK_RANGE)
|
||||
|
|
|
|||
|
|
@ -2091,6 +2091,9 @@ Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask)
|
|||
if (!unit->isAlive())
|
||||
return NULL;
|
||||
|
||||
if (isAlive() && unit->isInvisibleForAlive())
|
||||
return NULL;
|
||||
|
||||
// not allow interaction under control, but allow with own pets
|
||||
if (unit->GetCharmerGUID())
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -9603,7 +9603,7 @@ bool Unit::isTargetableForAttack(bool inverseAlive /*=false*/) const
|
|||
if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE))
|
||||
return false;
|
||||
|
||||
if (!(isAlive() != inverseAlive))
|
||||
if ((isAlive() && !isInvisibleForAlive()) == inverseAlive)
|
||||
return false;
|
||||
|
||||
return IsInWorld() && !hasUnitState(UNIT_STAT_DIED)&& !isInFlight() /*&& !isStealth()*/;
|
||||
|
|
@ -9717,6 +9717,9 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo
|
|||
return false;
|
||||
}
|
||||
|
||||
if (u->isAlive() && isInvisibleForAlive())
|
||||
return false;
|
||||
|
||||
// always seen by owner
|
||||
if (GetCharmerOrOwnerGUID()==u->GetGUID())
|
||||
return true;
|
||||
|
|
@ -10621,6 +10624,17 @@ bool Unit::isVisibleForInState( Player const* u, WorldObject const* viewPoint, b
|
|||
return isVisibleForOrDetect(u, viewPoint, false, inVisibleList, false);
|
||||
}
|
||||
|
||||
/// returns true if creature can't be seen by alive units
|
||||
bool Unit::isInvisibleForAlive() const
|
||||
{
|
||||
// TODO: more generic check for those auras
|
||||
// TODO: maybe we also don't need an isAlive() check for visibilty.. but only those auras
|
||||
if (HasAura(10848) || HasAura(36978) || HasAura(40131) || HasAura(27978) || HasAura(33900))
|
||||
return true;
|
||||
// TODO: maybe spiritservices also have just an aura
|
||||
return isSpiritService();
|
||||
}
|
||||
|
||||
uint32 Unit::GetCreatureType() const
|
||||
{
|
||||
if(GetTypeId() == TYPEID_PLAYER)
|
||||
|
|
|
|||
|
|
@ -1329,6 +1329,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const;
|
||||
// function for low level grid visibility checks in player/creature cases
|
||||
virtual bool IsVisibleInGridForPlayer(Player* pl) const = 0;
|
||||
bool isInvisibleForAlive() const;
|
||||
|
||||
AuraList & GetSingleCastAuras() { return m_scAuras; }
|
||||
AuraList const& GetSingleCastAuras() const { return m_scAuras; }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8688"
|
||||
#define REVISION_NR "8689"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue