Esempio n. 1
0
void ScriptedAI::UpdateAI(const uint32)
{
    if( m_creature->getVictim() != NULL )
    {
        if( needToStop() )
        {
            DoStopAttack();
        }
        else if( m_creature->IsStopped() )
        {
            if( m_creature->isAttackReady() )
            {
                if(!m_creature->canReachWithAttack(m_creature->getVictim()))
                    return;
                m_creature->AttackerStateUpdate(m_creature->getVictim());
                m_creature->resetAttackTimer();

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

                if( needToStop() )
                    DoStopAttack();
            }
        }
    }
}
void SpeechDetector::calculate(int value)
{
    this->counter1 ++;
    this->bufferedValues->append(value);
    if (this->counter1 >= this->firstPeriodStep)
    {
        this->counter1 = 0;
        if (this->bufferedValues->count() >= this->firstPeriod)
        {
            // calculate first value
            long value1 = 0;
            for( int i=0 ; i<this->firstPeriod; i++ )
                value1 += this->bufferedValues->at(i);
            // remove first elements
            this->bufferedValues->remove(0,this->firstPeriodStep);
            // add calculated value to vector <1>
            value1 = value1 * 3 / this->firstPeriod;
            if(value1 > m_maxAmplitude){
                this->firstStepValues->append( m_maxAmplitude );
                this->firstStepValuesBuf->append( m_maxAmplitude );
            }else{
                this->firstStepValues->append( value1 );
                this->firstStepValuesBuf->append( value1 );
            }
            this->counter2 ++;
            if(this->counter2 >= this->secondPeriodStep)
            {
                this->counter2 = 0;
                if(this->firstStepValues->count() >= this->secondPeriod)
                {
                    long value2 = 0;
                    // calculate second value
                    for(int i=0; i<this->secondPeriod; i++)
                        value2 += this->firstStepValues->at(i);
                    this->firstStepValues->remove(0,this->secondPeriodStep);
                    value2 = value2/this->secondPeriod;

                    if (m_isAuto){
                        if (value2 > criticalValue){
                            isCriticalOver = true;
                        }else
                            if(isCriticalOver)
                            {
                                emit needToStop();
                                isCriticalOver = false;
                            }
                    }

                    if(value2 > m_maxAmplitude)
                        this->secondStepValues->append( m_maxAmplitude );
                    else
                        this->secondStepValues->append( value2 );
                }
            }
        }
    }
}
Esempio n. 3
0
void RecThread::checkRecording()
{
    if(isRun){
        QTimer::singleShot(1, this, SLOT(checkRecording()));
        return;
    }
    emit logging("<RecThread> Stop recoding");
    // Stops the recording
    inputAudio->stop();
    m_audioInfo->stop();
    m_file->close();
    emit needToStop();
}
Esempio n. 4
0
void
ReactorAI::UpdateAI(const uint32 time_diff)
{
    // update i_victimGuid if i_creature.getVictim() !=0 and changed
    if(i_creature.getVictim())
        i_victimGuid = i_creature.getVictim()->GetGUID();

    // i_creature.getVictim() can't be used for check in case stop fighting, i_creature.getVictim() cleared at Unit death etc.
    if( i_victimGuid )
    {
        if( needToStop() )
        {
            DEBUG_LOG("Creature %u stopped attacking.", i_creature.GetGUIDLow());
            stopAttack();                                   // i_victimGuid == 0 && i_creature.getVictim() == NULL now
        }
        else if( i_creature.IsStopped() )
        {
            if( i_creature.isAttackReady() )
            {
                Unit* newtarget = i_creature.SelectHostilTarget();
                if(newtarget)
                    AttackStart(newtarget);

                if(!i_creature.canReachWithAttack(i_creature.getVictim()))
                    return;
                i_creature.AttackerStateUpdate(i_creature.getVictim());
                i_creature.resetAttackTimer();

                if ( !i_creature.getVictim() )
                    return;

                if( needToStop() )
                    stopAttack();
            }
        }
    }
}
Esempio n. 5
0
RecThread::RecThread(QAudioFormat format) :
    QObject(0)
  , isTesting(false)
  , m_file(NULL)
{
    isRun = false;
    this->m_format = format;

    this->m_device = QAudioDeviceInfo::defaultInputDevice();
    this->devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);

    this->inputAudio = new QAudioInput(m_device, m_format, this);
    this->m_audioInfo  = new AudioInfo(m_format, this);
    connect(m_audioInfo, SIGNAL(update()), SLOT(refreshVolumeInfo()));
    connect(m_audioInfo, SIGNAL(needToStop()), SLOT(stopRecording()));
}
Esempio n. 6
0
    void UpdateAI(const uint32 diff)
    {
        //If we had a target and it wasn't cleared then it means the target died from some unknown soruce
        //But we still need to reset
        if (InCombat && !m_creature->SelectHostilTarget())
        {
            Reset();
            return;
        }

        //Check if we have a current target
        if( m_creature->getVictim() && m_creature->isAlive())
        {
            //Check if we should stop attacking because our victim is no longer attackable
            if (needToStop())
            {
                Reset();
                return;
            }

			//If we are 100%MANA cast Arcane Erruption
           // if (j==1 && m_creature->GetMana()*100 / m_creature->GetMaxMana() == 100 && !m_creature->m_currentSpell)
           // {
			//	DoCast(m_creature->getVictim(),SPELL_ARCANEERUPTION);
			//	DoYell(SAY_MANA,LANG_UNIVERSAL,NULL);
           // }

            //If we are <50%HP cast MANA FIEND (Summon Mana) and Sleep
            if (i==0 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 50 && !m_creature->m_currentSpell)
            {
				i=1;
			DoCast(m_creature->getVictim(),SPELL_SUMMONMANA);
			DoCast(m_creature->getVictim(),SPELL_GRDRSLEEP);
            }

             //SUMMONMANA_Timer
            if (i==1 && SUMMONMANA_Timer < diff)
            {
                //Cast
				DoCast(m_creature->getVictim(),SPELL_SUMMONMANA);
				                //90 seconds until we should cast this agian
                SUMMONMANA_Timer = 90000;
            }else SUMMONMANA_Timer -= diff;

            //TRAMPLE_Timer
            if (TRAMPLE_Timer < diff)
            {
                //Cast
				DoCast(m_creature->getVictim(),SPELL_TRAMPLE);
				j=1;
                //30 seconds until we should cast this agian
                TRAMPLE_Timer = 30000;
            }else TRAMPLE_Timer -= diff;

            //DRAINMANA_Timer
            if (DRAINMANA_Timer < diff)
            {
                //Cast
                DoCast(m_creature->getVictim(),SPELL_DRAINMANA);

                //30 seconds until we should cast this agian
                DRAINMANA_Timer = 30000;
            }else DRAINMANA_Timer -= diff;



            //If we are within range melee the target
            if( m_creature->IsWithinDist(m_creature->getVictim(), ATTACK_DIST))
            {
                //Make sure our attack is ready and we arn't currently casting
                if( m_creature->isAttackReady() && !m_creature->m_currentSpell)
                {
                    m_creature->AttackerStateUpdate(m_creature->getVictim());
                    m_creature->resetAttackTimer();
                }
            }
        }
    }
    void UpdateAI(const uint32 diff)
    {
        //Return since we have no target
        if (!m_creature->SelectHostilTarget())
            return;

        //Check if we have a current target
        if( m_creature->getVictim() && m_creature->isAlive())
        {
            //Check if we should stop attacking because our victim is no longer in range
            if (needToStop())
            {
                EnterEvadeMode();
                return;
            }

            //If we are low on hp Do sayings
            if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 60 && !m_creature->m_currentSpell)
            {
                //Yell_Timer
                if (Yell_Timer < diff)
                {

                    DoYell(SAY_HEALTH1,LANG_UNIVERSAL,NULL);
                    DoPlaySoundToSet(m_creature,SOUND_HEALTH1);
                    return;

                    //60 seconds until we should cast this agian
                    Yell_Timer = 60000;
                }else Yell_Timer -= diff;
            }
            
            if ( m_creature->GetHealth()*100 / m_creature->GetMaxHealth() <= 30 && !m_creature->m_currentSpell)
            {
                //Yell_Timer
                if (Yell_Timer < diff)
                {

                    DoYell(SAY_HEALTH2,LANG_UNIVERSAL,NULL);
                    DoPlaySoundToSet(m_creature,SOUND_HEALTH2);
                    return;

                    //60 seconds until we should cast this agian
                    Yell_Timer = 6000000;
                }else Yell_Timer -= diff;
            }
            
            //PowerWordShield_Timer
            if (PowerWordShield_Timer < diff)
            {
                //Cast
                DoCast(m_creature,SPELL_POWERWORDSHIELD);

                //60 seconds until we should cast this agian
                PowerWordShield_Timer = 60000;
            }else PowerWordShield_Timer -= diff;

            //If we are within range melee the target
            if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DIST))
            {
                //Make sure our attack is ready and we arn't currently casting
                if( m_creature->isAttackReady() && !m_creature->m_currentSpell)
                {
                    m_creature->AttackerStateUpdate(m_creature->getVictim());
                    m_creature->resetAttackTimer();
                }
            }
        }
    }