void Vehicle::InstallAccessory(uint32 entry, int8 seatId, bool isVehicle, bool minion) { if(Unit *passenger = GetPassenger(seatId)) { // already installed if(passenger->GetEntry() == entry) { assert(passenger->GetTypeId() == TYPEID_UNIT); return; } passenger->ExitVehicle(); // this should not happen } //TODO: accessory should be minion if(isVehicle) { if(Vehicle *accessory = SummonVehicle(entry, 0, 0, 0, 0)) { accessory->EnterVehicle(this, seatId, true); // This is not good, we have to send update twice accessory->BuildVehicleInfo(accessory); } }else{ if(Creature *accessory = SummonCreature(entry, 0, 0, 0, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 30000)) { accessory->EnterVehicle(this, seatId); // This is not good, we have to send update twice WorldPacket data; accessory->BuildHeartBeatMsg(&data); accessory->SendMessageToSet(&data, false); } } }
void Vehicle::InstallAccessory(uint32 entry, int8 seatId) { if(Unit *passenger = GetPassenger(seatId)) { // already installed if(passenger->GetEntry() == entry) return; passenger->ExitVehicle(); // this should not happen } const CreatureInfo *cInfo = objmgr.GetCreatureTemplate(entry); if(!cInfo) return; Creature *accessory; if(cInfo->VehicleId) accessory = SummonVehicle(entry, GetPositionX(), GetPositionY(), GetPositionZ()); else accessory = SummonCreature(entry, GetPositionX(), GetPositionY(), GetPositionZ()); if(!accessory) return; accessory->EnterVehicle(this, seatId); // This is not good, we have to send update twice accessory->SendMovementFlagUpdate(); }
void hyjalAI::SummonNextWave(Wave wave[18], uint32 Count, float Base[4][3]) { if(rand()%4 == 0) // 1 in 4 chance we give a rally yell. Not sure if the chance is Blizzlike. Talk(RALLY); EnemyCount = 0; for(uint8 i = 0; i < 18; ++i) { if(wave[Count].Mob[i]) SummonCreature(wave[Count].Mob[i], Base); } if(!wave[Count].IsBoss) { uint32 stateValue = Count+1; if(FirstBossDead) stateValue -= 9; // Subtract 8 from it to give the proper wave number if we are greater than 8 UpdateWorldState(WORLDSTATE_WAVES, stateValue); // Set world state to our current wave number UpdateWorldState(WORLDSTATE_ENEMY, 1); UpdateWorldState(WORLDSTATE_ENEMYCOUNT, EnemyCount); NextWaveTimer = wave[Count].WaveTimer; } else { UpdateWorldState(WORLDSTATE_WAVES, 0); // Set world state for waves to 0 to disable it. UpdateWorldState(WORLDSTATE_ENEMYCOUNT, 1); // Set World State for enemies invading to 1. Summon = false; CheckBossTimer = 1000; } }
void hyjalAI::SummonNextWave(const Wave wave[18], uint32 Count, float Base[4][3]) { // 1 in 4 chance we give a rally yell. Not sure if the chance is offilike. if (rand()%4 == 0) Talk(RALLY); if (!instance) { sLog->outError(LOG_FILTER_TSCR, ERROR_INST_DATA); return; } InfernalCount = 0;//reset infernal count every new wave EnemyCount = instance->GetData(DATA_TRASH); for (uint8 i = 0; i < 18; ++i) { if (wave[Count].Mob[i]) SummonCreature(wave[Count].Mob[i], Base); } if (!wave[Count].IsBoss) { uint32 stateValue = Count+1; if (FirstBossDead) stateValue -= 9; // Subtract 9 from it to give the proper wave number if we are greater than 8 // Set world state to our current wave number instance->DoUpdateWorldState(WORLD_STATE_WAVES, stateValue); // Set world state to our current wave number // Enable world state instance->DoUpdateWorldState(WORLD_STATE_ENEMY, 1); // Enable world state instance->SetData(DATA_TRASH, EnemyCount); // Send data for instance script to update count if (!Debug) NextWaveTimer = wave[Count].WaveTimer; else { NextWaveTimer = 15000; sLog->outDebug(LOG_FILTER_TSCR, "HyjalAI: debug mode is enabled. Next Wave in 15 seconds"); } } else { // Set world state for waves to 0 to disable it. instance->DoUpdateWorldState(WORLD_STATE_WAVES, 0); instance->DoUpdateWorldState(WORLD_STATE_ENEMY, 1); // Set World State for enemies invading to 1. instance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 1); Summon = false; } CheckTimer = 5000; }
bool ProcessEventId_event_test_of_endurance(uint32 eventId, Object* pSource, Object* pTarget, bool isStart) { auto pGO = pTarget->ToGameObject(); auto pPlayer = pSource->ToPlayer(); if (!pGO || !pPlayer) return true; if (pGO->FindNearestCreature(NPC_GRENKA, 100.0f)) return true; if (auto pGrenka = pGO->SummonCreature(Harpies[4].entry, Harpies[4].x, Harpies[4].y, Harpies[4].z, Harpies[4].o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, MINUTE*IN_MILLISECONDS)) { if (auto pGrenkaAI = static_cast<npc_grenka_bloodscreechAI*>(pGrenka->AI())) pGrenkaAI->m_PlayerGuid = pPlayer->GetObjectGuid(); } return true; }
void UpdateAI(uint32 diff) { if (!me->IsInCombat()) return; if (IsBanished) { // Akama is set in the threatlist so when we reset, we make sure that he is not included in our check if (me->getThreatManager().getThreatList().size() < 2) { EnterEvadeMode(); return; } if (DefenderTimer <= diff) { uint32 ran = rand()%2; Creature* Defender = me->SummonCreature(NPC_DEFENDER, SpawnLocations[ran].x, SpawnLocations[ran].y, Z_SPAWN, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 25000); if (Defender) { Defender->SetWalk(false); bool move = true; if (AkamaGUID) { if (Creature* Akama = Unit::GetCreature(*me, AkamaGUID)) { float x, y, z; Akama->GetPosition(x, y, z); // They move towards AKama Defender->GetMotionMaster()->MovePoint(0, x, y, z); Defender->AI()->AttackStart(Akama); } else move = false; } else move = false; if (!move) Defender->GetMotionMaster()->MovePoint(0, AKAMA_X, AKAMA_Y, AKAMA_Z); } DefenderTimer = 15000; } else DefenderTimer -= diff; if (SummonTimer <= diff) { SummonCreature(); SummonTimer = 35000; } else SummonTimer -= diff; if (DeathCount >= 6) { if (AkamaGUID) { Creature* Akama = Unit::GetCreature((*me), AkamaGUID); if (Akama && Akama->IsAlive()) { IsBanished = false; me->GetMotionMaster()->Clear(false); me->GetMotionMaster()->MoveChase(Akama); Akama->GetMotionMaster()->Clear(); // Shade should move to Akama, not the other way around Akama->GetMotionMaster()->MoveIdle(); me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); // Crazy amount of threat me->AddThreat(Akama, 10000000.0f); Akama->AddThreat(me, 10000000.0f); me->Attack(Akama, true); Akama->Attack(me, true); } } } } else // No longer banished, let's fight Akama now { if (ReduceHealthTimer <= diff) { if (AkamaGUID) { Creature* Akama = Unit::GetCreature((*me), AkamaGUID); if (Akama && Akama->IsAlive()) { //10 % less health every few seconds. me->DealDamage(Akama, Akama->GetMaxHealth()/10, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); ReduceHealthTimer = 12000; } } } else ReduceHealthTimer -= diff; if (HasKilledAkama) { if (!HasKilledAkamaAndReseting)//do not let players kill Shade if Akama is dead and Shade is waiting for ResetTimer!! event would bug { HasKilledAkamaAndReseting = true; me->RemoveAllAuras(); me->DeleteThreatList(); me->CombatStop(); //me->SetFullHealth(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); me->GetMotionMaster()->MoveTargetedHome(); } if (ResetTimer <= diff) { EnterEvadeMode();// Reset a little while after killing Akama, evade and respawn Akama return; } else ResetTimer -= diff; } DoMeleeAttackIfReady(); } }