[9111] Implement ConditionType CONDITION_LEVEL for PlayerCondition

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-01-05 01:58:40 +01:00
parent 644cdf70d3
commit effe02fb25
3 changed files with 26 additions and 2 deletions

View file

@ -7257,6 +7257,15 @@ bool PlayerCondition::Meets(Player const * player) const
if ((!value1 || (player->getRaceMask() & value1)) && (!value2 || (player->getClassMask() & value2))) if ((!value1 || (player->getRaceMask() & value1)) && (!value2 || (player->getClassMask() & value2)))
return true; return true;
return false; return false;
case CONDITION_LEVEL:
{
switch(value2)
{
case 0: return player->getLevel() == value1;
case 1: return player->getLevel() >= value1;
case 2: return player->getLevel() <= value1;
}
}
default: default:
return false; return false;
} }
@ -7431,6 +7440,20 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
} }
break; break;
} }
case CONDITION_LEVEL:
{
if (!value1 || value1 > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{
sLog.outErrorDb("Level condition has invalid level %u, skipped", value1);
return false;
}
if (value2 > 2)
{
sLog.outErrorDb("Level condition has invalid argument %u (must be 0..2), skipped", value2);
return false;
}
}
case CONDITION_NONE: case CONDITION_NONE:
break; break;
} }

View file

@ -286,9 +286,10 @@ enum ConditionType
CONDITION_ACTIVE_EVENT = 12, // event_id 0 CONDITION_ACTIVE_EVENT = 12, // event_id 0
CONDITION_AREA_FLAG = 13, // area_flag area_flag_not CONDITION_AREA_FLAG = 13, // area_flag area_flag_not
CONDITION_RACE_CLASS = 14, // race_mask class_mask CONDITION_RACE_CLASS = 14, // race_mask class_mask
CONDITION_LEVEL = 15, // player_level 0, 1 or 2 (0: equal to, 1: equal or higher than, 2: equal or less than)
}; };
#define MAX_CONDITION 15 // maximum value in ConditionType enum #define MAX_CONDITION 16 // maximum value in ConditionType enum
struct PlayerCondition struct PlayerCondition
{ {

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9110" #define REVISION_NR "9111"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__