void UpdateAI(const uint32 uiDiff) override { if (!pEntered) // should also be in phase zero { float x,y,z; m_creature->GetClosePoint(x, y, z, m_creature->GetObjectBoundingRadius(), 15.0f, 0.0f); if (Creature* pTemp = m_creature->SummonCreature(NPC_HEAD, x, y, z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0)) HeadGUID = pTemp->GetObjectGuid(); pEntered = true; m_uiPhase = PHASE_ONE; } Creature* pHead = m_pInstance->GetSingleCreatureFromStorage(NPC_HEAD); if (!m_pInstance) return; if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; switch (m_uiPhase) { case PHASE_ONE: { // he gets his head if (!m_creature->HasAura(SPELL_HEAD)) DoCast(m_creature,SPELL_HEAD,false); if (((m_creature->GetHealth()*100) / (m_creature->GetMaxHealth())) <= 1) m_uiPhase = PHASE_TWO; if (m_uiCleave_Timer <= uiDiff) { m_creature->CastSpell(m_creature->getVictim(),SPELL_CLEAVE_PROC,false); m_uiCleave_Timer = 5000; }else m_uiCleave_Timer -= uiDiff; DoMeleeAttackIfReady(); break; } case PHASE_TWO: { if (m_creature->HasAura(SPELL_HEAD)) { m_creature->RemoveAurasDueToSpell(SPELL_HEAD); // visual of head flying off body ( really head flying at target which in this case needs to be the head npc ) DoCast(pHead,SPELL_SEND_HEAD,true); } ApplyRegenAuras(); if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) if (pHead && pHead->GetTypeId() == TYPEID_UNIT && pHead->AI()) pHead->AI()->AttackStart(pTarget); if ((pHead->GetHealth()*100) / (pHead->GetMaxHealth()) <= 66) /*|| (m_creature->GetHealth()*100) / (m_creature->GetMaxHealth()) <= 100)*/ { RemoveRegenAuras(); m_uiPhase = PHASE_THREE; } break; } case PHASE_THREE: { // give him his head back ( the head will target and cast spell send head at the body will look like head flying back on to body if (!m_creature->HasAura(SPELL_HEAD)) DoCast(m_creature,SPELL_HEAD,false); if (((m_creature->GetHealth()*100) / (m_creature->GetMaxHealth())) <= 1) m_uiPhase = PHASE_FOUR; if (m_uiConflageration_Timer <= uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { DoScriptText(SAY_CONFLAGRATION,m_creature); pTarget->CastSpell(pTarget,SPELL_CONFLAGRATION,false); } m_uiConflageration_Timer = 15000; }else m_uiConflageration_Timer -= uiDiff; DoMeleeAttackIfReady(); break; } case PHASE_FOUR: { if (m_creature->HasAura(SPELL_HEAD)) { m_creature->RemoveAurasDueToSpell(SPELL_HEAD); // visual of head flying off body ( really head flying at target which in this case needs to be the head npc ) DoCast(pHead,SPELL_SEND_HEAD,true); } ApplyRegenAuras(); if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) if (pHead->AI()) pHead->AI()->AttackStart(pTarget); if ((pHead->GetHealth()*100) / (pHead->GetMaxHealth()) <= 33) /*|| (m_creature->GetHealth()*100) / (m_creature->GetMaxHealth()) <= 100)*/ { RemoveRegenAuras(); m_uiPhase = PHASE_FIVE; } break; } case PHASE_FIVE: { if (!m_creature->HasAura(SPELL_HEAD)) DoCast(m_creature,SPELL_HEAD,false); if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) if (pHead->AI()) pHead->AI()->AttackStart(pTarget); if (m_uiPumpkinSprout_Timer <= uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { DoScriptText(SAY_SPROUTING_PUMPKINS,m_creature); m_creature->CastSpell(pTarget,SPELL_SUMMON_PUMPKIN,false); } m_uiPumpkinSprout_Timer = 30000; }else m_uiPumpkinSprout_Timer -= uiDiff; if (m_uiConflageration_Timer <= uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { DoScriptText(SAY_CONFLAGRATION,m_creature); pTarget->CastSpell(pTarget,SPELL_CONFLAGRATION,false); } m_uiConflageration_Timer = 15000; }else m_uiConflageration_Timer -= uiDiff; if (((m_creature->GetHealth()*100) / (m_creature->GetMaxHealth())) <= 1) { m_uiPhase = PHASE_FOUR; DoCast(pHead,SPELL_SEND_HEAD,true); } DoMeleeAttackIfReady(); break; //default: break; } } }
void UpdateAI(const uint32 uiDiff) { if (!pEntered) { if (m_uiFlyPoint_Timer <= uiDiff) { switch (point_id) { case 21: float x,y,z; m_creature->GetClosePoint(x, y, z, m_creature->GetObjectBoundingRadius(), 15.0f, 0.0f); if (Creature* pTemp = m_creature->SummonCreature(NPC_HEAD, x, y, z, 0, TEMPSUMMON_CORPSE_DESPAWN, 0)) HeadGUID = pTemp->GetGUID(); else { error_log("Headless Horsemann could't summon his head so abording the event"); m_creature->ForcedDespawn(); } pEntered = true; break; default: m_creature->SendMonsterMove(FlightPoint[point_id][0], FlightPoint[point_id][1], FlightPoint[point_id][2], SPLINETYPE_NORMAL, SPLINEFLAG_WALKMODE,999); ++point_id; break; } m_uiFlyPoint_Timer = 1000; }else m_uiFlyPoint_Timer -= uiDiff; } if (!m_pInstance) return; Creature* pHead = (Creature*)Unit::GetUnit((*m_creature),HeadGUID); if (pEntered && !pHead) { error_log("Debug: Headless Horseman aggroed but no Head of Horseman found so abording!"); m_creature->ForcedDespawn(); } switch (m_pInstance->GetData(TYPE_HALLOWSEND_EVENT)) { //Phase 1a case 0: if (!m_creature->HasAura(SPELL_HEAD)) DoCast(m_creature,SPELL_HEAD,false); if (((m_creature->GetHealth()*100) / (m_creature->GetMaxHealth())) <= 1) m_pInstance->SetData(TYPE_HALLOWSEND_EVENT,1); if (m_uiCleave_Timer <= uiDiff) { m_creature->CastSpell(m_creature->getVictim(),SPELL_CLEAVE_PROC,false); m_uiCleave_Timer = 5000; }else m_uiCleave_Timer -= uiDiff; DoMeleeAttackIfReady(); break; //Phase 1b case 1: if (m_creature->HasAura(SPELL_HEAD)) { m_creature->RemoveAurasDueToSpell(SPELL_HEAD); m_creature->CastSpell(pHead,SPELL_SEND_HEAD,false); } ApplyRegenAuras(); if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) if (pHead->AI()) pHead->AI()->AttackStart(pTarget); if ((pHead->GetHealth()*100) / (pHead->GetMaxHealth()) <= 66) { RemoveRegenAuras(); if ((m_creature->GetHealth()*100) / (m_creature->GetMaxHealth()) < 100) m_pInstance->SetData(TYPE_HALLOWSEND_EVENT,2); else m_pInstance->SetData(TYPE_HALLOWSEND_EVENT,0); pHead->SetHealth(pHead->GetMaxHealth()*0.7); } break; //Phase 2a case 2: if (((m_creature->GetHealth()*100) / (m_creature->GetMaxHealth())) <= 1) m_pInstance->SetData(TYPE_HALLOWSEND_EVENT,3); if (m_uiConflageration_Timer <= uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { DoScriptText(SAY_CONFLAGRATION,m_creature); pTarget->CastSpell(pTarget,SPELL_CONFLAGRATION,false); } m_uiConflageration_Timer = 15000; }else m_uiConflageration_Timer -= uiDiff; DoMeleeAttackIfReady(); break; //Phase 2b case 3: if (m_creature->HasAura(SPELL_HEAD)) { m_creature->RemoveAurasDueToSpell(SPELL_HEAD); m_creature->CastSpell(pHead,SPELL_SEND_HEAD,false); } ApplyRegenAuras(); if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) if (pHead->AI()) pHead->AI()->AttackStart(pTarget); if ((pHead->GetHealth()*100) / (pHead->GetMaxHealth()) <= 33) { RemoveRegenAuras(); if ((m_creature->GetHealth()*100) / (m_creature->GetMaxHealth()) < 100) m_pInstance->SetData(TYPE_HALLOWSEND_EVENT,4); else m_pInstance->SetData(TYPE_HALLOWSEND_EVENT,2); pHead->SetHealth(pHead->GetMaxHealth()*0.4); } break; //Phase 3a case 4: if ((m_creature->GetHealth()*100) / (m_creature->GetMaxHealth()) <= 1) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) if (pHead->AI()) pHead->AI()->AttackStart(pTarget); m_pInstance->SetData(TYPE_HALLOWSEND_EVENT,5); } if (m_uiPumpkinSprout_Timer <= uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { DoScriptText(SAY_SPROUTING_PUMPKINS,m_creature); m_creature->CastSpell(pTarget,SPELL_SUMMON_PUMPKIN,false); } m_uiPumpkinSprout_Timer = 30000; }else m_uiPumpkinSprout_Timer -= uiDiff; DoMeleeAttackIfReady(); break; //Phase 3b case 5: if (m_creature->HasAura(SPELL_HEAD)) { m_creature->RemoveAurasDueToSpell(SPELL_HEAD); m_creature->CastSpell(pHead,SPELL_SEND_HEAD,false); } ApplyRegenAuras(); if (((m_creature->GetHealth()*100) / (m_creature->GetMaxHealth())) == 100) { RemoveRegenAuras(); m_pInstance->SetData(TYPE_HALLOWSEND_EVENT,4); } break; // Head or body died case 6: if (m_creature->isAlive()) m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); break; default: break; } }