uint8 BSWScriptedAI::_findSpellIDX(uint32 SpellID) { if (bossSpellCount() > 0) for(uint8 i = 0; i < bossSpellCount(); ++i) if (m_BSWRecords[i].m_uiSpellEntry[RAID_DIFFICULTY_10MAN_NORMAL] == SpellID) return i; error_log("BSW: spell %u not found in m_creature %u spelltable. Memory or database error?", SpellID, m_creature->GetEntry()); return SPELL_INDEX_ERROR; }
uint8 BossSpellWorker::_findSpellIDX(uint32 SpellID) { if (bossSpellCount() >= 0) for(uint8 i = 0; i < bossSpellCount(); ++i) if (m_BossSpell[i].m_uiSpellEntry[RAID_DIFFICULTY_10MAN_NORMAL] == SpellID) return i; error_log("BSW: spell %u not found in boss %u spelltable. Memory or database error?", SpellID, bossID); return SPELL_INDEX_ERROR; }
void BossSpellWorker::_resetTimer(uint8 m_uiSpellIdx) { if (m_uiSpellIdx > bossSpellCount()) return; if (m_BossSpell[m_uiSpellIdx].m_uiSpellTimerMin[currentDifficulty] != m_BossSpell[m_uiSpellIdx].m_uiSpellTimerMax[currentDifficulty]) m_uiSpell_Timer[m_uiSpellIdx] = urand(0,m_BossSpell[m_uiSpellIdx].m_uiSpellTimerMax[currentDifficulty]); else m_uiSpell_Timer[m_uiSpellIdx] = m_BossSpell[m_uiSpellIdx].m_uiSpellTimerMin[currentDifficulty]; if (m_BossSpell[m_uiSpellIdx].m_uiSpellTimerMin[currentDifficulty] == 0 && m_BossSpell[m_uiSpellIdx].m_uiSpellTimerMax[currentDifficulty] >= HOUR*IN_MILLISECONDS) m_uiSpell_Timer[m_uiSpellIdx] = 0; };
bool BSWScriptedAI::doCastAll(uint32 diff) { uint8 succesfulCast = 0; if (bossSpellCount() > 0) { for(uint8 i = 0; i < bossSpellCount(); ++i) if (_QuerySpellPeriod(i, diff)) if (_BSWSpellSelector(i) == CAST_OK) ++succesfulCast; if (succesfulCast) debug_log("BSW: Casting all spells for creature %u done. Successful casted %u spells from %u.", m_creature->GetEntry(),succesfulCast,bossSpellCount()); } else { error_log("BSW: Casting all spells for creature %u failed. Database has no spells.", m_creature->GetEntry()); } return (succesfulCast >= 1) ? true : false; };
void BossSpellWorker::_fillEmptyDataField() { for (uint8 i = 0; i < bossSpellCount(); ++i) for (uint8 j = 1; j < DIFFICULTY_LEVELS; ++j) { if (m_BossSpell[i].m_uiSpellEntry[j] == 0) m_BossSpell[i].m_uiSpellEntry[j] = m_BossSpell[i].m_uiSpellEntry[j-1]; if (m_BossSpell[i].m_uiSpellTimerMin[j] == 0) m_BossSpell[i].m_uiSpellTimerMin[j] = m_BossSpell[i].m_uiSpellTimerMin[j-1]; if (m_BossSpell[i].m_uiSpellTimerMax[j] == 0) m_BossSpell[i].m_uiSpellTimerMax[j] = m_BossSpell[i].m_uiSpellTimerMax[j-1]; if (m_BossSpell[i].m_uiSpellData[j] == 0) m_BossSpell[i].m_uiSpellData[j] = m_BossSpell[i].m_uiSpellData[j-1]; }; };
void BSWScriptedAI::_fillEmptyDataField() { for (uint8 i = 0; i < bossSpellCount(); ++i) for (uint8 j = 1; j < DIFFICULTY_LEVELS; ++j) { if (m_BSWRecords[i].m_uiSpellEntry[j] == 0) { SpellEntry const* spell = GetSpellEntryByDifficulty(m_BSWRecords[i].m_uiSpellEntry[0],(Difficulty)j,true); if (spell) m_BSWRecords[i].m_uiSpellEntry[j] = spell->Id; else m_BSWRecords[i].m_uiSpellEntry[j] = m_BSWRecords[i].m_uiSpellEntry[j-1]; } if (m_BSWRecords[i].m_uiSpellTimerMin[j] == 0) m_BSWRecords[i].m_uiSpellTimerMin[j] = m_BSWRecords[i].m_uiSpellTimerMin[j-1]; if (m_BSWRecords[i].m_uiSpellTimerMax[j] == 0) m_BSWRecords[i].m_uiSpellTimerMax[j] = m_BSWRecords[i].m_uiSpellTimerMax[j-1]; if (m_BSWRecords[i].m_uiSpellData[j] == 0) m_BSWRecords[i].m_uiSpellData[j] = m_BSWRecords[i].m_uiSpellData[j-1]; }; };
void BSWScriptedAI::_loadFromDB() { // mutex block for process-safe request execute ACE_Process_Mutex mMutex = ACE_Process_Mutex("BSW_Lock"); debug_log("BSW: Loading table of creature %u spell on difficulty %u", m_creature->GetEntry(), currentDifficulty); char query[MAX_QUERY_LEN]; sprintf(query, "SELECT entry, spellID_N10, spellID_N25, spellID_H10, spellID_H25, timerMin_N10, timerMin_N25, timerMin_H10, timerMin_H25, timerMax_N10, timerMax_N25, timerMax_H10, timerMax_H25, data1, data2, data3, data4, locData_x, locData_y, locData_z, varData, StageMask_N, StageMask_H, CastType, isVisualEffect, isBugged, textEntry FROM `boss_spell_table` WHERE entry = %u;\r\n", m_creature->GetEntry()); mMutex.acquire(); QueryResult* Result = strSD2Pquery(query); mMutex.release(); if (Result) { uint32 uiCount = 0; do { BSWRecord m_BSWRecord; Field* pFields = Result->Fetch(); m_BSWRecord.id = uiCount; uint32 m_creatureEntry = pFields[0].GetUInt32(); for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j) m_BSWRecord.m_uiSpellEntry[j] = pFields[1+j].GetUInt32(); for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j) m_BSWRecord.m_uiSpellTimerMin[j] = pFields[1+DIFFICULTY_LEVELS+j].GetUInt32(); for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j) m_BSWRecord.m_uiSpellTimerMax[j] = pFields[1+DIFFICULTY_LEVELS*2+j].GetUInt32(); for (uint8 j = 0; j < DIFFICULTY_LEVELS; ++j) m_BSWRecord.m_uiSpellData[j] = pFields[1+DIFFICULTY_LEVELS*3+j].GetUInt32(); m_BSWRecord.LocData.x = pFields[1+DIFFICULTY_LEVELS*4].GetFloat(); m_BSWRecord.LocData.y = pFields[2+DIFFICULTY_LEVELS*4].GetFloat(); m_BSWRecord.LocData.z = pFields[3+DIFFICULTY_LEVELS*4].GetFloat(); m_BSWRecord.varData = pFields[4+DIFFICULTY_LEVELS*4].GetInt32(); m_BSWRecord.StageMaskN = pFields[5+DIFFICULTY_LEVELS*4].GetUInt32(); m_BSWRecord.StageMaskH = pFields[6+DIFFICULTY_LEVELS*4].GetUInt32(); m_BSWRecord.m_CastTarget = _getBSWCastType(pFields[7+DIFFICULTY_LEVELS*4].GetUInt8()); m_BSWRecord.m_IsVisualEffect = (pFields[8+DIFFICULTY_LEVELS*4].GetUInt8() == 0) ? false : true ; m_BSWRecord.m_IsBugged = (pFields[9+DIFFICULTY_LEVELS*4].GetUInt8() == 0) ? false : true ; m_BSWRecord.textEntry = pFields[10+DIFFICULTY_LEVELS*4].GetInt32(); m_BSWRecords.push_back(m_BSWRecord); if (m_creatureEntry != m_creature->GetEntry()) error_log("BSW: Unknown error while load boss_spell_table"); else ++uiCount; } while (Result->NextRow()); delete Result; debug_log("BSW: Loaded %u spell data records for creature %u", bossSpellCount(), m_creature->GetEntry()); } else { error_log("BSW: BSW table for creature %u is empty.", m_creature->GetEntry()); }; }