Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2013, 04:48 PM
quido
Fire Beetle
 
Join Date: Oct 2009
Posts: 16
Default New Quest Function help

So I'm trying to add a new quest function to my build and I attempted to follow the instructions at the top of questmgr.cpp to do so.

Quote:
Assuming you want to add a new perl quest function named joe
that takes 1 integer argument....

1. Add the prototype to the quest manager:
questmgr.h: add (~line 50)
void joe(int arg);

2. Define the actual function in questmgr.cpp:
void QuestManager::joe(int arg) {
//... do something
}

3. Copy one of the XS routines in perlparser.cpp, preferably
one with the same number of arguments as your routine. Rename
as needed.
Finally, add your routine to the list at the bottom of perlparser.cpp


4.
If you want it to work in old mode perl and .qst, edit parser.cpp
Parser::ExCommands (~line 777)
else if (!strcmp(command,"joe")) {
quest_manager.joe(atoi(arglist[0]));
}

And then at then end of embparser.cpp, add:
"sub joe{push(@cmd_queue,{func=>'joe',args=>join(',',@_ )});}"
Ok so I added my declaration in questmgr.h in public:

Code:
void InitiateEncounter(char *engager, int mob_index);
And I added an empty function definition in questmgr.cpp:

Code:
void QuestManager::InitiateEncounter(char *engager, int mob_index)
{

}
Now I couldn't find the file perlparser.cpp in the current release, but it appeared such a file got split into a bunch of files all starting with "perl." I found that the function "npcfeature" had the same parameters as my function so I went searching for its XS routine and found it in embparser_api.cpp. So I copied this routine and changed the appropriate names etc:

Code:
XS(XS__InitiateEncounter);
XS(XS__InitiateEncounter)
{
	dXSARGS;
	if (items != 2)
		Perl_croak(aTHX_ "Usage: InitiateEncounter(FTEer, mob_id)");

	char *	fte	= (char *)SvPV_nolen(ST(0));
	int		mobid	= (int)SvIV(ST(1));

	quest_manager.InitiateEncounter(fte, mobid);

	XSRETURN_EMPTY;
}
and then I added the routine to the list at the bottom:

Code:
newXS(strcpy(buf, "InitiateEncounter"), XS__InitiateEncounter, file);

When I try to use the function in an EVENT_COMBAT subroutine for Severilous, it hangs/dies at the invocation.

Code:
sub EVENT_COMBAT {
	if ($combat_state == 1)
	{
		quest::shout("you stink!!!");
		quest::InitiateEncounter("jerk", 7);
		quest::shout("you super stink!!!");
	}
}
I get the first shout, but not the second. What am I doing wrong? Should my XS routine be placed somewhere else? Or do I need to follow step 4 also? I couldn't find the file for those instructions.

I would greatly appreciate any help I could get on this subject - thanks!
Reply With Quote
  #2  
Old 12-13-2013, 07:41 PM
quido
Fire Beetle
 
Join Date: Oct 2009
Posts: 16
Default

I tried getting this to work by putting all the functionality within the client class.

I added a public function InitiateEncounter in client.h with no return or parameters.

I added a dummy definition for InitiateEncounter in client.cpp.

In perl_client.cpp I copied, pasted, and modified what I thought was an appropriate XS routine:

Code:
XS(XS_Client_InitiateEncounter);
XS(XS_Client_InitiateEncounter)
{
	dXSARGS;
	if (items != 1)
		Perl_croak(aTHX_ "Usage: Client::InitiateEncounter(THIS)");
	{
		Client *		THIS;

		if (sv_derived_from(ST(0), "Client")) {
			IV tmp = SvIV((SV*)SvRV(ST(0)));
			THIS = INT2PTR(Client *,tmp);
		}
		else
			Perl_croak(aTHX_ "THIS is not of type Client");
		if(THIS == nullptr)
			Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");

		THIS->InitiateEncounter();
	}
	XSRETURN_EMPTY;
}
And I added my routine at the bottom of the list in perl_client.cpp
Code:
newXSproto(strcpy(buf, "InitiateEncounter"), XS_Client_InitiateEncounter, file, "$");

Then my script:
Code:
sub EVENT_COMBAT {
	if ($combat_state == 1)
	{
		quest::shout("you super stink!!!");
		quest::shout("you stink!!!");
		$client->InitiateEncounter();
		quest::shout("you so bad!!!");
	}
	else
	{
		quest::shout("eat me");
	}
}
What am I missing here?
Reply With Quote
  #3  
Old 12-13-2013, 11:25 PM
quido
Fire Beetle
 
Join Date: Oct 2009
Posts: 16
Default

Please disregard! I'm an idiot. I've been debugging this problem all day now and have simply been forgetting to copy my executables from Build/Debug into my EQEmuServer folder that my start script hits =P
Reply With Quote
Reply


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 08: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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3