mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Conditions: allow CONDITION_OBJECT_ENTRY to check for object guid
Ref #12910
This commit is contained in:
@@ -211,10 +211,25 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
|
||||
condMeets = GetClosestGameObjectWithEntry(object, ConditionValue1, (float)ConditionValue2) ? true : false;
|
||||
break;
|
||||
}
|
||||
case CONDITION_OBJECT_ENTRY:
|
||||
case CONDITION_OBJECT_ENTRY_GUID:
|
||||
{
|
||||
if (uint32(object->GetTypeId()) == ConditionValue1)
|
||||
condMeets = (!ConditionValue2) || (object->GetEntry() == ConditionValue2);
|
||||
{
|
||||
condMeets = !ConditionValue2 || (object->GetEntry() == ConditionValue2);
|
||||
|
||||
if (ConditionValue3)
|
||||
{
|
||||
switch (object->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
condMeets &= object->ToCreature()->GetDBTableGUIDLow() == ConditionValue3;
|
||||
break;
|
||||
case TYPEID_GAMEOBJECT:
|
||||
condMeets &= object->ToGameObject()->GetDBTableGUIDLow() == ConditionValue3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONDITION_TYPE_MASK:
|
||||
@@ -419,7 +434,7 @@ uint32 Condition::GetSearcherTypeMaskForCondition()
|
||||
case CONDITION_NEAR_GAMEOBJECT:
|
||||
mask |= GRID_MAP_TYPE_MASK_ALL;
|
||||
break;
|
||||
case CONDITION_OBJECT_ENTRY:
|
||||
case CONDITION_OBJECT_ENTRY_GUID:
|
||||
switch (ConditionValue1)
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
@@ -1810,35 +1825,67 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
||||
TC_LOG_ERROR("sql.sql", "NearGameObject condition has useless data in value3 (%u)!", cond->ConditionValue3);
|
||||
break;
|
||||
}
|
||||
case CONDITION_OBJECT_ENTRY:
|
||||
case CONDITION_OBJECT_ENTRY_GUID:
|
||||
{
|
||||
switch (cond->ConditionValue1)
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
if (cond->ConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue2))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntry condition has non existing creature template entry (%u), skipped", cond->ConditionValue2);
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature template entry (%u), skipped", cond->ConditionValue2);
|
||||
return false;
|
||||
}
|
||||
if (cond->ConditionValue3)
|
||||
{
|
||||
if (CreatureData const* creatureData = sObjectMgr->GetCreatureData(cond->ConditionValue3))
|
||||
{
|
||||
if (cond->ConditionValue2 && creatureData->id != cond->ConditionValue2)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid %u set but does not match creature entry (%u), skipped", cond->ConditionValue3, cond->ConditionValue2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature guid (%u), skipped", cond->ConditionValue3);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TYPEID_GAMEOBJECT:
|
||||
if (cond->ConditionValue2 && !sObjectMgr->GetGameObjectTemplate(cond->ConditionValue2))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntry condition has non existing game object template entry (%u), skipped", cond->ConditionValue2);
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject template entry (%u), skipped", cond->ConditionValue2);
|
||||
return false;
|
||||
}
|
||||
if (cond->ConditionValue3)
|
||||
{
|
||||
if (GameObjectData const* goData = sObjectMgr->GetGOData(cond->ConditionValue3))
|
||||
{
|
||||
if (cond->ConditionValue2 && goData->id != cond->ConditionValue2)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid %u set but does not match gameobject entry (%u), skipped", cond->ConditionValue3, cond->ConditionValue2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject guid (%u), skipped", cond->ConditionValue3);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TYPEID_PLAYER:
|
||||
case TYPEID_CORPSE:
|
||||
if (cond->ConditionValue2)
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntry condition has useless data in value2 (%u)!", cond->ConditionValue2);
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value2 (%u)!", cond->ConditionValue2);
|
||||
if (cond->ConditionValue3)
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value3 (%u)!", cond->ConditionValue3);
|
||||
break;
|
||||
default:
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntry condition has wrong typeid set (%u), skipped", cond->ConditionValue1);
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has wrong typeid set (%u), skipped", cond->ConditionValue1);
|
||||
return false;
|
||||
}
|
||||
if (cond->ConditionValue3)
|
||||
TC_LOG_ERROR("sql.sql", "ObjectEntry condition has useless data in value3 (%u)!", cond->ConditionValue3);
|
||||
break;
|
||||
}
|
||||
case CONDITION_TYPE_MASK:
|
||||
|
||||
@@ -63,7 +63,7 @@ enum ConditionTypes
|
||||
CONDITION_QUEST_COMPLETE = 28, // quest_id 0 0 true if player has quest_id with all objectives complete, but not yet rewarded
|
||||
CONDITION_NEAR_CREATURE = 29, // creature entry distance 0 true if there is a creature of entry in range
|
||||
CONDITION_NEAR_GAMEOBJECT = 30, // gameobject entry distance 0 true if there is a gameobject of entry in range
|
||||
CONDITION_OBJECT_ENTRY = 31, // TypeID entry 0 true if object is type TypeID and the entry is 0 or matches entry of the object
|
||||
CONDITION_OBJECT_ENTRY_GUID = 31, // TypeID entry guid true if object is type TypeID and the entry is 0 or matches entry of the object or matches guid of the object
|
||||
CONDITION_TYPE_MASK = 32, // TypeMask 0 0 true if object is type object's TypeMask matches provided TypeMask
|
||||
CONDITION_RELATION_TO = 33, // ConditionTarget RelationType 0 true if object is in given relation with object specified by ConditionTarget
|
||||
CONDITION_REACTION_TO = 34, // ConditionTarget rankMask 0 true if object's reaction matches rankMask object specified by ConditionTarget
|
||||
|
||||
Reference in New Issue
Block a user