void Game::Create(int width, int height) { phase = 0; world = 0; screen = 0; next_phase = 0; font = 0; initialised = false; if (!InitialiseSDL(width, height)) return; font = new Font("font"); PhaseChange(New<Phase::Boot>()); // PhaseChange(New<Phase::Play>()); initialised = true; finished = false; }
void UpdateAI(const uint32 uiDiff) { if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; if (!m_bIsBerserk) { if (m_uiBerserkTimer < uiDiff) { DoScriptText(SAY_BERSERK, m_creature); DoCastSpellIfCan(m_creature, SPELL_BERSERK, CAST_TRIGGERED); m_bIsBerserk = true; } else m_uiBerserkTimer -= uiDiff; } if (m_uiPhase != PHASE_FINAL) { if (m_uiCheckTimer < uiDiff) { if (m_pInstance) PhaseChange(); else m_uiPhase = PHASE_FINAL; m_uiCheckTimer = IN_MILLISECONDS; } else m_uiCheckTimer -= uiDiff; } if (m_uiPhase == PHASE_FINAL || m_uiPhase == PHASE_SINGLE) { if (m_uiFrenzyTimer < uiDiff) { DoCastSpellIfCan(m_creature, SPELL_FRENZY); m_uiFrenzyTimer = 16*IN_MILLISECONDS; } else m_uiFrenzyTimer -= uiDiff; if (m_uiSaberLashTimer < uiDiff) { DoScriptText(urand(0, 1) ? SAY_SABERLASH1 : SAY_SABERLASH2, m_creature); DoCastSpellIfCan(m_creature->getVictim(), SPELL_SABER_LASH); m_uiSaberLashTimer = 20*IN_MILLISECONDS; } else m_uiSaberLashTimer -= uiDiff; } if (m_uiPhase == PHASE_FINAL || m_uiPhase == PHASE_TOTEM) { if (m_uiTotemTimer < uiDiff) { DoCastSpellIfCan(m_creature, SPELL_SUMMON_TOTEM); m_uiTotemTimer = 20*IN_MILLISECONDS; } else m_uiTotemTimer -= uiDiff; if (m_uiShockTimer < uiDiff) { if (Unit* pTarget = SelectUnit(SELECT_TARGET_RANDOM,0)) { if (pTarget->IsNonMeleeSpellCasted(false)) DoCastSpellIfCan(pTarget, SPELL_EARTHSHOCK); else DoCastSpellIfCan(pTarget, SPELL_FLAMESHOCK); m_uiShockTimer = urand(10000, 14000); } } else m_uiShockTimer -= uiDiff; } DoMeleeAttackIfReady(); }