mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 18:15:31 +01:00
Core/ConditionMgr: added placeholder for CONDITION_GUID
renamed targetOverride to invoker removed targetOverride code (had no use) --HG-- branch : trunk
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
|
||||
// Checks if player meets the condition
|
||||
// Can have CONDITION_SOURCE_TYPE_NONE && !mReferenceId if called from a special event (ie: eventAI)
|
||||
bool Condition::Meets(Player * player, Unit* targetOverride)
|
||||
bool Condition::Meets(Player * player, Unit* invoker)
|
||||
{
|
||||
if (!player)
|
||||
{
|
||||
@@ -130,8 +130,6 @@ bool Condition::Meets(Player * player, Unit* targetOverride)
|
||||
case CONDITION_CREATURE_TARGET:
|
||||
{
|
||||
Unit* target = player->GetSelectedUnit();
|
||||
if (targetOverride)
|
||||
target = targetOverride;
|
||||
if (target)
|
||||
if (Creature* cTarget = target->ToCreature())
|
||||
if (cTarget->GetEntry() == mConditionValue1)
|
||||
@@ -141,8 +139,6 @@ bool Condition::Meets(Player * player, Unit* targetOverride)
|
||||
case CONDITION_TARGET_HEALTH_BELOW_PCT:
|
||||
{
|
||||
Unit* target = player->GetSelectedUnit();
|
||||
if (targetOverride)
|
||||
target = targetOverride;
|
||||
if (target)
|
||||
condMeets = !target->HealthAbovePct(mConditionValue1);
|
||||
break;
|
||||
@@ -196,7 +192,7 @@ bool Condition::Meets(Player * player, Unit* targetOverride)
|
||||
if (sendErrorMsg && ErrorTextd && (!condMeets || !refMeets))//send special error from DB
|
||||
player->m_ConditionErrorMsgId = ErrorTextd;
|
||||
|
||||
bool script = sScriptMgr.OnConditionCheck(this, player, targetOverride); // Returns true by default.
|
||||
bool script = sScriptMgr.OnConditionCheck(this, player, invoker); // Returns true by default.
|
||||
return condMeets && refMeets && script;
|
||||
}
|
||||
|
||||
@@ -218,7 +214,7 @@ ConditionList ConditionMgr::GetConditionReferences(uint32 refId)
|
||||
return conditions;
|
||||
}
|
||||
|
||||
bool ConditionMgr::IsPlayerMeetToConditionList(Player* player,const ConditionList& conditions, Unit* targetOverride)
|
||||
bool ConditionMgr::IsPlayerMeetToConditionList(Player* player,const ConditionList& conditions, Unit* invoker)
|
||||
{
|
||||
std::map<uint32, bool>ElseGroupMap;
|
||||
for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
|
||||
@@ -237,7 +233,7 @@ bool ConditionMgr::IsPlayerMeetToConditionList(Player* player,const ConditionLis
|
||||
ConditionReferenceMap::const_iterator ref = m_ConditionReferenceMap.find((*i)->mReferenceId);
|
||||
if (ref != m_ConditionReferenceMap.end())
|
||||
{
|
||||
if(!IsPlayerMeetToConditionList(player, (*ref).second, targetOverride))
|
||||
if(!IsPlayerMeetToConditionList(player, (*ref).second, invoker))
|
||||
ElseGroupMap[(*i)->mElseGroup] = false;
|
||||
}
|
||||
else
|
||||
@@ -249,7 +245,7 @@ bool ConditionMgr::IsPlayerMeetToConditionList(Player* player,const ConditionLis
|
||||
}
|
||||
else //handle normal condition
|
||||
{
|
||||
if (!(*i)->Meets(player, targetOverride))
|
||||
if (!(*i)->Meets(player, invoker))
|
||||
ElseGroupMap[(*i)->mElseGroup] = false;
|
||||
}
|
||||
}
|
||||
@@ -261,7 +257,7 @@ bool ConditionMgr::IsPlayerMeetToConditionList(Player* player,const ConditionLis
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConditionMgr::IsPlayerMeetToConditions(Player* player, ConditionList conditions, Unit* targetOverride)
|
||||
bool ConditionMgr::IsPlayerMeetToConditions(Player* player, ConditionList conditions, Unit* invoker)
|
||||
{
|
||||
if (conditions.empty())
|
||||
return true;
|
||||
@@ -270,7 +266,7 @@ bool ConditionMgr::IsPlayerMeetToConditions(Player* player, ConditionList condit
|
||||
player->m_ConditionErrorMsgId = 0;
|
||||
|
||||
sLog.outDebug("ConditionMgr::IsPlayerMeetToConditions");
|
||||
bool result = IsPlayerMeetToConditionList(player, conditions, targetOverride);
|
||||
bool result = IsPlayerMeetToConditionList(player, conditions, invoker);
|
||||
|
||||
if (player && player->m_ConditionErrorMsgId && player->GetSession() && !result)
|
||||
player->GetSession()->SendNotification(player->m_ConditionErrorMsgId);//m_ConditionErrorMsgId is set only if a condition was not met
|
||||
|
||||
@@ -55,7 +55,8 @@ enum ConditionType
|
||||
CONDITION_AREAID = 23, // area_id 0 +referenceID true if in area_id
|
||||
CONDITION_ITEM_TARGET = 24, // ItemRequiredTargetType, TargetEntry, 0
|
||||
CONDITION_SPELL = 25, // spell_id 0 +referenceID true if knows spell
|
||||
CONDITION_MAX = 26 // MAX
|
||||
CONDITION_GUID = 26, // guid 0 0 true if creature's guid is equal to 'guid'
|
||||
CONDITION_MAX = 27 // MAX
|
||||
};
|
||||
|
||||
enum ConditionSourceType
|
||||
@@ -113,7 +114,7 @@ struct Condition
|
||||
mScriptId = 0;
|
||||
}
|
||||
|
||||
bool Meets(Player * player, Unit* targetOverride = NULL);
|
||||
bool Meets(Player * player, Unit* invoker = NULL);
|
||||
bool isLoaded() { return mConditionType > CONDITION_NONE || mReferenceId; }
|
||||
};
|
||||
|
||||
@@ -135,7 +136,7 @@ class ConditionMgr
|
||||
bool isConditionTypeValid(Condition* cond);
|
||||
ConditionList GetConditionReferences(uint32 refId);
|
||||
|
||||
bool IsPlayerMeetToConditions(Player* player, ConditionList conditions, Unit* targetOverride = NULL);
|
||||
bool IsPlayerMeetToConditions(Player* player, ConditionList conditions, Unit* invoker = NULL);
|
||||
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sType, uint32 uEntry);
|
||||
|
||||
protected:
|
||||
@@ -149,7 +150,7 @@ class ConditionMgr
|
||||
bool addToLootTemplate(Condition* cond, LootTemplate* loot);
|
||||
bool addToGossipMenus(Condition* cond);
|
||||
bool addToGossipMenuItems(Condition* cond);
|
||||
bool IsPlayerMeetToConditionList(Player* player,const ConditionList& conditions, Unit* targetOverride = NULL);
|
||||
bool IsPlayerMeetToConditionList(Player* player,const ConditionList& conditions, Unit* invoker = NULL);
|
||||
|
||||
bool isGroupable(ConditionSourceType sourceType)
|
||||
{
|
||||
|
||||
@@ -930,14 +930,14 @@ void ScriptMgr::OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry)
|
||||
FOREACH_SCRIPT(AuctionHouseScript)->OnAuctionExpire(ah, entry);
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnConditionCheck(Condition* condition, Player* player, Unit* targetOverride)
|
||||
bool ScriptMgr::OnConditionCheck(Condition* condition, Player* player, Unit* invoker)
|
||||
{
|
||||
ASSERT(condition);
|
||||
ASSERT(player);
|
||||
// targetOverride can be NULL.
|
||||
// invoker can be NULL.
|
||||
|
||||
GET_SCRIPT_RET(ConditionScript, condition->mScriptId, tmpscript, true);
|
||||
return tmpscript->OnConditionCheck(condition, player, targetOverride);
|
||||
return tmpscript->OnConditionCheck(condition, player, invoker);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnInstall(Vehicle* veh)
|
||||
|
||||
@@ -573,7 +573,7 @@ class ConditionScript : public ScriptObject
|
||||
bool IsDatabaseBound() const { return true; }
|
||||
|
||||
// Called when a single condition is checked for a player.
|
||||
virtual bool OnConditionCheck(Condition* /*condition*/, Player* /*player*/, Unit* /*targetOverride*/) { return true; }
|
||||
virtual bool OnConditionCheck(Condition* /*condition*/, Player* /*player*/, Unit* /*invoker*/) { return true; }
|
||||
};
|
||||
|
||||
class VehicleScript : public ScriptObject
|
||||
@@ -889,7 +889,7 @@ class ScriptMgr
|
||||
|
||||
public: /* ConditionScript */
|
||||
|
||||
bool OnConditionCheck(Condition* condition, Player* player, Unit* targetOverride);
|
||||
bool OnConditionCheck(Condition* condition, Player* player, Unit* invoker);
|
||||
|
||||
public: /* VehicleScript */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user