mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +01:00
Core/Db/Conditions: Drop CONDITION_CREATURE_TARGET, CONDITION_TARGET_HEALTH_BELOW_PCT, CONDITION_TARGET_RANGE and 3rd parameter for CONDITION_AURA. Instead of those use other available conditions, which are not limited to player's selection only.
This commit is contained in:
3
sql/updates/world/2012_16_02_01_world_conditions.sql
Normal file
3
sql/updates/world/2012_16_02_01_world_conditions.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
UPDATE `conditions` SET ConditionValue3 = 0, ConditionTarget = 1 WHERE ConditionTypeOrReference = 1 AND ConditionValue3 = 1;
|
||||
UPDATE `conditions` SET ConditionTypeOrReference = 31, ConditionValue2 = ConditionValue1, ConditionValue1 = 3, ConditionTarget = 1 WHERE ConditionTypeOrReference = 19;
|
||||
UPDATE `conditions` SET ConditionTypeOrReference = 38, ConditionValue2 = 4, ConditionTarget = 1 WHERE ConditionTypeOrReference = 20;
|
||||
@@ -49,15 +49,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
|
||||
case CONDITION_AURA:
|
||||
{
|
||||
if (Unit* unit = object->ToUnit())
|
||||
{
|
||||
if (!ConditionValue3)
|
||||
condMeets = unit->HasAuraEffect(ConditionValue1, ConditionValue2);
|
||||
else if (Player* player = unit->ToPlayer())
|
||||
{
|
||||
if (Unit* target = player->GetSelectedUnit())
|
||||
condMeets = target->HasAuraEffect(ConditionValue1, ConditionValue2);
|
||||
}
|
||||
}
|
||||
condMeets = unit->HasAuraEffect(ConditionValue1, ConditionValue2);
|
||||
break;
|
||||
}
|
||||
case CONDITION_ITEM:
|
||||
@@ -165,38 +157,6 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
|
||||
case CONDITION_SPELL_SCRIPT_TARGET:
|
||||
condMeets = true;//spell target condition is handled in spellsystem, here it is always true
|
||||
break;
|
||||
case CONDITION_CREATURE_TARGET:
|
||||
{
|
||||
if (Player* player = object->ToPlayer())
|
||||
{
|
||||
Unit* target = player->GetSelectedUnit();
|
||||
if (target)
|
||||
if (Creature* cTarget = target->ToCreature())
|
||||
if (cTarget->GetEntry() == ConditionValue1)
|
||||
condMeets = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONDITION_TARGET_HEALTH_BELOW_PCT:
|
||||
{
|
||||
if (Player* player = object->ToPlayer())
|
||||
{
|
||||
Unit* target = player->GetSelectedUnit();
|
||||
if (target)
|
||||
condMeets = !target->HealthAbovePct(ConditionValue1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
case CONDITION_TARGET_RANGE:
|
||||
{
|
||||
if (Player* player = object->ToPlayer())
|
||||
{
|
||||
if (Unit* target = player->GetSelectedUnit())
|
||||
if (player->GetDistance(target) >= ConditionValue1 && (!ConditionValue2 || player->GetDistance(target) <= ConditionValue2))
|
||||
condMeets = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONDITION_MAPID:
|
||||
condMeets = object->GetMapId() == ConditionValue1;
|
||||
break;
|
||||
@@ -1116,7 +1076,7 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
|
||||
}
|
||||
break;
|
||||
case CONDITION_SOURCE_TYPE_UNUSED_18:
|
||||
sLog->outErrorDb("Found SourceTypeOrReferenceId = CONDITION_SOURCE_TYPE_UNUSED_18 in `condition` table - ignoring");
|
||||
sLog->outErrorDb("Found SourceTypeOrReferenceId = CONDITION_SOURCE_TYPE_UNUSED_18 in `conditions` table - ignoring");
|
||||
return false;
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
|
||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
||||
@@ -1157,6 +1117,8 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
||||
sLog->outErrorDb("Aura condition has non existing effect index (%u) (must be 0..2), skipped", cond->ConditionValue2);
|
||||
return false;
|
||||
}
|
||||
if (cond->ConditionValue3)
|
||||
sLog->outErrorDb("Aura condition has useless data in value3 (%u)!", cond->ConditionValue3);
|
||||
break;
|
||||
}
|
||||
case CONDITION_ITEM:
|
||||
@@ -1370,45 +1332,6 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONDITION_CREATURE_TARGET:
|
||||
{
|
||||
if (!cond->ConditionValue1 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue1))
|
||||
{
|
||||
sLog->outErrorDb("CreatureTarget condition has non existing creature template entry (%u) as target, skipped", cond->ConditionValue1);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cond->ConditionValue2)
|
||||
sLog->outErrorDb("CreatureTarget condition has useless data in value2 (%u)!", cond->ConditionValue2);
|
||||
if (cond->ConditionValue3)
|
||||
sLog->outErrorDb("CreatureTarget condition has useless data in value3 (%u)!", cond->ConditionValue3);
|
||||
break;
|
||||
}
|
||||
case CONDITION_TARGET_HEALTH_BELOW_PCT:
|
||||
{
|
||||
if (cond->ConditionValue1 > 100)
|
||||
{
|
||||
sLog->outErrorDb("TargetHealthBelowPct condition has invalid data in value1 (%u), skipped", cond->ConditionValue1);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cond->ConditionValue2)
|
||||
sLog->outErrorDb("TargetHealthBelowPct condition has useless data in value2 (%u)!", cond->ConditionValue2);
|
||||
if (cond->ConditionValue3)
|
||||
sLog->outErrorDb("TargetHealthBelowPct condition has useless data in value3 (%u)!", cond->ConditionValue3);
|
||||
break;
|
||||
}
|
||||
case CONDITION_TARGET_RANGE:
|
||||
{
|
||||
if (cond->ConditionValue2 && cond->ConditionValue2 < cond->ConditionValue1)//maxDist can be 0 for infinit max range
|
||||
{
|
||||
sLog->outErrorDb("TargetRange condition has max distance closer then min distance, skipped");
|
||||
return false;
|
||||
}
|
||||
if (cond->ConditionValue3)
|
||||
sLog->outErrorDb("TargetRange condition has useless data in value3 (%u)!", cond->ConditionValue3);
|
||||
break;
|
||||
}
|
||||
case CONDITION_MAPID:
|
||||
{
|
||||
MapEntry const* me = sMapStore.LookupEntry(cond->ConditionValue1);
|
||||
@@ -1649,6 +1572,18 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
||||
sLog->outErrorDb("Phasemask condition has useless data in value3 (%u)!", cond->ConditionValue3);
|
||||
break;
|
||||
}
|
||||
case CONDITION_UNUSED_19:
|
||||
sLog->outErrorDb("Found ConditionTypeOrReference = CONDITION_UNUSED_19 in `conditions` table - ignoring");
|
||||
return false;
|
||||
case CONDITION_UNUSED_20:
|
||||
sLog->outErrorDb("Found ConditionTypeOrReference = CONDITION_UNUSED_19 in `conditions` table - ignoring");
|
||||
return false;
|
||||
case CONDITION_UNUSED_21:
|
||||
sLog->outErrorDb("Found ConditionTypeOrReference = CONDITION_UNUSED_19 in `conditions` table - ignoring");
|
||||
return false;
|
||||
case CONDITION_UNUSED_24:
|
||||
sLog->outErrorDb("Found ConditionTypeOrReference = CONDITION_UNUSED_19 in `conditions` table - ignoring");
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -49,9 +49,9 @@ enum ConditionTypes
|
||||
CONDITION_RACE = 16, // race 0 0 true if player's race is equal to race
|
||||
CONDITION_ACHIEVEMENT = 17, // achievement_id 0 0 true if achievement is complete
|
||||
CONDITION_SPELL_SCRIPT_TARGET = 18, // SpellScriptTargetType, TargetEntry, 0
|
||||
CONDITION_CREATURE_TARGET = 19, // creature entry 0 0 true if current target is creature with value1 entry
|
||||
CONDITION_TARGET_HEALTH_BELOW_PCT = 20, // 0-100 0 0 true if target's health is below value1 percent, false if over or no target
|
||||
CONDITION_TARGET_RANGE = 21, // minDistance maxDist 0 true if target is closer then minDist and further then maxDist or if max is 0 then max dist is infinit
|
||||
CONDITION_UNUSED_19 = 19, //
|
||||
CONDITION_UNUSED_20 = 20, //
|
||||
CONDITION_UNUSED_21 = 21, //
|
||||
CONDITION_MAPID = 22, // map_id 0 0 true if in map_id
|
||||
CONDITION_AREAID = 23, // area_id 0 0 true if in area_id
|
||||
CONDITION_UNUSED_24 = 24, //
|
||||
|
||||
@@ -1074,25 +1074,6 @@ bool Item::IsBindedNotWith(Player const* player) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ItemRequiredTarget::IsFitToRequirements(Unit* pUnitTarget) const
|
||||
{
|
||||
if (pUnitTarget->GetTypeId() != TYPEID_UNIT)
|
||||
return false;
|
||||
|
||||
if (pUnitTarget->GetEntry() != m_uiTargetEntry)
|
||||
return false;
|
||||
|
||||
switch (m_uiType)
|
||||
{
|
||||
case ITEM_TARGET_TYPE_CREATURE:
|
||||
return pUnitTarget->isAlive();
|
||||
case ITEM_TARGET_TYPE_DEAD:
|
||||
return !pUnitTarget->isAlive();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Item::BuildUpdate(UpdateDataMapType& data_map)
|
||||
{
|
||||
if (Player* owner = GetOwner())
|
||||
|
||||
@@ -201,26 +201,8 @@ enum ItemUpdateState
|
||||
ITEM_REMOVED = 3
|
||||
};
|
||||
|
||||
enum ItemRequiredTargetType
|
||||
{
|
||||
ITEM_TARGET_TYPE_CREATURE = 1,
|
||||
ITEM_TARGET_TYPE_DEAD = 2
|
||||
};
|
||||
|
||||
#define MAX_ITEM_REQ_TARGET_TYPE 2
|
||||
|
||||
#define MAX_ITEM_SPELLS 5
|
||||
|
||||
struct ItemRequiredTarget
|
||||
{
|
||||
ItemRequiredTarget(ItemRequiredTargetType uiType, uint32 uiTargetEntry) : m_uiType(uiType), m_uiTargetEntry(uiTargetEntry) {}
|
||||
ItemRequiredTargetType m_uiType;
|
||||
uint32 m_uiTargetEntry;
|
||||
|
||||
// helpers
|
||||
bool IsFitToRequirements(Unit* pUnitTarget) const;
|
||||
};
|
||||
|
||||
bool ItemCanGoIntoBag(ItemTemplate const* proto, ItemTemplate const* pBagProto);
|
||||
|
||||
class Item : public Object
|
||||
|
||||
Reference in New Issue
Block a user