本文整理汇总了C++中QuestLogEntry::Finish方法的典型用法代码示例。如果您正苦于以下问题:C++ QuestLogEntry::Finish方法的具体用法?C++ QuestLogEntry::Finish怎么用?C++ QuestLogEntry::Finish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuestLogEntry
的用法示例。
在下文中一共展示了QuestLogEntry::Finish方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleQuestlogRemoveQuestOpcode
void WorldSession::HandleQuestlogRemoveQuestOpcode(WorldPacket& recvPacket)
{
sLog.outDebug( "WORLD: Recieved CMSG_QUESTLOG_REMOVE_QUEST" );
uint8 quest_slot;
recvPacket >> quest_slot;
if(quest_slot >= 25)
return;
QuestLogEntry *qEntry = GetPlayer()->GetQuestLogInSlot(quest_slot);
if (!qEntry)
{
sLog.outDebug("WORLD: No quest in slot %d.", quest_slot);
return;
}
Quest *qPtr = qEntry->GetQuest();
qEntry->Finish();
// Remove all items given by the questgiver at the beginning
for(uint32 i = 0; i < 4; ++i)
{
if(qPtr->receive_items[i])
GetPlayer()->GetItemInterface()->RemoveItemAmt( qPtr->receive_items[i], 1 );
}
if(qPtr->time > 0)
{
GetPlayer()->timed_quest_slot = 0;
}
GetPlayer()->UpdateNearbyGameObjects();
}
示例2: HandleQuestlogRemoveQuestOpcode
void WorldSession::HandleQuestlogRemoveQuestOpcode(WorldPacket& recvPacket)
{
CHECK_INWORLD_RETURN;
DEBUG_LOG( "QuestHandler","Received CMSG_QUESTLOG_REMOVE_QUEST" );
uint8 quest_slot;
recvPacket >> quest_slot;
if(quest_slot >= 25)
return;
QuestLogEntry *qEntry = _player->GetQuestLogInSlot(quest_slot);
if (!qEntry)
{
DEBUG_LOG("QuestHandler","No quest in slot %d.", quest_slot);
return;
}
Quest *qPtr = qEntry->GetQuest();
if (!qPtr)
{
DEBUG_LOG("QuestHandler","Quest %u does not exist in database", qPtr->id);
return;
}
CALL_QUESTSCRIPT_EVENT(qPtr->id, OnQuestCancel)(_player);
qEntry->Finish();
// Remove all items given by the questgiver at the beginning
for(uint32 i = 0; i < 4; i++)
{
if(qPtr->receive_items[i])
_player->GetItemInterface()->RemoveItemAmt( qPtr->receive_items[i], 1 );
}
// Remove source item
if(qPtr->srcitem)
_player->GetItemInterface()->RemoveItemAmt( qPtr->srcitem, 1 );
// Reset timed quests, remove timed event
if(qPtr->time > 0)
{
if (sEventMgr.HasEvent(_player,EVENT_TIMED_QUEST_EXPIRE))
sEventMgr.RemoveEvents(_player, EVENT_TIMED_QUEST_EXPIRE);
}
if(qPtr->start_phase != 0)
{
if(_player->GetPhaseMask() == (int32)qPtr->start_phase)
_player->SetPhaseMask(_player->LastPhase, true);
}
_player->UpdateNearbyGameObjects();
sHookInterface.OnQuestCancelled(_player, qPtr);
_player->SaveToDB(false);
}
示例3: RemoveQuestFromPlayer
string RemoveQuestFromPlayer(Player* plr, Quest *qst)
{
std::string recout = "|cff00ff00";
bool has = false;
if ( plr->HasFinishedQuest(qst->id) )
{
if( plr->m_finishedQuests.find(qst->id) != plr->m_finishedQuests.end())
{
plr->m_finishedQuests.erase(qst->id);
recout += "Quest removed from finished quests history.\n\n";
has = true;
}
}
if ( plr->HasFinishedDailyQuest(qst->id) )
{
if( plr->m_finishedDailyQuests.find(qst->id) != plr->m_finishedDailyQuests.end())
{
plr->m_finishedDailyQuests.erase(qst->id);
recout += "Quest removed from finished dailies history.\n\n";
has = true;
}
}
if (plr->HasQuests())
{
QuestLogEntry * qLogEntry = plr->GetQuestLogForEntry(qst->id);
if (qLogEntry)
{
CALL_QUESTSCRIPT_EVENT(qLogEntry, OnQuestCancel)(plr);
qLogEntry->Finish();
// Remove all items given by the questgiver at the beginning
for(uint32 i = 0; i < 4; ++i)
{
if(qst->receive_items[i])
plr->GetItemInterface()->RemoveItemAmt(qst->receive_items[i], 1 );
}
plr->UpdateNearbyGameObjects();
}
recout += "Quest removed from current questlog.";
has = true;
}
if(!has)
recout += "Quest not found on player.";
recout += "\n\n";
return recout;
}
示例4: HandleQuestlogRemoveQuestOpcode
void WorldSession::HandleQuestlogRemoveQuestOpcode(WorldPacket & recvPacket)
{
CHECK_INWORLD_RETURN
LOG_DEBUG("WORLD: Received CMSG_QUESTLOG_REMOVE_QUEST");
uint8 quest_slot;
recvPacket >> quest_slot;
if(quest_slot >= 25)
return;
QuestLogEntry* qEntry = GetPlayer()->GetQuestLogInSlot(quest_slot);
if(!qEntry)
{
LOG_DEBUG("WORLD: No quest in slot %d.", quest_slot);
return;
}
Quest* qPtr = qEntry->GetQuest();
CALL_QUESTSCRIPT_EVENT(qEntry, OnQuestCancel)(GetPlayer());
qEntry->Finish();
// Remove all items given by the questgiver at the beginning
for(uint32 i = 0; i < 4; ++i)
{
if(qPtr->receive_items[i])
GetPlayer()->GetItemInterface()->RemoveItemAmt(qPtr->receive_items[i], 1);
}
if( qPtr->srcitem && qPtr->srcitem != qPtr->receive_items[0] )
{
ItemPrototype *itemProto = ::ItemPrototypeStorage.LookupEntry( qPtr->srcitem );
if( itemProto != NULL )
if( itemProto->QuestId != qPtr->id )
_player->GetItemInterface()->RemoveItemAmt(qPtr->srcitem, qPtr->srcitemcount ? qPtr->srcitemcount : 1);
}
//remove all quest items (but not trade goods) collected and required only by this quest
for(uint32 i = 0; i < MAX_REQUIRED_QUEST_ITEM; ++i)
{
if(qPtr->required_item[i] != 0)
{
ItemPrototype* itemProto = ItemPrototypeStorage.LookupEntry(qPtr->required_item[i]);
if(itemProto != NULL && itemProto->Class == ITEM_CLASS_QUEST)
GetPlayer()->GetItemInterface()->RemoveItemAmt(qPtr->required_item[i], qPtr->required_itemcount[i]);
}
}
GetPlayer()->UpdateNearbyGameObjects();
sHookInterface.OnQuestCancelled(_player, qPtr);
}
示例5: RemoveQuestFromPlayer
string RemoveQuestFromPlayer(Player *plr, Quest *qst)
{
std::string recout = "|cff00ff00";
if (plr->HasQuests())
{
if (plr->HasFinishedQuest(qst->id))
recout += "Player has already completed that quest.\n\n";
else
{
QuestLogEntry * qLogEntry = plr->GetQuestLogForEntry(qst->id);
if (qLogEntry)
{
CALL_QUESTSCRIPT_EVENT(qLogEntry, OnQuestCancel)(plr);
qLogEntry->Finish();
// Remove all items given by the questgiver at the beginning
for(uint32 i = 0; i < 4; ++i)
{
if(qst->receive_items[i])
plr->GetItemInterface()->RemoveItemAmt(qst->receive_items[i], 1 );
}
if(qst->time > 0)
plr->timed_quest_slot = 0;
plr->UpdateNearbyGameObjects();
}
else
recout += "No quest log entry found for that player.";
}
}
else
{
recout += "Player has no quests to remove.";
}
recout += "\n\n";
return recout;
}
示例6: HandleQuestFinishCommand
bool ChatHandler::HandleQuestFinishCommand(const char * args, WorldSession * m_session)
{
if(!*args) return false;
Player *plr = getSelectedChar(m_session, true);
if(!plr)
{
plr = m_session->GetPlayer();
SystemMessage(m_session, "Auto-targeting self.");
}
uint32 quest_id = atol(args);
std::string recout = "|cff00ff00";
Quest * qst = QuestStorage.LookupEntry(quest_id);
if(qst)
{
if (plr->HasFinishedQuest(quest_id))
recout += "Player has already completed that quest.\n\n";
else
{
QuestLogEntry * IsPlrOnQuest = plr->GetQuestLogForEntry(quest_id);
if (IsPlrOnQuest)
{
uint32 giver_id = 0;
std::string my_query = "";
my_query = "SELECT id FROM creature_quest_starter WHERE quest = " + string(args);
QueryResult *creatureResult = WorldDatabase.Query(my_query.c_str());
if(creatureResult)
{
Field *creatureFields = creatureResult->Fetch();
giver_id = creatureFields[0].GetUInt32();
delete creatureResult;
}
else
{
my_query = "SELECT id FROM gameobject_quest_starter WHERE quest = " + string(args);
QueryResult *objectResult = WorldDatabase.Query(my_query.c_str());
if(objectResult)
{
Field *objectFields = objectResult->Fetch();
giver_id = objectFields[0].GetUInt32();
delete objectResult;
}
}
if(giver_id == 0)
SystemMessage(m_session, "Unable to find quest giver creature or object.");
else
{
// I need some way to get the guid without targeting the creature or looking through all the spawns...
Object *quest_giver;
for(uint32 guid=1; guid < plr->GetMapMgr()->m_CreatureArraySize; guid++)
{
Creature *pCreature = plr->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if(pCreature)
{
if(pCreature->GetEntry() == giver_id) //found creature
{
quest_giver = (Object*)pCreature;
guid = plr->GetMapMgr()->m_CreatureArraySize;
}
}
}
if(quest_giver)
{
GreenSystemMessage(m_session, "Found a quest_giver creature.");
//WorldPacket data;
//sQuestMgr.BuildOfferReward(&data, qst, quest_giver, 1);
//m_session->SendPacket(&data);
sQuestMgr.GiveQuestRewardReputation(plr, qst, quest_giver);
}
else
RedSystemMessage(m_session, "Unable to find quest_giver object.");
}
sQuestMgr.GenerateQuestXP(plr, qst);
sQuestMgr.BuildQuestComplete(plr, qst);
IsPlrOnQuest->Finish();
recout += "Player was on that quest, but has now completed it.";
}
else
recout += "The quest has now been completed for that player.";
plr->AddToFinishedQuests(quest_id);
}
}
else
{
recout += "Quest Id [";
recout += args;
recout += "] was not found and unable to add it to the player's quest log.";
}
recout += "\n\n";
//.........这里部分代码省略.........
示例7: OnQuestFinished
void QuestMgr::OnQuestFinished(Player* plr, Quest* qst, Object *qst_giver, uint32 reward_slot)
{
QuestLogEntry *qle = plr->GetQuestLogForEntry(qst->id);
if(!qle)
return;
BuildQuestComplete(plr, qst);
CALL_QUESTSCRIPT_EVENT(qle, OnQuestComplete)(plr);
ScriptSystem->OnQuestEvent(qst, ((Creature*)qst_giver), plr, QUEST_EVENT_ON_COMPLETE);
qle->Finish();
if(IsQuestRepeatable(qst))
return;
if(qst_giver->GetTypeId() == TYPEID_UNIT)
{
if(!((Creature*)qst_giver)->HasQuest(qst->id, 2))
{
sCheatLog.writefromsession(plr->GetSession(), "tried to finish quest from invalid npc.");
plr->GetSession()->Disconnect();
return;
}
}
plr->ModUInt32Value(PLAYER_FIELD_COINAGE, qst->reward_money);
// Reputation reward
for(int z = 0; z < 2; z++)
{
uint32 fact = 19; // default to 19 if no factiondbc
uint32 amt = uint32(float(GenerateQuestXP(plr, qst)) * 0.1f * sWorld.getRate(RATE_QUESTREPUTATION)); // guess
if(!qst->reward_repfaction[z])
{
if(z == 1)
break;
// Let's do this properly. Determine the faction of the creature, and give reputation to his faction.
if(qst_giver->GetTypeId() == TYPEID_UNIT)
if(((Creature*)qst_giver)->m_factionDBC != NULL)
fact = ((Creature*)qst_giver)->m_factionDBC->ID;
if(qst_giver->GetTypeId() == TYPEID_GAMEOBJECT)
fact = qst_giver->GetUInt32Value(GAMEOBJECT_FACTION);
}
else
{
fact = qst->reward_repfaction[z];
if(qst->reward_repvalue[z])
amt = qst->reward_repvalue[z];
}
if(qst->reward_replimit)
if(plr->GetStanding(fact) >= (int32)qst->reward_replimit)
continue;
plr->ModStanding(fact, amt);
}
// Static Item reward
for(uint32 i = 0; i < 4; ++i)
{
if(qst->reward_item[i])
{
ItemPrototype *proto = ItemPrototypeStorage.LookupEntry(qst->reward_item[i]);
if(!proto)
{
sLog.outError("Invalid item prototype in quest reward! ID %d, quest %d", qst->reward_item[i], qst->id);
}
else
{
Item *itm = objmgr.CreateItem(qst->reward_item[i], plr);
itm->SetUInt32Value(ITEM_FIELD_STACK_COUNT, uint32(qst->reward_itemcount[i]));
plr->GetItemInterface()->AddItemToFreeSlot(itm); //possible memleak and no safe check.
}
}
}
// Choice Rewards
if(qst->reward_choiceitem[reward_slot])
{
ItemPrototype *proto = ItemPrototypeStorage.LookupEntry(qst->reward_choiceitem[reward_slot]);
if(!proto)
{
sLog.outError("Invalid item prototype in quest reward! ID %d, quest %d", qst->reward_choiceitem[reward_slot], qst->id);
}
else
{
Item *itm = objmgr.CreateItem(qst->reward_choiceitem[reward_slot], plr);
itm->SetUInt32Value(ITEM_FIELD_STACK_COUNT, qst->reward_choiceitemcount[reward_slot]);
plr->GetItemInterface()->AddItemToFreeSlot(itm); //possible mem leak and no item check
}
}
// Remove items
for(uint32 i = 0; i < 4; ++i)
{
if(qst->required_item[i]) plr->GetItemInterface()->RemoveItemAmt(qst->required_item[i],qst->required_itemcount[i]);
}
//.........这里部分代码省略.........