From 20565c174baa4c9e1c182f4b45f6a623f4bf8799 Mon Sep 17 00:00:00 2001 From: WildEgo Date: Sat, 1 Jun 2024 18:45:38 +0100 Subject: [PATCH] add: Owsap quest renewal. --- gamefiles/data/quest/questcategory.txt | 146 +++++++++++++++++++++++++ src/common/service.h | 1 + src/game/src/packet.h | 4 + src/game/src/questmanager.cpp | 37 ++++++- src/game/src/questmanager.h | 4 + src/game/src/questnpc.cpp | 14 +++ src/game/src/questpc.cpp | 8 ++ src/game/src/questpc.h | 28 +++++ 8 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 gamefiles/data/quest/questcategory.txt diff --git a/gamefiles/data/quest/questcategory.txt b/gamefiles/data/quest/questcategory.txt new file mode 100644 index 0000000..cfeeece --- /dev/null +++ b/gamefiles/data/quest/questcategory.txt @@ -0,0 +1,146 @@ +####################################### +# Main Quests +# 0 +0 main_quest_lv1 +0 main_quest_lv2 +0 main_quest_lv3 +0 main_quest_lv6 +0 main_quest_lv7 +0 main_quest_lv9 +0 main_quest_lv10 +0 main_quest_lv12 +0 main_quest_lv14 +0 main_quest_lv15 +0 main_quest_lv16 +0 main_quest_lv27 +0 main_quest_lv30 +0 main_quest_lv32 +0 main_quest_lv40 +0 main_quest_lv47 +0 main_quest_lv50 +0 main_quest_lv55 +0 main_quest_lv60 +0 main_quest_lv66 +0 main_quest_lv72 +0 main_quest_lv78 +0 main_quest_lv84 +0 main_quest_lv90 +0 main_quest_lv91 +0 main_quest_lv92 +0 main_quest_lv93 +0 main_quest_lv94 +0 main_quest_lv95 +0 main_quest_lv96 +0 main_quest_lv97 +0 main_quest_lv98 +0 main_quest_flame_lv99 +0 main_quest_flame_lv100 +0 main_quest_flame_lv101 +0 main_quest_flame_lv102 +0 main_quest_flame_lv103 +0 main_quest_flame_lv104 +0 main_quest_flame_lv105 + +####################################### +# Side Quests +# 1 +1 new_quest_premium_lv4 +1 subquest_1 +1 subquest_2 +1 subquest_3 +1 subquest_4 +1 subquest_5 +1 subquest_6 +1 subquest_7 +1 subquest_8 +1 subquest_9 +1 subquest_10 +1 subquest_11 +1 subquest_12 +1 subquest_13 +1 subquest_15 +1 subquest_16 +1 subquest_17 +1 subquest_18 +1 subquest_19 +1 subquest_20 +1 subquest_21 +1 subquest_22 +1 subquest_23 +1 subquest_24 +1 subquest_25 +1 subquest_26 +1 subquest_27 +1 subquest_30 +1 subquest_31 +1 subquest_32 +1 subquest_33 +1 subquest_34 +1 subquest_36 +1 subquest_37 +1 subquest_38 +1 subquest_39 +1 subquest_40 +1 subquest_41 +1 subquest_42 +1 subquest_44 +1 subquest_45 +1 subquest_46 +1 subquest_47 +1 subquest_48 +1 subquest_49 +1 new_quest_lv7 +1 new_quest_lv17 +1 new_quest_lv22 +1 new_quest_lv26 +1 new_quest_lv28 +1 new_quest_lv29 +1 new_quest_lv42 +1 new_quest_lv43 +1 new_quest_lv52 +1 new_quest_lv54 +1 new_quest_lv75 +1 new_quest_lv80 + +####################################### +# Hunting Mission +# 2 + +####################################### +# Event Mission +# 3 + +####################################### +# Biologist Quests +# 4 +4 make_herb_lv4 +4 make_herb_lv7 +4 make_herb_lv10 +4 make_herb_lv15 +4 make_herb_lv20 +4 make_herb_lv25 +4 collect_quest_lv30 +4 collect_quest_lv40 +4 collect_quest_lv50 +4 collect_quest_lv60 +4 collect_quest_lv70 +4 collect_quest_lv80 +4 collect_quest_lv85 +4 collect_quest_lv90 +4 collect_quest_lv92 +4 collect_quest_lv94 + +####################################### +# Game Mission +# 5 +5 find_brother_article +5 find_squareguard +5 find_senior_soldier + +####################################### +# Mission Book Quests +# 6 + +####################################### +# Daily Quests +# 7 diff --git a/src/common/service.h b/src/common/service.h index dc5131d..0933d97 100644 --- a/src/common/service.h +++ b/src/common/service.h @@ -3,4 +3,5 @@ //#define __AUCTION__ #define __PET_SYSTEM__ +#define __QUEST_RENEWAL__ // Quest Page Renewal by Owsap #endif diff --git a/src/game/src/packet.h b/src/game/src/packet.h index e925e01..93c703d 100644 --- a/src/game/src/packet.h +++ b/src/game/src/packet.h @@ -1415,6 +1415,10 @@ struct packet_quest_info WORD size; WORD index; BYTE flag; +#if defined(__QUEST_RENEWAL__) + BYTE type; + bool is_confirmed; +#endif }; enum diff --git a/src/game/src/questmanager.cpp b/src/game/src/questmanager.cpp index d1065f0..8d4bd65 100644 --- a/src/game/src/questmanager.cpp +++ b/src/game/src/questmanager.cpp @@ -199,9 +199,44 @@ namespace quest CloseState(*pPC->GetRunningQuestState()); pPC->EndRunning(); } - } +#if defined(__QUEST_RENEWAL__) + int CQuestManager::ReadQuestCategoryFile(WORD quest_index) + { + // ¹ÞÀº quest_index¸¦ quest_name·Î º¯È¯ ÈÄ ºñ±³ + int quest_type = 0; + string quest_name = CQuestManager::instance().GetQuestNameByIndex(quest_index); + ifstream file((g_stQuestDir + "/questcategory.txt").c_str()); + if (file) + { + std::string line; + while (getline(file, line)) + { + line.erase(remove(line.begin(), line.end(), ' '), line.end()); // remove all white spaces + if (line.empty() || line.front() == '#') + continue; // Skip empty lines or lines starting with # + + int type = stoi(line.substr(0, line.find('\t'))); + string name = line.substr(line.find('\t') + 1); + + if (test_server) + sys_log(0, "QUEST reading script of %s(%d)", name.c_str(), type); + + if (quest_name == name) + { + quest_type = type; + break; + } + } + } + else + sys_err("QUEST Cannot open 'questcategory.txt'"); + + return quest_type; + } +#endif + void CQuestManager::Input(unsigned int pc, const char* msg) { PC* pPC = GetPC(pc); diff --git a/src/game/src/questmanager.h b/src/game/src/questmanager.h index 7f505f4..8880fe6 100644 --- a/src/game/src/questmanager.h +++ b/src/game/src/questmanager.h @@ -181,6 +181,10 @@ namespace quest #endif void RegisterNPCVnum(DWORD dwVnum); +#if defined(__QUEST_RENEWAL__) + // Quest Category + int ReadQuestCategoryFile(WORD quest_index); +#endif private: LPDUNGEON m_pSelectedDungeon; diff --git a/src/game/src/questnpc.cpp b/src/game/src/questnpc.cpp index ddaf676..9f67c49 100644 --- a/src/game/src/questnpc.cpp +++ b/src/game/src/questnpc.cpp @@ -778,6 +778,20 @@ namespace quest return false; } +#if defined(__QUEST_RENEWAL__) + CQuestManager& rkQmgr = CQuestManager::instance(); + const LPCHARACTER c_lpCh = rkQmgr.GetCurrentCharacterPtr(); + if (c_lpCh != NULL) + { + char szBuf[255]{}; + snprintf(szBuf, sizeof(szBuf), "%s.%s", questName, "is_confirmed"); + c_lpCh->SetQuestFlag(string(questName) + ".is_confirmed", 1); + + if (test_server) + SPDLOG_DEBUG("NPC::OnInfo: pc (name) %s has confirmed the quest %s", c_lpCh->GetName(), questName); + } +#endif + CQuestManager::ExecuteQuestScript(pc, quest_index, itPCQuest->second.st, itQuestScript->second.GetCode(), itQuestScript->second.GetSize()); return true; } diff --git a/src/game/src/questpc.cpp b/src/game/src/questpc.cpp index 766087c..8d7579d 100644 --- a/src/game/src/questpc.cpp +++ b/src/game/src/questpc.cpp @@ -236,6 +236,14 @@ namespace quest qi.size = sizeof(struct packet_quest_info); qi.index = m_RunningQuestState->iIndex; qi.flag = m_iSendToClient; +#if defined(__QUEST_RENEWAL__) + qi.type = CQuestManager::instance().ReadQuestCategoryFile(qi.index); + + qi.is_confirmed = false; + const LPCHARACTER c_lpCh = CQuestManager::instance().GetCurrentCharacterPtr(); + if (c_lpCh != NULL) + qi.is_confirmed = static_cast(c_lpCh->GetQuestFlag(m_stCurQuest + ".is_confirmed")); +#endif TEMP_BUFFER buf; buf.write(&qi, sizeof(qi)); diff --git a/src/game/src/questpc.h b/src/game/src/questpc.h index 1fd64fe..90af5f5 100644 --- a/src/game/src/questpc.h +++ b/src/game/src/questpc.h @@ -43,6 +43,34 @@ namespace quest QUEST_SEND_ICON_FILE = (1 << 6), // 24자 까지 }; +#if defined(__QUEST_RENEWAL__) + enum EQuestType + { + QUEST_TYPE_MAIN, + QUEST_TYPE_SUB, + QUEST_TYPE_LEVELUP, + QUEST_TYPE_EVENT, + QUEST_TYPE_COLLECTION, + QUEST_TYPE_SYSTEM, + QUEST_TYPE_SCROLL, + QUEST_TYPE_DAILY, + QUEST_TYPE_UNEXPOSED, + QUEST_TYPE_MAX + }; + + enum EQuestSkin + { + QUEST_SKIN_NOWINDOW, + QUEST_SKIN_NORMAL, + QUEST_SKIN_UNKOWN1, + QUEST_SKIN_UNKOWN2, + QUEST_SKIN_SCROLL, + QUEST_SKIN_CINEMATIC, + QUEST_SKIN_COUNT, + QUEST_SKIN_MAX + }; +#endif + typedef map QuestInfo; typedef QuestInfo::iterator QuestInfoIterator;