PDA

View Full Version : Working for variables.


cofruben
04-26-2004, 07:39 AM
News variables is going to be inserted here.Working for adding more at the moment.
in embparser:

ExportVar(packagename.c_str(), "name", mob->GetName());
ExportVar(packagename.c_str(), "race", GetRaceName(mob->GetRace()));
ExportVar(packagename.c_str(), "class", GetEQClassName(mob->GetClass()));
ExportVar(packagename.c_str(), "ulevel", itoa(mob->GetLevel()));
ExportVar(packagename.c_str(), "userid", itoa(mob->GetID()));
ExportVar(packagename.c_str(), "ugender", itoa(mob->GetGender()));//Cofruben:-my variables starts here
ExportVar(packagename.c_str(), "uhp", itoa(mob->GetHP()));
}
in embparser.cpp you will see this,add ugender:

if (mob) {
ExportVar(packagename.c_str(), "name", mob->GetName());
ExportVar(packagename.c_str(), "race", GetRaceName(mob->GetRace()));
ExportVar(packagename.c_str(), "class", GetEQClassName(mob->GetClass()));
ExportVar(packagename.c_str(), "ulevel", itoa(mob->GetLevel()));
ExportVar(packagename.c_str(), "userid", itoa(mob->GetID()));
ExportVar(packagename.c_str(), "ugender", itoa(mob->GetGender()));


I will keep adding more.

sandy
04-26-2004, 09:27 AM
you should not use the hps of the monster but its hpratio
=)

smogo
04-26-2004, 11:13 AM
just a hint imho :

setting variables gets them exported for ALL mobs, on MANY events. This can really be useless overhead. e.g. the $userid and $ugender beeing exported every EVENT_ATTACK is wasted CPU.

When in need of a variable, for a specific quest or situation or mob , it's advisable to use perl calling C functions, as submitted by m0oni9

Just my 2 copper.

m0oni9
04-26-2004, 11:20 AM
per Scorpicus2k, this change will be going in: http://www.eqemulator.net/forums/viewtopic.php?t=13920

meaning that we can start calling functions from the server. IMO we should move as many of these exported variables into getVariable functions on the server as possible. This will save some overhead. Once you have the userid exported (I'm assuming this is charid?.. haven't checked), you can use that to determine player level, inventory, race, gender, etc.

It just doesn't make sense to keep a lot of these variables the way they are with this new capability, so if you are thinking of adding new ones, please take a look at the perl/XS docs. The framework is now in to start adding functions. Briefly, the way I do it is:

create C function that we are going to be calling
run h2xs in some directory to create a workspace (one-time thing)
create .xs file, including C function or C function prototype (whatever you feel like doing)
generate C code from .xs file
insert original C function, and XS-generated C code into cperl.cpp, also adding in the appropriate newXS() call.

I had plans to add some new functions (to replace hasitem, etc), and also write a little tutorial.. I'm thinking I may not get around to it before I take off to school this week, though. :cry: