PDA

View Full Version : Target Variables


Rogean
05-14-2004, 11:03 AM
I wanted people to have a change to test these before i put them in the code. Heres some more Variables!

$hpp - Returns the HitPoints Numerical Perecent of the Mob
$engaged - Returns 1 if the mob is Engaged (Attacking)
$hastarget - Returns 1 if the mob has a Target
$target[isclient] - Returns 1 if our target IS a Client (Player)
$target[accountid] - Returns Account Id if mob's target is a Client
$target[accountname] - Returns Account Name if mob's target is a client
$target[charid] - Returns CharacterID if mob's target is a client
$target[userid] - Returns UserID if mob's target is a client
$target[guildrank] - Returns Guild Rank if mob's target is a client
$target[status] - Returns Status if mob's target is a client
$target[isnpc] - Returns 1 if mob's target is an NPC
$target[name] - Returns the Name of the mob's target
$target[race] - Returns the Race of the mob's target
$target[class] - Returns the Class of the mob's target
$target[level] - Returns the Level of the mob's target
$target[hpp] - Returns the HitPoint Percent of the mob's target

Here is the Code:

EmbParser.cpp in PerlembParser::Event Under packagename = GetPkgPrefix(npcid); Add:

ExportVar(packagename.c_str(), "hpp", itoa(npcmob->GetHPRatio()));
if (npcmob->IsEngaged()) ExportVar(packagename.c_str(), "engaged", "1");
if (npcmob->GetTarget()) {
ExportVar(packagename.c_str(), "hastarget", "1");
Mob* target = npcmob->GetTarget();
if (target->IsClient()) {
ExportVar(packagename.c_str(), "target[isclient]", "1");
ExportVar(packagename.c_str(), "target[accountid]", itoa(target->CastToClient()->AccountID()));
ExportVar(packagename.c_str(), "target[accountname]", target->CastToClient()->AccountName());
ExportVar(packagename.c_str(), "target[charid]", itoa(target->CastToClient()->CharacterID()));
ExportVar(packagename.c_str(), "target[userid]", itoa(target->GetID()));
ExportVar(packagename.c_str(), "target[guildrank]", itoa(target->CastToClient()->GuildRank()));
ExportVar(packagename.c_str(), "target[status]", itoa(target->CastToClient()->Admin()));

} else ExportVar(packagename.c_str(), "target[isnpc]", "1");

ExportVar(packagename.c_str(), "target[name]", target->GetName());
ExportVar(packagename.c_str(), "target[race]", GetRaceName(target->GetRace()));
ExportVar(packagename.c_str(), "target[class]", GetEQClassName(target->GetClass()));
ExportVar(packagename.c_str(), "target[level]", itoa(target->GetLevel()));
ExportVar(packagename.c_str(), "taget[hpp]", itoa(target->GetHPRatio()));
}


Thats it! Compile and have fun. Heres an example Death Touch script that will cause the mob to DT His Target every 5 minutes:


sub EVENT_SPAWN
{
quest::settimer(1,300);

sub EVENT_ATTACK
{
if (!$hastouched){
quest::castspell($userid,982);
quest::setglobal("hastouched","1","7","M5");
}
}

sub EVENT_TIMER
{
if (!$hastouched && $hastarget && $engaged){
quest::castspell($userid,982);
quest::setglobal("hastouched","1","7","M5");
}
}


Go test and post how it works =)

m0oni9
05-14-2004, 02:06 PM
Any chance you could look at changing these into C functions? As long as there is some sort of mob ID that can be used to look things up from the server it should be pretty doable. Also, a lot of those itoa() conversions, etc, could be done away with. Would save lots of overhead.

BTW, there is a typo in the below code: ExportVar(packagename.c_str(), "taget[hpp]", itoa(target->GetHPRatio()));

smogo
05-16-2004, 09:16 AM
yup, this is gonna look like a bump to m0oni's post :)

If you can give it a try, accessing EMU variables from perl just takes you to declare prototype in a *.xs source file, then you call for that function in the quest as you need, instead of processing all ExportVars for each event.

Also, maybe i missed something, but is this is Perl, $target[xxx] just thrills me (means you exported the xxx as a constant to qstnnn:: package :?)

take a look there :
http://www.eqemulator.net/forums/viewtopic.php?t=12393