aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp31
-rw-r--r--src/server/game/Conditions/ConditionMgr.h1
2 files changed, 32 insertions, 0 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index 94de593cc8b..53dd9ca9451 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -19,6 +19,7 @@
#include "AchievementMgr.h"
#include "AreaTrigger.h"
#include "AreaTriggerDataStore.h"
+#include "BattlePetMgr.h"
#include "Containers.h"
#include "ConversationDataStore.h"
#include "DatabaseEnv.h"
@@ -144,6 +145,7 @@ ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[COND
{ "Is Gamemaster", true, false, false },
{ "Object Entry or Guid", true, true, true },
{ "Object TypeMask", true, false, false },
+ { "BattlePet Species Learned", true, true, true },
};
// Checks if object meets the condition
@@ -564,6 +566,14 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) const
}
break;
}
+ case CONDITION_BATTLE_PET_COUNT:
+ {
+ if (Player* player = object->ToPlayer())
+ condMeets = CompareValues(static_cast<ComparisionType>(ConditionValue3),
+ player->GetSession()->GetBattlePetMgr()->GetPetCount(sBattlePetSpeciesStore.AssertEntry(ConditionValue1), player->GetGUID()),
+ static_cast<uint8>(ConditionValue2));
+ break;
+ }
default:
condMeets = false;
break;
@@ -765,6 +775,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition() const
case CONDITION_GAMEMASTER:
mask |= GRID_MAP_TYPE_MASK_PLAYER;
break;
+ case CONDITION_BATTLE_PET_COUNT:
+ mask |= GRID_MAP_TYPE_MASK_PLAYER;
+ break;
default:
ABORT_MSG("Condition::GetSearcherTypeMaskForCondition - missing condition handling!");
break;
@@ -2553,6 +2566,24 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) const
return false;
}
break;
+ case CONDITION_BATTLE_PET_COUNT:
+ if (!sBattlePetSpeciesStore.LookupEntry(cond->ConditionValue1))
+ {
+ TC_LOG_ERROR("sql.sql", "%s has non existing BattlePet SpeciesId in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
+ return false;
+ }
+ if (cond->ConditionValue2 > BattlePets::DEFAULT_MAX_BATTLE_PETS_PER_SPECIES)
+ {
+ TC_LOG_ERROR("sql.sql", "%s has invalid (greater than %u) value2 (%u), skipped.", cond->ToString(true).c_str(),
+ uint32(BattlePets::DEFAULT_MAX_BATTLE_PETS_PER_SPECIES), cond->ConditionValue2);
+ return false;
+ }
+ if (cond->ConditionValue3 >= COMP_TYPE_MAX)
+ {
+ TC_LOG_ERROR("sql.sql", "%s has invalid ComparisionType (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3);
+ return false;
+ }
+ break;
default:
TC_LOG_ERROR("sql.sql", "%s Invalid ConditionType in `condition` table, ignoring.", cond->ToString().c_str());
return false;
diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
index 0daa1305e60..44001f94a5f 100644
--- a/src/server/game/Conditions/ConditionMgr.h
+++ b/src/server/game/Conditions/ConditionMgr.h
@@ -109,6 +109,7 @@ enum ConditionTypes
CONDITION_GAMEMASTER = 50, // canBeGM 0 0 true if player is gamemaster (or can be gamemaster)
CONDITION_OBJECT_ENTRY_GUID = 51, // 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 = 52, // TypeMask 0 0 true if object is type object's TypeMask matches provided TypeMask
+ CONDITION_BATTLE_PET_COUNT = 53, // SpecieId count ComparisonType true if player has `count` of battle pet species
CONDITION_MAX
};