本文整理汇总了C++中Quest::hasStartJobRewards方法的典型用法代码示例。如果您正苦于以下问题:C++ Quest::hasStartJobRewards方法的具体用法?C++ Quest::hasStartJobRewards怎么用?C++ Quest::hasStartJobRewards使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quest
的用法示例。
在下文中一共展示了Quest::hasStartJobRewards方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: giveRewards
bool PlayerQuests::giveRewards(int16_t questid, bool start) {
Quest *questinfo = QuestDataProvider::Instance()->getInfo(questid);
if (!questinfo->hasRewards()) {
return true;
}
QuestRewardInfo info;
vector<QuestRewardInfo> items;
int32_t chance = 0;
Rewards::iterator startiter;
Rewards::iterator enditer;
Rewards::iterator sjobiter;
Rewards::iterator ejobiter;
Rewards::iterator iter;
bool jobrewards = false;
int16_t job = m_player->getStats()->getJob();
if (start) {
startiter = questinfo->getStartRewardsBegin();
enditer = questinfo->getStartRewardsEnd();
if (questinfo->hasStartJobRewards(job)) {
sjobiter = questinfo->getStartJobRewardsBegin(job);
ejobiter = questinfo->getStartJobRewardsEnd(job);
jobrewards = true;
}
}
else {
startiter = questinfo->getEndRewardsBegin();
enditer = questinfo->getEndRewardsEnd();
if (questinfo->hasEndJobRewards(job)) {
sjobiter = questinfo->getEndJobRewardsBegin(job);
ejobiter = questinfo->getEndJobRewardsEnd(job);
jobrewards = true;
}
}
if (!checkRewards(questid, startiter, enditer) || (jobrewards && !checkRewards(questid, sjobiter, ejobiter))) {
return false;
}
for (iter = startiter; iter != enditer; iter++) { // Give all applicable rewards
if (iter->isitem && iter->prop > 0) {
chance += iter->prop;
items.push_back(*iter);
}
else {
giveRewards(*iter);
}
}
if (jobrewards) {
for (iter = sjobiter; iter != ejobiter; iter++) {
if (iter->isitem && iter->prop > 0) {
chance += iter->prop;
items.push_back(*iter);
}
else {
giveRewards(*iter);
}
}
}
if (chance > 0) {
int32_t random = Randomizer::Instance()->randInt(chance - 1);
chance = 0;
for (size_t i = 0; i < items.size(); i++) {
info = items[i];
if (chance >= random) {
QuestsPacket::giveItem(m_player, info.id, info.count);
if (info.count > 0) {
Inventory::addNewItem(m_player, info.id, info.count);
}
else {
Inventory::takeItem(m_player, info.id, -info.count);
}
break;
}
else {
chance += info.prop;
}
}
}
return true;
}