EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   sub EVENT_SPAWN - Check for clients around npc. Need some help please. (https://www.eqemulator.org/forums/showthread.php?t=36788)

Drakiyth 04-28-2013 06:08 PM

sub EVENT_SPAWN - Check for clients around npc. Need some help please.
 
I have an idea on how to buff temporary (swarm) pets based on the user's charisma but it requires that npc to check for the player with a certain item in their inventory && their charisma value.


Just an example below. This quest goes in the folder where that npc resides either templates or the zone folder with its name.pl

sub EVENT_SPAWN
{
my $x;
my $y;
my $z;
my $h;

$x = $npc->GetX();
$y = $npc->GetY();
$z = $npc->GetZ();
$h = $npc->GetHeading();


quest::set_proximity( $x-6,$x+6,$y-6,$y+6,$z-6,$z+6);
}

sub EVENT_???? (ENTER/EXIT WORK BUT ARE INCONVENIENT)
{

$cha = $client->GetCHA();
my $npcid = $npc->GetID();

if ($cha >= 50 && $cha <= 99 && $hasitem{1384})
{
quest::say("Test");
$npc->CastSpell(777,$npcid);
}


The example above works on proximity tests (EVENT_ENTER/EXIT) but it's annoying as hell since you have to move towards and away from the mob. So, my question to anybody reading this: How would you make an NPC check for the client and these conditions as soon as it's spawned only using sub EVENT_SPAWN?

nenelan 04-28-2013 06:22 PM

I'm pretty sure you can take a look at how steadfast servant works to detect an owner on spawn and see how that goes. Best of luck!

Drakiyth 04-28-2013 06:38 PM

Thank you very much! This helped a great deal!

NatedogEZ 04-28-2013 08:49 PM

Doesn't work with Offensive Swarm Pets.

They always spawn with an owner ID of 0


And their Follow ID is not the client that spawned them

NatedogEZ 04-28-2013 09:41 PM

Figured out a work around... not sure how efficient this is yet. But it works!

Checks for an Item on the player ... So if they are holding X item the swarm pet will buff itself with a nice buff!

So I guess you could make multiple different ranks of an item that make swarm pets more and more powerful.. heh

Code:


sub EVENT_SPAWN {
        quest::settimer("Buffs", 1);
}

sub EVENT_TIMER {
                my $petitem = 1733;
                my $petbuff = 27424;
                #Hostile Target of the Swarm PET!
        $KillTarg = $npc->GetTarget();
               
        if($KillTarg <= 0)
        {
                        #Return if we have no target
                return;
        }
                #Grabbing all clients
                my @clientlist = $entity_list->GetClientList();
                foreach $ent (@clientlist)
                {
                my $ClientName = $ent->GetName();
                my $PlayerENT = $ent;
                my @hatelist = $KillTarg->GetHateList();    #Compare clients to those on the Hatelist of the Target
                        foreach $ent (@hatelist)
                        {
                                my $h_ent = $ent->GetEnt();
                                my $h_ent_name = $h_ent->GetName();
                                if ($ClientName eq $h_ent_name)
                                {
                                        if(plugin::check_hasitem($PlayerENT, $petitem))  #Check the clients on the hatelist for Worn Pet Buff item
                                        {
                                        my $myid = $npc->GetID();
                                        $npc->CastSpell($petbuff, $myid);
                                        quest::stoptimer("Buffs");
                                        return;  #Turn this on if you want it to stop after it finds ONE client with the item
                                        }
                                }
                        }
                }
}



All times are GMT -4. The time now is 01:44 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.