Klank
Althea ¤ A New World Developer
Greetings!
I was in need of a task tracker inside the questlog and i did not find anything here on the forum, except for TFS 0.X versions.
So i wanted to share this, as i think many could need it. I am fairly new to C++ so It is made with assistance from ChatGPT and it has 1 flaw, it does not work if ignoreValue = true in the quest.xml file.
If someone wants to improve this code to use it with ignoreValue, feel free to post it here.
Simply change the whole function in quests.cpp (or replace only the whole else statement)
with
Demonstration:
Simply use the |STATE|STORAGEID| inside the quest description ( is for double new line):
I was in need of a task tracker inside the questlog and i did not find anything here on the forum, except for TFS 0.X versions.
So i wanted to share this, as i think many could need it. I am fairly new to C++ so It is made with assistance from ChatGPT and it has 1 flaw, it does not work if ignoreValue = true in the quest.xml file.
If someone wants to improve this code to use it with ignoreValue, feel free to post it here.
Simply change the whole function in quests.cpp (or replace only the whole else statement)
C++:
std::string Mission::getDescription(Player* player) const
with
C++:
std::string Mission::getDescription(Player* player) const
{
int32_t value;
player->getStorageValue(storageID, value);
if (!mainDescription.empty()) {
std::string desc = mainDescription;
replaceString(desc, "|STATE|", std::to_string(value));
replaceString(desc, "\\n", "\n");
return desc;
}
if (ignoreEndValue) {
for (int32_t current = endValue; current >= startValue; current--) {
if (value >= current) {
auto sit = descriptions.find(current);
if (sit != descriptions.end()) {
return sit->second;
}
}
}
}
else {
for (int32_t current = endValue; current >= startValue; current--) {
if (value == current) {
auto sit = descriptions.find(current);
if (sit != descriptions.end()) {
std::string desc = sit->second;
size_t statePos = desc.find("|STATE|");
while (statePos != std::string::npos) {
size_t startPos = statePos + 7; // start looking for value after |STATE|.
size_t endPos = desc.find("|", startPos); // find the last digit of the storage
if (endPos != std::string::npos) {
uint32_t storageValueIdentifier = std::stoul(desc.substr(startPos, endPos - startPos));
int32_t IdentifiedStorageValue;
player->getStorageValue(storageValueIdentifier, IdentifiedStorageValue);
desc.replace(statePos, endPos - statePos + 1, std::to_string(IdentifiedStorageValue));
}
statePos = desc.find("|STATE|", statePos + 1);
}
return desc;
}
}
}
}
return "An error has occurred, please contact a gamemaster.";
}
Demonstration:
Simply use the |STATE|STORAGEID| inside the quest description ( is for double new line):
XML:
<mission name="Quest/Task/Mission" storageid="250" startvalue="1" endvalue="3">
<missionstate id="1" description="Trolls killed: |STATE|249|/200 Dragons killed: |STATE|1203| /500 Discovered places: |STATE|250|x" />
</mission>