This is more of a pre-submission. I think I have this worked out. I'll spare the details to create the code, and just give it to you. I've trimmed this down to the least amount of code to keep it workable, I think.. These changes all occur within the zone directory.
First, we are going to create a new file. Name it cperl.cpp, and paste into it the following:
Code:
#ifdef EMBPERL
#include "masterentity.h"
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "cperl.h"
extern Database database;
const char *getItemName(unsigned itemid)
{
const Item_Struct* item = NULL;
item = database.GetItem(itemid);
if (item)
return item->Name;
else
return NULL;
}
XS(XS_qc_getItemName); /* prototype to pass -Wmissing-prototypes */
XS(XS_qc_getItemName)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: quest::getItemName(itemid)");
{
unsigned itemid = (unsigned)SvUV(ST(0));
const char * RETVAL;
dXSTARG;
RETVAL = getItemName(itemid);
sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
}
XSRETURN(1);
}
EXTERN_C XS(boot_qc); /* prototype to pass -Wmissing-prototypes */
EXTERN_C XS(boot_qc)
{
dXSARGS;
char* file = __FILE__;
XS_VERSION_BOOTCHECK ;
newXS("quest::getItemName", XS_qc_getItemName, file);
XSRETURN_YES;
}
#endif // EMBPERL
Now, create a file named cperl.h. Paste this into it:
Code:
#ifndef CPERL_H
#define CPERL_H
const char *getItemName(unsigned itemid);
XS(XS_qc_getItemName); /* prototype to pass -Wmissing-prototypes */
EXTERN_C XS(boot_qc); /* prototype to pass -Wmissing-prototypes */
#endif // CPERL_H
Now, open up embperl.cpp. At about line 17, you will have:
Code:
#include "embperl.h"
Below this, insert:
At about line 30, you will see the following:
Code:
EXTERN_C void xs_init(pTHX) { char *file = __FILE__; newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); }
We're going to add a new line to it (and put in some line breaks for readability sake):
Code:
EXTERN_C void xs_init(pTHX) {
char *file = __FILE__;
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
newXS("quest::boot_qc", boot_qc, file);
}
Now, open up embparser.cpp. About line 380 you will have this:
Code:
perl->eval(
"{"
"package quest;"
"@cmd_queue = ();"
Between the "package" and "@cmd_queue" lines we want to paste in "&boot_qc;". It will look like this:
Code:
perl->eval(
"{"
"package quest;"
"&boot_qc;"
"@cmd_queue = ();"
Finally, we need to change makefile.perl -- I don't know what you windows users do to add a file to the project.

At the veerrrryyy end of SF=.... (line 14) we are going to add cperl.o. It will then look like this:
Code:
../common/EMuShareMem.o ../common/EQEMuError.o beacon.o \
.obj/debug.o .obj/database.o .obj/Item.o .obj/misc.o \
doors.o command.o cperl.o
Note, if you don't have beacon.o in there, that's because I added it to my makefile so that it would compile. You should do the same if you don't have it included in the SF=... line.

Recompile, and you should now be able to use your script:
Code:
sub EVENT_ITEM {
quest::say("Ooh, a " . quest::getItemName($item1) . "! Here's your reward!");
quest::givecash(5,0,0,0);
quest::exp(100);
}
Have not been able to get anyone besides myself to test this code yet, so please let me know how you fare.
(last update 4/7/04)