feat(Core/Conditions): CONDITION_PET_TYPE (#10299)

This commit is contained in:
IntelligentQuantum
2022-01-30 09:18:04 +03:30
committed by GitHub
parent cbe3da09b8
commit 5577ea3fdc
2 changed files with 19 additions and 3 deletions

View File

@@ -21,6 +21,7 @@
#include "InstanceScript.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "Pet.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
@@ -419,7 +420,13 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
condMeets = unit->HasAuraType(AuraType(ConditionValue1));
break;
}
case CONDITION_PET_TYPE:
{
if (Player* player = object->ToPlayer())
if (Pet* pet = player->GetPet())
condMeets = (((1 << pet->getPetType()) & ConditionValue1) != 0);
break;
}
case CONDITION_TAXI:
{
if (Player* player = object->ToPlayer())
@@ -617,6 +624,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition()
case CONDITION_HAS_AURA_TYPE:
mask |= GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_PLAYER;
break;
case CONDITION_PET_TYPE:
mask |= GRID_MAP_TYPE_MASK_PLAYER;
break;
case CONDITION_TAXI:
mask |= GRID_MAP_TYPE_MASK_PLAYER;
break;
@@ -1681,7 +1691,6 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table has a ConditionType that is not supported on 3.3.5a ({}), ignoring.", cond->SourceEntry, uint32(cond->ConditionType));
return false;
case CONDITION_STAND_STATE:
case CONDITION_PET_TYPE:
LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table has a ConditionType that is not yet supported on AzerothCore ({}), ignoring.", cond->SourceEntry, uint32(cond->ConditionType));
return false;
default:
@@ -2265,6 +2274,13 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
}
break;
}
case CONDITION_PET_TYPE:
if (cond->ConditionValue1 >= (1 << MAX_PET_TYPE))
{
LOG_ERROR("sql.sql", "CONDITION_PET_TYPE has non-existing pet type %u, skipped.", cond->ConditionValue1);
return false;
}
break;
case CONDITION_TAXI:
case CONDITION_IN_WATER:
case CONDITION_CHARMED:

View File

@@ -77,7 +77,7 @@ enum ConditionTypes
CONDITION_STAND_STATE = 42, // TODO: NOT SUPPORTED YET
CONDITION_DAILY_QUEST_DONE = 43, // quest id 0 0 true if daily quest has been completed for the day
CONDITION_CHARMED = 44, // 0 0 0 true if unit is currently charmed
CONDITION_PET_TYPE = 45, // TODO: NOT SUPPORTED YET
CONDITION_PET_TYPE = 45, // mask 0 0 true if player has a pet of given type(s)
CONDITION_TAXI = 46, // 0 0 0 true if player is on taxi
CONDITION_QUESTSTATE = 47, // quest_id state_mask 0 true if player is in any of the provided quest states for the quest (1 = not taken, 2 = completed, 8 = in progress, 32 = failed, 64 = rewarded)
CONDITION_QUEST_OBJECTIVE_PROGRESS = 48, // quest_id objectiveIndex objectiveCount true if player has reached the specified objectiveCount quest progress for the objectiveIndex for the specified quest