MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / complete

Method complete

source/game/StarQuests.cpp:267–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267void Quest::complete(Maybe<size_t> followupIndex) {
268 setState(QuestState::Complete);
269 m_showDialog = showCompleteDialog();
270 m_scriptComponent.invoke("questComplete");
271 uninitScript();
272
273 // Grant reward items and money
274 for (auto const& item : rewards())
275 m_player->giveItem(item->clone());
276 m_player->inventory()->addCurrency("money", money());
277
278 // Offer follow-up quests
279 bool trackNewQuest = m_player->questManager()->isTracked(questId());
280 size_t nextArcPos = followupIndex.value(questArcPosition() + 1);
281 if (nextArcPos < m_arc.quests.size()) {
282 auto followUp = make_shared<Quest>(m_arc, nextArcPos, m_player);
283 followUp->setWorldId(worldId());
284 followUp->setLocation(location());
285 followUp->setServerUuid(serverUuid());
286 m_player->questManager()->offer(followUp);
287 if (trackNewQuest)
288 m_player->questManager()->setAsTracked(followUp->questId());
289 } else if (trackNewQuest) {
290 // no followup, track another main quest or clear quest tracker
291 if (auto main = m_player->questManager()->getFirstMainQuest())
292 m_player->questManager()->setAsTracked(main.value()->questId());
293 else
294 m_player->questManager()->setAsTracked({});
295 }
296}
297
298void Quest::fail() {
299 setState(QuestState::Failed);

Callers 2

interactWithEntityMethod · 0.80
completeQuestMethod · 0.80

Calls 15

giveItemMethod · 0.80
addCurrencyMethod · 0.80
inventoryMethod · 0.80
isTrackedMethod · 0.80
setLocationMethod · 0.80
setAsTrackedMethod · 0.80
questIdMethod · 0.80
getFirstMainQuestMethod · 0.80
invokeMethod · 0.45
cloneMethod · 0.45
questManagerMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected