Refresh::Refresh(int millis) { this->needRefresh = false; connect(this, SIGNAL(timeout()), this, SLOT(refreshTimer())); this->setInterval(millis); this->start(); }
void UpdateAI(const uint32 diff) { if (!UpdateVictim()) return; if (uiUnstableSunbeamTimer <= 0) { float randomX = -10 + rand() % 20; float randomY = -10 + rand() % 20; //Z + 1: Make sure the sun beam isnt spawned beneath the ground me->SummonCreature(NPC_UNSTABLE_SUN_BEAM, me->GetPositionX() + randomX, me->GetPositionY() + randomY, me->GetPositionZ() + 1, 0); uiUnstableSunbeamTimer = UNSTABLE_SUN_BEAM_TIMER; } else uiUnstableSunbeamTimer -= diff; if (uiSolarFlareTimer <= 0) { DoCast(me, RAID_MODE(RAID_10_SPELL_SOLAR_FLARE, RAID_25_SPELL_SOLAR_FLARE)); uiSolarFlareTimer = refreshTimer(SOLAR_FLARE_TIMER_MIN, SOLAR_FLARE_TIMER_MAX); } else uiSolarFlareTimer -= diff; DoMeleeAttackIfReady(); }
creature_unstable_sun_beamAI(Creature* pCreature) : Scripted_NoMovementAI(pCreature) { m_pInstance = pCreature->GetInstanceData(); Reset(); DoCast(me, SPELL_UNSTABLE_SUN_BEAM); DoCast(me, SPELL_PHOTOSYNTHESIS); uiDespawnTimer = refreshTimer(UNSTABLE_SUN_BEAM_DESPAWN_TIMER_MIN, UNSTABLE_SUN_BEAM_DESPAWN_TIMER_MAX); me->SetDisplayId(MODEL_INVISIBLE); }
void Reset() { uiSunbeamTimer = refreshTimer(SUNBEAM_TIMER_MIN, SUNBEAM_TIMER_MAX); uiSpawnAddTimer = SPAWN_ADD_TIMER / 4; uiEnterPhaseTwoTimer = ENTER_PHASE_TWO_TIMER; phase = 1; attunedToNatureStacks = 150; spawnedAdds = 0; randomizeSpawnOrder(); uiEonarsTimer = refreshTimer(EONARS_GIFT_TIMER_MIN, EONARS_GIFT_TIMER_MAX); uiNatureBombTimer = NATURE_BOMB_TIMER; bFirstWave = true; uiRessTimer[0] = RESURRECTION_TIMER; uiRessTimer[1] = RESURRECTION_TIMER; uiEnrageTimer = ENRAGE_TIMER; bEnraged = false; uiGroundTremorTimer = refreshTimer(FREYA_GROUND_TREMOR_TIMER_MIN, FREYA_GROUND_TREMOR_TIMER_MAX); uiIronRootTimer = refreshTimer(FREYA_IRON_ROOTS_TIMER_MIN, FREYA_IRON_ROOTS_TIMER_MAX); uiUnstableSunBeamTimer = refreshTimer(FREYA_SUN_BEAM_TIMER_MIN, FREYA_SUN_BEAM_TIMER_MAX); }
void UpdateAI(const uint32 diff) { if (!UpdateVictim()) return; if (uiImpaleTimer <= 0 && me->IsWithinMeleeRange(me->getVictim())) { DoCast(me->getVictim(), RAID_MODE(RAID_10_SPELL_IMPALE, RAID_25_SPELL_IMPALE)); uiImpaleTimer = refreshTimer(IMPALE_TIMER_MIN, IMPALE_TIMER_MAX); } else uiImpaleTimer -= diff; if (uiThornSwarmTimer <= 0) { Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM); DoCast(pTarget, RAID_MODE(RAID_10_SPELL_THORN_SWARM, RAID_25_SPELL_THORN_SWARM)); uiThornSwarmTimer = refreshTimer(THORN_SWARM_TIMER_MIN, THORN_SWARM_TIMER_MAX); } else uiThornSwarmTimer -= diff; if (uiIronRootTimer <= 0) { pRootTarget = SelectTarget(SELECT_TARGET_RANDOM); if (!pRootTarget->HasAura(RAID_MODE(RAID_10_SPELL_IMPALE, RAID_25_SPELL_IMPALE))) { pRootTarget->CastSpell(me, RAID_MODE(RAID_10_SPELL_IRON_ROOTS, RAID_25_SPELL_IRON_ROOTS), false); uiIronRootTimer = refreshTimer(IRON_ROOTS_TIMER_MIN, IRON_ROOTS_TIMER_MAX); } } else uiIronRootTimer -= diff; DoMeleeAttackIfReady(); }
void UpdateAI(const uint32 diff) { if (!UpdateVictim()) return; if (uiGroundTremorTimer <= 0) { DoCast(me->getVictim(), RAID_MODE(RAID_10_SPELL_GROUND_TREMOR, RAID_25_SPELL_GROUND_TREMOR)); uiGroundTremorTimer = refreshTimer(GROUND_TREMOR_TIMER_MIN, GROUND_TREMOR_TIMER_MAX); } else uiGroundTremorTimer -= diff; if (uiFistsOfStoneTimer <= 0) { DoCast(me, SPELL_FISTS_OF_STONE); uiFistsOfStoneTimer = FISTS_OF_STONE_TIMER; } else uiFistsOfStoneTimer -= diff; DoMeleeAttackIfReady(); }
void updateAI(const uint32 diff) { if (!UpdateVictim()) return; if (uiFlameLashTimer <= 0) { DoCast(me, SPELL_FLAME_LASH); uiFlameLashTimer = FLAME_LASH_TIMER; } else uiFlameLashTimer -= diff; if (uiSwitchTargetTimer <= 0) { Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM); me->Attack(pTarget, true); uiSwitchTargetTimer = refreshTimer(SWITCH_TARGET_TIMER_MIN, SWITCH_TARGET_TIMER_MAX); } else uiSwitchTargetTimer -= diff; DoMeleeAttackIfReady(); }
void Reset() { uiFlameLashTimer = FLAME_LASH_TIMER; uiSwitchTargetTimer = refreshTimer(SWITCH_TARGET_TIMER_MIN, SWITCH_TARGET_TIMER_MAX); }
void UpdateAI(const uint32 diff) { //Freya wont reset unless this is done if (!UpdateVictim()) { me->RemoveAllAuras(); me->DeleteThreatList(); me->CombatStop(false); me->GetMotionMaster()->MoveTargetedHome(); Reset(); return; } if (uiSunbeamTimer <= 0) { Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM); DoCast(pTarget, RAID_MODE(RAID_10_SPELL_SUNBEAM, RAID_25_SPELL_SUNBEAM)); uiSunbeamTimer = refreshTimer(SUNBEAM_TIMER_MIN, SUNBEAM_TIMER_MAX); } else uiSunbeamTimer -= diff; if (uiEonarsTimer <= 0) { int8 randomX = -25 + rand() % 50; int8 randomY = -25 + rand() % 50; me->SummonCreature(NPC_EONARS_GIFT, me->GetPositionX() + randomX, me->GetPositionY() + randomY, me->GetPositionZ() + 5, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 60000); uiEonarsTimer = refreshTimer(EONARS_GIFT_TIMER_MIN, EONARS_GIFT_TIMER_MAX); } else uiEonarsTimer -= diff; if (uiGroundTremorTimer <= 0) { DoCastAOE(RAID_MODE(RAID_10_SPELL_FREYA_GROUND_TREMOR, RAID_25_SPELL_FREYA_GROUND_TREMOR)); uiGroundTremorTimer = refreshTimer(FREYA_GROUND_TREMOR_TIMER_MIN, FREYA_GROUND_TREMOR_TIMER_MAX); } else if (pStonebark->isAlive()) uiGroundTremorTimer -= diff; if (uiIronRootTimer <= 0) { pRootTarget = SelectTarget(SELECT_TARGET_RANDOM); pRootTarget->CastSpell(me, RAID_MODE(RAID_10_SPELL_IRON_ROOTS, RAID_25_SPELL_IRON_ROOTS), false); uiIronRootTimer = refreshTimer(IRON_ROOTS_TIMER_MIN, IRON_ROOTS_TIMER_MAX); } else if (pIronbranch->isAlive()) uiIronRootTimer -= diff; if (uiUnstableSunBeamTimer <= 0) { for (int8 n = 0; n < 3; n++) { Unit* pTarget = SelectTarget(SELECT_TARGET_RANDOM); me->SummonCreature(NPC_SUN_BEAM, pTarget->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, SUN_BEAM_DESPAWN_TIME); } uiUnstableSunBeamTimer = refreshTimer(FREYA_SUN_BEAM_TIMER_MIN, FREYA_SUN_BEAM_TIMER_MAX); } else if (pBrightleaf->isAlive()) uiUnstableSunBeamTimer -= diff; if (uiEnrageTimer <= 0 && !bEnraged) { DoCast(me, SPELL_ENRAGE); me->MonsterYell("You have strayed too far, wasted too much time!", 0, 0); bEnraged = true; } else uiEnrageTimer -= diff; if (phase == 1) { if (uiSpawnAddTimer <= 0) { spawnAdd(); uiSpawnAddTimer = SPAWN_ADD_TIMER; } else uiSpawnAddTimer -= diff; if (uiEnterPhaseTwoTimer <= 0 && phase == 1) phase = 2; else uiEnterPhaseTwoTimer -= diff; potentPheromones(); } else { if (uiNatureBombTimer <= 0) { spawnNatureBomb(); uiNatureBombTimer = NATURE_BOMB_TIMER; } else uiNatureBombTimer -= diff; } //Ressurrection of elemental adds handler - works even if both waves of elemental adds are alive at the same time! if (bElementalAddKilled[0]) uiRessTimer[0] -= diff; else if (bElementalAddKilled[1]) uiRessTimer[1] -= diff; if (uiRessTimer[0] <= 0) { //Im not 100% sure that this is neccessary bool swap = false; if (!bFirstWave) { bFirstWave = true; swap = true; } bElementalAddKilled[0] = false; if (elementalAdds[0]->isAlive() || elementalAdds[1]->isAlive() || elementalAdds[2]->isAlive()) { //Resurrect those mobs that are dead - if not dead, give full health. if (!elementalAdds[0]->isAlive()) { elementalAdds[0]->Respawn(); attunedToNatureStacks += 10; } else elementalAdds[0]->SetHealth(elementalAdds[0]->GetMaxHealth()); if (!elementalAdds[1]->isAlive()) { elementalAdds[1]->Respawn(); attunedToNatureStacks += 10; } else elementalAdds[1]->SetHealth(elementalAdds[0]->GetMaxHealth()); if (!elementalAdds[2]->isAlive()) { elementalAdds[2]->Respawn(); attunedToNatureStacks += 10; } else elementalAdds[2]->SetHealth(elementalAdds[0]->GetMaxHealth()); updateAttunedToNatureStacks(); } if (swap) bFirstWave = false; uiRessTimer[0] = RESURRECTION_TIMER; } else if (uiRessTimer[1] <= 0) { bElementalAddKilled[1] = false; if (elementalAdds[3]->isAlive() || elementalAdds[4]->isAlive() || elementalAdds[5]->isAlive()) { //Ress those mobs that are dead if (!elementalAdds[3]->isAlive()) { elementalAdds[3]->Respawn(); attunedToNatureStacks += 10; } else elementalAdds[3]->SetHealth(elementalAdds[0]->GetMaxHealth()); if (!elementalAdds[4]->isAlive()) { elementalAdds[4]->Respawn(); attunedToNatureStacks += 10; } else elementalAdds[4]->SetHealth(elementalAdds[0]->GetMaxHealth()); if (!elementalAdds[5]->isAlive()) { elementalAdds[5]->Respawn(); attunedToNatureStacks += 10; } else elementalAdds[5]->SetHealth(elementalAdds[0]->GetMaxHealth()); updateAttunedToNatureStacks(); } uiRessTimer[1] = RESURRECTION_TIMER; } //Become friendly and give loot if (HealthBelowPct(1)) { me->setFaction(FACTION_FRIENDLY); me->MonsterYell("His hold on me dissipates. I can see clearly once more. Thank you, heroes.", 0, 0); if (m_pInstance) m_pInstance->SetData(TYPE_FREYA, DONE); float x = me->GetPositionX(); float y = me->GetPositionY(); float z = me->GetPositionZ(); float ang = me->GetOrientation(); float rot2 = sin(ang/2); float rot3 = cos(ang/2); me->SummonGameObject(RAID_MODE(OBJECT_FREYAS_GIFT_N, OBJECT_FREYAS_GIFT_H), x, y, z, ang, 0, 0, rot2, rot3, 0); //Resets me->RemoveAllAuras(); me->DeleteThreatList(); me->CombatStop(false); me->GetMotionMaster()->MoveTargetedHome(); Reset(); } DoMeleeAttackIfReady(); }
void Reset() { uiUnstableSunbeamTimer = UNSTABLE_SUN_BEAM_TIMER; uiSolarFlareTimer = refreshTimer(SOLAR_FLARE_TIMER_MIN, SOLAR_FLARE_TIMER_MAX); }
void Reset() { uiImpaleTimer = refreshTimer(IMPALE_TIMER_MIN, IMPALE_TIMER_MAX); uiThornSwarmTimer = refreshTimer(THORN_SWARM_TIMER_MIN, THORN_SWARM_TIMER_MAX); uiIronRootTimer = refreshTimer(IRON_ROOTS_TIMER_MIN, IRON_ROOTS_TIMER_MAX); }
void Reset() { uiGroundTremorTimer = refreshTimer(GROUND_TREMOR_TIMER_MIN, GROUND_TREMOR_TIMER_MAX); uiFistsOfStoneTimer = FISTS_OF_STONE_TIMER; }
void TelescopeClientJsonRts2::replyFinished(QNetworkReply *reply) { if (reply->error() != QNetworkReply::NoError) { if (reply->url().path().endsWith("/api/cmd") && reply->error() == QNetworkReply::ProtocolInvalidOperationError) { setReadOnly(true); return; } qDebug() << "TelescopeRTS2(" << name << ")::replyFinished: error " << reply->error() << " url: " << reply->url().toString(); telName = ""; if (reconnectTimer < 0) reconnectTimer = startTimer(15000); return; } if (reconnectTimer > 0) { killTimer(reconnectTimer); reconnectTimer = -1; } QByteArray data = reply->readAll(); //qDebug() << "TelescopeRTS2(" << name << ")::replyFinished: data " << (QString) data; QJsonDocument doc; QJsonParseError jsonError; doc = QJsonDocument::fromJson(data, &jsonError); if (reply->url().path().endsWith("/api/devbytype")) { QJsonArray arr = doc.array(); telName = arr[0].toString(); getReadOnly(); } else if (reply->url().path().endsWith("/api/deviceinfo")) { QJsonObject docObject = doc.object(); setReadOnly(docObject["readonly"].toBool()); QUrl rurl(baseurl); rurl.setPath(baseurl.path() + "/api/get"); QUrlQuery query; query.addQueryItem("d", telName); rurl.setQuery(query); request.setUrl(rurl); qDebug() << "TelescopeRTS2(" << name << ")::replyFinished: request url:" << rurl.toString(); refreshTimer(); } else if (reply->url().path().endsWith("/api/get")) { QJsonObject docObject = doc.object(); QJsonObject dObject = docObject["d"].toObject(); QJsonObject telObject = dObject["TEL"].toObject(); telLongitude = dObject["LONGITUD"].toDouble() * M_PI / 180.0; telLatitude = dObject["LATITUDE"].toDouble() * M_PI / 180.0; telAltitude = dObject["ALTITUDE"].toDouble(); telTargetDist = dObject["target_distance"].toDouble() * M_PI / 180.0; const double ra = telObject["ra"].toDouble() * M_PI / 180.0; const double dec = telObject["dec"].toDouble() * M_PI / 180.0; const double cdec = cos(dec); qDebug() << "TelescopeRTS2(" << name << ")::replyFinished: RADEC" << ra << dec; lastPos.set(cos(ra)*cdec, sin(ra)*cdec, sin(dec)); interpolatedPosition.add(lastPos, getNow(), server_micros, 0); QTimer::singleShot(refresh_delay, this, SLOT(refreshTimer())); } else if (reply->url().path().endsWith("/api/cmd")) { QJsonObject docObject = doc.object(); int cmdRet = docObject["ret"].toInt(); qDebug() << "Move command finished: " << cmdRet; if (cmdRet == 0) getReadOnly(); else setReadOnly(true); } else { qWarning() << "TelescopeRTS2(" << name << ")::replyFinished: unhandled reply: " << reply->url().toString(); } reply->deleteLater(); }
Alarm::Alarm (MainPage *parent) { this->setFixedSize (500, 300); this->parent = parent; this->setParent (parent->contantPane); // SET CURRENT DIRECTORY QString dir = QDir::homePath () + FILE_APPDIR; QDir().mkpath (dir); QDir::setCurrent (dir); // INITIALIZE DATABASE CONNECTION this->db = QSqlDatabase::addDatabase ("QSQLITE", "alarm.db"); this->db.setDatabaseName ("alarm.db"); if (this->db.open() == false) EventLog (1, "Error Open Database"); // CREATE NEW TABLE this->query = new QSqlQuery (this->db); if (query->exec ("CREATE TABLE IF NOT EXISTS alarm("\ "id INTEGER PRIMARY KEY AUTOINCREMENT,"\ "hh TEXT NOT NULL,"\ "mm TEXT NOT NULL,"\ "zone TEXT NOT NULL,"\ "sun TEXT NOT NULL,"\ "mon TEXT NOT NULL,"\ "tue TEXT NOT NULL,"\ "wen TEXT NOT NULL,"\ "thr TEXT NOT NULL,"\ "fri TEXT NOT NULL,"\ "sat TEXT NOT NULL);") == false) { EventLog (1, "Error Creation table"); } // SET LABEL TO DISPLAY CURRENT TIME this->time = new QLabel (this); this->time->setText (QTime::currentTime().toString ()); this->time->setGeometry (this->width()/2-125, 10, 250, 80); this->time->setFixedSize (250, 80); this->time->setStyleSheet ("color:black; font-size: 60px"); this->time->setAlignment (Qt::AlignHCenter); // SET TITLE this->title = new QLabel (this); this->title->setText ("Create Alarm"); this->title->setStyleSheet ("color:black; font-size:20px"); this->title->setGeometry (this->width()/2-75, 105, 150, 30); // SET TIMER TO REFRESH TIME this->timer = new QTimer; connect (this->timer, SIGNAL (timeout ()), SLOT (refreshTimer ())); this->timer->start (1000); // SET REPEAT ALARM OPTION this->repeat = new QLabel (this); this->repeat->setText ("Repeat"); this->repeat->setGeometry (30, 140, 80, 25); this->repeat->setStyleSheet ("color:#404040; font-size:16px;"); // SET SUNDAY this->sun = new QToolButton (this); this->sun->setText ("Sunday"); this->sun->setGeometry (10, 170, 60, 20); this->sun->installEventFilter (this); this->sun->setCheckable (false); // SET MONDAY this->mon = new QToolButton (this); this->mon->setText ("Monday"); this->mon->setGeometry (80, 170, 60, 20); this->mon->installEventFilter (this); this->mon->setCheckable (false); // SET TUESDAY this->tue = new QToolButton (this); this->tue->setText ("Tuesday"); this->tue->setGeometry (150, 170, 60, 20); this->tue->installEventFilter (this); this->tue->setCheckable (false); // SET WEDNESDAY this->wen = new QToolButton (this); this->wen->setText ("Wednesday"); this->wen->setGeometry (220, 170, 60, 20); this->wen->installEventFilter (this); this->wen->setCheckable (false); // SET THURSDAY this->thr = new QToolButton (this); this->thr->setText ("Thursday"); this->thr->setGeometry (290, 170, 60, 20); this->thr->installEventFilter (this); this->thr->setCheckable (false); // SET FRIDAY this->fri = new QToolButton (this); this->fri->setText ("Friday"); this->fri->setGeometry (360, 170, 60, 20); this->fri->installEventFilter (this); this->fri->setCheckable (false); // SET SATURDAY this->sat = new QToolButton (this); this->sat->setText ("Saturday"); this->sat->setGeometry (430, 170, 60, 20); this->sat->installEventFilter (this); this->sat->setCheckable (false); // SET HOUR this->hh = new QLineEdit (this); this->hh->setGeometry (this->width()/2-63,200,40, 50); this->hh->setStyleSheet ("font-size:30px"); this->hh->setMaxLength(2); this->hh->setFrame (false); this->hh->setValidator( new QIntValidator (0, 12, this)); this->hh->setText ("00"); this->hh->installEventFilter (this); // SET COLON BETWEEN HH & MM this->colon = new QLabel (this); this->colon->setText (":"); this->colon->setStyleSheet ("font-size:30px;"); this->colon->setGeometry (this->width()/2-25, 200, 10,50); // SET MINUTE this->mm = new QLineEdit (this); this->mm->setGeometry (this->width()/2-15,200, 40, 50); this->mm->setStyleSheet ("font-size:30px"); this->mm->setMaxLength (2); this->mm->setValidator (new QIntValidator (0,59, this)); this->mm->setFrame (false); this->mm->installEventFilter (this); this->mm->setText ("00"); // SET AM/PM this->zone = new QComboBox (this); this->zone->addItem ("AM"); this->zone->addItem ("PM"); this->zone->setGeometry (this->width()/2+25, 205, 40,40); this->zone->setStyleSheet ("font-size:16px"); this->zone->setFrame (false); // SET SAVE BUTTON this->save = new QPushButton (this); this->save->setText ("Save"); this->save->setGeometry (150, 250, 100, 30); this->save->setStyleSheet ("font-size:20px"); connect (this->save, SIGNAL (clicked ()), SLOT (clickSave ())); // SET CANCEL BUTTON this->cancel = new QPushButton (this); this->cancel->setText ("Cancel"); this->cancel->setGeometry (this->width()-250, 250, 100,30); this->cancel->setStyleSheet ("font-size:20px"); connect (this->cancel, SIGNAL (clicked ()), SLOT (clickCancel ())); this->setStyleSheet ( "QToolButton {color: #000; background: #fff;}"\ "QToolButton:pressed {color: #fff; background: #000;}"\ "QToolButton:true {color:red;}"\ "background-color:white;"); this->show (); }