mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
Merge pull request #16457 from Treeston/3.3.5-standstatecondition
[3.3.5] Add condition for unit sitting/standing
This commit is contained in:
@@ -100,7 +100,8 @@ ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[COND
|
||||
{ "Health Value", true, true, false },
|
||||
{ "Health Pct", true, true, false },
|
||||
{ "Realm Achievement", true, false, false },
|
||||
{ "In Water", false, false, false }
|
||||
{ "In Water", false, false, false },
|
||||
{ "Sit/stand state", true, true, false }
|
||||
};
|
||||
|
||||
// Checks if object meets the condition
|
||||
@@ -432,6 +433,19 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) const
|
||||
condMeets = unit->IsInWater();
|
||||
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;
|
||||
@@ -602,6 +616,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition() const
|
||||
case CONDITION_IN_WATER:
|
||||
mask |= GRID_MAP_TYPE_MASK_CREATURE | GRID_MAP_TYPE_MASK_PLAYER;
|
||||
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;
|
||||
@@ -2090,6 +2107,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;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ enum ConditionTypes
|
||||
CONDITION_HP_PCT = 38, // hpPct ComparisonType 0 true if unit's hp matches given pct
|
||||
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_MAX = 41 // MAX
|
||||
CONDITION_STAND_STATE = 41, // 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 = 42 // MAX
|
||||
};
|
||||
|
||||
/*! Documentation on implementing a new ConditionSourceType:
|
||||
|
||||
Reference in New Issue
Block a user