diff options
| author | Nay <dnpd.dd@gmail.com> | 2011-09-05 15:18:12 +0100 |
|---|---|---|
| committer | Nay <dnpd.dd@gmail.com> | 2011-09-05 15:20:02 +0100 |
| commit | fd3bd4c49d511569fcd19826eaa38c69696db1d4 (patch) | |
| tree | cbc225cbfaa5cfed6fa7d05863c10a9c75c10498 /src/server/game/Entities | |
| parent | 99935fd98c71dc8939bb5be1c2bb7656147a2211 (diff) | |
Core/Quests: Implement quests that require PlayerSlain. Closes #169
Diffstat (limited to 'src/server/game/Entities')
| -rwxr-xr-x | src/server/game/Entities/Player/Player.cpp | 84 | ||||
| -rwxr-xr-x | src/server/game/Entities/Player/Player.h | 2 |
2 files changed, 79 insertions, 7 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 063127c77a9..f06386a842f 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -539,8 +539,13 @@ void KillRewarder::_RewardPlayer(Player* player, bool isDungeon) { // 4. Reward player. if (!_isBattleGround) + { // 4.1. Give honor (player must be alive and not on BG). _RewardHonor(player); + // 4.1.1 Send player killcredit for quests with PlayerSlain + if (_victim->GetTypeId() == TYPEID_PLAYER) + player->KilledPlayerCredit(); + } // Give XP only in PvE or in battlegrounds. // Give reputation and kill credit only in PvE. if (!_isPvP || _isBattleGround) @@ -14610,6 +14615,10 @@ bool Player::CanCompleteQuest(uint32 quest_id) } } + if (qInfo->HasFlag(QUEST_TRINITY_FLAGS_PLAYER_KILL)) + if (qInfo->GetPlayersSlain() != 0 && q_status.m_playercount < qInfo->GetPlayersSlain()) + return false; + if (qInfo->HasFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT) && !q_status.m_explored) return false; @@ -14753,6 +14762,9 @@ void Player::AddQuest(Quest const *pQuest, Object *questGiver) questStatusData.m_creatureOrGOcount[i] = 0; } + if (pQuest->HasFlag(QUEST_TRINITY_FLAGS_PLAYER_KILL)) + questStatusData.m_playercount = 0; + GiveQuestSourceItem(pQuest); AdjustQuestReqItemCount(pQuest, questStatusData); @@ -15816,6 +15828,46 @@ void Player::KilledMonsterCredit(uint32 entry, uint64 guid) } } +void Player::KilledPlayerCredit() +{ + uint16 addkillcount = 1; + + for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i) + { + uint32 questid = GetQuestSlotQuestId(i); + if (!questid) + continue; + + Quest const* qInfo = sObjectMgr->GetQuestTemplate(questid); + if (!qInfo) + continue; + // just if !ingroup || !noraidgroup || raidgroup + QuestStatusData& q_status = m_QuestStatus[questid]; + if (q_status.m_status == QUEST_STATUS_INCOMPLETE && (!GetGroup() || !GetGroup()->isRaidGroup() || qInfo->IsAllowedInRaid())) + { + if (qInfo->HasFlag(QUEST_TRINITY_FLAGS_PLAYER_KILL)) + { + uint32 reqkill = qInfo->GetPlayersSlain(); + uint16 curkill = q_status.m_playercount; + + if (curkill < reqkill) + { + q_status.m_playercount = curkill + addkillcount; + + m_QuestStatusSave[questid] = true; + + SendQuestUpdateAddPlayer(qInfo, curkill, addkillcount); + } + + if (CanCompleteQuest(questid)) + CompleteQuest(questid); + + break; + } + } + } +} + void Player::CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id) { bool isCreature = IS_CRE_OR_VEH_GUID(guid); @@ -16231,6 +16283,22 @@ void Player::SendQuestUpdateAddCreatureOrGo(Quest const* pQuest, uint64 guid, ui SetQuestSlotCounter(log_slot, creatureOrGO_idx, GetQuestSlotCounter(log_slot, creatureOrGO_idx)+add_count); } +void Player::SendQuestUpdateAddPlayer(Quest const* pQuest, uint16 old_count, uint16 add_count) +{ + ASSERT(old_count + add_count < 65536 && "player count store in 16 bits"); + + WorldPacket data(SMSG_QUESTUPDATE_ADD_PVP_KILL, (3*4)); + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Sent SMSG_QUESTUPDATE_ADD_PVP_KILL"); + data << uint32(pQuest->GetQuestId()); + data << uint32(old_count + add_count); + data << uint32(pQuest->GetPlayersSlain()); + GetSession()->SendPacket(&data); + + uint16 log_slot = FindQuestSlot(pQuest->GetQuestId()); + if (log_slot < MAX_QUEST_LOG_SIZE) + SetQuestSlotCounter(log_slot, QUEST_PVP_KILL_SLOT, GetQuestSlotCounter(log_slot, QUEST_PVP_KILL_SLOT) + add_count); +} + /*********************************************************/ /*** LOAD SYSTEM ***/ /*********************************************************/ @@ -17574,8 +17642,8 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) //// 0 1 2 3 4 5 6 7 8 9 10 //QueryResult *result = CharacterDatabase.PQuery("SELECT quest, status, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, - // 11 - // itemcount4 FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); + // 11 12 + // itemcount4, playercount FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); if (result) { @@ -17624,6 +17692,7 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) questStatusData.m_itemcount[1] = fields[9].GetUInt16(); questStatusData.m_itemcount[2] = fields[10].GetUInt16(); questStatusData.m_itemcount[3] = fields[11].GetUInt16(); + questStatusData.m_playercount = fields[12].GetUInt16(); // add to quest log if (slot < MAX_QUEST_LOG_SIZE && questStatusData.m_status != QUEST_STATUS_NONE) @@ -17639,6 +17708,9 @@ void Player::_LoadQuestStatus(PreparedQueryResult result) if (questStatusData.m_creatureOrGOcount[idx]) SetQuestSlotCounter(slot, idx, questStatusData.m_creatureOrGOcount[idx]); + if (questStatusData.m_playercount) + SetQuestSlotCounter(slot, QUEST_PVP_KILL_SLOT, questStatusData.m_playercount); + ++slot; } @@ -18676,11 +18748,9 @@ void Player::_SaveQuestStatus(SQLTransaction& trans) { statusItr = m_QuestStatus.find(saveItr->first); if (statusItr != m_QuestStatus.end() && (keepAbandoned || statusItr->second.m_status != QUEST_STATUS_NONE)) - { - trans->PAppend("REPLACE INTO character_queststatus (guid, quest, status, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4) " - "VALUES ('%u', '%u', '%u', '%u', '" UI64FMTD "', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')", - GetGUIDLow(), statusItr->first, statusItr->second.m_status, statusItr->second.m_explored, uint64(statusItr->second.m_timer / IN_MILLISECONDS+ sWorld->GetGameTime()), statusItr->second.m_creatureOrGOcount[0], statusItr->second.m_creatureOrGOcount[1], statusItr->second.m_creatureOrGOcount[2], statusItr->second.m_creatureOrGOcount[3], statusItr->second.m_itemcount[0], statusItr->second.m_itemcount[1], statusItr->second.m_itemcount[2], statusItr->second.m_itemcount[3]); - } + trans->PAppend("REPLACE INTO character_queststatus (guid, quest, status, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4, playercount) " + "VALUES ('%u', '%u', '%u', '%u', '" UI64FMTD "', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')", + GetGUIDLow(), statusItr->first, statusItr->second.m_status, statusItr->second.m_explored, uint64(statusItr->second.m_timer / IN_MILLISECONDS+ sWorld->GetGameTime()), statusItr->second.m_creatureOrGOcount[0], statusItr->second.m_creatureOrGOcount[1], statusItr->second.m_creatureOrGOcount[2], statusItr->second.m_creatureOrGOcount[3], statusItr->second.m_itemcount[0], statusItr->second.m_itemcount[1], statusItr->second.m_itemcount[2], statusItr->second.m_itemcount[3], statusItr->second.m_playercount); } else trans->PAppend("DELETE FROM character_queststatus WHERE guid = %u AND quest = %u", GetGUIDLow(), saveItr->first); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 9a0f35313f6..3d19fe65f19 100755 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1462,6 +1462,7 @@ class Player : public Unit, public GridObject<Player> void ItemRemovedQuestCheck(uint32 entry, uint32 count); void KilledMonster(CreatureTemplate const* cInfo, uint64 guid); void KilledMonsterCredit(uint32 entry, uint64 guid); + void KilledPlayerCredit(); void CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id); void TalkedToCreature(uint32 entry, uint64 guid); void MoneyChanged(uint32 value); @@ -1481,6 +1482,7 @@ class Player : public Unit, public GridObject<Player> void SendPushToPartyResponse(Player *pPlayer, uint32 msg); void SendQuestUpdateAddItem(Quest const* pQuest, uint32 item_idx, uint16 count); void SendQuestUpdateAddCreatureOrGo(Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint16 old_count, uint16 add_count); + void SendQuestUpdateAddPlayer(Quest const* pQuest, uint16 old_count, uint16 add_count); uint64 GetDivider() { return m_divider; } void SetDivider(uint64 guid) { m_divider = guid; } |
