void UnitsDialog::loadConversionTable( ConversionTable *table, Unit::Type type ) { UnitList unitList; database->loadUnits( &unitList, type ); QStringList unitNames; IDList unitIDs; // We need to store these in the table, so rows and cols are identified by unitID, not name. table->clear(); for ( UnitList::const_iterator unit_it = unitList.constBegin(); unit_it != unitList.constEnd(); ++unit_it ) { unitNames.append( ( *unit_it ).name() ); unitIDs.append( ( *unit_it ).id() ); // append the element } // Resize the table table->resize( unitNames.count(), unitNames.count() ); // Set the table labels, and id's table->setRowLabels( unitNames ); table->setColumnLabels( unitNames ); table->setUnitIDs( unitIDs ); // Load and Populate the data into the table UnitRatioList ratioList; database->loadUnitRatios( &ratioList, type ); for ( UnitRatioList::const_iterator ratio_it = ratioList.constBegin(); ratio_it != ratioList.constEnd(); ++ratio_it ) { table->setRatio( ( *ratio_it ).unitId1(), ( *ratio_it ).unitId2(), ( *ratio_it ).ratio() ); } }
VC3 UnitList::getTrackableUnifiedHandleVelocity(UnifiedHandle unifiedHandle) const { UnitList *thism = const_cast<UnitList *>(this); Unit *u = thism->getUnitById(unifiedHandleToUnitId(unifiedHandle)); assert(u != NULL); return u->getVelocity(); }
bool UnitList::doesTrackableUnifiedHandleObjectExist(UnifiedHandle unifiedHandle) const { UnitList *thism = const_cast<UnitList *>(this); if (thism->getUnitById(unifiedHandleToUnitId(unifiedHandle)) != NULL) return true; else return false; }
QUAT UnitList::getTrackableUnifiedHandleRotation(UnifiedHandle unifiedHandle) const { UnitList *thism = const_cast<UnitList *>(this); Unit *u = thism->getUnitById(unifiedHandleToUnitId(unifiedHandle)); assert(u != NULL); VC3 rot = u->getRotation(); QUAT ret = QUAT(UNIT_ANGLE_TO_RAD(rot.x), UNIT_ANGLE_TO_RAD(rot.y), UNIT_ANGLE_TO_RAD(rot.z)); return ret; }
void SelectUnitDialog::loadUnits( const UnitList &unitList ) { for ( UnitList::const_iterator unit_it = unitList.begin(); unit_it != unitList.end(); ++unit_it ) { QString unitName = ( *unit_it ).name(); if ( unitName.isEmpty() ) { if ( m_showEmpty == ShowEmptyUnit ) unitName = ' '+i18nc("@item", "-No unit-"); else continue; } ( void ) new Q3ListViewItem( unitChooseView, QString::number( ( *unit_it ).id() ), unitName ); } }
// ---------------------------------------------------------------------- void Squad::getUnitList(UnitList & unitList) { LOGC(ConfigServerGame::isSpaceAiLoggingEnabled(), "space_debug_ai", ("Squad::getUnitList() className(%s) squadId(%d)", getClassName(), m_id)); LOGC((ConfigServerGame::isSpaceAiLoggingEnabled() && m_unitMap->empty()), "space_debug_ai", ("Squad::getUnitList() className(%s) squadId(%d) The current squad list should not be empty!", getClassName(), m_id)); unitList.clear(); unitList.reserve(m_unitMap->size()); UnitMap::const_iterator iterUnitMap = m_unitMap->begin(); for (; iterUnitMap != m_unitMap->end(); ++iterUnitMap) { unitList.push_back(iterUnitMap->first); } }
/** * @return unit which belong to playerIndex */ UnitBase * BotPlayer::getRandomUnit(int playerIndex) { UnitBase *unit = 0; UnitList *unitList = UnitInterface::getUnitList(playerIndex); assert(unitList != 0); long size = unitList->size(); if (size > 0) { int unitIndex = rand() % size; int p = 0; for(UnitList::iterator i = unitList->begin(); i != unitList->end(); ++i) { unit = *i; if(p == unitIndex) break; ++p; } } return unit; }
void UpdateAI(uint32 const diff) { events.Update(diff); if (!UpdateVictim()) return; if (phase1_timer) { if (phase1 <= diff) { phase1_timer = false; phase2_timer = true; deadvanced = true; me->CastSpell(me, ADVANCE); if (me->HasAura(ADVANCE)) { AuraPtr Advance = me->GetAura(ADVANCE); if (Advance) { Advance->SetDuration(10000000); } } me->MonsterSay("Power.. I must have more power.. Guards, Protect your empress!", LANG_UNIVERSAL, me->GetGUID()); DoPlaySoundToSet(me, 29270); events.ScheduleEvent(EVENT_SUMMON_MOBS, 500); events.ScheduleEvent(EVENT_ADVANCE, 500); } else phase1 -= diff; } if (phase2_timer) { if (phase2 <= diff) { phase2_timer = false; if (deadvanced) { deadvanced = false; me->RemoveAura(ADVANCE); events.ScheduleEvent(EVENT_DEADVANCE, 500); } } else phase2 -= diff; } if (thirdphase) { if (Unit* victim = me->getVictim()) { if (!me->IsWithinDistInMap(victim, 2.0f)) { events.ScheduleEvent(EVENT_MOVE_FIX, 1000); } } } if (SayCharmed) { SayCharmed = false; me->MonsterYell("You are mine now!", LANG_UNIVERSAL, me->GetGUID()); DoPlaySoundToSet(me, 29282); } // Introduction RP while (uint32 eventId = events.ExecuteEvent()) { switch (eventId) { case EVENT_SUMMON_MOBS: // side a me->SummonCreature(MOB_REAVER, -2453.20f, 989.60f, 569.630f, 3.498173f, TEMPSUMMON_MANUAL_DESPAWN); me->SummonCreature(MOB_WIND, -2448.70f, 992.45f, 569.630f, 3.407852f, TEMPSUMMON_MANUAL_DESPAWN); me->SummonCreature(MOB_WIND, -2445.68f, 989.26f, 569.630f, 3.407852f, TEMPSUMMON_MANUAL_DESPAWN); // side b me->SummonCreature(MOB_REAVER, -2504.68f, 987.24f, 569.630f, 0.295318f, TEMPSUMMON_MANUAL_DESPAWN); me->SummonCreature(MOB_WIND, -2508.52f, 981.49f, 569.630f, 0.295318f, TEMPSUMMON_MANUAL_DESPAWN); me->SummonCreature(MOB_WIND, -2510.62f, 992.30f, 569.630f, 0.295318f, TEMPSUMMON_MANUAL_DESPAWN); break; case EVENT_ADVANCE: me->SetDisplayId(11686); // invis if (MotionMaster* motion = me->GetMotionMaster()) motion->MovePoint(1, -2476.62f, 1035.45f, 572.818f); me->SetReactState(REACT_PASSIVE); me->AddUnitState(UNIT_STATE_CANNOT_AUTOATTACK); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC); events.CancelEvent(EVENT_DEAD_SCREECH); events.CancelEvent(EVENT_CRY_TERROR); events.CancelEvent(EVENT_EYE_OF_THE_EMPRESS); events.CancelEvent(EVENT_DISSONANCE_SHIELD); me->DespawnCreaturesInArea(DISSONANCE_SHIELD_TRIGGER); me->SetSpeed(MOVE_RUN, 0.0f); break; case EVENT_DEADVANCE: me->SetDisplayId(42730); // originial dis events.ScheduleEvent(EVENT_CRY_TERROR, 7500); events.ScheduleEvent(EVENT_DEAD_SCREECH, 10000); events.ScheduleEvent(EVENT_EYE_OF_THE_EMPRESS, 8000); events.ScheduleEvent(EVENT_DISSONANCE_SHIELD, 30000); me->Attack(me->getVictim(), true); me->SetReactState(REACT_AGGRESSIVE); me->ClearUnitState(UNIT_STATE_CANNOT_AUTOATTACK); me->SetSpeed(MOVE_RUN, 1.13f); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC); break; case EVENT_CRY_TERROR: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true)) { me->AddAura(123788, target); } events.ScheduleEvent(EVENT_CRY_TERROR, 7500); break; case EVENT_DEAD_SCREECH: for (int i = 0; i <= 1; i++) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true)) { me->CastSpell(target, DEAD_SCREECH_DMG); } } events.ScheduleEvent(EVENT_DEAD_SCREECH, 10000); break; case EVENT_EYE_OF_THE_EMPRESS: if (!me->getVictim()->HasAura(EYE_OF_THE_EMPRESS)) { me->getVictim()->CastSpell(me->getVictim(), EYE_OF_THE_EMPRESS); } else { AuraPtr aura_B = me->getVictim()->GetAura(EYE_OF_THE_EMPRESS); if (aura_B && aura_B->GetStackAmount() <= 5) { aura_B->SetStackAmount(aura_B->GetStackAmount() + 1); } } events.ScheduleEvent(EVENT_EYE_OF_THE_EMPRESS, 6000); break; case EVENT_DISSONANCE_SHIELD: if (!me->FindNearestCreature(DISSONANCE_SHIELD_TRIGGER, 100.0f, true)) { me->SummonCreature(DISSONANCE_SHIELD_TRIGGER, dis_1, TEMPSUMMON_MANUAL_DESPAWN, 0); me->SummonCreature(DISSONANCE_SHIELD_TRIGGER, dis_2, TEMPSUMMON_MANUAL_DESPAWN, 0); } events.ScheduleEvent(EVENT_DISSONANCE_SHIELD, 65000); break; // phase 3 case EVENT_SHA_ENERGY: int count; if (Is25ManRaid()) count = 4; else count = 1; for (int i = 0; i <= count; i++) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true)) { me->CastSpell(target, SHA_ENERGY); } } events.ScheduleEvent(EVENT_SHA_ENERGY, 10000); break; case EVENT_AMASSING_DARKNESS: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true)) { if (!target->HasAura(AMASSING_DARKNESS_AURA)) { me->CastSpell(target, AMASSING_DARKNESS); me->AddAura(AMASSING_DARKNESS_AURA, target); } UnitList targets; JadeCore::AnyUnitHavingBuffInObjectRangeCheck u_check(target, target, 100, AMASSING_DARKNESS_AURA, true); JadeCore::UnitListSearcher<JadeCore::AnyUnitHavingBuffInObjectRangeCheck> searcher(target, targets, u_check); target->VisitNearbyObject(100, searcher); for (UnitList::const_iterator it = targets.begin(); it != targets.end(); ++it) { if (!(*it)) return; if ((*it)->GetGUID() != target->GetGUID()) me->CastSpell((*it), AMASSING_DARKNESS); } if (Is25ManRaid()) events.ScheduleEvent(EVENT_AMASSING_DARKNESS, 2500); else events.ScheduleEvent(EVENT_AMASSING_DARKNESS, 6500); } break; case EVENT_CONSUMING_TERROR: if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true)) { // cancel first phase abilities events.CancelEvent(EVENT_SHA_ENERGY); events.CancelEvent(EVENT_AMASSING_DARKNESS);; events.CancelEvent(EVENT_VISIONS_OF_DEMISE); events.CancelEvent(EVENT_CALAMITY); // scehdule new abilities third phase events.ScheduleEvent(EVENT_SHA_ENERGY, 10000); events.ScheduleEvent(EVENT_AMASSING_DARKNESS, 10000); events.ScheduleEvent(EVENT_CONSUMING_TERROR, 40000); events.ScheduleEvent(EVENT_VISIONS_OF_DEMISE, urand(29000, 35000)); events.ScheduleEvent(EVENT_CALAMITY, urand(15000, 20000)); me->CastSpell(target, CONSUMING_TERROR); events.ScheduleEvent(EVENT_CONSUMING_TERROR, 40000); } break; case EVENT_CALAMITY: DoCastAOE(CALAMITY); events.ScheduleEvent(EVENT_CALAMITY, 20000); break; case EVENT_VISIONS_OF_DEMISE: for (int i = 0; i <= 1; i++) { if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 50, true)) { me->AddAura(124862, target); } } events.ScheduleEvent(EVENT_VISIONS_OF_DEMISE, urand(29000, 35000)); break; case EVENT_MOVE_FIX: if (Unit* victim = me->getVictim()) { if (!me->IsWithinDistInMap(victim, 2.0f)) { if (MotionMaster* motion = me->GetMotionMaster()) { motion->MovePoint(1, victim->GetPositionX(), victim->GetPositionY(), victim->GetPositionZ()); } events.ScheduleEvent(EVENT_MOVE_FIX, 2000); } } break; } } DoMeleeAttackIfReady(); }