mirror of
https://github.com/mangosfour/server.git
synced 2025-12-21 10:37:06 +00:00
[c12599] Add support for condition_id to spell_area table
This commit is contained in:
parent
4f86b168c0
commit
15bb475d40
10 changed files with 111 additions and 138 deletions
|
|
@ -3845,15 +3845,12 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg)
|
|||
void SpellMgr::LoadSpellAreas()
|
||||
{
|
||||
mSpellAreaMap.clear(); // need for reload case
|
||||
mSpellAreaForQuestMap.clear();
|
||||
mSpellAreaForActiveQuestMap.clear();
|
||||
mSpellAreaForQuestEndMap.clear();
|
||||
mSpellAreaForAuraMap.clear();
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8
|
||||
QueryResult* result = WorldDatabase.Query("SELECT spell, area, quest_start, quest_start_active, quest_end, aura_spell, racemask, gender, autocast FROM spell_area");
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
QueryResult* result = WorldDatabase.Query("SELECT spell, area, quest_start, quest_start_active, quest_end, condition_id, aura_spell, racemask, gender, autocast FROM spell_area");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
|
|
@ -3881,10 +3878,11 @@ void SpellMgr::LoadSpellAreas()
|
|||
spellArea.questStart = fields[2].GetUInt32();
|
||||
spellArea.questStartCanActive = fields[3].GetBool();
|
||||
spellArea.questEnd = fields[4].GetUInt32();
|
||||
spellArea.auraSpell = fields[5].GetInt32();
|
||||
spellArea.raceMask = fields[6].GetUInt32();
|
||||
spellArea.gender = Gender(fields[7].GetUInt8());
|
||||
spellArea.autocast = fields[8].GetBool();
|
||||
spellArea.conditionId = fields[5].GetUInt16();
|
||||
spellArea.auraSpell = fields[6].GetInt32();
|
||||
spellArea.raceMask = fields[7].GetUInt32();
|
||||
spellArea.gender = Gender(fields[8].GetUInt8());
|
||||
spellArea.autocast = fields[9].GetBool();
|
||||
|
||||
if (!sSpellStore.LookupEntry(spell))
|
||||
{
|
||||
|
|
@ -3928,6 +3926,13 @@ void SpellMgr::LoadSpellAreas()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (spellArea.conditionId && !sConditionStorage.LookupEntry<PlayerCondition>(spellArea.conditionId))
|
||||
{
|
||||
sLog.outErrorDb("Spell %u listed in `spell_area` have wrong conditionId (%u) requirement", spell, spellArea.conditionId);
|
||||
continue;
|
||||
}
|
||||
else if (!spellArea.conditionId)
|
||||
{
|
||||
if (spellArea.questStart && !sObjectMgr.GetQuestTemplate(spellArea.questStart))
|
||||
{
|
||||
sLog.outErrorDb("Spell %u listed in `spell_area` have wrong start quest (%u) requirement", spell, spellArea.questStart);
|
||||
|
|
@ -3949,6 +3954,19 @@ void SpellMgr::LoadSpellAreas()
|
|||
}
|
||||
}
|
||||
|
||||
if (spellArea.raceMask && (spellArea.raceMask & RACEMASK_ALL_PLAYABLE) == 0)
|
||||
{
|
||||
sLog.outErrorDb("Spell %u listed in `spell_area` have wrong race mask (%u) requirement", spell, spellArea.raceMask);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (spellArea.gender != GENDER_NONE && spellArea.gender != GENDER_FEMALE && spellArea.gender != GENDER_MALE)
|
||||
{
|
||||
sLog.outErrorDb("Spell %u listed in `spell_area` have wrong gender (%u) requirement", spell, spellArea.gender);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (spellArea.auraSpell)
|
||||
{
|
||||
SpellEntry const* spellInfo = sSpellStore.LookupEntry(abs(spellArea.auraSpell));
|
||||
|
|
@ -4017,37 +4035,12 @@ void SpellMgr::LoadSpellAreas()
|
|||
}
|
||||
}
|
||||
|
||||
if (spellArea.raceMask && (spellArea.raceMask & RACEMASK_ALL_PLAYABLE) == 0)
|
||||
{
|
||||
sLog.outErrorDb("Spell %u listed in `spell_area` have wrong race mask (%u) requirement", spell, spellArea.raceMask);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (spellArea.gender != GENDER_NONE && spellArea.gender != GENDER_FEMALE && spellArea.gender != GENDER_MALE)
|
||||
{
|
||||
sLog.outErrorDb("Spell %u listed in `spell_area` have wrong gender (%u) requirement", spell, spellArea.gender);
|
||||
continue;
|
||||
}
|
||||
|
||||
SpellArea const* sa = &mSpellAreaMap.insert(SpellAreaMap::value_type(spell, spellArea))->second;
|
||||
|
||||
// for search by current zone/subzone at zone/subzone change
|
||||
if (spellArea.areaId)
|
||||
mSpellAreaForAreaMap.insert(SpellAreaForAreaMap::value_type(spellArea.areaId, sa));
|
||||
|
||||
// for search at quest start/reward
|
||||
if (spellArea.questStart)
|
||||
{
|
||||
if (spellArea.questStartCanActive)
|
||||
mSpellAreaForActiveQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart, sa));
|
||||
else
|
||||
mSpellAreaForQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart, sa));
|
||||
}
|
||||
|
||||
// for search at quest start/reward
|
||||
if (spellArea.questEnd)
|
||||
mSpellAreaForQuestEndMap.insert(SpellAreaForQuestMap::value_type(spellArea.questEnd, sa));
|
||||
|
||||
// for search at aura apply
|
||||
if (spellArea.auraSpell)
|
||||
mSpellAreaForAuraMap.insert(SpellAreaForAuraMap::value_type(abs(spellArea.auraSpell), sa));
|
||||
|
|
@ -4716,6 +4709,13 @@ DiminishingReturnsType GetDiminishingReturnsGroupType(DiminishingGroup group)
|
|||
|
||||
bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 newArea) const
|
||||
{
|
||||
if (conditionId)
|
||||
{
|
||||
if (!player || !sObjectMgr.IsPlayerMeetToCondition(conditionId, player, player->GetMap(), NULL, CONDITION_FROM_SPELL_AREA))
|
||||
return false;
|
||||
}
|
||||
else // This block will be removed
|
||||
{
|
||||
if (gender != GENDER_NONE)
|
||||
{
|
||||
// not in expected gender
|
||||
|
|
@ -4730,13 +4730,6 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
|
|||
return false;
|
||||
}
|
||||
|
||||
if (areaId)
|
||||
{
|
||||
// not in expected zone
|
||||
if (newZone != areaId && newArea != areaId)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (questStart)
|
||||
{
|
||||
// not in expected required quest state
|
||||
|
|
@ -4750,6 +4743,14 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
|
|||
if (!player || player->GetQuestRewardStatus(questEnd))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (areaId)
|
||||
{
|
||||
// not in expected zone
|
||||
if (newZone != areaId && newArea != areaId)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auraSpell)
|
||||
{
|
||||
|
|
@ -4758,15 +4759,28 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
|
|||
return false;
|
||||
if (auraSpell > 0)
|
||||
// have expected aura
|
||||
return player->HasAura(auraSpell, EFFECT_INDEX_0);
|
||||
return player->HasAura(auraSpell);
|
||||
else
|
||||
// not have expected aura
|
||||
return !player->HasAura(-auraSpell, EFFECT_INDEX_0);
|
||||
return !player->HasAura(-auraSpell);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SpellArea::ApplyOrRemoveSpellIfCan(Player* player, uint32 newZone, uint32 newArea, bool onlyApply) const
|
||||
{
|
||||
MANGOS_ASSERT(player);
|
||||
|
||||
if (IsFitToRequirements(player, newZone, newArea))
|
||||
{
|
||||
if (autocast && !player->HasAura(spellId))
|
||||
player->CastSpell(player, spellId, true);
|
||||
}
|
||||
else if (!onlyApply && player->HasAura(spellId))
|
||||
player->RemoveAurasDueToSpell(spellId);
|
||||
}
|
||||
|
||||
SpellEntry const* GetSpellEntryByDifficulty(uint32 id, Difficulty difficulty, bool isRaid)
|
||||
{
|
||||
SpellDifficultyEntry const* spellDiff = sSpellDifficultyStore.LookupEntry(id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue