void Aggro(Unit *who) { if(!m_pInstance) return; m_pInstance->SetData(TYPE_CRUSADERS, IN_PROGRESS); DoCast(m_creature, SPELL_ANTI_AOE, true); if(who->GetTypeId() != TYPEID_PLAYER) if (Unit* player = doSelectRandomPlayerAtRange(80.0f)) m_creature->AddThreat(player, 100.0f); }
void JustSummoned(Creature* summoned) { if(!m_pInstance || !summoned) return; if (Unit* pTarget = doSelectRandomPlayerAtRange(100.0f)) { summoned->SetInCombatWith(pTarget); summoned->AddThreat(pTarget,100.0f); } }
void JustSummoned(Creature* summoned) { if(!pInstance || !summoned) return; if (Unit* pTarget = doSelectRandomPlayerAtRange(60.0f)) { summoned->SetInCombatWith(pTarget); summoned->AddThreat(pTarget,100.0f); } mobsGUIDList.push_back(summoned->GetObjectGuid()); }
void UpdateAI(const uint32 diff) { if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; switch(getStage()) { case 0: if (timedQuery(SPELL_BONE_STRIKE, diff)) if (Unit* pTarget = doSelectRandomPlayer(SPELL_BONE_STRIKE_IMPALE, false, 60.0f)) if (doCast(SPELL_BONE_STRIKE, pTarget) == CAST_OK) { doSummonSpike(pTarget); switch (urand(0,1)) { case 0: DoScriptText(-1631003,m_creature,pTarget); break; case 1: DoScriptText(-1631004,m_creature,pTarget); break; case 2: DoScriptText(-1631005,m_creature,pTarget); break; }; }; if (timedQuery(SPELL_BONE_STORM, diff)) setStage(1); if (timedQuery(SPELL_CALL_COLD_FLAME, diff)) { if (urand(0,1)) doCast(SPELL_CALL_COLD_FLAME); else doCast(SPELL_CALL_COLD_FLAME_1); if (m_creature->GetHealthPercent() <= 30.0f) { if (urand(0,1)) doCast(SPELL_CALL_COLD_FLAME); else doCast(SPELL_CALL_COLD_FLAME_1); } } timedCast(SPELL_SABER_LASH, diff); DoMeleeAttackIfReady(); break; case 1: m_creature->InterruptNonMeleeSpells(true); doCast(SPELL_BONE_STORM); setStage(2); DoScriptText(-1631002,m_creature); DoResetThreat(); m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE); m_creature->SetSpeedRate(MOVE_RUN, 3); m_creature->SetSpeedRate(MOVE_WALK, 3); break; case 2: if (!m_creature->IsNonMeleeSpellCasted(false)) setStage(3); break; case 3: if (isHeroic()) if (timedQuery(SPELL_BONE_STRIKE, diff, true)) if (Unit* pTarget = doSelectRandomPlayer(SPELL_BONE_STRIKE_IMPALE, false, 60.0f)) doSummonSpike(pTarget); if (timedQuery(SPELL_CALL_COLD_FLAME, diff, true) && m_creature->IsWithinDistInMap(m_creature->getVictim(),2.0f)) { pInstance->SetData(DATA_DIRECTION, (uint32)(1000*2.0f*M_PI_F*((float)urand(1,16)/16.0f))); // if (urand(0,1)) doCast(SPELL_CALL_COLD_FLAME); // else doCast(SPELL_CALL_COLD_FLAME_1); float fPosX, fPosY, fPosZ; m_creature->GetPosition(fPosX, fPosY, fPosZ); doSummon(NPC_COLD_FLAME, fPosX, fPosY, fPosZ); DoResetThreat(); if (Unit* pTarget = doSelectRandomPlayerAtRange(60.0f)) AttackStart(pTarget); } if (!hasAura(SPELL_BONE_STORM_STRIKE, m_creature) && !hasAura(SPELL_BONE_STORM, m_creature)) setStage(4); break; case 4: pInstance->SetData(DATA_DIRECTION, 0); m_creature->SetSpeedRate(MOVE_RUN, 1); m_creature->SetSpeedRate(MOVE_WALK, 1); // m_creature->AddSplineFlag(SPLINEFLAG_WALKMODE); setStage(0); break; default: break; } if (timedQuery(SPELL_BERSERK, diff)) { doCast(SPELL_BERSERK); DoScriptText(-1631008,m_creature); } }
void UpdateAI(const uint32 diff) { if (!pInstance) return; Unit* pTarget = NULL; if (pInstance->GetData(TYPE_EVENT_NPC) == NPC_LICH_KING) { UpdateTimer = pInstance->GetData(TYPE_EVENT_TIMER); if (UpdateTimer <= diff) { debug_log("EventMGR: creature %u received signal %u ",m_creature->GetEntry(),pInstance->GetData(TYPE_EVENT)); switch (pInstance->GetData(TYPE_EVENT)) { case 12000: m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STAND); m_creature->SetStandState(UNIT_STAND_STATE_STAND); StartMovement(0,12020); break; case 12020: m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK); DoScriptText(-1631501, m_creature); UpdateTimer = 12000; pInstance->SetData(TYPE_EVENT,12030); break; case 12040: m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_READY2H); DoScriptText(-1631503, m_creature); UpdateTimer = 8000; pInstance->SetData(TYPE_EVENT,12041); break; case 12041: m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_LAUGH); UpdateTimer = 3000; pInstance->SetData(TYPE_EVENT,12042); break; case 12042: m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,EMOTE_ONESHOT_POINT_NOSHEATHE); UpdateTimer = 2000; pInstance->SetData(TYPE_EVENT,12043); break; case 12043: m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,EMOTE_ONESHOT_NONE); UpdateTimer = 10000; pInstance->SetData(TYPE_EVENT,12050); break; case 12060: m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_TALK); DoScriptText(-1631505, m_creature); UpdateTimer = 10000; pInstance->SetData(TYPE_EVENT,12080); break; case 12080: m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,EMOTE_STATE_READY2H); UpdateTimer = 2000; pInstance->SetData(TYPE_EVENT,12100); break; case 12100: m_creature->SetUInt32Value(UNIT_NPC_EMOTESTATE,EMOTE_ONESHOT_NONE); UpdateTimer = 6000; pInstance->SetData(TYPE_EVENT,12120); break; case 12120: m_creature->GetMotionMaster()->Clear(); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); SetCombatMovement(true); m_creature->SetInCombatWithZone(); battlestarted = true; pInstance->SetData(TYPE_EVENT,12200); pTarget = doSelectRandomPlayerAtRange(140.0f); if (pTarget) m_creature->AddThreat(pTarget,100.0f); SetCombatMovement(true); UpdateTimer = 10000; break; case 12200: DoScriptText(-1631506, m_creature); UpdateTimer = 5000; pInstance->SetData(TYPE_EVENT,12220); break; case 13000: m_creature->SetOrientation(3.1146f); DoScriptText(-1631507, m_creature); UpdateTimer = 12000; finalphase = true; doCast(SPELL_FURY_OF_FROSTMOURNE); pInstance->SetData(TYPE_EVENT,13020); if (pTirion = m_creature->GetMap()->GetCreature(pInstance->GetData64(NPC_TIRION))) { m_creature->SetInCombatWith(pTirion); pTirion->AddThreat(m_creature, 1000.0f); } m_creature->SetInCombatWithZone(); break; case 13020: DoScriptText(-1631508, m_creature); UpdateTimer = 12000; pInstance->SetData(TYPE_EVENT,13060); break; case 13060: DoScriptText(-1631509, m_creature); UpdateTimer = 15000; pInstance->SetData(TYPE_EVENT,13100); break; case 13100: DoScriptText(-1631510, m_creature); UpdateTimer = 15000; pInstance->SetData(TYPE_EVENT,13110); doCast(SPELL_CHANNEL_KING); break; case 13120: DoScriptText(-1631511, m_creature); UpdateTimer = 12000; pInstance->SetData(TYPE_EVENT,13130); break; case 13140: UpdateTimer = 6000; doRemove(SPELL_CHANNEL_KING); pInstance->SetData(TYPE_EVENT,13150); m_creature->CastSpell(m_creature, SPELL_SUMMON_BROKEN_FROSTMOURNE, false); break; case 13160: UpdateTimer = 6000; pInstance->SetData(TYPE_EVENT,13170); m_creature->CastSpell(m_creature, SPELL_SUMMON_BROKEN_FROSTMOURNE_2, false); break; case 13180: UpdateTimer = 12000; pInstance->SetData(TYPE_EVENT,13190); if (pFrostmourne = m_creature->SummonCreature(NPC_FROSTMOURNE_HOLDER, SpawnLoc[7].x, SpawnLoc[7].y, SpawnLoc[7].z, 0, TEMPSUMMON_MANUAL_DESPAWN, 5000)) { pFrostmourne->CastSpell(pFrostmourne, SPELL_BROKEN_FROSTMOURNE, false); pFrostmourne->CastSpell(pFrostmourne, SPELL_FROSTMOURNE_TRIGGER, false); pFrostmourne->GetMotionMaster()->MoveChase(m_creature); m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED); } break; case 13200: DoScriptText(-1631512, m_creature); m_creature->RemoveAurasDueToSpell(SPELL_SUMMON_BROKEN_FROSTMOURNE); m_creature->RemoveAllAuras(); pFrostmourne->RemoveAurasDueToSpell(SPELL_FROSTMOURNE_TRIGGER); UpdateTimer = 5000; pInstance->SetData(TYPE_EVENT,13210); break; case 13280: UpdateTimer = 2000; pInstance->SetData(TYPE_EVENT,13290); stage = 13; if (pFrostmourne) pFrostmourne->ForcedDespawn(); if (Creature* pTemp = m_creature->GetMap()->GetCreature(pInstance->GetData64(NPC_FROSTMOURNE_TRIGGER))) pTemp->ForcedDespawn(); if (Creature* pTemp = m_creature->GetMap()->GetCreature(pInstance->GetData64(NPC_FROSTMOURNE_HOLDER))) pTemp->ForcedDespawn(); SetCombatMovement(true); battlestarted = true; break; default: break; } } else UpdateTimer -= diff; pInstance->SetData(TYPE_EVENT_TIMER, UpdateTimer); } if (battlestarted && !m_creature->SelectHostileTarget() && !finalphase) { battlestarted = false; pInstance->SetData(TYPE_LICH_KING, FAIL); pInstance->SetData(TYPE_EVENT,0); EnterEvadeMode(); return; } if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; switch(stage) { case 0: // Phase 1 // timedCast(SPELL_SHOCKWAVE, diff); timedCast(SPELL_INFEST, diff); timedCast(SPELL_SUMMON_DRUDGE_GHOULS, diff); timedCast(SPELL_PLAGUE_SIPHON, diff); if (!horrorCasted) if (timedCast(SPELL_SUMMON_SHAMBLING_HORROR, diff) == CAST_OK) horrorCasted = true; timedCast(SPELL_NECROTIC_PLAGUE, diff); DoMeleeAttackIfReady(); if (timedQuery(SPELL_BERSERK, diff)) { doCast(SPELL_BERSERK); DoScriptText(-1631518,m_creature); } if (m_creature->GetHealthPercent() < 70.0f) { stage = 1; DoScriptText(-1631515,m_creature); } break; case 1: // Go in transition phase m_creature->AttackStop(); m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); SetCombatMovement(false); StartMovement(1,0); stage = 2; break; case 2: if (movementstarted) return; doCast(SPELL_REMORSELESS_WINTER); stage = 3; break; case 3: timedCast(SPELL_SUMMON_RAGING_SPIRIT, diff); timedCast(SPELL_SUMMON_ICE_SPHERE, diff); timedCast(SPELL_PAIN_AND_SUFFERING, diff); if (timedQuery(SPELL_BERSERK, diff)) { doCast(SPELL_BERSERK); DoScriptText(-1631518,m_creature); } if (timedQuery(SPELL_REMORSELESS_WINTER, diff)) { doCast(SPELL_QUAKE); stage = 4; DoScriptText(-1631524, m_creature); pInstance->DoOpenDoorGuid(pInstance->GetData64(GO_SNOW_EDGE)); } break; case 4: // Platform destruct if (timedQuery(SPELL_QUAKE, diff)) { pInstance->DoOpenDoorGuid(pInstance->GetData64(GO_ICESHARD_1)); pInstance->DoOpenDoorGuid(pInstance->GetData64(GO_ICESHARD_2)); pInstance->DoOpenDoorGuid(pInstance->GetData64(GO_ICESHARD_3)); pInstance->DoOpenDoorGuid(pInstance->GetData64(GO_ICESHARD_4)); if (GameObject* pGoFloor = pInstance->instance->GetGameObject(pInstance->GetData64(GO_ARTHAS_PLATFORM))) { pGoFloor->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED | GO_FLAG_NODESPAWN); oldflag = pGoFloor->GetUInt32Value(GAMEOBJECT_BYTES_1); pGoFloor->SetUInt32Value(GAMEOBJECT_BYTES_1,8449); } pInstance->DoCloseDoorGuid(pInstance->GetData64(GO_FROSTY_WIND)); pInstance->DoCloseDoorGuid(pInstance->GetData64(GO_SNOW_EDGE)); m_creature->GetMotionMaster()->Clear(); pTarget = m_creature->getVictim(); if (!pTarget) { m_creature->SelectHostileTarget(); pTarget = m_creature->getVictim(); } if (!pTarget) pTarget = doSelectRandomPlayerAtRange(140.0f); //megai2: FAIL! if (!pTarget) { battlestarted = false; pInstance->SetData(TYPE_LICH_KING, FAIL); pInstance->SetData(TYPE_EVENT,0); EnterEvadeMode(); return; } SetCombatMovement(true); m_creature->GetMotionMaster()->MoveChase(pTarget); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); stage = 5; } break; case 5: // Phase 2 if (timedQuery(SPELL_SPAWN_DEFILE, diff)) { doCast(SPELL_SPAWN_DEFILE); DoScriptText(-1631531,m_creature); } if (timedQuery(SPELL_SUMMON_VALKYR, diff)) { doCast(SPELL_SUMMON_VALKYR); DoScriptText(-1631527,m_creature); } timedCast(SPELL_SOUL_REAPER, diff); timedCast(SPELL_INFEST, diff); DoMeleeAttackIfReady(); if (timedQuery(SPELL_BERSERK, diff)) { doCast(SPELL_BERSERK); DoScriptText(-1631518,m_creature); } if (m_creature->GetHealthPercent() < 40.0f) { stage = 6; DoScriptText(-1631523,m_creature); } break; case 6: // Go in transition phase m_creature->AttackStop(); m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); SetCombatMovement(false); StartMovement(1,0); stage = 7; break; case 7: // Platform restore if (movementstarted) return; if (GameObject* pGoFloor = pInstance->instance->GetGameObject(pInstance->GetData64(GO_ARTHAS_PLATFORM))) { pGoFloor->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED | GO_FLAG_NODESPAWN); pGoFloor->SetUInt32Value(GAMEOBJECT_BYTES_1, oldflag); } pInstance->DoOpenDoorGuid(pInstance->GetData64(GO_FROSTY_WIND)); doCast(SPELL_REMORSELESS_WINTER); stage = 8; break; case 8: timedCast(SPELL_SUMMON_RAGING_SPIRIT, diff); timedCast(SPELL_SUMMON_ICE_SPHERE, diff); timedCast(SPELL_PAIN_AND_SUFFERING, diff); if (timedQuery(SPELL_BERSERK, diff)) { doCast(SPELL_BERSERK); DoScriptText(-1631518,m_creature); } if (timedQuery(SPELL_REMORSELESS_WINTER, diff)) { DoScriptText(-1631524, m_creature); doCast(SPELL_SUMMON_VILE_SPIRITS); for (uint8 i = 0; i < getSpellData(SPELL_SUMMON_VILE_SPIRITS); ++i) doCast(NPC_VILE_SPIRIT); doCast(SPELL_QUAKE); stage = 9; pInstance->DoOpenDoorGuid(pInstance->GetData64(GO_SNOW_EDGE)); } break; case 9: // Platform destruct if (timedQuery(SPELL_QUAKE, diff)) { if (GameObject* pGoFloor = pInstance->instance->GetGameObject(pInstance->GetData64(GO_ARTHAS_PLATFORM))) { pGoFloor->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED | GO_FLAG_NODESPAWN); oldflag = pGoFloor->GetUInt32Value(GAMEOBJECT_BYTES_1); pGoFloor->SetUInt32Value(GAMEOBJECT_BYTES_1,8449); } pInstance->DoCloseDoorGuid(pInstance->GetData64(GO_SNOW_EDGE)); pInstance->DoCloseDoorGuid(pInstance->GetData64(GO_FROSTY_WIND)); m_creature->GetMotionMaster()->Clear(); pTarget = m_creature->getVictim(); if (!pTarget) { m_creature->SelectHostileTarget(); pTarget = m_creature->getVictim(); } m_creature->SelectHostileTarget(); if (!pTarget) pTarget = doSelectRandomPlayerAtRange(140.0f); //megai2: FAIL! if (!pTarget) { battlestarted = false; pInstance->SetData(TYPE_LICH_KING, FAIL); pInstance->SetData(TYPE_EVENT,0); EnterEvadeMode(); return; } SetCombatMovement(true); m_creature->GetMotionMaster()->MoveChase(pTarget); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); stage = 10; } break; case 10: // Phase 3 if (timedQuery(SPELL_SPAWN_DEFILE, diff)) { doCast(SPELL_SPAWN_DEFILE); // DoScriptText(-1631527,m_creature); } timedCast(SPELL_SOUL_REAPER, diff); if (timedQuery(SPELL_HARVEST_SOUL, diff)) { doCast(SPELL_HARVEST_SOUL); DoScriptText(-1631520,m_creature); } timedCast(SPELL_SOUL_REAPER, diff); timedCast(SPELL_INFEST, diff); DoMeleeAttackIfReady(); if (m_creature->GetHealthPercent() < 10.0f) { stage = 11; DoScriptText(-1631513,m_creature); } break; case 11: // Ending Phase start m_creature->AttackStop(); SetCombatMovement(false); StartMovement(6,13000); stage = 12; battlestarted = false; break; case 12: break; case 13: DoMeleeAttackIfReady(); break; } }
void UpdateAI(const uint32 diff) { if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; switch(getStage()) { case 0: // Bone Slice and single Coldflames phase { if (timedQuery(SPELL_BONE_SPIKE, diff)) { if (Unit* pTarget = doSelectRandomPlayer(SPELL_BONE_SPIKE_IMPALE, false, 60.0f, isHeroic())) { doCast(pTarget, SPELL_BONE_SPIKE); DoSummonSpike(pTarget); DoScriptText(-1631003 - urand(0,2), m_creature, pTarget); } } if (timedQuery(SPELL_BONE_STORM, diff)) setStage(1); if (timedQuery(SPELL_CALL_COLD_FLAME, diff)) doCast(SPELL_CALL_COLD_FLAME); if (m_uiSliceTimer <= 1000) { if (m_uiSliceTimer <= diff) { doCast(SPELL_BONE_SLICE, m_creature->getVictim()); m_uiSliceTimer = 1000; } else m_uiSliceTimer -= diff; } else m_uiSliceTimer -= diff; DoMeleeAttackIfReady(); break; } case 1: // Bone Storm initialization phase { m_creature->InterruptNonMeleeSpells(true); doCast(SPELL_BONE_STORM); DoScriptText(-1631002,m_creature); SetCombatMovement(false); m_creature->GetMotionMaster()->Clear(); m_creature->SetSpeedRate(MOVE_RUN, 3); // initial X Coldflames are in Marrowgar's place m_creature->GetPosition(targetPosX, targetPosY, targetPosZ); setStage(2); break; } case 2: // Bone Storm waiting to end casting the spell { if (!m_creature->IsNonMeleeSpellCasted(false)) setStage(3); break; } case 3: // Whirling in Bone Storm and casting Cold Flames { if (isHeroic()) { if (timedQuery(SPELL_BONE_SPIKE, diff)) { if (Unit* pTarget = doSelectRandomPlayer(SPELL_BONE_SPIKE_IMPALE, false, 60.0f, isHeroic())) { doCast(pTarget, SPELL_BONE_SPIKE); DoSummonSpike(pTarget); DoScriptText(-1631003 - urand(0,2), m_creature, pTarget); } } } if (m_creature->GetDistance2d(targetPosX, targetPosY) < 5.0f) { if (!m_bIsColdFlameXCast) { float myPosX, myPosY, myPosZ; m_creature->GetPosition(myPosX, myPosY, myPosZ); m_pInstance->SetData(DATA_DIRECTION, (uint32)(1000*2.0f*M_PI_F*((float)urand(1,16)/16.0f))); doCast(SPELL_CALL_COLD_FLAME); doSummon(NPC_COLD_FLAME, myPosX, myPosY, myPosZ); if (++m_uiColdFlameCounter >= 4 + isHeroic()) { doRemove(SPELL_BONE_STORM_STRIKE); doRemove(SPELL_BONE_STORM); } m_bIsColdFlameXCast = true; } if (m_uiBoneStormChargeTimer <= diff) { if (Unit* pTarget = doSelectRandomPlayerAtRange(60.0f)) { pTarget->GetPosition(targetPosX, targetPosY, targetPosZ); m_creature->GetMotionMaster()->MovePoint(0, targetPosX, targetPosY, targetPosZ); m_bIsColdFlameXCast = false; m_uiBoneStormChargeTimer = 3000; } } else m_uiBoneStormChargeTimer -= diff; } if (!hasAura(SPELL_BONE_STORM_STRIKE, m_creature) && !hasAura(SPELL_BONE_STORM, m_creature)) setStage(4); break; } case 4: { m_pInstance->SetData(DATA_DIRECTION, 0); m_creature->SetSpeedRate(MOVE_RUN, 1); m_uiColdFlameCounter = 0; SetCombatMovement(true); m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); m_uiSliceTimer = 10000; setStage(0); break; } default: break; } if (timedQuery(SPELL_BERSERK, diff)) { doCast(SPELL_BERSERK); DoScriptText(-1631008, m_creature); } }
CanCastResult BSWScriptedAI::_BSWSpellSelector(uint8 m_uiSpellIdx, Unit* pTarget) { SpellTable* pSpell = &m_BossSpell[m_uiSpellIdx]; Unit* pSummon = NULL; debug_log("BSW: Casting spell number %u type %u",pSpell->m_uiSpellEntry[currentDifficulty], pSpell->m_CastTarget); switch (pSpell->m_CastTarget) { case DO_NOTHING: return CAST_OK; case CAST_ON_SELF: if (!pSpell->m_IsBugged) return _DoCastSpellIfCan(m_creature, pSpell->m_uiSpellEntry[currentDifficulty]); else return _BSWDoCast(m_uiSpellIdx, m_creature); break; case CAST_ON_SUMMONS: if (!pTarget) return CAST_FAIL_OTHER; else return _DoCastSpellIfCan(pTarget, pSpell->m_uiSpellEntry[currentDifficulty]); break; case CAST_ON_VICTIM: pTarget = m_creature->getVictim(); return _BSWCastOnTarget(pTarget, m_uiSpellIdx); break; case CAST_ON_RANDOM: pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0); return _BSWCastOnTarget(pTarget, m_uiSpellIdx); break; case CAST_ON_BOTTOMAGGRO: pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_BOTTOMAGGRO,0); return _BSWCastOnTarget(pTarget, m_uiSpellIdx); break; case CAST_ON_TARGET: return _BSWCastOnTarget(pTarget, m_uiSpellIdx); break; case APPLY_AURA_SELF: if (_doAura(m_uiSpellIdx, m_creature, EFFECT_INDEX_0)) return CAST_OK; else return CAST_FAIL_OTHER; break; case APPLY_AURA_TARGET: if (!pTarget || !pTarget->IsInMap(m_creature)) return CAST_FAIL_OTHER; if (_doAura(m_uiSpellIdx, pTarget, EFFECT_INDEX_0)) return CAST_OK; else return CAST_FAIL_OTHER; break; case SUMMON_NORMAL: pSummon = _doSummon(m_uiSpellIdx, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 5000); if (pSummon) return CAST_OK; else return CAST_FAIL_OTHER; break; case SUMMON_TEMP: pSummon = _doSummon(m_uiSpellIdx, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, urand(pSpell->m_uiSpellTimerMin[currentDifficulty],pSpell->m_uiSpellTimerMax[currentDifficulty])); if (pSummon) return CAST_OK; else return CAST_FAIL_OTHER; break; case SUMMON_INSTANT: pSummon = _doSummon(m_uiSpellIdx, TEMPSUMMON_MANUAL_DESPAWN,0); if (pSummon) return CAST_OK; else return CAST_FAIL_OTHER; break; case CAST_ON_ALLPLAYERS: { CanCastResult res1 = CAST_FAIL_OTHER; Map::PlayerList const& pPlayers = pMap->GetPlayers(); for (Map::PlayerList::const_iterator itr = pPlayers.begin(); itr != pPlayers.end(); ++itr) { pTarget = itr->getSource(); if (pTarget && pTarget->isAlive() && pTarget->IsWithinDistInMap(m_creature, pSpell->LocData.x)) { if (!pSpell->m_IsBugged) { res1 = _DoCastSpellIfCan(pTarget, pSpell->m_uiSpellEntry[currentDifficulty]); } else { _BSWDoCast(m_uiSpellIdx, pTarget); res1 = CAST_OK; }; }; return res1; } break; } case CAST_ON_FRENDLY: pTarget = doSelectLowHPFriendly(pSpell->LocData.x); return _BSWCastOnTarget(pTarget, m_uiSpellIdx); break; case CAST_ON_FRENDLY_LOWHP: pTarget = doSelectLowHPFriendly(pSpell->LocData.x); return _BSWCastOnTarget(pTarget, m_uiSpellIdx); break; case CAST_ON_RANDOM_POINT: if (!pTarget) pTarget = m_creature; if (pSpell->LocData.z <= 1.0f) { float fPosX, fPosY, fPosZ; if (!pTarget->IsPositionValid() || !pTarget->IsInMap(m_creature)) { if (pTarget->GetTypeId() == TYPEID_PLAYER) error_log("BSW: CAST_ON_RANDOM_POINT FAILED: player has invalid position. SpellID is %u",pSpell->m_uiSpellEntry[currentDifficulty]); else error_log("BSW: CAST_ON_RANDOM_POINT FAILED: creature has invalid position. SpellID is %u",pSpell->m_uiSpellEntry[currentDifficulty]); return CAST_FAIL_OTHER; } pTarget->GetPosition(fPosX, fPosY, fPosZ); pTarget->GetRandomPoint(fPosX, fPosY, fPosZ, urand((uint32)pSpell->LocData.x, (uint32)pSpell->LocData.y), fPosX, fPosY, fPosZ); if ((int)fPosZ == 0) { error_log("BSW: CAST_ON_RANDOM_POINT FAILED: Positon Z is NULL. Strange bug"); return CAST_FAIL_OTHER; } if (SpellEntry const *spell = (SpellEntry *)GetSpellStore()->LookupEntry(pSpell->m_uiSpellEntry[currentDifficulty])) if (SpellRangeEntry const *pSpellRange = GetSpellRangeStore()->LookupEntry(spell->rangeIndex)) if (m_creature->GetDistance(fPosX, fPosY, fPosZ) <= pSpellRange->maxRange) { m_creature->CastSpell(fPosX, fPosY, fPosZ, pSpell->m_uiSpellEntry[currentDifficulty], false); return CAST_OK; }; return CAST_FAIL_TOO_FAR; } else return CAST_FAIL_OTHER; break; case CAST_ON_RANDOM_PLAYER: if ( pSpell->LocData.x < 1 ) pTarget = doSelectRandomPlayer(); else pTarget = doSelectRandomPlayerAtRange((float)pSpell->LocData.x); if (pTarget && pTarget->IsInMap(m_creature)) return _BSWCastOnTarget(pTarget, m_uiSpellIdx); else return CAST_FAIL_OTHER; break; case APPLY_AURA_ALLPLAYERS: { Map::PlayerList const& pPlayers = pMap->GetPlayers(); for (Map::PlayerList::const_iterator itr = pPlayers.begin(); itr != pPlayers.end(); ++itr) { pTarget = itr->getSource(); if (pTarget && pTarget->isAlive() && pTarget->IsWithinDistInMap(m_creature, pSpell->LocData.x)) _doAura(m_uiSpellIdx, pTarget, EFFECT_INDEX_0); } return CAST_OK; } break; case SPELLTABLEPARM_NUMBER: default: return CAST_FAIL_OTHER; break; }; error_log("BSW: FAILED casting spell number %u type %u - type not exists",pSpell->m_uiSpellEntry[currentDifficulty], pSpell->m_CastTarget); return CAST_FAIL_OTHER; };