*Destroy quest items on quest failure, and some cleanup.
--HG-- branch : trunk
This commit is contained in:
@@ -108,7 +108,7 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
|
||||
}
|
||||
}
|
||||
|
||||
bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker)
|
||||
bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker /*=NULL*/)
|
||||
{
|
||||
if (!pHolder.Enabled || pHolder.Time)
|
||||
return false;
|
||||
@@ -336,7 +336,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
||||
return false;
|
||||
|
||||
//Process actions
|
||||
for (uint32 j = 0; j < MAX_ACTIONS; j++)
|
||||
for (uint8 j = 0; j < MAX_ACTIONS; ++j)
|
||||
ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker);
|
||||
|
||||
return true;
|
||||
@@ -1017,7 +1017,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
|
||||
if (!bEmptyList)
|
||||
{
|
||||
//Events are only updated once every EVENT_UPDATE_TIME ms to prevent lag with large amount of events
|
||||
if (EventUpdateTime < diff)
|
||||
if (EventUpdateTime <= diff)
|
||||
{
|
||||
EventDiff += diff;
|
||||
|
||||
@@ -1027,7 +1027,7 @@ void CreatureEventAI::UpdateAI(const uint32 diff)
|
||||
//Decrement Timers
|
||||
if ((*i).Time)
|
||||
{
|
||||
if ((*i).Time > EventDiff)
|
||||
if (EventDiff <= (*i).Time)
|
||||
{
|
||||
//Do not decrement timers if event cannot trigger in this phase
|
||||
if (!((*i).Event.event_inverse_phase_mask & (1 << Phase)))
|
||||
|
||||
@@ -351,8 +351,8 @@ bool LootItem::AllowedForPlayer(Player const * player) const
|
||||
else
|
||||
{
|
||||
// Not quest only drop (check quest starting items for already accepted non-repeatable quests)
|
||||
ItemPrototype const *pProto = objmgr.GetItemPrototype(itemid);
|
||||
if (pProto && pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE && !player->HasQuestForItem(itemid))
|
||||
if (ItemPrototype const *pProto = objmgr.GetItemPrototype(itemid))
|
||||
if (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE && !player->HasQuestForItem(itemid))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+30
-24
@@ -11169,8 +11169,7 @@ void Player::RemoveItem( uint8 bag, uint8 slot, bool update )
|
||||
}
|
||||
else
|
||||
{
|
||||
Bag *pBag = (Bag*)GetItemByPos( INVENTORY_SLOT_BAG_0, bag );
|
||||
if( pBag )
|
||||
if (Bag *pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag))
|
||||
pBag->RemoveItem(slot, update);
|
||||
}
|
||||
pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0);
|
||||
@@ -11275,7 +11274,6 @@ void Player::DestroyItem( uint8 bag, uint8 slot, bool update )
|
||||
|
||||
if (slot == EQUIPMENT_SLOT_MAINHAND)
|
||||
UpdateExpertise(BASE_ATTACK);
|
||||
|
||||
else if (slot == EQUIPMENT_SLOT_OFFHAND)
|
||||
UpdateExpertise(OFF_ATTACK);
|
||||
|
||||
@@ -11310,7 +11308,7 @@ void Player::DestroyItemCount( uint32 item, uint32 count, bool update, bool uneq
|
||||
uint32 remcount = 0;
|
||||
|
||||
// in inventory
|
||||
for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++)
|
||||
for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
|
||||
{
|
||||
if (Item* pItem = GetItemByPos( INVENTORY_SLOT_BAG_0, i ))
|
||||
{
|
||||
@@ -13146,11 +13144,9 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver
|
||||
|
||||
uint32 quest_id = pQuest->GetQuestId();
|
||||
|
||||
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++ )
|
||||
{
|
||||
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
|
||||
if (pQuest->ReqItemId[i])
|
||||
DestroyItemCount( pQuest->ReqItemId[i], pQuest->ReqItemCount[i], true);
|
||||
}
|
||||
|
||||
TakeQuestSourceItem(quest_id, true); // take quest src item from player on completing quest
|
||||
|
||||
@@ -13382,6 +13378,11 @@ void Player::FailQuest(uint32 questId)
|
||||
}
|
||||
else
|
||||
SendQuestFailed(questId);
|
||||
|
||||
// Destroy quest items on quest failure.
|
||||
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
|
||||
if (pQuest->ReqItemId[i] > 0 && pQuest->ReqItemCount[i] > 0)
|
||||
DestroyItemCount(pQuest->ReqItemId[i], pQuest->ReqItemCount[i], true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13845,14 +13846,14 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status)
|
||||
UpdateForQuestWorldObjects();
|
||||
}
|
||||
|
||||
// not used in TrinIty, but used in scripting code
|
||||
// not used in Trinity, but used in scripting code
|
||||
uint32 Player::GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry)
|
||||
{
|
||||
Quest const* qInfo = objmgr.GetQuestTemplate(quest_id);
|
||||
if (!qInfo)
|
||||
return 0;
|
||||
|
||||
for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
|
||||
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
|
||||
if ( qInfo->ReqCreatureOrGOId[j] == entry )
|
||||
return mQuestStatus[quest_id].m_creatureOrGOcount[j];
|
||||
|
||||
@@ -13871,7 +13872,8 @@ void Player::AdjustQuestReqItemCount( Quest const* pQuest, QuestStatusData& ques
|
||||
uint32 curitemcount = GetItemCount(pQuest->ReqItemId[i],true);
|
||||
|
||||
questStatusData.m_itemcount[i] = std::min(curitemcount, reqitemcount);
|
||||
if (questStatusData.uState != QUEST_NEW) questStatusData.uState = QUEST_CHANGED;
|
||||
if (questStatusData.uState != QUEST_NEW)
|
||||
questStatusData.uState = QUEST_CHANGED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13942,7 +13944,7 @@ void Player::ItemAddedQuestCheck( uint32 entry, uint32 count )
|
||||
if( !qInfo || !qInfo->HasFlag(QUEST_TRINITY_FLAGS_DELIVER))
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++)
|
||||
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
|
||||
{
|
||||
uint32 reqitem = qInfo->ReqItemId[j];
|
||||
if (reqitem == entry)
|
||||
@@ -13951,7 +13953,7 @@ void Player::ItemAddedQuestCheck( uint32 entry, uint32 count )
|
||||
uint32 curitemcount = q_status.m_itemcount[j];
|
||||
if (curitemcount < reqitemcount)
|
||||
{
|
||||
uint32 additemcount = ( curitemcount + count <= reqitemcount ? count : reqitemcount - curitemcount);
|
||||
uint32 additemcount = curitemcount + count <= reqitemcount ? count : reqitemcount - curitemcount;
|
||||
q_status.m_itemcount[j] += additemcount;
|
||||
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
|
||||
|
||||
@@ -13979,7 +13981,7 @@ void Player::ItemRemovedQuestCheck( uint32 entry, uint32 count )
|
||||
if( !qInfo->HasFlag(QUEST_TRINITY_FLAGS_DELIVER))
|
||||
continue;
|
||||
|
||||
for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++)
|
||||
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
|
||||
{
|
||||
uint32 reqitem = qInfo->ReqItemId[j];
|
||||
if (reqitem == entry)
|
||||
@@ -13994,9 +13996,10 @@ void Player::ItemRemovedQuestCheck( uint32 entry, uint32 count )
|
||||
curitemcount = GetItemCount(entry,true);
|
||||
if (curitemcount < reqitemcount + count)
|
||||
{
|
||||
uint32 remitemcount = ( curitemcount <= reqitemcount ? count : count + reqitemcount - curitemcount);
|
||||
uint32 remitemcount = curitemcount <= reqitemcount ? count : count + reqitemcount - curitemcount;
|
||||
q_status.m_itemcount[j] = curitemcount - remitemcount;
|
||||
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
|
||||
if (q_status.uState != QUEST_NEW)
|
||||
q_status.uState = QUEST_CHANGED;
|
||||
|
||||
IncompleteQuest(questid);
|
||||
}
|
||||
@@ -14012,7 +14015,7 @@ void Player::KilledMonster( CreatureInfo const* cInfo, uint64 guid )
|
||||
if (cInfo->Entry)
|
||||
KilledMonsterCredit(cInfo->Entry,guid);
|
||||
|
||||
for (int i = 0; i < MAX_KILL_CREDIT; ++i)
|
||||
for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
|
||||
if (cInfo->KillCredit[i])
|
||||
KilledMonsterCredit(cInfo->KillCredit[i],guid);
|
||||
}
|
||||
@@ -14044,7 +14047,7 @@ void Player::KilledMonsterCredit( uint32 entry, uint64 guid )
|
||||
{
|
||||
if (qInfo->HasFlag( QUEST_TRINITY_FLAGS_KILL_OR_CAST))
|
||||
{
|
||||
for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++)
|
||||
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
|
||||
{
|
||||
// skip GO activate objective or none
|
||||
if (qInfo->ReqCreatureOrGOId[j] <= 0)
|
||||
@@ -14063,7 +14066,8 @@ void Player::KilledMonsterCredit( uint32 entry, uint64 guid )
|
||||
if (curkillcount < reqkillcount)
|
||||
{
|
||||
q_status.m_creatureOrGOcount[j] = curkillcount + addkillcount;
|
||||
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
|
||||
if (q_status.uState != QUEST_NEW)
|
||||
q_status.uState = QUEST_CHANGED;
|
||||
|
||||
SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, curkillcount, addkillcount);
|
||||
}
|
||||
@@ -14100,7 +14104,7 @@ void Player::CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id )
|
||||
{
|
||||
if (qInfo->HasFlag( QUEST_TRINITY_FLAGS_KILL_OR_CAST))
|
||||
{
|
||||
for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++)
|
||||
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
|
||||
{
|
||||
// skip kill creature objective (0) or wrong spell casts
|
||||
if (qInfo->ReqSpell[j] != spell_id)
|
||||
@@ -14132,7 +14136,8 @@ void Player::CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id )
|
||||
if (curCastCount < reqCastCount)
|
||||
{
|
||||
q_status.m_creatureOrGOcount[j] = curCastCount + addCastCount;
|
||||
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
|
||||
if (q_status.uState != QUEST_NEW)
|
||||
q_status.uState = QUEST_CHANGED;
|
||||
|
||||
SendQuestUpdateAddCreatureOrGo(qInfo, guid, j, curCastCount, addCastCount);
|
||||
}
|
||||
@@ -14167,7 +14172,7 @@ void Player::TalkedToCreature( uint32 entry, uint64 guid )
|
||||
{
|
||||
if (qInfo->HasFlag(QUEST_TRINITY_FLAGS_KILL_OR_CAST | QUEST_TRINITY_FLAGS_SPEAKTO))
|
||||
{
|
||||
for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++)
|
||||
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
|
||||
{
|
||||
// skip spell casts and Gameobject objectives
|
||||
if (qInfo->ReqSpell[j] > 0 || qInfo->ReqCreatureOrGOId[j] < 0)
|
||||
@@ -14188,7 +14193,8 @@ void Player::TalkedToCreature( uint32 entry, uint64 guid )
|
||||
if (curTalkCount < reqTalkCount)
|
||||
{
|
||||
q_status.m_creatureOrGOcount[j] = curTalkCount + addTalkCount;
|
||||
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
|
||||
if (q_status.uState != QUEST_NEW)
|
||||
q_status.uState = QUEST_CHANGED;
|
||||
|
||||
SendQuestUpdateAddCreatureOrGo(qInfo, guid, j, curTalkCount, addTalkCount);
|
||||
}
|
||||
@@ -14289,13 +14295,13 @@ bool Player::HasQuestForItem( uint32 itemid ) const
|
||||
|
||||
// There should be no mixed ReqItem/ReqSource drop
|
||||
// This part for ReqItem drop
|
||||
for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++)
|
||||
for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j)
|
||||
{
|
||||
if (itemid == qinfo->ReqItemId[j] && q_status.m_itemcount[j] < qinfo->ReqItemCount[j])
|
||||
return true;
|
||||
}
|
||||
// This part - for ReqSource
|
||||
for (int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; j++)
|
||||
for (uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j)
|
||||
{
|
||||
// examined item is a source item
|
||||
if (qinfo->ReqSourceId[j] == itemid)
|
||||
|
||||
Reference in New Issue
Block a user