LucasFerraz
Systems Analyst
Since this code do not work properly.
It's not my credits and I'm not sure who deserve that.
In Quests.h find:
[cpp]std::string parseStorages(std::string state, std::string value, Player* player);[/cpp]
And add // before it.
In quests.cpp find:
[cpp]std::string Mission:arseStorages(std::string state, std::string value, Player* player)[/cpp]
and then:
[cpp]
/*
std::string Mission:arseStorages(std::string state, std::string value, Player* player)
{
std::string::size_type start, end;
while((start = state.find("|STORAGE:")) != std::string::npos)
{
if((end = state.find("|", start)) = std::string::npos)
continue;
std::string value, storage = state.substr(start, end - start);
player->getStorage(storage, value);
state.replace(start, end, value);
}
replaceString(state, "|STATE|", value);
return state;
}*/[/cpp]
Then find:
[cpp]std::string Mission::getDescription(Player* player)[/cpp]
Replace with:
[cpp]std::string Mission::getDescription(Player* player)
{
std::string value;
int32_t find_storage;
player->getStorage(storageId, value);
if(state.size())
{
std::string ret = state;
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
if(atoi(value.c_str()) >= endValue)
{
std::string ret = states.rbegin()->second;
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
for(int32_t i = endValue; i >= startValue; --i)
{
player->getStorage(storageId, value);
if(atoi(value.c_str()) != i)
continue;
std::string ret = states[i - startValue];
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
return "Couldn't retrieve any mission description, please report to a gamemaster.";
}[/cpp]
Then you can use in Quests.xml:
It's not my credits and I'm not sure who deserve that.
In Quests.h find:
[cpp]std::string parseStorages(std::string state, std::string value, Player* player);[/cpp]
And add // before it.
In quests.cpp find:
[cpp]std::string Mission:arseStorages(std::string state, std::string value, Player* player)[/cpp]
and then:
[cpp]
/*
std::string Mission:arseStorages(std::string state, std::string value, Player* player)
{
std::string::size_type start, end;
while((start = state.find("|STORAGE:")) != std::string::npos)
{
if((end = state.find("|", start)) = std::string::npos)
continue;
std::string value, storage = state.substr(start, end - start);
player->getStorage(storage, value);
state.replace(start, end, value);
}
replaceString(state, "|STATE|", value);
return state;
}*/[/cpp]
Then find:
[cpp]std::string Mission::getDescription(Player* player)[/cpp]
Replace with:
[cpp]std::string Mission::getDescription(Player* player)
{
std::string value;
int32_t find_storage;
player->getStorage(storageId, value);
if(state.size())
{
std::string ret = state;
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
if(atoi(value.c_str()) >= endValue)
{
std::string ret = states.rbegin()->second;
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
for(int32_t i = endValue; i >= startValue; --i)
{
player->getStorage(storageId, value);
if(atoi(value.c_str()) != i)
continue;
std::string ret = states[i - startValue];
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
return "Couldn't retrieve any mission description, please report to a gamemaster.";
}[/cpp]
Then you can use in Quests.xml:
XML:
<mission name="The head of Kiper" storageid="1001" startvalue="1" endvalue="3">
<missionstate id="0" description="Kill Rotworms to summon a Kiper!! You've killed already |STORAGE:1002|/50 Rotworms and |STORAGE:1500|/2 Carrion Rotworms."/>
<missionstate id="1" description="Give his head to Talaturen!"/>
<missionstate id="2" description="Take the medal you got from Talaturen to Ruly!"/>
</mission>
Last edited: