diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 944eee8d3..4aef68a37 100755 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -7953,6 +7953,31 @@ bool PlayerCondition::Meets(Player const* player) const FactionEntry const* faction = sFactionStore.LookupEntry(m_value1); return faction && player->GetReputationMgr().GetRank(faction) <= ReputationRank(m_value2); } + case CONDITION_COMPLETED_ENCOUNTER: + { + if (!player->GetMap()->IsDungeon()) + { + sLog.outErrorDb("CONDITION_COMPLETED_ENCOUNTER (entry %u) is used outside of a dungeon (on Map %u) by %s", m_entry, player->GetMapId(), player->GetGuidStr().c_str()); + return false; + } + + uint32 completedEncounterMask = ((DungeonMap*)player->GetMap())->GetPersistanceState()->GetCompletedEncountersMask(); + DungeonEncounterEntry const* dbcEntry1 = sDungeonEncounterStore.LookupEntry(m_value1); + DungeonEncounterEntry const* dbcEntry2 = sDungeonEncounterStore.LookupEntry(m_value2); + // Check that on proper map + if (dbcEntry1->mapId != player->GetMapId()) + { + sLog.outErrorDb("CONDITION_COMPLETED_ENCOUNTER (entry %u, DungeonEncounterEntry -value1- %u) is used on wrong map (used on Map %u) by %s", m_entry, m_value1, player->GetMapId(), player->GetGuidStr().c_str()); + return false; + } + // Select matching difficulties + if (player->GetDifficulty(player->GetMap()->IsRaid()) != Difficulty(dbcEntry1->Difficulty)) + dbcEntry1 = NULL; + if (dbcEntry2 && player->GetDifficulty(player->GetMap()->IsRaid()) != Difficulty(dbcEntry2->Difficulty)) + dbcEntry2 = NULL; + + return completedEncounterMask & ((dbcEntry1 ? 1 << dbcEntry1->encounterIndex : 0) | (dbcEntry2 ? 1 << dbcEntry2->encounterIndex : 0)); + } default: return false; } @@ -8260,7 +8285,7 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu if (bounds.first == bounds.second) { - sLog.outErrorDb("Learnable ability conditon (entry %u, type %u) has spell id %u defined, but this spell is not listed in SkillLineAbility and can not be used, skipping.", entry, condition, value1); + sLog.outErrorDb("Learnable ability condition (entry %u, type %u) has spell id %u defined, but this spell is not listed in SkillLineAbility and can not be used, skipping.", entry, condition, value1); return false; } @@ -8269,13 +8294,34 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu ItemPrototype const* proto = ObjectMgr::GetItemPrototype(value2); if (!proto) { - sLog.outErrorDb("Learnable ability conditon (entry %u, type %u) has item entry %u defined but item does not exist, skipping.", entry, condition, value2); + sLog.outErrorDb("Learnable ability condition (entry %u, type %u) has item entry %u defined but item does not exist, skipping.", entry, condition, value2); return false; } } break; } + case CONDITION_COMPLETED_ENCOUNTER: + { + DungeonEncounterEntry const* dbcEntry1 = sDungeonEncounterStore.LookupEntry(value1); + DungeonEncounterEntry const* dbcEntry2 = sDungeonEncounterStore.LookupEntry(value2); + if (!dbcEntry1) + { + sLog.outErrorDb("Completed Encounter condition (entry %u, type %u) has an unknown DungeonEncounter entry %u defined (in value1), skipping.", entry, condition, value1); + return false; + } + if (value2 && !dbcEntry2) + { + sLog.outErrorDb("Completed Encounter condition (entry %u, type %u) has an unknown DungeonEncounter entry %u defined (in value2), skipping.", entry, condition, value2); + return false; + } + if (dbcEntry2 && dbcEntry1->mapId != dbcEntry2->mapId) + { + sLog.outErrorDb("Completed Encounter condition (entry %u, type %u) has different mapIds for both encounters, skipping.", entry, condition); + return false; + } + break; + } case CONDITION_NONE: break; default: diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 8e8aa41b5..51b67607a 100755 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -389,6 +389,7 @@ enum ConditionType // True if player has skill skill_id and skill less than (and not equal) skill_value (for skill_value > 1) // If skill_value == 1, then true if player has not skill skill_id CONDITION_REPUTATION_RANK_MAX = 30, // faction_id max_rank + CONDITION_COMPLETED_ENCOUNTER = 31, // encounter_id encounter_id2 encounter_id[2] = DungeonEncounter(dbc).id (if value2 provided it will return value1 OR value2) }; class PlayerCondition diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index f3bb58eb3..f7759e4e5 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12144" + #define REVISION_NR "12145" #endif // __REVISION_NR_H__