Creature* SelectRandomCreatureOfEntryInRange(uint32 uiEntry, float fRange) { CreatureList lCreatureList; GetCreatureListWithEntryInGrid(lCreatureList, m_creature, uiEntry, fRange); if (lCreatureList.empty()) return NULL; CreatureList::iterator iter = lCreatureList.begin(); advance(iter, urand(0, lCreatureList.size()-1)); return *iter; }
void JustSummoned(Creature* pSummoned) override { lCreatureList.push_back(pSummoned); pSummoned->setFaction(FACTION_GENERIC_FRIENDLY); if (pSummoned->GetEntry() == NPC_CALDWELL) pSummoned->GetMotionMaster()->MovePoint(0, m_afMoveTo[0], m_afMoveTo[1], m_afMoveTo[2]); else { if (Creature* pCaldwell = GetCreature(NPC_CALDWELL)) { // will this conversion work without compile warning/error? size_t iSize = lCreatureList.size(); pSummoned->GetMotionMaster()->MoveFollow(pCaldwell, 0.5f, (M_PI / 2) * (int)iSize); } } }
void UpdateAI(const uint32 uiDiff) override { if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; // Demoralizing Shout Timer if (m_uiDemoralizingShoutTimer < uiDiff) { if (DoCastSpellIfCan(m_creature, SPELL_DEMORALIZING_SHOUT) == CAST_OK) m_uiDemoralizingShoutTimer = urand(15000, 20000); } else m_uiDemoralizingShoutTimer -= uiDiff; // Inspire Timer if (m_uiInspireTimer < uiDiff) { Creature* pTarget = nullptr; CreatureList pList = DoFindFriendlyMissingBuff(45.0f, SPELL_INSPIRE); if (!pList.empty()) { CreatureList::iterator i = pList.begin(); advance(i, (rand() % pList.size())); pTarget = (*i); } if (!pTarget) pTarget = m_creature; if (DoCastSpellIfCan(pTarget, SPELL_INSPIRE) == CAST_OK) m_uiInspireTimer = 10000; } else m_uiInspireTimer -= uiDiff; // Hand of Ragnaros Timer if (m_uiKnockdownTimer < uiDiff) { if (DoCastSpellIfCan(m_creature, SPELL_HAND_OF_RAGNAROS) == CAST_OK) m_uiKnockdownTimer = urand(12000, 15000); } else m_uiKnockdownTimer -= uiDiff; // Flamespear Timer if (m_uiFlamespearTimer < uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { if (DoCastSpellIfCan(pTarget, SPELL_FLAMESPEAR) == CAST_OK) m_uiFlamespearTimer = urand(12000, 16000); } } else m_uiFlamespearTimer -= uiDiff; // Dark Strike Timer if (m_uiDarkstrikeTimer < uiDiff) { if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_DARK_STRIKE) == CAST_OK) m_uiDarkstrikeTimer = urand(15000, 18000); } else m_uiDarkstrikeTimer -= uiDiff; DoMeleeAttackIfReady(); }
bool EffectDummyCreature_spell_anchor(Unit* /*pCaster*/, uint32 uiSpellId, SpellEffectIndex uiEffIndex, Creature* pCreatureTarget, ObjectGuid /*originalCasterGuid*/) { if (uiEffIndex != EFFECT_INDEX_0 || pCreatureTarget->GetEntry() != NPC_SUB_BOSS_TRIGGER) return true; instance_naxxramas* pInstance = (instance_naxxramas*)pCreatureTarget->GetInstanceData(); if (!pInstance) return true; switch (uiSpellId) { case SPELL_A_TO_ANCHOR_1: // trigger mobs at high right side case SPELL_B_TO_ANCHOR_1: case SPELL_C_TO_ANCHOR_1: { if (Creature* pAnchor2 = pInstance->GetClosestAnchorForGoth(pCreatureTarget, false)) { uint32 uiTriggered = SPELL_A_TO_ANCHOR_2; if (uiSpellId == SPELL_B_TO_ANCHOR_1) uiTriggered = SPELL_B_TO_ANCHOR_2; else if (uiSpellId == SPELL_C_TO_ANCHOR_1) uiTriggered = SPELL_C_TO_ANCHOR_2; pCreatureTarget->CastSpell(pAnchor2, uiTriggered, TRIGGERED_OLD_TRIGGERED); } return true; } case SPELL_A_TO_ANCHOR_2: // trigger mobs at high left side case SPELL_B_TO_ANCHOR_2: case SPELL_C_TO_ANCHOR_2: { CreatureList lTargets; pInstance->GetGothSummonPointCreatures(lTargets, false); if (!lTargets.empty()) { CreatureList::iterator itr = lTargets.begin(); uint32 uiPosition = urand(0, lTargets.size() - 1); advance(itr, uiPosition); if (Creature* pTarget = (*itr)) { uint32 uiTriggered = SPELL_A_TO_SKULL; if (uiSpellId == SPELL_B_TO_ANCHOR_2) uiTriggered = SPELL_B_TO_SKULL; else if (uiSpellId == SPELL_C_TO_ANCHOR_2) uiTriggered = SPELL_C_TO_SKULL; pCreatureTarget->CastSpell(pTarget, uiTriggered, TRIGGERED_OLD_TRIGGERED); } } return true; } case SPELL_A_TO_SKULL: // final destination trigger mob case SPELL_B_TO_SKULL: case SPELL_C_TO_SKULL: { if (Creature* pGoth = pInstance->GetSingleCreatureFromStorage(NPC_GOTHIK)) { uint32 uiNpcEntry = NPC_SPECT_TRAINEE; if (uiSpellId == SPELL_B_TO_SKULL) uiNpcEntry = NPC_SPECT_DEATH_KNIGHT; else if (uiSpellId == SPELL_C_TO_SKULL) uiNpcEntry = NPC_SPECT_RIDER; pGoth->SummonCreature(uiNpcEntry, pCreatureTarget->GetPositionX(), pCreatureTarget->GetPositionY(), pCreatureTarget->GetPositionZ(), pCreatureTarget->GetOrientation(), TEMPSPAWN_DEAD_DESPAWN, 0); if (uiNpcEntry == NPC_SPECT_RIDER) pGoth->SummonCreature(NPC_SPECT_HORSE, pCreatureTarget->GetPositionX(), pCreatureTarget->GetPositionY(), pCreatureTarget->GetPositionZ(), pCreatureTarget->GetOrientation(), TEMPSPAWN_DEAD_DESPAWN, 0); } return true; } } return true; };