Code/ConditionMgr: added CONDITION_LEVEL(27) value1: player level, value2: modify test statement, default(0) is '=='

--HG--
branch : trunk
This commit is contained in:
Rat
2010-10-05 17:54:27 +02:00
parent cac4cfda42
commit f733d8b224
2 changed files with 33 additions and 1 deletions

View File

@@ -156,6 +156,28 @@ bool Condition::Meets(Player * player, Unit* invoker)
case CONDITION_NOITEM:
condMeets = !player->HasItemCount(mConditionValue1, 1, mConditionValue2 ? true : false);
break;
case CONDITION_LEVEL:
{
switch (mConditionValue2)
{
case 0:
condMeets = player->getLevel() == mConditionValue1;
break;
case 1:
condMeets = player->getLevel() > mConditionValue1;
break;
case 2:
condMeets = player->getLevel() < mConditionValue1;
break;
case 3:
condMeets = player->getLevel() >= mConditionValue1;
break;
case 4:
condMeets = player->getLevel() <= mConditionValue1;
break;
}
break;
}
default:
condMeets = false;
refId = 0;
@@ -1241,6 +1263,15 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
}
break;
}
case CONDITION_LEVEL:
{
if (cond->mConditionValue2 > 4)
{
sLog.outErrorDb("Level condition has invalid option (%u), skipped", cond->mConditionValue2);
return false;
}
break;
}
case CONDITION_AREAID:
case CONDITION_INSTANCE_DATA:
break;

View File

@@ -56,7 +56,8 @@ enum ConditionType
CONDITION_ITEM_TARGET = 24, // ItemRequiredTargetType, TargetEntry, 0
CONDITION_SPELL = 25, // spell_id 0 +referenceID true if knows spell
CONDITION_NOITEM = 26, // item_id bank +referenceID true if player does not have any of the item (if 'bank' is set it searches in bank slots too)
CONDITION_MAX = 27 // MAX
CONDITION_LEVEL = 27, // level opt +referenceID true if player's level is equal to param1 (param2 can modify the statement)
CONDITION_MAX = 28 // MAX
};
enum ConditionSourceType