mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[12145] Add new condition CONDITION_COMPLETED_ENCOUNTER
This condition returns true if a DungeonEncounter is done in this map. value1, value2 are expected to be the IDs from DungeonEncounter(dbc) value2 is optional, if both values are given, the condition will be true if one of the two DungeonEncounters are done. Thanks to crackm for testing
This commit is contained in:
parent
d387c20dad
commit
c8ebd1678e
3 changed files with 50 additions and 3 deletions
|
|
@ -7953,6 +7953,31 @@ bool PlayerCondition::Meets(Player const* player) const
|
||||||
FactionEntry const* faction = sFactionStore.LookupEntry(m_value1);
|
FactionEntry const* faction = sFactionStore.LookupEntry(m_value1);
|
||||||
return faction && player->GetReputationMgr().GetRank(faction) <= ReputationRank(m_value2);
|
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:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -8260,7 +8285,7 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu
|
||||||
|
|
||||||
if (bounds.first == bounds.second)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -8269,13 +8294,34 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu
|
||||||
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(value2);
|
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(value2);
|
||||||
if (!proto)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
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:
|
case CONDITION_NONE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -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)
|
// 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
|
// If skill_value == 1, then true if player has not skill skill_id
|
||||||
CONDITION_REPUTATION_RANK_MAX = 30, // faction_id max_rank
|
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
|
class PlayerCondition
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "12144"
|
#define REVISION_NR "12145"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue