本文整理汇总了C++中QuestLogEntry::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ QuestLogEntry::Init方法的具体用法?C++ QuestLogEntry::Init怎么用?C++ QuestLogEntry::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuestLogEntry
的用法示例。
在下文中一共展示了QuestLogEntry::Init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleQuestgiverAcceptQuestOpcode
//.........这里部分代码省略.........
if( _player->GetQuestLogForEntry( qst->id ) )
return;
if( qst_giver->GetTypeId() == TYPEID_UNIT && TO_CREATURE( qst_giver )->m_escorter != NULL )
{
SystemMessage("You cannot accept this quest at this time.");
return;
}
// Check the player hasn't already taken this quest, or
// it isn't available.
uint32 status = sQuestMgr.CalcQuestStatus(_player,qst,3, bSkipLevelCheck);
if((!sQuestMgr.IsQuestRepeatable(qst) && _player->HasFinishedQuest(qst->id)) || ( status != QMGR_QUEST_AVAILABLE && status != QMGR_QUEST_REPEATABLE && status != QMGR_QUEST_CHAT )
|| !hasquest)
{
// We've got a hacker. Disconnect them.
//sWorld.LogCheater(this, "tried to accept incompatible quest %u from %u.", qst->id, qst_giver->GetEntry());
//Disconnect();
return;
}
int32 log_slot = _player->GetOpenQuestSlot();
if (log_slot == -1)
{
sQuestMgr.SendQuestLogFull(GetPlayer());
return;
}
//FIXME
/*if(Player Has Timed quest && qst->HasFlag(QUEST_FLAG_TIMED))
sQuestMgr.SendQuestInvalid(INVALID_REASON_HAVE_TIMED_QUEST);*/
if(qst->count_receiveitems || qst->srcitem)
{
uint32 slots_required = qst->count_receiveitems;
if(_player->GetItemInterface()->CalculateFreeSlots(NULL) < slots_required)
{
_player->GetItemInterface()->BuildInventoryChangeError(NULLITEM, NULLITEM, INV_ERR_BAG_FULL);
sQuestMgr.SendQuestFailed(FAILED_REASON_INV_FULL, qst, _player);
return;
}
}
/* if(qst_giver->GetTypeId() == TYPEID_UNIT && !ScriptSystem->OnQuestRequireEvent(qst, TO_CREATURE( qst_giver ), _player, QUEST_EVENT_CAN_ACCEPT))
return;*/
QuestLogEntry *qle = new QuestLogEntry();
qle->Init(qst, _player, log_slot);
qle->UpdatePlayerFields();
// If the quest should give any items on begin, give them the items.
for(uint32 i = 0; i < 4; i++)
{
if(qst->receive_items[i])
{
Item* item = objmgr.CreateItem( qst->receive_items[i], GetPlayer());
if(item)
{
if(!_player->GetItemInterface()->AddItemToFreeSlot(item))
{
item->DeleteMe();
item = NULLITEM;
}
else
SendItemPushResult(item, false, true, false, true,
_player->GetItemInterface()->LastSearchItemBagSlot(), _player->GetItemInterface()->LastSearchItemSlot(),
1);
}
}
}
if(qst->srcitem && qst->srcitem != qst->receive_items[0])
{
Item* item = objmgr.CreateItem( qst->srcitem, _player );
if(item)
{
item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, qst->srcitemcount ? qst->srcitemcount : 1);
if(!_player->GetItemInterface()->AddItemToFreeSlot(item))
{
item->DeleteMe();
item = NULLITEM;
}
}
}
if(qst->count_required_item || qst_giver->GetTypeId() == TYPEID_GAMEOBJECT) // gameobject quests deactivate
_player->UpdateNearbyGameObjects();
CALL_QUESTSCRIPT_EVENT(qst->id, OnQuestStart)(_player, qle);
sQuestMgr.OnQuestAccepted(_player,qst,qst_giver);
if(qst->start_phase != 0 )
_player->SetPhaseMask(qst->start_phase, true);
sHookInterface.OnQuestAccept(_player, qst, qst_giver);
}
示例2: HandleQuestStartCommand
bool ChatHandler::HandleQuestStartCommand(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.";
else
{
QuestLogEntry * IsPlrOnQuest = plr->GetQuestLogForEntry(quest_id);
if (IsPlrOnQuest)
recout += "Player is currently on that quest.";
else
{
int32 open_slot = plr->GetOpenQuestSlot();
if (open_slot == -1)
{
sQuestMgr.SendQuestLogFull(plr);
recout += "Player's quest log is full.";
}
else
{
QuestLogEntry *qle = new QuestLogEntry();
qle->Init(qst, plr, (uint32)open_slot);
qle->UpdatePlayerFields();
// If the quest should give any items on begin, give them the items.
for(uint32 i = 0; i < 4; ++i)
{
if(qst->receive_items[i])
{
Item *item = objmgr.CreateItem( qst->receive_items[i], plr);
if(!plr->GetItemInterface()->AddItemToFreeSlot(item))
delete item;
}
}
if(qst->srcitem && qst->srcitem != qst->receive_items[0])
{
Item * item = objmgr.CreateItem( qst->srcitem, plr);
if(item)
{
item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, qst->srcitemcount ? qst->srcitemcount : 1);
if(!plr->GetItemInterface()->AddItemToFreeSlot(item))
delete item;
}
}
//if(qst->count_required_item || qst_giver->GetTypeId() == TYPEID_GAMEOBJECT) // gameobject quests deactivate
// plr->UpdateNearbyGameObjects();
//ScriptSystem->OnQuestEvent(qst, static_cast< Creature* >( qst_giver ), _player, QUEST_EVENT_ON_ACCEPT);
sHookInterface.OnQuestAccept( plr, qst );
recout += "Quest has been added to the player's quest log.";
}
}
}
}
else
{
recout += "Quest Id [";
recout += args;
recout += "] was not found and unable to add it to the player's quest log.";
}
recout += "\n\n";
SendMultilineMessage(m_session, recout.c_str());
return true;
}
示例3: HandleQuestgiverAcceptQuestOpcode
//.........这里部分代码省略.........
qst_giver = (Object*)quest_giver;
else
return;
bValid = quest_giver->isQuestGiver();
if(bValid)
qst = sQuestMgr.FindQuest(quest_id);
}
else if(UINT32_LOPART(GUID_HIPART(guid))==HIGHGUID_ITEM)
{
Item *quest_giver = GetPlayer()->GetItemInterface()->GetItemByGUID(guid);
if(quest_giver)
qst_giver = (Object*)quest_giver;
else
return;
bValid = true;
qst = sQuestMgr.FindQuest(quest_id);
}
if (!qst_giver)
{
sLog.outDebug("WORLD: Invalid questgiver GUID.");
return;
}
if (!bValid || qst == NULL)
{
sLog.outDebug("WORLD: Creature is not a questgiver.");
return;
}
if(_player->GetQuestLogForEntry(qst->id))
return;
// Check the player hasn't already taken this quest, or
// it isn't available.
uint32 status = sQuestMgr.CalcStatus(qst_giver, _player);
if((!sQuestMgr.IsQuestRepeatable(qst) && _player->HasFinishedQuest(qst->id)) || ( status != QMGR_QUEST_AVAILABLE && status != QMGR_QUEST_REPEATABLE )
|| !hasquest)
{
// We've got a hacker. Disconnect them.
sCheatLog.writefromsession(this, "tried to accept incompatible quest %u from %u.", qst->id, qst_giver->GetEntry());
//Disconnect();
return;
}
int32 log_slot = GetPlayer()->GetOpenQuestSlot();
if (log_slot == -1)
{
sQuestMgr.SendQuestLogFull(GetPlayer());
return;
}
//FIXME
/*if(Player Has Timed quest && qst->HasFlag(QUEST_FLAG_TIMED))
sQuestMgr.SendQuestInvalid(INVALID_REASON_HAVE_TIMED_QUEST);*/
if(qst->count_receiveitems)
{
if(GetPlayer()->GetItemInterface()->CalculateFreeSlots(NULL) < qst->count_receiveitems)
{
GetPlayer()->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_BAG_FULL);
sQuestMgr.SendQuestFailed(FAILED_REASON_INV_FULL, GetPlayer());
return;
}
}
QuestLogEntry *qle = new QuestLogEntry();
qle->Init(qst, _player, log_slot);
qle->UpdatePlayerFields();
// If the quest should give any items on begin, give them the items.
for(uint32 i = 0; i < 4; ++i)
{
if(qst->receive_items[i])
{
Item *item = objmgr.CreateItem( qst->receive_items[i], GetPlayer());
if(!GetPlayer()->GetItemInterface()->AddItemToFreeSlot(item))
{
delete item;
}
}
}
// Timed quest handler.
if(qst->time > 0)
{
//Start Quest Timer Event Here
//sEventMgr.AddEvent(GetPlayer(), &Player::EventTimedQuestExpire, qst, qle, static_cast<uint32>(log_slot), EVENT_TIMED_QUEST_EXPIRE, qst->time * 1000, 1);
uint32 qtime = static_cast<uint32>(time(NULL) + qst->time);
GetPlayer()->SetUInt32Value(log_slot+2, qtime);
GetPlayer()->timed_quest_slot = (log_slot - (PLAYER_QUEST_LOG_1_1) / 3);
}
if(qst->count_required_item || qst_giver->GetTypeId() == TYPEID_GAMEOBJECT) // gameobject quests deactivate
GetPlayer()->UpdateNearbyGameObjects();
sLog.outDebug("WORLD: Added new QLE.");
}
示例4: HandleQuestgiverAcceptQuestOpcode
//.........这里部分代码省略.........
{
SystemMessage("You cannot accept this quest at this time.");
return;
}
// Check the player hasn't already taken this quest, or
// it isn't available.
uint32 status = sQuestMgr.CalcQuestStatus(qst_giver, _player,qst,3, bSkipLevelCheck);
if((!sQuestMgr.IsQuestRepeatable(qst) && _player->HasFinishedQuest(qst->id)) || ( status != QMGR_QUEST_AVAILABLE && status != QMGR_QUEST_REPEATABLE && status != QMGR_QUEST_CHAT )
|| !hasquest)
{
// We've got a hacker. Disconnect them.
//sCheatLog.writefromsession(this, "tried to accept incompatible quest %u from %u.", qst->id, qst_giver->GetEntry());
//Disconnect();
return;
}
int32 log_slot = GetPlayer()->GetOpenQuestSlot();
if (log_slot == -1)
{
sQuestMgr.SendQuestLogFull(GetPlayer());
return;
}
//FIXME
/*if(Player Has Timed quest && qst->HasFlag(QUEST_FLAG_TIMED))
sQuestMgr.SendQuestInvalid(INVALID_REASON_HAVE_TIMED_QUEST);*/
if(qst->count_receiveitems || qst->srcitem)
{
uint32 slots_required = qst->count_receiveitems;
if(GetPlayer()->GetItemInterface()->CalculateFreeSlots(NULL) < slots_required)
{
GetPlayer()->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_BAG_FULL);
sQuestMgr.SendQuestFailed(FAILED_REASON_INV_FULL, qst, GetPlayer());
return;
}
}
/* if(qst_giver->GetTypeId() == TYPEID_UNIT && !ScriptSystem->OnQuestRequireEvent(qst, static_cast< Creature* >( qst_giver ), _player, QUEST_EVENT_CAN_ACCEPT))
return;*/
QuestLogEntry *qle = new QuestLogEntry();
qle->Init(qst, _player, log_slot);
qle->UpdatePlayerFields();
// If the quest should give any items on begin, give them the items.
for(uint32 i = 0; i < 4; ++i)
{
if(qst->receive_items[i])
{
Item *item = objmgr.CreateItem( qst->receive_items[i], GetPlayer());
if(item == NULL)
continue;
if(!GetPlayer()->GetItemInterface()->AddItemToFreeSlot(item))
{
item->DeleteMe();
}
else
SendItemPushResult(item, false, true, false, true,
_player->GetItemInterface()->LastSearchItemBagSlot(), _player->GetItemInterface()->LastSearchItemSlot(),
1);
}
}
if(qst->srcitem && qst->srcitem != qst->receive_items[0])
{
Item * item = objmgr.CreateItem( qst->srcitem, _player );
if(item)
{
item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, qst->srcitemcount ? qst->srcitemcount : 1);
if(!_player->GetItemInterface()->AddItemToFreeSlot(item))
item->DeleteMe();
}
}
// Timed quest handler.
if(qst->time > 0)
{
//Start Quest Timer Event Here
//sEventMgr.AddEvent(GetPlayer(), &Player::EventTimedQuestExpire, qst, qle, static_cast<uint32>(log_slot), EVENT_TIMED_QUEST_EXPIRE, qst->time * 1000, 1);
//uint32 qtime = static_cast<uint32>(time(NULL) + qst->time);
//GetPlayer()->SetUInt32Value(log_slot+2, qtime);
//GetPlayer()->SetUInt32Value(PLAYER_QUEST_LOG_1_01 + (log_slot * 3), qtime);
//GetPlayer()->timed_quest_slot = log_slot;
}
if(qst->count_required_item || qst_giver->GetTypeId() == TYPEID_GAMEOBJECT) // gameobject quests deactivate
GetPlayer()->UpdateNearbyGameObjects();
//ScriptSystem->OnQuestEvent(qst, static_cast< Creature* >( qst_giver ), _player, QUEST_EVENT_ON_ACCEPT);
sQuestMgr.OnQuestAccepted(_player,qst,qst_giver);
sLog.outDebug("WORLD: Added new QLE.");
sHookInterface.OnQuestAccept(_player, qst, qst_giver);
}