feat(Core/Conditions): Implement CONDITION_SOURCE_CREATURE_VISIBILITY (#10208)

This commit is contained in:
Skjalf
2022-01-17 06:05:32 -03:00
committed by GitHub
parent 0f2c092df7
commit fe4899202d
2 changed files with 18 additions and 3 deletions

View File

@@ -149,7 +149,8 @@ enum ConditionSourceType
CONDITION_SOURCE_TYPE_GRAVEYARD = 27, // don't use on 3.3.5a
CONDITION_SOURCE_TYPE_PLAYER_LOOT_TEMPLATE = 28,
CONDITION_SOURCE_TYPE_CREATURE_RESPAWN = 29,
CONDITION_SOURCE_TYPE_MAX = 30 // placeholder
CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY = 30,
CONDITION_SOURCE_TYPE_MAX = 31 // placeholder
};
enum RelationType

View File

@@ -1908,8 +1908,22 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
// Creature scripts
if (Creature const* cObj = obj->ToCreature())
if (cObj->IsAIEnabled && this->ToPlayer() && !cObj->AI()->CanBeSeen(this->ToPlayer()))
return false;
{
if (Player const* player = this->ToPlayer())
{
if (cObj->IsAIEnabled && !cObj->AI()->CanBeSeen(player))
{
return false;
}
ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY, cObj->GetEntry());
if (!sConditionMgr->IsObjectMeetToConditions((WorldObject*)this, conditions))
{
return false;
}
}
}
// Gameobject scripts
if (GameObject const* goObj = obj->ToGameObject())