Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 11-09-2012, 06:34 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

yeah, i guess the OOCRegen rule would probably be easier. i keep forgetting to familiarize myself with the various rules... :|

i'm a bit confused about what i'm reading in the source about the loading of npc quest files, however. i come up with this order from reading PerlembParser::LoadScript() in zone/embparser.cpp

1) quests/default.pl
2) quests/<zone>/<npcid>.pl
3) quests/<zone>/<npcname>.pl
4) quests/templates/<npcname>.pl
5) quests/templates/<npcid>.pl
6) quests/<zone>/default.pl
7) quests/templates/default.pl

this is what i'm looking at to come to this conclusion:

Code:
int PerlembParser::LoadScript(int npcid, const char * zone, Mob* activater)
{
	if(!perl)
	{
		return(0);
	}

	//we have already tried to load this quest...
	if(hasQuests.count(npcid) == 1)
	{
		return(1);
	}

	string filename = "quests/", packagename = GetPkgPrefix(npcid);
	//each package name is of the form qstxxxx where xxxx = npcid (since numbers alone are not valid package names)
	questMode curmode = questDefault;
	FILE *tmpf;
	//LogFile->write(EQEMuLog::Debug, "LoadScript(%d, %s):\n", npcid, zone);
	if(!npcid || !zone)
	{
		//Load quests/default.pl
		filename += DEFAULT_QUEST_PREFIX;
		filename += ".pl";
		curmode = questDefault;
	}
	else
	{
		filename += zone;
		filename += "/";
#ifdef QUEST_SCRIPTS_BYNAME
		string bnfilename = filename;
#endif
		filename += itoa(npcid);
		filename += ".pl";
		curmode = questByID;

#ifdef QUEST_SCRIPTS_BYNAME
		//assuming name limit stays 64 chars.
		char tmpname[64];
		int count0 = 0;
		bool filefound = false;
		tmpf = fopen(filename.c_str(), "r");
		if(tmpf != NULL)
		{
			fclose(tmpf);
			filefound = true;
		}
		//LogFile->write(EQEMuLog::Debug, "	tried '%s': %d", filename.c_str(), filefound);

		tmpname[0] = 0;
		//if there is no file for the NPC's ID, try for the NPC's name
		if(!filefound)
		{
			//revert to just path
			filename = bnfilename;
			const NPCType *npct = database.GetNPCType(npcid);
			if(npct == NULL)
			{
				//LogFile->write(EQEMuLog::Debug, "	no npc type");
				//revert and go on with life
				filename += itoa(npcid);
				filename += ".pl";
				curmode = questByID;
			}
			else
			{
				//trace out the ` characters, turn into -
				int nlen = strlen(npct->name);
				//just to make sure
				if(nlen < 64)
				{
					int r;
					//this should get our NULL as well..
					for(r = 0; r <= nlen; r++)
					{
						tmpname[r] = npct->name[r];

						//watch for 00 delimiter
						if(tmpname[r] == '0')
						{
							count0++;
							//second '0'
							if(count0 > 1)
							{
								//stop before previous 0
								tmpname[r-1] = '\0';
								break;
							}
						}
						else
						{
							count0 = 0;
						}

						//rewrite ` to be more file name friendly
						if(tmpname[r] == '`')
						{
							tmpname[r] = '-';
						}

					}
					filename += tmpname;
					filename += ".pl";
					curmode = questByName;
				}
				else
				{
					//LogFile->write(EQEMuLog::Debug, "	namelen too long");
					//revert and go on with life, again
					filename += itoa(npcid);
					filename += ".pl";
					curmode = questByID;
				}
			}
		}

#ifdef QUEST_TEMPLATES_BYNAME

		tmpf = fopen(filename.c_str(), "r");
		if(tmpf != NULL)
		{
			fclose(tmpf);
			filefound = true;
		}


		//LogFile->write(EQEMuLog::Debug, "	tried '%s': %d", filename.c_str(), filefound2);

		//if there is no file for the NPC's ID or name,
		//try for the NPC's name in the templates directory
		//only works if we have gotten the NPC's name above
		if(!filefound)
		{
			if(tmpname[0] != 0)
			{
				//revert to just path
				filename = "quests/";
				filename += QUEST_TEMPLATES_DIRECTORY;
				filename += "/";
				filename += tmpname;
				filename += ".pl";
				curmode = questTemplate;
				//LogFile->write(EQEMuLog::Debug, "	template '%s'", filename.c_str(), filefound2);
			}
			else
			{
				//LogFile->write(EQEMuLog::Debug, "	no template name");
				filename = "quests/";
				filename += QUEST_TEMPLATES_DIRECTORY;
				filename += "/";
				filename += itoa(npcid);
				filename += ".pl";
				curmode = questTemplateByID;
			}
		}
		
#endif	//QUEST_TEMPLATES_BYNAME

#endif //QUEST_SCRIPTS_BYNAME

		tmpf = fopen(filename.c_str(), "r");
		if(tmpf != NULL)
		{
			fclose(tmpf);
			filefound = true;
		}
		
		// If by ID, Name or Template wasn't found, load /quests/zone/default.pl
		if(!filefound)
		{
			//Load Default Quests Per Zone quests/zonename/default.pl
			filename = bnfilename;
			filename += "default.pl";
			curmode = questDefaultByZone;
			//LogFile->write(EQEMuLog::Debug, "LoadScript(%s)", filename.c_str());
		}

		tmpf = fopen(filename.c_str(), "r");
		if(tmpf != NULL)
		{
			fclose(tmpf);
			filefound = true;
		}
		
		// If zone template isn't found look for it globally /quests/template/default.pl
		if(!filefound)
		{
			//Load Default Quests Globally
			//filename = bnfilename;
			filename = "quests/";
			filename += QUEST_TEMPLATES_DIRECTORY;
			filename += "/";
			filename += "default.pl";
			curmode = questDefaultByZone;
			//LogFile->write(EQEMuLog::Debug, "LoadScript(%s)", filename.c_str());
		}
	}
am i just not reading/understanding something correctly?

EDIT:
i may have just answered my own question. it's only looking for quests/default.pl if no npcid or zoneid are supplied. i haven't looked at where this is called from, but i'm guessing it's probably pretty rare for that to occur.

Last edited by c0ncrete; 11-09-2012 at 06:38 AM.. Reason: duh...
Reply With Quote
  #2  
Old 11-09-2012, 07:29 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

It looks like that would only happen if there is no NPCID or zone passed to the function. I am not sure what scenario would cause that to happen, but to my knowledge using a default.pl in the quests folder directly does not work. If it worked like that, it would override any zone specific (or any other) scripts for all NPCs.

I do know it works fine from the templates folder and it loads the default.pl file from there if it doesn't find a more specific script to load first.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 07:30 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3