Ejemplo n.º 1
0
void EnemieN::Fire()
{
    if(!m_bUsable){
        return;
    }
    if(m_ClockFire.getElapsedTime().asMilliseconds() >= 1000){
        bool ok = true;
        for(auto it = m_TirList.begin(); it != m_TirList.end(); it++){
            if(it->IsOut()){
                it->SetPos(m_Enemie.getPosition().x, m_Enemie.getPosition().y);
                it->Revive();
                ok = false;
                break;
            }
        }
        if(m_cmpt == 0 && ok) {
            Tir t = Tir(m_Tileset, 11, 4, 1, 1, Mathf::PI * 0.5, m_Enemie.getPosition().x +5, m_Enemie.getPosition().y + 30);
            t.GetSprite().setScale(0.5f, 0.5f);
            m_TirList.push_back(t);
            m_step *= -1;
        }
        if(m_cmpt == 1 && ok) {
            Tir t = Tir(m_Tileset, 11, 4, 1, 1, Mathf::PI * 0.5, m_Enemie.getPosition().x + 30, m_Enemie.getPosition().y + 30);
            t.GetSprite().setScale(0.5f, 0.5f);
            m_TirList.push_back(t);
            m_step *= -1;
        }
        m_ClockFire.restart();
        m_cmpt+=m_step;
    }
}
Ejemplo n.º 2
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_uiReviveTimer)
        {
            if (m_uiReviveTimer <= uiDiff)
                Revive();
            else
                m_uiReviveTimer -= uiDiff;

            return;
        }

        if (m_uiCastTimer < uiDiff)
        {
            if (m_bIsRegularMode)
                DoCastSpellIfCan(m_creature->getVictim(), SPELL_DECREPIFY);
            else
            {
                if (urand(0, 3))
                    DoCastSpellIfCan(m_creature->getVictim(), SPELL_DECREPIFY_H);
                else if (m_pInstance && m_pInstance->GetData(TYPE_KELESETH) == IN_PROGRESS)
                    if (Creature* pKeleseth = m_pInstance->GetSingleCreatureFromStorage(NPC_KELESETH))
                        DoCastSpellIfCan(pKeleseth, SPELL_BONE_ARMOR);
            }

            m_uiCastTimer = urand(5000, 15000);
        }
        else
            m_uiCastTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
Ejemplo n.º 3
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_uiReviveTimer)
        {
            if (m_uiReviveTimer <= uiDiff)
                Revive();
            else
                m_uiReviveTimer -= uiDiff;

            return;
        }

        if (m_uiCastTimer < uiDiff)
        {
            if (m_bIsHeroicMode)
            {
                if (urand(0, 3))
                    DoCast(m_creature->getVictim(), SPELL_DECREPIFY_H);
                else if (m_pKeleseth && m_pKeleseth->isAlive())
                    DoCast(m_pKeleseth, SPELL_BONE_ARMOR);
            }
            else
                DoCast(m_creature->getVictim(), SPELL_DECREPIFY);

            m_uiCastTimer = urand(5000, 15000);
        }
        else
            m_uiCastTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
Ejemplo n.º 4
0
static rc_t CC KHttpUndyingFileTimedRead(const KHttpUndyingFile *self,
    uint64_t pos, void *buffer, size_t bsize, size_t *num_read,
    struct timeout_t *tm)
{
    if (self == NULL || self->file == NULL) {
        return KFileTimedRead(NULL, pos, buffer, bsize, num_read, tm);
    }
    else {
        rc_t rc = 0, prev_rc = 0;
        int i = 0;
        for (i = 0; i < RETRY_REVIVE; ++i) {
            int r = 0;
            for (r = 0; r < RETRY_READ; ++r) {
                rc = KFileTimedRead(self->file, pos, buffer, bsize, num_read,
                    tm);
                if (rc == 0) {
                    return rc;
                }
                else {
                    DBGMSG(DBG_KNS, DBG_FLAG(DBG_KNS_ERR), (
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@3 %s KFileTimedRead(%s, %d)(%d/%d) = %R @@"
                        "\n", __FUNCTION__,
                        self->url, pos, r + 1, RETRY_READ, rc));
                    if (prev_rc == 0) {
                        prev_rc = rc;
                    }
                    else if (rc == prev_rc) {
                        break;
                    }
                }
            }

            if (i < RETRY_REVIVE - 1) {
                DBGMSG(DBG_KNS, DBG_FLAG(DBG_KNS_ERR), (
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@5 %s %d/%d KFileTimedRead: Reviving... @@@"
                        "\n", __FUNCTION__, i + 1, RETRY_REVIVE));
                rc = Revive(self);
                if (rc != 0) {
                    DBGMSG(DBG_KNS, DBG_FLAG(DBG_KNS_ERR), (
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@5 %s KFileTimedRead(%s, %d): Revive = %R @"
                        "\n", __FUNCTION__, self->url, pos, rc));
                    return rc;
                }
            }
            else {
                DBGMSG(DBG_KNS, DBG_FLAG(DBG_KNS_ERR), (
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@5 %s %d/%d KFileTimedRead: Not Reviving @@"
                        "\n", __FUNCTION__, i + 1, RETRY_REVIVE));
            }
        }
        return rc;
    }
}
Ejemplo n.º 5
0
static rc_t KNSManagerVMakeUndyingHttpFile(const KNSManager *self, const KFile **file,
    struct KStream *conn, ver_t vers, const char *url, va_list args)
{
    char buffer[PATH_MAX] = "";
    size_t num_writ = 0;
    rc_t rc = 0;
    KHttpUndyingFile *f = NULL;
    if (file == NULL) {
        return RC(rcNS, rcFile, rcConstructing, rcParam, rcNull);
    }
    *file = NULL;
    f = calloc(1, sizeof *f);
    if (f == NULL) {
        return RC(rcNS, rcFile, rcConstructing, rcMemory, rcExhausted);
    }
    rc = string_vprintf(buffer, sizeof buffer, &num_writ, url, args);
    if (rc == 0) {
        f->url = string_dup_measure(url, NULL);
    }
    if (f->url == NULL) {
        rc = RC(rcNS, rcFile, rcConstructing, rcMemory, rcExhausted);
    }
    f->vers = vers;
    if (rc == 0) {
        rc = KNSManagerAddRef(self);
        if (rc == 0) {
            f->mgr = self;
        }
    }
    if (rc == 0) {
        assert(conn == NULL);
        rc = Revive(f);
    }
    if (rc == 0) {
        KHttpUndyingFileSize(f, &f->size);
        DBGMSG(DBG_KNS, DBG_FLAG(DBG_KNS_MGR), (
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@4 %s KNSManagerMakeUndyingHttpFile: size = %ld"
            "\n", __FUNCTION__, f->size));
    }
    if (rc == 0) {
        rc = KFileInit(&f->dad, (const KFile_vt*)&vtKHttpFile,
            "KHttpUndyingFile", url, true, false);
    }
    if (rc == 0) {
        *file = &f->dad;
    }
    else {
        KHttpUndyingFileDestroy(f);
    }

    return rc;
}
Ejemplo n.º 6
0
    void Reset() override
    {
        m_uiShieldTimer         = 1000;
        m_uiBloodLustTimer      = 16000;
        m_uiGreaterHealTimer    = 32000;
        m_uiDisarmTimer         = 6000;
        m_uiPhase               = PHASE_NORMAL;

        if (m_pInstance)
            m_pInstance->SetData(TYPE_LORKHAN, NOT_STARTED);

        Revive(true);
    }
Ejemplo n.º 7
0
    void Reset() override
    {
        m_uiSinisterStrikeTimer     = 8000;
        m_uiGougeTimer              = 25000;
        m_uiKickTimer               = 18000;
        m_uiBlindTimer              = 5000;
        m_uiPhase                   = PHASE_NORMAL;

        if (m_pInstance)
            m_pInstance->SetData(TYPE_ZATH, NOT_STARTED);

        Revive(true);
    }
Ejemplo n.º 8
0
    void Reset() override
    {
        m_uiLightningShieldTimer = 1000;
        m_uiGreatHealTimer       = 32000;
        m_uiDisarmTimer          = 6000;
        m_uiDispelTimer          = 0;
        m_uiPhase                = PHASE_NORMAL;

        if (m_pInstance)
            m_pInstance->SetData(TYPE_LORKHAN, NOT_STARTED);

        Revive(true);
    }
Ejemplo n.º 9
0
    void Reset() override
    {
        m_uiMortalCleaveTimer   = 4000;
        m_uiSilenceTimer        = 9000;
        m_uiFrenzyTimer         = 30000;
        m_uiForcePunchTimer     = 4000;
        m_uiChargeTimer         = 12000;
        m_uiEnrageTimer         = 32000;
        m_uiSummonTigersTimer   = 25000;
        m_uiResurrectTimer      = 10000;
        m_uiPhase               = PHASE_NORMAL;

        m_bEnraged              = false;

        // remove fake death
        Revive(true);
    }
Ejemplo n.º 10
0
void EnemieG::Fire()
{
    if(!m_bUsable){
        return;
    }
    if(m_ClockFire.getElapsedTime().asMilliseconds() >= 1000){
        bool ok = true;
        for(auto it = m_TirList.begin(); it != m_TirList.end(); it++){
            if(it->IsOut()){
                it->SetPos(m_Enemie.getPosition().x, m_Enemie.getPosition().y);
                it->Revive();
                ok = false;
                break;
            }
        }
        if(ok) {
            Tir t = Tir(m_Tileset, 6, 12, 1, 1, Mathf::PI * 0.5, m_Enemie.getPosition().x, m_Enemie.getPosition().y + 30);
            m_TirList.push_back(t);
        }
        m_ClockFire.restart();
    }
}
Ejemplo n.º 11
0
    void UpdateAI(const uint32 uiDiff) override
    {
        if (m_bBothDead)                                    // This is the case while fighting Thaddius
            return;

        if (m_bFakeDeath)
        {
            if (m_uiReviveTimer < uiDiff)
            {
                if (Creature* pOther = GetOtherAdd())
                {
                    if (boss_thaddiusAddsAI* pOtherAI = dynamic_cast<boss_thaddiusAddsAI*>(pOther->AI()))
                    {
                        if (!pOtherAI->IsCountingDead())    // Raid was to slow to kill the second add
                            Revive();
                        else
                        {
                            m_bBothDead = true;             // Now both adds are counting dead
                            pOtherAI->m_bBothDead = true;
                            // Set both Teslas to overload
                            GuidList lTeslaGUIDList;
                            m_pInstance->GetThadTeslaCreatures(lTeslaGUIDList);
                            for (GuidList::const_iterator itr = lTeslaGUIDList.begin(); itr != lTeslaGUIDList.end(); ++itr)
                            {
                                if (Creature* pTesla = m_pInstance->instance->GetCreature(*itr))
                                {
                                    if (npc_tesla_coilAI* pTeslaAI = dynamic_cast<npc_tesla_coilAI*>(pTesla->AI()))
                                        pTeslaAI->SetOverloading();
                                }
                            }
                        }
                    }
                }
            }
            else
                m_uiReviveTimer -= uiDiff;
            return;
        }

        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        if (m_uiHoldTimer)                                  // A short timer preventing combat movement after revive
        {
            if (m_uiHoldTimer <= uiDiff)
            {
                SetCombatMovement(true);
                m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                m_uiHoldTimer = 0;
            }
            else
                m_uiHoldTimer -= uiDiff;
        }

        if (m_uiWarStompTimer < uiDiff)
        {
            if (DoCastSpellIfCan(m_creature, SPELL_WARSTOMP) == CAST_OK)
                m_uiWarStompTimer = urand(8 * IN_MILLISECONDS, 10 * IN_MILLISECONDS);
        }
        else
            m_uiWarStompTimer -= uiDiff;

        UpdateAddAI(uiDiff);                    // For Add Specific Abilities

        DoMeleeAttackIfReady();
    }