Exemple #1
0
void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket)
{
    ;//sLog->outDetail("CMSG_PET_SPELL_AUTOCAST");
    uint64 guid;
    uint32 spellid;
    uint8  state;                                           //1 for on, 0 for off
    recvPacket >> guid >> spellid >> state;

    if (!_player->GetGuardianPet() && !_player->GetCharm())
        return;

    if (IS_PLAYER_GUID(guid))
        return;

	SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
	if (!spellInfo)
		return;

    Creature* checkPet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, guid);
    if (!checkPet || (checkPet != _player->GetGuardianPet() && checkPet != _player->GetCharm()))
    {
        sLog->outError("HandlePetSpellAutocastOpcode.Pet %u isn't pet of player %s .", uint32(GUID_LOPART(guid)), GetPlayer()->GetName().c_str());
        return;
    }

	Unit::ControlSet petsSet;
	if (checkPet->GetEntry() != GUID_ENPART(guid))
		petsSet.insert(checkPet);
	else
		petsSet = _player->m_Controlled;

	// Xinef: loop all pets with same entry (fixes partial state change for feral spirits)
	for (Unit::ControlSet::const_iterator itr = petsSet.begin(); itr != petsSet.end(); ++itr)
	{
		Unit* pet = *itr;
		if (checkPet->GetEntry() == GUID_ENPART(guid) && pet->GetEntry() != GUID_ENPART(guid))
			continue;

		// do not add not learned spells/ passive spells
		if (!pet->HasSpell(spellid) || !spellInfo->IsAutocastable())
			continue;

		CharmInfo* charmInfo = pet->GetCharmInfo();
		if (!charmInfo)
		{
			sLog->outError("WorldSession::HandlePetSpellAutocastOpcod: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
			continue;
		}

		if (pet->IsPet())
			((Pet*)pet)->ToggleAutocast(spellInfo, state);
		else
			pet->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, state);

		charmInfo->SetSpellAutocast(spellInfo, state);
	}
}
            void UpdateAI(uint32 diff)
            {
                ScriptedAI::UpdateAI(diff);

                _switchImageTimer += diff;
                if (_switchImageTimer > MINUTE*IN_MILLISECONDS)
                {
                    _switchImageTimer = 0;
                    QuestRelationBounds objectQR = sObjectMgr->GetCreatureQuestRelationBounds(me->GetEntry());
                    for (QuestRelations::const_iterator i = objectQR.first; i != objectQR.second; ++i)
                    {
                        uint32 questId = i->second;
                        Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
                        if (!quest || !quest->IsWeekly())
                            continue;

                        uint32 newEntry = GetImageEntry(questId);
                        if (GUID_ENPART(_summonGUID) != newEntry)
                        {
                            if (Creature* image = ObjectAccessor::GetCreature(*me, _summonGUID))
                                image->DespawnOrUnsummon();

                            float z = 653.622f;
                            if (newEntry == NPC_MALYGOS_IMAGE || newEntry == NPC_RAZORSCALE_IMAGE || newEntry == NPC_SARTHARION_IMAGE)
                                z += 3.0f;
                            me->SummonCreature(newEntry, 5703.077f, 583.9757f, z, 3.926991f);
                        }
                    }
                }
            }
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::SellGuard(uint64 guid)
{
    if(!guid)
        return;
    Player* player = GetPlayer();
    if(!player)
        return;
    Creature* creature = player->GetMap()->GetCreature(guid);
    if(!creature)
        return;
    uint32 entry = GUID_ENPART(guid);
    if (Guards.find(guid) != Guards.end())
    {
        GuardInfo* guard = Guards[guid];
        if(QueryResult queryResult = CharacterDatabase.PQuery("SELECT creatureName, creatureEntry, creatureCost FROM custom_td_base_stats WHERE creatureEntry = '%u'", entry))
        {   
            creature->CastSpell(creature, GetSpellIdByUniqueId(5),true);
            uint32 SellPrice = guard->GetSellPrice(guard->GetLevel());
            switch(GetEventMode())
            {
            case TD_EVENT_MODE_HARD:
                SellPrice = SellPrice - (SellPrice/4);
                break;
            case TD_EVENT_MODE_EXTREME:
                SellPrice = SellPrice - (SellPrice/2);
                break;
            }
            UpdateResources(TD_EVENT_INC,SellPrice);
            SendMessageToPlayer(TD_SYSTEM_MSG_SOLD_TOWER_FOR, creature->GetName(),SellPrice);
            creature->DisappearAndDie();
            Guards.erase(guid);
        }
    } 
}
Exemple #4
0
        bool OnCheck(Player* source, Unit* /*target*/)
        {
            static uint32 const orphanEntries[6] = {14305, 14444, 22818, 22817, 33533, 33532};
            uint32 currentPet = GUID_ENPART(source->GetCritterGUID());
            for (uint8 i = 0; i < 6; ++i)
                if (currentPet == orphanEntries[i])
                    return true;

            return false;
        }
void WorldSession::HandlePageQuerySkippedOpcode(WorldPacket& recvData)
{
    IC_LOG_DEBUG("network", "WORLD: Received CMSG_PAGE_TEXT_QUERY");

    uint32 itemid;
    uint64 guid;

    recvData >> itemid >> guid;

    IC_LOG_INFO("network", "Packet Info: itemid: %u guidlow: %u guidentry: %u guidhigh: %u",
        itemid, GUID_LOPART(guid), GUID_ENPART(guid), GUID_HIPART(guid));
}
void WorldSession::HandlePageQuerySkippedOpcode(WorldPacket& recvData)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_PAGE_TEXT_QUERY");

    uint32 itemid;
    uint64 guid;

    recvData >> itemid >> guid;

    sLog->outInfo(LOG_FILTER_NETWORKIO, "Packet Info: itemid: %u guidlow: %u guidentry: %u guidhigh: %u",
        itemid, GUID_LOPART(guid), GUID_ENPART(guid), GUID_HIPART(guid));
}
Exemple #7
0
void WorldSession::HandlePageQuerySkippedOpcode( WorldPacket & recv_data )
{
    CHECK_PACKET_SIZE(recv_data,4+8);

    sLog.outDebug(  "WORLD: Received CMSG_PAGE_TEXT_QUERY" );

    uint32 itemid;
    uint64 guid;

    recv_data >> itemid >> guid;

    sLog.outDetail( "Packet Info: itemid: %u guidlow: %u guidentry: %u guidhigh: %u",
        itemid, GUID_LOPART(guid), GUID_ENPART(guid), GUID_HIPART(guid));
}
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::UpgradeGuardMenu(uint64 guid)
{
    if(!guid)
        return;
    Player *player = GetPlayer();
    if(!player)
        return;
    uint32 currentLevel = 0;
    uint32 entry = GUID_ENPART(guid);
    std::string upgradeText = "";
    if (Guards.find(guid) != Guards.end())
    {
        GuardInfo* guard = Guards[guid];
        currentLevel = guard->Level;
        uint32 newLevel = currentLevel +1;
        if(QueryResult queryResult = CharacterDatabase.PQuery("SELECT creatureName, creatureEntry, creatureCost FROM custom_td_base_stats WHERE creatureEntry = '%u'", entry))
        {
            uint32 UpgradeCost = guard->GetUpgradeCost();
            switch(GetEventMode())
            {
            case TD_EVENT_MODE_HARD:
                UpgradeCost = UpgradeCost + (UpgradeCost/4);
                break;
            case TD_EVENT_MODE_EXTREME:
                UpgradeCost = UpgradeCost + (UpgradeCost/2);
                break;
            }
            if(QueryResult queryResult = CharacterDatabase.PQuery("SELECT * FROM custom_td_base_levels WHERE creatureEntry = '%u' AND creatureLevel = '%u'", entry, newLevel))
            {
                Field* Fields = queryResult->Fetch();
                upgradeText = Fields[3].GetString();
                AddSimpleMenuItemToPlayer(player,TD_ICON_UPGRADE_GUARD,TD_GUARD_MENU_UPGRADE, GOSSIP_ACTION_INFO_DEF + 1,upgradeText.c_str(),newLevel,UpgradeCost);
            }else
                AddSimpleMenuItemToPlayer(player,TD_ICON_DOT_EVENT,TD_GUARD_MENU_UPGRADE, GOSSIP_ACTION_INFO_DEF + 1,TD_GUARD_TEXT_UPGRADE_LEVEL_MAX);
        }
    }
}
void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data)
{
    sLog->outDebug("WORLD: Recvd CMSG_SET_ACTIVE_MOVER");

    uint64 guid;
    recv_data >> guid;

    // do not re-set the active mover if it didn't change
    if (guid == _player->m_mover->GetGUID())
        return;
    // Anti-cheat check
    if (guid != _player->GetCharmGUID() && guid != _player->GetGUID())
    {
        sLog->outError("Player %s is trying to change mover to an invalid value!", _player->GetName());
        GetPlayer()->SetMover(GetPlayer());
        return;
    }

    if (GetPlayer()->IsInWorld())
    {
        if (Unit *mover = ObjectAccessor::GetUnit(*GetPlayer(), guid))
        {
            GetPlayer()->SetMover(mover);
            if (mover != GetPlayer() && mover->canFly())
            {
                WorldPacket data(SMSG_MOVE_SET_CAN_FLY, 12);
                data.append(mover->GetPackGUID());
                data << uint32(0);
                SendPacket(&data);
            }
        }
        else
        {
            sLog->outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID());
            GetPlayer()->SetMover(GetPlayer());
        }
    }
}
Exemple #10
0
void WorldSession::HandleSetActiveMoverOpcode(WorldPacket& recvPacket)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_SET_ACTIVE_MOVER");

    ObjectGuid guid;

    uint8 unk;
    unk = recvPacket.ReadBit();
    guid[6] = recvPacket.ReadBit();
    guid[7] = recvPacket.ReadBit();
    guid[3] = recvPacket.ReadBit();
    guid[1] = recvPacket.ReadBit();
    guid[2] = recvPacket.ReadBit();
    guid[4] = recvPacket.ReadBit();
    guid[5] = recvPacket.ReadBit();
    guid[0] = recvPacket.ReadBit();

    recvPacket.ReadByteSeq(guid[2]);
    recvPacket.ReadByteSeq(guid[0]);
    recvPacket.ReadByteSeq(guid[1]);
    recvPacket.ReadByteSeq(guid[5]);
    recvPacket.ReadByteSeq(guid[3]);
    recvPacket.ReadByteSeq(guid[7]);
    recvPacket.ReadByteSeq(guid[6]);
    recvPacket.ReadByteSeq(guid[4]);

    if (GetPlayer()->IsInWorld())
    {
        if (_player->m_mover->GetGUID() != guid)
            sLog->outError(LOG_FILTER_NETWORKIO, "HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, uint64(guid), GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID());
    }
}
Exemple #11
0
void WorldSession::HandlePetSetAction(WorldPacket & recvData)
{
    ;//sLog->outDetail("HandlePetSetAction. CMSG_PET_SET_ACTION");

    uint64 petguid;
    uint8  count;

    recvData >> petguid;

    Unit* checkPet = ObjectAccessor::GetUnit(*_player, petguid);
    if (!checkPet || checkPet != _player->GetFirstControlled())
    {
        sLog->outError("HandlePetSetAction: Unknown pet (GUID: %u) or pet owner (GUID: %u)", GUID_LOPART(petguid), _player->GetGUIDLow());
        return;
    }

    count = (recvData.size() == 24) ? 2 : 1;

    uint32 position[2];
    uint32 data[2];
    bool move_command = false;

    for (uint8 i = 0; i < count; ++i)
    {
        recvData >> position[i];
        recvData >> data[i];

        uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]);

        //ignore invalid position
        if (position[i] >= MAX_UNIT_ACTION_BAR_INDEX)
            return;

        // in the normal case, command and reaction buttons can only be moved, not removed
        // at moving count == 2, at removing count == 1
        // ignore attempt to remove command|reaction buttons (not possible at normal case)
        if (act_state == ACT_COMMAND || act_state == ACT_REACTION)
        {
            if (count == 1)
                return;

            move_command = true;
        }
    }

	Unit::ControlSet petsSet;
	if (checkPet->GetEntry() != GUID_ENPART(petguid))
		petsSet.insert(checkPet);
	else
		petsSet = _player->m_Controlled;

	// Xinef: loop all pets with same entry (fixes partial state change for feral spirits)
	for (Unit::ControlSet::const_iterator itr = petsSet.begin(); itr != petsSet.end(); ++itr)
	{
		Unit* pet = *itr;
		if (checkPet->GetEntry() == GUID_ENPART(petguid) && pet->GetEntry() != GUID_ENPART(petguid))
			continue;

		CharmInfo* charmInfo = pet->GetCharmInfo();
		if (!charmInfo)
		{
			sLog->outError("WorldSession::HandlePetSetAction: object (GUID: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!", pet->GetGUIDLow(), pet->GetTypeId());
			continue;
		}

		// check swap (at command->spell swap client remove spell first in another packet, so check only command move correctness)
		if (move_command)
		{
			uint8 act_state_0 = UNIT_ACTION_BUTTON_TYPE(data[0]);
			if (act_state_0 == ACT_COMMAND || act_state_0 == ACT_REACTION)
			{
				uint32 spell_id_0 = UNIT_ACTION_BUTTON_ACTION(data[0]);
				UnitActionBarEntry const* actionEntry_1 = charmInfo->GetActionBarEntry(position[1]);
				if (!actionEntry_1 || spell_id_0 != actionEntry_1->GetAction() ||
					act_state_0 != actionEntry_1->GetType())
					continue;
			}

			uint8 act_state_1 = UNIT_ACTION_BUTTON_TYPE(data[1]);
			if (act_state_1 == ACT_COMMAND || act_state_1 == ACT_REACTION)
			{
				uint32 spell_id_1 = UNIT_ACTION_BUTTON_ACTION(data[1]);
				UnitActionBarEntry const* actionEntry_0 = charmInfo->GetActionBarEntry(position[0]);
				if (!actionEntry_0 || spell_id_1 != actionEntry_0->GetAction() ||
					act_state_1 != actionEntry_0->GetType())
					continue;
			}
		}

		for (uint8 i = 0; i < count; ++i)
		{
			uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(data[i]);
			uint8 act_state = UNIT_ACTION_BUTTON_TYPE(data[i]);

			//if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
			if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
			{
				if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id))
				{
					//sign for autocast
					if (act_state == ACT_ENABLED)
					{
						if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet())
							((Pet*)pet)->ToggleAutocast(spellInfo, true);
						else
							for (Unit::ControlSet::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
								if ((*itr)->GetEntry() == pet->GetEntry())
									(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, true);
					}
					//sign for no/turn off autocast
					else if (act_state == ACT_DISABLED)
					{
						if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet())
							((Pet*)pet)->ToggleAutocast(spellInfo, false);
						else
							for (Unit::ControlSet::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
								if ((*itr)->GetEntry() == pet->GetEntry())
									(*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, false);
					}
				}

				charmInfo->SetActionBar(position[i], spell_id, ActiveStates(act_state));
			}
		}
	}
}
Exemple #12
0
void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recvData)
{
    ;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_SET_ACTIVE_MOVER");

    uint64 guid;
    recvData >> guid;

    if (GetPlayer()->IsInWorld() && _player->m_mover && _player->m_mover->IsInWorld())
    {
        if (_player->m_mover->GetGUID() != guid)
            sLog->outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID());
    }
}
void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recvData)
{
    TC_LOG_DEBUG("network", "WORLD: Recvd CMSG_SET_ACTIVE_MOVER");

    uint64 guid;
    recvData >> guid;

    if (GetPlayer()->IsInWorld())
    {
        if (_player->m_mover->GetGUID() != guid)
            TC_LOG_ERROR("network", "HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID());
    }
}
Exemple #14
0
void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID, bool canComplete, bool closeOnCancel) const
{
    // We can always call to RequestItems, but this packet only goes out if there are actually
    // items.  Otherwise, we'll skip straight to the OfferReward

    std::string questTitle = quest->GetTitle();
    std::string requestItemsText = quest->GetRequestItemsText();

    uint32 itemCount = quest->GetQuestObjectiveCountType(QUEST_OBJECTIVE_TYPE_ITEM);
    uint32 currencyCount = quest->GetQuestObjectiveCountType(QUEST_OBJECTIVE_TYPE_CURRENCY);
    uint32 moneyCount = quest->GetQuestObjectiveCountType(QUEST_OBJECTIVE_TYPE_MONEY);
    if (!itemCount && !currencyCount && !moneyCount && canComplete)
    {
        SendQuestGiverOfferReward(quest, npcGUID, true);
        return;
    }

    int32 locale = _session->GetSessionDbLocaleIndex();
    if (locale >= 0)
    {
        if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
        {
            ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
            ObjectMgr::GetLocaleString(localeData->RequestItemsText, locale, requestItemsText);
        }
    }

    uint32 requiredMoney = 0;
    ByteBuffer currencyData, itemData;
    for (const auto &questObjective : quest->m_questObjectives)
    {
        switch (questObjective->Type)
        {
            case QUEST_OBJECTIVE_TYPE_ITEM:
            {
                if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(questObjective->ObjectId))
                    itemData << uint32(itemTemplate->DisplayInfoID);
                else
                    itemData << uint32(0);

                itemData << uint32(questObjective->Amount);
                itemData << uint32(questObjective->ObjectId);

                break;
            }
            case QUEST_OBJECTIVE_TYPE_CURRENCY:
            {
                currencyData << uint32(questObjective->Amount);
                currencyData << uint32(questObjective->ObjectId);

                break;
            }
            case QUEST_OBJECTIVE_TYPE_MONEY:
            {
                requiredMoney = questObjective->Amount;
                break;
            }
            default:
                break;
        }
    }

    ObjectGuid guid = npcGUID;

    WorldPacket data(SMSG_QUESTGIVER_REQUEST_ITEMS, 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 1 + 8 + 8 +
        questTitle.size() + requestItemsText.size() + itemCount * (4 + 4 + 4) + currencyCount * (4 + 4));

    data << uint32(0);
    data << uint32(canComplete ? quest->GetCompleteEmote() : quest->GetIncompleteEmote());
    data << uint32(quest->GetFlags());
    data << uint32(quest->GetQuestId());
    data << uint32(GUID_ENPART(npcGUID));
    data << uint32(requiredMoney);
    data << uint32(0);
    data << uint32(canComplete ? 0x5F : 0x5B);              // status flags
    data << uint32(0);

    data.WriteBit(closeOnCancel);
    data.WriteBitSeq<5, 1, 0>(guid);
    data.WriteBits(requestItemsText.size(), 12);
    data.WriteBitSeq<4>(guid);
    data.WriteBits(currencyCount, 21);
    data.WriteBits(itemCount, 20);
    data.WriteBitSeq<3, 2, 6, 7>(guid);
    data.WriteBits(questTitle.size(), 9);
    data.FlushBits();

    data.WriteByteSeq<6>(guid);
    data.append(itemData);
    data.WriteString(questTitle);
    data.append(currencyData);
    data.WriteByteSeq<4>(guid);
    data.WriteString(requestItemsText);
    data.WriteByteSeq<0, 7, 2, 5, 1, 3>(guid);

    _session->SendPacket(&data);
    TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid=%u, questid=%u", GUID_LOPART(npcGUID), quest->GetQuestId());
}
Exemple #15
0
void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_SET_ACTIVE_MOVER");

    uint64 guid;
    recv_data >> guid;

    if (GetPlayer()->IsInWorld())
    {
        if (Unit* mover = ObjectAccessor::GetUnit(*GetPlayer(), guid))
        {
            GetPlayer()->SetMover(mover);
            if (mover != GetPlayer() && mover->canFly())
            {
                WorldPacket data(SMSG_MOVE_SET_CAN_FLY, 12);
                data.append(mover->GetPackGUID());
                data << uint32(0);
                SendPacket(&data);
            }
        }
        else
        {
            sLog->outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID());
            GetPlayer()->SetMover(GetPlayer());
        }
    }
}
void WorldSession::HandleSetActiveMoverOpcode(WorldPacket& recvPacket)
{
    TC_LOG_DEBUG("network", "WORLD: Recvd CMSG_SET_ACTIVE_MOVER");

    ObjectGuid guid;

    guid[7] = recvPacket.ReadBit();
    guid[2] = recvPacket.ReadBit();
    guid[1] = recvPacket.ReadBit();
    guid[0] = recvPacket.ReadBit();
    guid[4] = recvPacket.ReadBit();
    guid[5] = recvPacket.ReadBit();
    guid[6] = recvPacket.ReadBit();
    guid[3] = recvPacket.ReadBit();

    recvPacket.ReadByteSeq(guid[3]);
    recvPacket.ReadByteSeq(guid[2]);
    recvPacket.ReadByteSeq(guid[4]);
    recvPacket.ReadByteSeq(guid[0]);
    recvPacket.ReadByteSeq(guid[5]);
    recvPacket.ReadByteSeq(guid[1]);
    recvPacket.ReadByteSeq(guid[6]);
    recvPacket.ReadByteSeq(guid[7]);

    if (GetPlayer()->IsInWorld())
    {
        if (_player->m_mover->GetGUID() != guid)
            TC_LOG_ERROR("network", "HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, uint64(guid), GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID());
    }
}
void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_SET_ACTIVE_MOVER");

    uint64 guid;
    recv_data >> guid;

   // do not reset the active mover if it didn't change
   if (guid == _player->_mover->GetGUID())
       return;
   // Anti-cheat check
   if (guid != _player->GetCharmGUID() && guid != _player->GetGUID())
   {
       sLog->outError("Player %s is trying to change mover to an invalid value!", _player->GetName());
        GetPlayer()->SetMover(GetPlayer());
       return;
   }

    if (GetPlayer()->IsInWorld())
    {
        if (_player->_mover->GetGUID() != guid)
        {
            sLog->outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->_mover->GetGUID());
            GetPlayer()->SetMover(GetPlayer());
        }
    }
}
Exemple #18
0
void TowerDefenseInstanceScript::TowerDefenseMapInstanceScript::UpgradeGuard(uint64 guid)
{
    if(!guid)
        return;
    Player* player = GetPlayer();
    if(!player)
        return;

    Creature* creature = player->GetMap()->GetCreature(guid);
    if(!creature)
        return;
    uint32 currentLevel = 0;
    uint32 entry = GUID_ENPART(guid);
    if (Guards.find(guid) != Guards.end())
    {
        GuardInfo* guard = Guards[guid];
        currentLevel = guard->Level;
        uint32 newLevel = currentLevel +1;
        if(QueryResult queryResult = CharacterDatabase.PQuery("SELECT creatureName, creatureEntry, creatureCost FROM custom_td_base_stats WHERE creatureEntry = '%u'", entry))
        {   
            uint32 UpgradeCost = guard->GetUpgradeCost();
            switch(GetEventMode())
            {
            case TD_EVENT_MODE_HARD:
                UpgradeCost = UpgradeCost + (UpgradeCost/4);
                break;
            case TD_EVENT_MODE_EXTREME:
                UpgradeCost = UpgradeCost + (UpgradeCost/2);
                break;
            }
            if(GetResources() < UpgradeCost){
                SendMessageToPlayer(TD_SYSTEM_MSG_MORE_RESOURCES_UPG, UpgradeCost - GetResources());
                return;
            }
            if(QueryResult queryResult = CharacterDatabase.PQuery("SELECT * FROM custom_td_base_levels WHERE creatureEntry = '%u' AND creatureLevel = '%u'", entry, newLevel))
            {
                creature->CastSpell(creature, GetSpellIdByUniqueId(4),true); // upgrade level visual
                guard->SetLevel(newLevel);
                UpdateResources(TD_EVENT_DEC,UpgradeCost); // remove resource cost from player
                creature->RemoveAllAuras(); // remove all auras to apply new ones.
                SendMessageToPlayer(TD_SYSTEM_MSG_UPGRADED_TOWER_FOR, creature->GetName(),UpgradeCost);

                Field* Fields = queryResult->Fetch();

                uint32 newDefaultSpell = Fields[4].GetUInt32();
                if(newDefaultSpell)
                    guard->SetDefSpell(newDefaultSpell);

                uint32 newAttackSpeed = Fields[9].GetUInt32();
                if (newAttackSpeed)
                    guard->SetAttSpeed(newAttackSpeed);

                float newAttackDistance = Fields[8].GetFloat();
                if(newAttackDistance)
                    guard->SetAttackDistance(newAttackDistance);

                uint32 newAura = Fields[7].GetUInt32();
                if(newAura)
                    creature->CastSpell(creature,newAura,true);

                uint32 newDisplay = Fields[6].GetUInt32();
                if(newDisplay)
                    creature->SetDisplayId(newDisplay);

                float  newScale = Fields[5].GetFloat();
                if(newScale)
                    creature->SetObjectScale(newScale);

                uint32 newDamage = Fields[10].GetUInt32();
                if (newDamage)
                    guard->SetDamage(newDamage);

                uint32 newIsAntiAir = Fields[11].GetBool();
                if (newIsAntiAir)
                    guard->SetIsAntiAir(newIsAntiAir);

                uint32 newIsAntiGround = Fields[12].GetBool();
                if (newIsAntiGround)
                    guard->SetIsAntiGround(newIsAntiGround);
            }
        }
    } 
}
void WorldSession::HandleGravityAckMessage(WorldPacket& recvData)
{
    MovementInfo movementInfo;
    GetPlayer()->ReadMovementInfo(recvData, &movementInfo);
    if (movementInfo.guid != _player->m_mover->GetGUID())
        TC_LOG_ERROR("network", "HandleGravityAckMessage: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, uint64(movementInfo.guid), GetLogNameForGuid(movementInfo.guid), GUID_ENPART(movementInfo.guid), _player->m_mover->GetGUID());

}