From 5577ea3fdcd398f67a7d286598ddd40781f8fdfb Mon Sep 17 00:00:00 2001 From: IntelligentQuantum Date: Sun, 30 Jan 2022 09:18:04 +0330 Subject: [PATCH] feat(Core/Conditions): CONDITION_PET_TYPE (#10299) --- src/server/game/Conditions/ConditionMgr.cpp | 20 ++++++++++++++++++-- src/server/game/Conditions/ConditionMgr.h | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 23adf4696..482ce909b 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -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: diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 4be6071d5..b099c0e46 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -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