Core/ConditionMgr: added two new conditions NEAR_CREATURE and NEAR_GAMEOBJECT

--HG--
branch : trunk
This commit is contained in:
Rat
2010-10-31 22:10:31 +01:00
parent 9a02ae79c9
commit 32f088558d
2 changed files with 32 additions and 1 deletions

View File

@@ -27,6 +27,7 @@
#include "InstanceScript.h"
#include "ConditionMgr.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
// Checks if player meets the condition
// Can have CONDITION_SOURCE_TYPE_NONE && !mReferenceId if called from a special event (ie: eventAI)
@@ -187,6 +188,16 @@ bool Condition::Meets(Player * player, Unit* invoker)
condMeets = (uint32)Player::GetDrunkenstateByValue(player->GetDrunkValue()) >= mConditionValue1;
break;
}
case CONDITION_NEAR_CREATURE:
{
condMeets = GetClosestCreatureWithEntry(player, mConditionValue1, (float)mConditionValue2) ? true : false;
break;
}
case CONDITION_NEAR_GAMEOBJECT:
{
condMeets = GetClosestGameObjectWithEntry(player, mConditionValue1, (float)mConditionValue2) ? true : false;
break;
}
default:
condMeets = false;
refId = 0;
@@ -1344,6 +1355,24 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
}
break;
}
case CONDITION_NEAR_CREATURE:
{
if (!sCreatureStorage.LookupEntry<CreatureInfo>(cond->mConditionValue1))
{
sLog.outErrorDb("NearCreature condition has non existing creature template entry (%u), skipped", cond->mConditionValue1);
return false;
}
break;
}
case CONDITION_NEAR_GAMEOBJECT:
{
if (!sGOStorage.LookupEntry<GameObjectInfo>(cond->mConditionValue1))
{
sLog.outErrorDb("NearGameObject condition has non existing gameobject template entry (%u), skipped", cond->mConditionValue1);
return false;
}
break;
}
case CONDITION_AREAID:
case CONDITION_INSTANCE_DATA:
break;

View File

@@ -56,7 +56,9 @@ enum ConditionType
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_LEVEL = 27, // level opt +referenceID true if player's level is equal to param1 (param2 can modify the statement)
CONDITION_QUEST_COMPLETE = 28, // quest_id 0 +referenceID true if player has quest_id with all objectives complete, but not yet rewarded
CONDITION_MAX = 29 // MAX
CONDITION_NEAR_CREATURE = 29, // creature entry distance +referenceID true if there is a creature of entry in range
CONDITION_NEAR_GAMEOBJECT = 30, // gameobject entry distance +referenceID true if there is a gameobject of entry in range
CONDITION_MAX = 31 // MAX
};
enum LevelConditionType