Skip to content

Commit

Permalink
DB/Conditions: Add new CONDITION_STAND_STATE (41). value1 selects the…
Browse files Browse the repository at this point in the history
… type of state check to apply, value2 specifies the particular state we are looking for.

Valuing: 0,x: has exactly state x; 1,0: any standing state; 1,1: any sitting state;
  • Loading branch information
Treeston committed Feb 25, 2016
1 parent 2eb9621 commit ea53f79
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
41 changes: 40 additions & 1 deletion src/server/game/Conditions/ConditionMgr.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/server/game/Conditions/ConditionMgr.h
Expand Up @@ -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:
Expand Down

0 comments on commit ea53f79

Please sign in to comment.