aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortreeston <treeston.mmoc@gmail.com>2016-08-06 20:20:07 +0200
committertreeston <treeston.mmoc@gmail.com>2016-08-06 20:20:07 +0200
commite9d4bbc74effad4b16de1a5514cea531f4e5e444 (patch)
treeb48cbf2e81db100c50ef4d6a83d4ba78b38bf7a7 /src
parent97855469678bce6101a927c3d0666267c7e4acc2 (diff)
Core/Conditions: Add new CONDITION_PET_TYPE (45). Matches target player's pet against specified (value1) bitmask.
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp21
-rw-r--r--src/server/game/Conditions/ConditionMgr.h3
2 files changed, 22 insertions, 2 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index 9f69e2b0acb..2629013585a 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -22,6 +22,7 @@
#include "InstanceScript.h"
#include "ObjectMgr.h"
#include "Player.h"
+#include "Pet.h"
#include "ReputationMgr.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
@@ -105,7 +106,8 @@ ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[COND
{ "Terrain Swap", false, false, false },
{ "Sit/stand state", true, true, false },
{ "Daily Quest Completed",true, false, false },
- { "Charmed", false, false, false }
+ { "Charmed", false, false, false },
+ { "Pet type", true, false, false }
};
// Checks if object meets the condition
@@ -462,6 +464,13 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) const
condMeets = unit->IsCharmed();
break;
}
+ case CONDITION_PET_TYPE:
+ {
+ if (Player* player = object->ToPlayer())
+ if (Pet* pet = player->GetPet())
+ condMeets = (((1 << pet->getPetType()) & ConditionValue1) != 0);
+ break;
+ }
default:
condMeets = false;
break;
@@ -641,6 +650,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition() const
case CONDITION_CHARMED:
mask |= GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_PLAYER;
break;
+ case CONDITION_PET_TYPE:
+ mask |= GRID_MAP_TYPE_MASK_PLAYER;
+ break;
default:
ASSERT(false && "Condition::GetSearcherTypeMaskForCondition - missing condition handling!");
break;
@@ -2164,6 +2176,13 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) const
}
break;
}
+ case CONDITION_PET_TYPE:
+ if (cond->ConditionValue1 >= (1 << MAX_PET_TYPE))
+ {
+ TC_LOG_ERROR("sql.sql", "%s has non-existing pet type %u, skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
+ return false;
+ }
+ break;
case CONDITION_IN_WATER:
case CONDITION_CHARMED:
default:
diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
index fc37946603b..659cec02d37 100644
--- a/src/server/game/Conditions/ConditionMgr.h
+++ b/src/server/game/Conditions/ConditionMgr.h
@@ -75,7 +75,8 @@ enum ConditionTypes
CONDITION_STAND_STATE = 42, // stateType state 0 true if unit matches specified sitstate (0,x: has exactly state x; 1,0: any standing state; 1,1: any sitting state;)
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_MAX = 45 // MAX
+ CONDITION_PET_TYPE = 45, // mask 0 0 true if player has a pet of given type(s)
+ CONDITION_MAX = 46 // MAX
};
/*! Documentation on implementing a new ConditionSourceType: