• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Request new function at Quests (cpp)

Dankoo

Active Member
Joined
Sep 4, 2010
Messages
1,007
Reaction score
27
It would be awesome if we could modify sources so quests.xml work like this?

Lua:
<mission name="Paw and Fur: Hydras" storageid="14021" startvalue="0" endvalue="2000">
			<missionstate fromid="0" toid "1999" description="You already hunted |STORAGE:14021|/2000 hydras."/>
			<missionstate id="2000" description="You killed 2000 hydras. Report back to Grizzly Adams."/>
			<missionstate id="2001" description="You killed 2000 hydras. You can restart that task."/>
		</mission>

Fromid, toid... like actions.xml, know?

Here's the source code for Quests.xml:

[cpp]bool Quests::parseQuestNode(xmlNodePtr p, bool checkDuplicate)
{
if(xmlStrcmp(p->name, (const xmlChar*)"quest"))
return false;

int32_t intValue;
std::string strValue;

uint32_t id = m_lastId;
if(readXMLInteger(p, "id", intValue) && id > 0)
{
id = intValue;
if(id > m_lastId)
m_lastId = id;
}[/cpp]

And here are some examples of script that uses fromid toid script:

actions.xml
[cpp]else if(readXMLString(p, "fromid", strValue) && readXMLString(p, "toid", endValue))
{
IntegerVec intVector = vectorAtoi(explodeString(strValue, ";")), endVector = vectorAtoi(explodeString(endValue, ";"));
if(intVector[0] && endVector[0] && intVector.size() == endVector.size())
{
int32_t tmp = 0;
for(size_t i = 0, size = intVector.size(); i < size; ++i)
{
tmp = intVector;
while(intVector <= endVector)
{
if(useItemMap.find(intVector) != useItemMap.end())
{
if(!override)
{
std::clog << "[Warning - Actions::registerEvent] Duplicate registered item with id: " << intVector <<
", in fromid: " << tmp << " and toid: " << endVector << std::endl;
intVector++;
continue;
}
else
delete useItemMap[intVector];
}

useItemMap[intVector++] = new Action(action);
}
}
}
else
std::clog << "[Warning - Actions::registerEvent] Malformed entry (from item: \"" << strValue <<
"\", to item: \"" << endValue << "\")" << std::endl;
}[/cpp]

movements.xml
[cpp]if(readXMLString(p, "fromid", strValue) && readXMLString(p, "toid", endStrValue))
{
intVector = vectorAtoi(explodeString(strValue, ";"));
endIntVector = vectorAtoi(explodeString(endStrValue, ";"));
if(intVector[0] && endIntVector[0] && intVector.size() == endIntVector.size())
{
for(size_t i = 0, size = intVector.size(); i < size; ++i)
{
bool equip = moveEvent->getEventType() == MOVE_EVENT_EQUIP;
addEvent(moveEvent, intVector, m_itemIdMap, override);
if(equip)
{
ItemType& it = Item::items.getItemType(intVector);
it.wieldInfo = moveEvent->getWieldInfo();
it.minReqLevel = moveEvent->getReqLevel();
it.minReqMagicLevel = moveEvent->getReqMagLv();
it.vocationString = moveEvent->getVocationString();
}

while(intVector < endIntVector)
{
addEvent(new MoveEvent(moveEvent), ++intVector, m_itemIdMap, override);
if(equip)
{
ItemType& tit = Item::items.getItemType(intVector);
tit.wieldInfo = moveEvent->getWieldInfo();
tit.minReqLevel = moveEvent->getReqLevel();
tit.minReqMagicLevel = moveEvent->getReqMagLv();
tit.vocationString = moveEvent->getVocationString();
}
}
}
}
else
std::clog << "[Warning - MoveEvents::registerEvent] Malformed entry (from item: \"" << strValue << "\", to item: \"" << endStrValue << "\")" << std::endl;
}[/cpp]

items.xml
[cpp]if(readXMLInteger(itemNode, "id", intValue))
parseItemNode(itemNode, intValue);
else if(readXMLString(itemNode, "fromid", strValue) && readXMLString(itemNode, "toid", endValue))
{
intVector = vectorAtoi(explodeString(strValue, ";"));
endVector = vectorAtoi(explodeString(endValue, ";"));
if(intVector[0] && endVector[0] && intVector.size() == endVector.size())
{
size_t size = intVector.size();
for(size_t i = 0; i < size; ++i)
{
parseItemNode(itemNode, intVector);
while(intVector < endVector)
parseItemNode(itemNode, ++intVector);
}
}
else
std::clog << "[Warning - Items::loadFromXml] Malformed entry (from: \"" << strValue << "\", to: \"" << endValue << "\")" << std::endl;
}
else
std::clog << "[Warning - Items::loadFromXml] No itemid found" << std::endl;
}[/cpp]

Can someone merge some of the functions of these scripts so quests.xml works with fromid toid?

Thanks in advance. ^_^
 
Next time you BUMP your thread and 24 hours haven't passed yet, I will be forced to infract you. Please, avoid that.
 
Next time you BUMP your thread and 24 hours haven't passed yet, I will be forced to infract you. Please, avoid that.

Absolutely, I've done that on my birthday only, and before the bump odyssey started, at the first page.

Bump.
 
replace this part in Quests::parseQuestNode
Code:
				// parse sub-states only if main is not set
				for(xmlNodePtr stateNode = missionNode->children; stateNode; stateNode = stateNode->next)
				{
					if(xmlStrcmp(stateNode->name, (const xmlChar*)"missionstate"))
						continue;

					if(!readXML[B][COLOR="red"]String[/COLOR][/B](stateNode, "id", [B][COLOR="red"]str[/COLOR][/B]Value))
					{
						std::cout << "[Warning - Quests::parseQuestNode] Missing missionId for mission state" << std::endl;
						continue;
					}
[B][COLOR="red"]					IntegerVec intVector;
					if(!parseIntegerVec(strValue, intVector))
					{
						std::cout << "[Warning - Quests::parseQuestNode] Invalid missionId - '" << strValue << "' for mission state" << std::endl;
						continue;
					}[/COLOR][/B]

					std::string description;
					if(readXMLString(stateNode, "description", strValue))
						description = strValue;

[B][COLOR="red"]					for(size_t i = 0, size = intVector.size(); i < size; ++i)[/COLOR][/B]
						mission->newState([B][COLOR="red"]intVector[i][/COLOR][/B], description);
				}
sample quests.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<quests>
	<quest name="Killing in the Name of..." startstorageid="14503" startstoragevalue="1">
		<mission name="Turmoil of War" storageid="14004" startvalue="0" endvalue="5001">
			<missionstate id="0-5000" description="Budrik asked you to kill 5000 minotaurs for him. You already killed |STATE| minotaurs."/>
			<missionstate id="5001" description="You have slain 5000 minotaurs and fought The Horned Fox for Budrik and the whole dwarven kind."/>
		</mission>
		<mission name="Paw and Fur - Hunting Elite" storageid="14501" startvalue="0" endvalue="500">
			<missionstate id="0" description="You joined the 'Paw and Fur - Hunting Elite'. Ask Grizzly Adams for some hunting tasks."/>
			<missionstate id="1-500" description="You joined the 'Paw and Fur - Hunting Elite'. Ask Grizzly Adams for some hunting tasks. You already completed |STATE| of them."/>
		</mission>
		<mission name="Paw and Fur - Rank" storageid="14502" startvalue="0" endvalue="6">
			<missionstate id="1" description="You have been promoted to the rank of a 'Huntsman' in the 'Paw and Fur - Hunting Elite'."/>
			<missionstate id="2" description="You have been promoted to the rank of a 'Ranger' in the 'Paw and Fur - Hunting Elite'."/>
			<missionstate id="3" description="You have been promoted to the rank of a 'Big Game Hunter' in the 'Paw and Fur - Hunting Elite'."/>
			<missionstate id="4" description="You have been promoted to the rank of a 'Trophy Hunter' in the 'Paw and Fur - Hunting Elite'."/>
			<missionstate id="5" description="You have been promoted to the rank of a 'Elite Hunter' in the 'Paw and Fur - Hunting Elite'. This is the highest rank you can get."/>
		</mission>
		<mission name="Paw and Fur: Energy Elementals" storageid="14017" startvalue="0" endvalue="71">
			<missionstate id="0-70" description="You already hunted |STATE| energy elementals. You are supposed to kill 70 in total."/>
			<missionstate id="71" description="You killed 70 energy elementals. You can restart that task if you are still under Level 90."/>
		</mission>
		<mission name="Paw and Fur: Mutated Rats" storageid="14019" startvalue="0" endvalue="201">
			<missionstate id="0-200" description="You already hunted |STATE|/200 mutated rats."/>
			<missionstate id="201" description="You killed 200 mutated rats. You can restart that task if you are still under Level 90."/>
		</mission>
		<mission name="Paw and Fur: Earth Elementals" storageid="14016" startvalue="0" endvalue="71">
			<missionstate id="0-70" description="You already hunted |STATE| earth elementals. You are supposed to kill 70 in total."/>
			<missionstate id="71" description="You killed 70 earth elementals. You can restart that task if you are still under Level 90."/>
		</mission>
		<mission name="Paw and Fur: Carniphilas" storageid="14009" startvalue="0" endvalue="151">
			<missionstate id="0-150" description="You already hunted |STATE|/150 carniphilas."/>
			<missionstate id="151" description="You killed 150 carniphilas. You can restart that task if you are still under Level 50."/>
		</mission>
		<mission name="Paw and Fur: Quara Scouts" storageid="14013" startvalue="0" endvalue="301">
			<missionstate id="0-300" description="You already hunted |STATE|/300 quara scouts."/>
			<missionstate id="301" description="You killed 300 quara scouts. You can restart that task if you are still under Level 90."/>
		</mission>
		<mission name="Paw and Fur: Demons" storageid="14006" startvalue="0" endvalue="6666">
			<missionstate id="0-6665" description="You already hunted |STATE|/6666 demons."/>
			<missionstate id="6666" description="You killed 6666 demons."/>
		</mission>
		<mission name="Paw and Fur: Behemoths" storageid="14022" startvalue="0" endvalue="2001">
			<missionstate id="0-2000" description="You already hunted |STATE|/2000 behemoths."/>
			<missionstate id="2001" description="You killed 2000 behemoths. You can restart that task."/>
		</mission>
		<mission name="Paw and Fur: Giant Spiders" storageid="14020" startvalue="0" endvalue="501">
			<missionstate id="0-500" description="You already hunted |STATE|/500 giant spiders."/>
			<missionstate id="501" description="You killed 500 giant spiders. You can restart that task if you are still under Level 90."/>
		</mission>
		<mission name="Paw and Fur: Serpent Spawns" storageid="14002" startvalue="0" endvalue="1501">
			<missionstate id="0-1500" description="You already hunted |STATE|/1500 serpent spawns."/>
			<missionstate id="1501" description="You killed 1500 serpent spawns. You can restart that task."/>
		</mission>
		<mission name="Paw and Fur: Water Elementals" storageid="14015" startvalue="0" endvalue="71">
			<missionstate id="0-70" description="You already hunted |STATE| water elementals. You are supposed to kill 70 in total."/>
			<missionstate id="71" description="You killed 70 water elementals. You can restart that task if you are still under Level 90."/>
		</mission>
		<mission name="Paw and Fur: Hydras" storageid="14021" startvalue="0" endvalue="2001">
			<missionstate id="0-2000" description="You already hunted |STATE|/2000 hydras."/>
			<missionstate id="2001" description="You killed 2000 hydras. You can restart that task."/>
		</mission>
		<mission name="Paw and Fur: Stone Golems" storageid="14010" startvalue="0" endvalue="201">
			<missionstate id="0-200" description="You already hunted |STATE|/200 stone golems."/>
			<missionstate id="201" description="You killed 200 stone golems. You can restart that task if you are still under Level 50."/>
		</mission>
		<mission name="Paw and Fur: Quaras" storageid="14014" startvalue="0" endvalue="301">
			<missionstate id="0-300" description="You already hunted |STATE|/300 quaras."/>
			<missionstate id="301" description="You killed 300 quaras. You can restart that task if you are still under Level 90."/>
		</mission>
		<mission name="Paw and Fur: Sea Serpents" storageid="14001" startvalue="0" endvalue="2001">
			<missionstate id="0-2000" description="You already hunted |STATE|/2000 sea serpents."/>
			<missionstate id="2001" description="You killed 2000 sea serpents. You can restart that task."/>
		</mission>
		<mission name="Paw and Fur: Crocodiles" storageid="14007" startvalue="0" endvalue="301">
			<missionstate id="0-300" description="You already hunted |STATE|/300 crocodiles."/>
			<missionstate id="301" description="You killed 300 crocodiles. You can restart that task if you are still under Level 50."/>
		</mission>
		<mission name="Paw and Fur: Fire Elementals" storageid="14018" startvalue="0" endvalue="71">
			<missionstate id="0-70" description="You already hunted |STATE| fire elementals. You are supposed to kill 70 in total."/>
			<missionstate id="71" description="You killed 70 fire elementals. You can restart that task if you are still under Level 90."/>
		</mission>
		<mission name="Paw and Fur: Ice Golems" storageid="14012" startvalue="0" endvalue="301">
			<missionstate id="0-300" description="You already hunted |STATE|/300 ice golems."/>
			<missionstate id="301" description="You killed 300 ice golems. You can restart that task if you are still under Level 90."/>
		</mission>
		<mission name="Paw and Fur: Tarantulas" storageid="14008" startvalue="0" endvalue="301">
			<missionstate id="0-300" description="You already hunted |STATE|/300 tarantulas."/>
			<missionstate id="301" description="You killed 300 tarantulas. You can restart that task if you are still under Level 50."/>
		</mission>
		<mission name="Paw and Fur: Mammoths" storageid="14011" startvalue="0" endvalue="301">
			<missionstate id="0-300" description="You already hunted |STATE|/300 mammoths."/>
			<missionstate id="301" description="You killed 300 mammoths. You can restart that task if you are still under Level 50."/>
		</mission>
		<mission name="Lugri: Necromancers and Priestesses" storageid="14003" startvalue="0" endvalue="4000">
			<missionstate id="0-4000" description="Lugri sent you to kill a total of 4000 Necromancers and Priestesses, however he also said there won't be a reward for it. So far you've killed |STATE| Necromancers and Priestesses."/>
		</mission>
	</quest>
</quests>
also updated my post
 
EmnJBnVPE5.png
 
Back
Top