void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket*/) { DEBUG_LOG("WORLD: Received opcode CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY"); uint32 count = 0; WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4); data << uint32(count); // placeholder for (GuidSet::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr) { uint8 dialogStatus = DIALOG_STATUS_NONE; if (itr->IsAnyTypeCreature()) { // need also pet quests case support Creature* questgiver = GetPlayer()->GetMap()->GetAnyTypeCreature(*itr); if (!questgiver || questgiver->IsHostileTo(_player)) continue; if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)) continue; dialogStatus = sScriptMgr.GetDialogStatus(_player, questgiver); if (dialogStatus > DIALOG_STATUS_REWARD_REP) dialogStatus = getDialogStatus(_player, questgiver, DIALOG_STATUS_NONE); data << questgiver->GetObjectGuid(); data << uint8(dialogStatus); ++count; } else if (itr->IsGameObject()) { GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr); if (!questgiver) continue; if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER) continue; dialogStatus = sScriptMgr.GetDialogStatus(_player, questgiver); if (dialogStatus > DIALOG_STATUS_REWARD_REP) dialogStatus = getDialogStatus(_player, questgiver, DIALOG_STATUS_NONE); data << questgiver->GetObjectGuid(); data << uint8(dialogStatus); ++count; } } data.put<uint32>(0, count); // write real count SendPacket(&data); }
void FetchDragons() { Creature* pTene = m_pInstance->GetSingleCreatureFromStorage(NPC_TENEBRON); Creature* pShad = m_pInstance->GetSingleCreatureFromStorage(NPC_SHADRON); Creature* pVesp = m_pInstance->GetSingleCreatureFromStorage(NPC_VESPERON); // if at least one of the dragons are alive and are being called uint8 uiCountFetchableDragons = 0; if (pTene && pTene->IsAlive() && !pTene->getVictim()) { ++uiCountFetchableDragons; pTene->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aTene[0].m_fX, m_aTene[0].m_fY, m_aTene[0].m_fZ); if (!pTene->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) pTene->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } if (pShad && pShad->IsAlive() && !pShad->getVictim()) { ++uiCountFetchableDragons; pShad->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aShad[0].m_fX, m_aShad[0].m_fY, m_aShad[0].m_fZ); if (!pShad->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) pShad->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } if (pVesp && pVesp->IsAlive() && !pVesp->getVictim()) { ++uiCountFetchableDragons; pVesp->GetMotionMaster()->MovePoint(POINT_ID_INIT, m_aVesp[0].m_fX, m_aVesp[0].m_fY, m_aVesp[0].m_fZ); if (!pVesp->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) pVesp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } if (uiCountFetchableDragons) DoCastSpellIfCan(m_creature, SPELL_WILL_OF_SARTHARION); m_pInstance->SetData(TYPE_ALIVE_DRAGONS, uiCountFetchableDragons); }
void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket*/) { TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY"); uint32 count = 0; WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4); data << uint32(count); // placeholder for (Player::ClientGUIDs::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr) { uint8 questStatus = DIALOG_STATUS_NONE; uint8 defstatus = DIALOG_STATUS_NONE; if (IS_CRE_OR_VEH_OR_PET_GUID(*itr)) { // need also pet quests case support Creature* questgiver = ObjectAccessor::GetCreatureOrPetOrVehicle(*GetPlayer(), *itr); if (!questgiver || questgiver->IsHostileTo(_player)) continue; if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)) continue; questStatus = sScriptMgr->GetDialogStatus(_player, questgiver); if (questStatus > 6) questStatus = getDialogStatus(_player, questgiver, defstatus); data << uint64(questgiver->GetGUID()); data << uint8(questStatus); ++count; } else if (IS_GAMEOBJECT_GUID(*itr)) { GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr); if (!questgiver) continue; if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER) continue; questStatus = sScriptMgr->GetDialogStatus(_player, questgiver); if (questStatus > 6) questStatus = getDialogStatus(_player, questgiver, defstatus); data << uint64(questgiver->GetGUID()); data << uint8(questStatus); ++count; } } data.put<uint32>(0, count); // write real count SendPacket(&data); }
void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket*/) { sLog.outDebug("WORLD: Received CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY"); uint32 count = 0; WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4); data << uint32(count); // placeholder for(ObjectGuidSet::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr) { uint8 questStatus = DIALOG_STATUS_NONE; uint8 defstatus = DIALOG_STATUS_NONE; if (itr->IsCreatureOrPet()) { // need also pet quests case support Creature *questgiver = GetPlayer()->GetMap()->GetCreatureOrPetOrVehicle(*itr); if(!questgiver || questgiver->IsHostileTo(_player)) continue; if(!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)) continue; questStatus = Script->NPCDialogStatus(_player, questgiver); if( questStatus > 6 ) questStatus = getDialogStatus(_player, questgiver, defstatus); data << uint64(questgiver->GetGUID()); data << uint8(questStatus); ++count; } else if (itr->IsGameobject()) { GameObject *questgiver = GetPlayer()->GetMap()->GetGameObject(*itr); if(!questgiver) continue; if(questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER) continue; questStatus = Script->GODialogStatus(_player, questgiver); if( questStatus > 6 ) questStatus = getDialogStatus(_player, questgiver, defstatus); data << uint64(questgiver->GetGUID()); data << uint8(questStatus); ++count; } } data.put<uint32>(0, count); // write real count SendPacket(&data); }
void WorldSession::HandleQuestgiverStatusQueryMultipleOpcode(WorldPacket& /*recvPacket*/) { sLog.outDebug("WORLD: Received CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY"); uint32 count = 0; WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4); data << uint32(count); // placeholder for (Player::ClientGUIDs::iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr) { uint8 questStatus = DIALOG_STATUS_NONE; uint8 defstatus = DIALOG_STATUS_NONE; if (IS_CREATURE_GUID(*itr)) { Creature *questgiver = GetPlayer()->GetMap()->GetCreature(*itr); if (!questgiver || questgiver->IsHostileTo(_player)) continue; if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)) continue; questStatus = sScriptMgr.GetDialogStatus(_player, questgiver); if (questStatus == DIALOG_STATUS_SCRIPTED_NO_STATUS) questStatus = getDialogStatus(_player, questgiver, defstatus); data << uint64(questgiver->GetGUID()); data << uint8(questStatus); ++count; } else if (IS_GAMEOBJECT_GUID(*itr)) { GameObject *questgiver = GetPlayer()->GetMap()->GetGameObject(*itr); if (!questgiver) continue; if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER) continue; questStatus = sScriptMgr.GetDialogStatus(_player, questgiver); if (questStatus == DIALOG_STATUS_SCRIPTED_NO_STATUS) questStatus = getDialogStatus(_player, questgiver, defstatus); data << uint64(questgiver->GetGUID()); data << uint8(questStatus); ++count; } } data.put<uint32>(0, count); // write real count SendPacket(&data); }
void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket*/) { TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY"); uint32 count = 0; WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 4); data << uint32(count); // placeholder for (auto itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr) { uint32 questStatus = DIALOG_STATUS_NONE; if (itr->IsAnyTypeCreature()) { // need also pet quests case support Creature* questgiver = ObjectAccessor::GetCreatureOrPetOrVehicle(*GetPlayer(), *itr); if (!questgiver || questgiver->IsHostileTo(_player)) continue; if (!questgiver->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)) continue; questStatus = _player->GetQuestDialogStatus(questgiver); data << uint64(questgiver->GetGUID()); data << uint8(questStatus); ++count; } else if (itr->IsGameObject()) { GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr); if (!questgiver || questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER) continue; questStatus = _player->GetQuestDialogStatus(questgiver); data << uint64(questgiver->GetGUID()); data << uint8(questStatus); ++count; } } data.put<uint32>(0, count); // write real count SendPacket(&data); }
Creature* ObjectAccessor::GetNPCIfCanInteractWith(Player const &player, uint64 guid, uint32 npcflagmask) { // unit checks if (!guid) return NULL; // exist Creature *unit = GetCreature(player, guid); if (!unit) return NULL; // player check if(!player.CanInteractWithNPCs(!unit->isSpiritService())) return NULL; // appropriate npc type if(npcflagmask && !unit->HasFlag( UNIT_NPC_FLAGS, npcflagmask )) return NULL; // alive or spirit healer if(!unit->isAlive() && (!unit->isSpiritService() || player.isAlive() )) return NULL; // not allow interaction under control if(unit->GetCharmerOrOwnerGUID()) return NULL; // not enemy if( unit->IsHostileTo(&player)) return NULL; // not unfriendly if(FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(unit->getFaction())) if(factionTemplate->faction) if(FactionEntry const* faction = sFactionStore.LookupEntry(factionTemplate->faction)) if(faction->reputationListID >= 0 && player.GetReputationMgr().GetRank(faction) <= REP_UNFRIENDLY) return NULL; // not too far if(!unit->IsWithinDistInMap(&player,INTERACTION_DISTANCE)) return NULL; return unit; }
void WorldSession::HandleBattleMasterHelloOpcode(WorldPacket &recv_data) { CHECK_PACKET_SIZE(recv_data, 8); if( !_player || !_player->IsInWorld() ) return; uint64 guid; recv_data >> guid; sLog.outDebug("Received CMSG_BATTLEMASTER_HELLO from " I64FMT, guid); Creature * bm = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid)); if(!bm) return; if(!bm->HasFlag( UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BATTLEFIELDPERSON )) // Not a Battlemaster return; SendBattlegroundList(bm, 0); }
void CallDragon(uint32 uiEntry) { if (m_pInstance) { Creature* pTemp = m_pInstance->GetSingleCreatureFromStorage(uiEntry); if (pTemp && pTemp->IsAlive()) { if (pTemp->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) pTemp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); if (pTemp->getVictim()) return; pTemp->SetWalk(false); int32 iTextId = 0; switch (uiEntry) { case NPC_TENEBRON: iTextId = SAY_SARTHARION_CALL_TENEBRON; pTemp->GetMotionMaster()->MovePoint(POINT_ID_LAND, m_aTene[1].m_fX, m_aTene[1].m_fY, m_aTene[1].m_fZ); break; case NPC_SHADRON: iTextId = SAY_SARTHARION_CALL_SHADRON; pTemp->GetMotionMaster()->MovePoint(POINT_ID_LAND, m_aShad[1].m_fX, m_aShad[1].m_fY, m_aShad[1].m_fZ); break; case NPC_VESPERON: iTextId = SAY_SARTHARION_CALL_VESPERON; pTemp->GetMotionMaster()->MovePoint(POINT_ID_LAND, m_aVesp[1].m_fX, m_aVesp[1].m_fY, m_aVesp[1].m_fZ); break; } DoScriptText(iTextId, m_creature); } } }
void CallDragon(uint32 uiDataId) { if (m_pInstance) { Creature* pTemp = (Creature*)Unit::GetUnit((*m_creature),m_pInstance->GetData64(uiDataId)); if (pTemp && pTemp->isAlive() && !pTemp->getVictim()) { if (pTemp->HasSplineFlag(SPLINEFLAG_WALKMODE)) pTemp->RemoveSplineFlag(SPLINEFLAG_WALKMODE); if (pTemp->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) pTemp->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); int32 iTextId = 0; switch(pTemp->GetEntry()) { case NPC_TENEBRON: iTextId = SAY_SARTHARION_CALL_TENEBRON; pTemp->GetMotionMaster()->MovePoint(POINT_ID_LAND, m_aTene[1].m_fX, m_aTene[1].m_fY, m_aTene[1].m_fZ); break; case NPC_SHADRON: iTextId = SAY_SARTHARION_CALL_SHADRON; pTemp->GetMotionMaster()->MovePoint(POINT_ID_LAND, m_aShad[1].m_fX, m_aShad[1].m_fY, m_aShad[1].m_fZ); break; case NPC_VESPERON: iTextId = SAY_SARTHARION_CALL_VESPERON; pTemp->GetMotionMaster()->MovePoint(POINT_ID_LAND, m_aVesp[1].m_fX, m_aVesp[1].m_fY, m_aVesp[1].m_fZ); break; } DoScriptText(iTextId, m_creature); } } }
void UpdateAI(const uint32 diff) { if (!Phase) return; if (me->getThreatManager().getThreatList().empty()) // Reset if event is begun and we don't have a threatlist { EnterEvadeMode(); return; } Creature* Essence = NULL; if (EssenceGUID) { Essence = Unit::GetCreature(*me, EssenceGUID); if (!Essence) { EnterEvadeMode(); return; } } if (Timer <= diff) { switch (Counter) { case 0: me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_READY2H); // I R ANNNGRRRY! DoStartNoMovement(me); Timer = 3000; break; case 1: Timer = 2800; me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_SUBMERGE); // Release the cube DoCast(me, SPELL_SUBMERGE); DoStartNoMovement(me); break; case 2: Timer = 5000; if (Creature* Summon = DoSpawnCreature(23417+Phase, 0, 0, 0, 0, TEMPSUMMON_DEAD_DESPAWN, 0)) { me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_SUBMERGED); // Ribs: open Summon->AI()->AttackStart(SelectTarget(SELECT_TARGET_TOPAGGRO, 0)); EssenceGUID = Summon->GetGUID(); DoStartNoMovement(me); } else EnterEvadeMode(); break; case 3: Timer = 1000; if (Phase == 3) { if (!Essence->isAlive()) DoCast(me, 7, true); else return; } else { if (Essence->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)) { MergeThreatList(Essence); Essence->RemoveAllAuras(); Essence->DeleteThreatList(); Essence->GetMotionMaster()->MoveFollow(me, 0.0f, 0.0f); } else return; } break; case 4: Timer = 1500; if (Essence->IsWithinDistInMap(me, 10)) { Essence->SetUInt32Value(UNIT_NPC_EMOTESTATE, 374); //rotate and disappear Timer = 2000; me->RemoveAurasDueToSpell(SPELL_SUBMERGE); } else { MergeThreatList(Essence); Essence->RemoveAllAuras(); Essence->DeleteThreatList(); Essence->GetMotionMaster()->MoveFollow(me, 0, 0); return; } break; case 5: if (Phase == 1) { DoScriptText(SUFF_SAY_AFTER, Essence); } else { DoScriptText(DESI_SAY_AFTER, Essence); } Essence->DespawnOrUnsummon(); me->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); EssenceGUID = 0; SoulCount = 0; SoulDeathCount = 0; Timer = 3000; break; case 6: if (SoulCount < NUMBER_ENSLAVED_SOUL) { if (SummonSoul()) ++SoulCount; Timer = 500; return; } break; case 7: if (SoulDeathCount >= SoulCount) { Counter = 1; ++Phase; Timer = 5000; } return; default: break; } ++Counter; } else Timer -= diff; }
void ExclusivePoolMgr::ExecuteEvent(ExclusivePool& pool) { sLog.outBasic("ExclusivePool: Shuffling pool %u...", pool.poolID); // Get the spawn points and shuffle them. std::vector<ExclusivePoolSpot> poolSpotList; poolSpotList.insert(poolSpotList.begin(), m_poolSpots[pool.poolID].begin(), m_poolSpots[pool.poolID].end()); std::random_shuffle(poolSpotList.begin(), poolSpotList.end()); for (std::pair<const uint32, std::list<ObjectGuid> >& poolPair : pool.m_objects) { // If we have run out of spawn positions we stop spawning creatures. if (poolSpotList.empty()) break; std::list<ObjectGuid> poolObjectList = poolPair.second; // Check if any creatures in the current group are alive. // If they are the group should be skipped. bool foundAlive = false; for (ObjectGuid currentCreature : poolObjectList) { const CreatureData* pData = sObjectMgr.GetCreatureData(currentCreature.GetCounter()); if (pData) { Map* pMap = sMapMgr.FindMap(pData->mapid); if (pMap) { if (!pMap->IsLoaded(pData->posX, pData->posY)) { MaNGOS::ObjectUpdater updater(0); // for creature TypeContainerVisitor<MaNGOS::ObjectUpdater, GridTypeMapContainer > grid_object_update(updater); // for pets TypeContainerVisitor<MaNGOS::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater); // Make sure that the creature is loaded before checking its status. CellPair cellPair = MaNGOS::ComputeCellPair(pData->posX, pData->posY); Cell cell(cellPair); pMap->Visit(cell, grid_object_update); pMap->Visit(cell, world_object_update); } Creature* pCreature = pMap->GetCreature(currentCreature); if (pCreature) { // If the creature is alive or being looted we don't include it in the randomisation. if (pCreature->isAlive() || pCreature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE)) { sLog.outBasic("ExclusivePool: Skipping creature with guid %u.", currentCreature.GetCounter()); auto itr = std::find_if(poolSpotList.begin(), poolSpotList.end(), [&](const ExclusivePoolSpot& spot) { if (spot.x == pData->posX && spot.y == pData->posY && spot.z == pData->posZ && spot.mapID == pData->mapid) { return true; } else return false; }); // If we found the spot on which the living creature is standing // we remove that spot since it's occupied. if (itr != poolSpotList.end()) { poolSpotList.erase(itr); foundAlive = true; } else { sLog.outBasic("ExclusivePool: Could not find the pool position for creature %u. Moving it to avoid double spawns!", currentCreature.GetCounter()); } DespawnAllExcept(poolObjectList, currentCreature); break; } } } } } // If a creature in the current group was alive we skip it. if (foundAlive) continue; // Pick a random creature from the current group. auto itr = poolObjectList.begin(); std::advance(itr, urand(0, poolObjectList.size() - 1)); // Get a spawn point for the creature. ExclusivePoolSpot spot = poolSpotList.back(); poolSpotList.pop_back(); CreatureData& rData = sObjectMgr.mCreatureDataMap[itr->GetCounter()]; // If the creature is already in the correct spot we skip it. if (rData.posX == spot.x && rData.posY == spot.y && rData.posZ == spot.z && rData.mapid == spot.mapID) { continue; } // Do the actual spawning. sObjectMgr.RemoveCreatureFromGrid(itr->GetCounter(), &rData); Creature::AddToRemoveListInMaps(itr->GetCounter(), &rData); rData.posX = spot.x; rData.posY = spot.y; rData.posZ = spot.z; rData.orientation = spot.orientation; rData.mapid = spot.mapID; // Update the creature entry in the database. WorldDatabase.PQuery("UPDATE creature SET map=%u, position_x=%f, position_y=%f, position_z=%f, orientation=%f WHERE guid=%u", spot.mapID, spot.x, spot.y, spot.z, spot.orientation, itr->GetCounter()); // Make sure that all other creatures in the group are despawned. DespawnAllExcept(poolObjectList, *itr); } SaveRespawnTime(pool); sLog.outBasic("ExclusivePool: Finished shuffling pool %u.", pool.poolID); }
void LootObject::Refresh(Player* bot, ObjectGuid guid) { skillId = SKILL_NONE; reqSkillValue = 0; reqItem = NULL; this->guid = ObjectGuid(); PlayerbotAI* ai = bot->GetPlayerbotAI(); Creature *creature = ai->GetCreature(guid); if (creature && creature->getDeathState() == CORPSE) { if (creature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE)) this->guid = guid; if (creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE)) { skillId = creature->GetCreatureTemplate()->GetRequiredLootSkill(); uint32 targetLevel = creature->getLevel(); reqSkillValue = targetLevel < 10 ? 0 : targetLevel < 20 ? (targetLevel - 10) * 10 : targetLevel * 5; if (bot->HasSkill(skillId) && bot->GetSkillValue(skillId) >= reqSkillValue) this->guid = guid; } return; } GameObject* go = ai->GetGameObject(guid); if (go && go->isSpawned()) { uint32 lockId = go->GetGOInfo()->GetLockId(); LockEntry const *lockInfo = sLockStore.LookupEntry(lockId); if (!lockInfo) return; // TODO: remove? /*for(uint32 i = 0; i < 6; ++i) { if (go->GetGOInfo()->questItems[i]) { this->guid = guid; return; } }*/ for (int i = 0; i < 8; ++i) { switch (lockInfo->Type[i]) { case LOCK_KEY_ITEM: if (lockInfo->Index[i] > 0) { reqItem = lockInfo->Index[i]; this->guid = guid; } break; case LOCK_KEY_SKILL: if (SkillByLockType(LockType(lockInfo->Index[i])) > 0) { skillId = SkillByLockType(LockType(lockInfo->Index[i])); reqSkillValue = lockInfo->Skill[i]; this->guid = guid; } break; default: break; } } } }
void WorldSession::HandleSpellClick( WorldPacket & recv_data ) { uint64 guid; recv_data >> guid; if (_player->isInCombat()) // client prevent click and set different icon at combat state return; Creature *unit = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid); if (!unit || unit->isInCombat()) // client prevent click and set different icon at combat state return; if(!_player->IsWithinDistInMap(unit, 10)) return; // cheater? if(!unit->HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_SPELLCLICK)) return; uint32 vehicleId = 0; CreatureDataAddon const *cainfo = unit->GetCreatureAddon(); if(cainfo) vehicleId = cainfo->vehicle_id; // handled other (hacky) way to avoid overwriting auras if(vehicleId || unit->isVehicle()) { if(!unit->isAlive()) return; if(_player->GetVehicleGUID()) return; // create vehicle if no one present and kill the original creature to avoid double, triple etc spawns if(!unit->isVehicle()) { Vehicle *v = _player->SummonVehicle(unit->GetEntry(), unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetOrientation(), vehicleId); if(!v) return; if(v->GetVehicleFlags() & VF_DESPAWN_NPC) { v->SetSpawnDuration(unit->GetRespawnDelay()*IN_MILISECONDS); unit->setDeathState(JUST_DIED); unit->RemoveCorpse(); unit->SetHealth(0); } unit = v; } if(((Vehicle*)unit)->GetVehicleData()) if(uint32 r_aura = ((Vehicle*)unit)->GetVehicleData()->req_aura) if(!_player->HasAura(r_aura)) return; _player->EnterVehicle((Vehicle*)unit, 0); } else { SpellClickInfoMapBounds clickPair = objmgr.GetSpellClickInfoMapBounds(unit->GetEntry()); for(SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) { if (itr->second.IsFitToRequirements(_player)) { Unit *caster = (itr->second.castFlags & 0x1) ? (Unit*)_player : (Unit*)unit; Unit *target = (itr->second.castFlags & 0x2) ? (Unit*)_player : (Unit*)unit; caster->CastSpell(target, itr->second.spellId, true); } } } }
void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket*/) { TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY"); uint32 count = 0; ByteBuffer byteData; WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 3 + count * (1 + 8 + 4)); size_t pos = data.bitwpos(); data.WriteBits(count, 21); // placeholder for (Player::ClientGUIDs::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr) { uint32 questStatus = DIALOG_STATUS_NONE; uint32 defstatus = DIALOG_STATUS_NONE; if (IS_CRE_OR_VEH_OR_PET_GUID(*itr)) { // need also pet quests case support Creature* questgiver = ObjectAccessor::GetCreatureOrPetOrVehicle(*GetPlayer(), *itr); if (!questgiver || questgiver->IsHostileTo(_player)) continue; if (!questgiver->HasFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)) continue; questStatus = sScriptMgr->GetDialogStatus(_player, questgiver); if (questStatus > 6) questStatus = getDialogStatus(_player, questgiver, defstatus); ObjectGuid guid = questgiver->GetGUID(); data.WriteBit(guid[4]); data.WriteBit(guid[0]); data.WriteBit(guid[3]); data.WriteBit(guid[6]); data.WriteBit(guid[5]); data.WriteBit(guid[7]); data.WriteBit(guid[1]); data.WriteBit(guid[2]); byteData.WriteByteSeq(guid[6]); byteData.WriteByteSeq(guid[2]); byteData.WriteByteSeq(guid[7]); byteData.WriteByteSeq(guid[5]); byteData.WriteByteSeq(guid[4]); byteData << uint32(questStatus); byteData.WriteByteSeq(guid[1]); byteData.WriteByteSeq(guid[3]); byteData.WriteByteSeq(guid[0]); ++count; } else if (IS_GAMEOBJECT_GUID(*itr)) { GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr); if (!questgiver) continue; if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER) continue; questStatus = sScriptMgr->GetDialogStatus(_player, questgiver); if (questStatus > 6) questStatus = getDialogStatus(_player, questgiver, defstatus); ObjectGuid guid = questgiver->GetGUID(); data.WriteBit(guid[4]); data.WriteBit(guid[0]); data.WriteBit(guid[3]); data.WriteBit(guid[6]); data.WriteBit(guid[5]); data.WriteBit(guid[7]); data.WriteBit(guid[1]); data.WriteBit(guid[2]); byteData.WriteByteSeq(guid[6]); byteData.WriteByteSeq(guid[2]); byteData.WriteByteSeq(guid[7]); byteData.WriteByteSeq(guid[5]); byteData.WriteByteSeq(guid[4]); byteData << uint32(questStatus); byteData.WriteByteSeq(guid[1]); byteData.WriteByteSeq(guid[3]); byteData.WriteByteSeq(guid[0]); ++count; } } data.FlushBits(); data.PutBits(pos, count, 21); data.append(byteData); SendPacket(&data); }