aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp41
-rw-r--r--src/server/game/Conditions/ConditionMgr.h3
2 files changed, 42 insertions, 2 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index c0c4c7c485c..1d338a45a8b 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -103,7 +103,8 @@ ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[COND
{ "Health Pct", true, true, false },
{ "Realm Achievement", true, false, false },
{ "In Water", false, false, false },
- { "Terrain Swap", true, false, false }
+ { "Terrain Swap", true, false, false },
+ { "Sit/stand state", true, true, false }
};
// Checks if object meets the condition
@@ -440,6 +441,19 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) const
condMeets = object->IsInTerrainSwap(ConditionValue1);
break;
}
+ case CONDITION_STAND_STATE:
+ {
+ if (Unit* unit = object->ToUnit())
+ {
+ if (ConditionValue1 == 0)
+ condMeets = (unit->getStandState() == ConditionValue2);
+ else if (ConditionValue2 == 0)
+ condMeets = unit->IsStandState();
+ else if (ConditionValue2 == 1)
+ condMeets = unit->IsSitState();
+ }
+ break;
+ }
default:
condMeets = false;
break;
@@ -618,6 +632,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition() const
case CONDITION_TERRAIN_SWAP:
mask |= GRID_MAP_TYPE_MASK_ALL;
break;
+ case CONDITION_STAND_STATE:
+ mask |= GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_PLAYER;
+ break;
default:
ASSERT(false && "Condition::GetSearcherTypeMaskForCondition - missing condition handling!");
break;
@@ -2204,6 +2221,28 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) const
}
case CONDITION_IN_WATER:
break;
+ case CONDITION_STAND_STATE:
+ {
+ bool valid = false;
+ switch (cond->ConditionValue1)
+ {
+ case 0:
+ valid = cond->ConditionValue2 <= UNIT_STAND_STATE_SUBMERGED;
+ break;
+ case 1:
+ valid = cond->ConditionValue2 <= 1;
+ break;
+ default:
+ valid = false;
+ break;
+ }
+ if (!valid)
+ {
+ TC_LOG_ERROR("sql.sql", "%s has non-existing stand state (%u,%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1, cond->ConditionValue2);
+ return false;
+ }
+ break;
+ }
default:
break;
}
diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
index db5b78215b3..7c61b4d2955 100644
--- a/src/server/game/Conditions/ConditionMgr.h
+++ b/src/server/game/Conditions/ConditionMgr.h
@@ -90,7 +90,8 @@ enum ConditionTypes
CONDITION_REALM_ACHIEVEMENT = 39, // achievement_id 0 0 true if realm achievement is complete
CONDITION_IN_WATER = 40, // 0 0 0 true if unit in water
CONDITION_TERRAIN_SWAP = 41, // terrainSwap 0 0 true if object is in terrainswap
- CONDITION_MAX = 42 // MAX
+ 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_MAX = 43 // MAX
};
/*! Documentation on implementing a new ConditionSourceType: