Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 11-29-2008, 09:03 PM
Neiv
Hill Giant
 
Join Date: May 2008
Location: Colorado
Posts: 238
Default Hatelist Aggro Issues

I'm trying to get four mobs in a zone to attack the client after acquiring an item from an NPC. The hate script is triggered by a timer associated with a SAY event. Here is the SAY, followed by the TIMER:

Code:
sub EVENT_SAY
	{
	if($text=~/accept/i)
		{
		quest::say("Very well, here it is. But have a care, $name, and treat it with caution. It has magical properties that can help or hinder the bearer. Go and practice your new skills.");
		quest::settimer("aggro",10);
		quest::summonitem(13732);
		$client->Message(257, "A strange, unsettled feeling falls upon you.");
		$client->Message(257, "You feel . . . heavy.");
		}
	}
I placed checkmark emotes throughout the following TIMER script to see where it is breaking, and it makes it to "ticking 5," then starts over.

Code:
sub EVENT_TIMER 
	{
	quest::emote("sees that his timer is ticking 1");
	if($timer eq "aggro")
		{
		quest::emote("sees that his timer is ticking 2");
		quest::rebind(183,21,36,8);

		my $guard_one = $entity_list->GetMobByNpcTypeID(999287);
		my $guard_two = $entity_list->GetMobByNpcTypeID(999288);
		my $guard_three = $entity_list->GetMobByNpcTypeID(999289);
		my $guard_four = $entity_list->GetMobByNpcTypeID(999290);
		quest::emote("sees that his timer is ticking 3");
					
		if ($guard_one) 
			{
			quest::emote("sees that his timer is ticking 4");
			my $hate_guard_one = $guard_one->CastToNPC();
			quest::emote("sees that his timer is ticking 5");
			$hate_guard_one->AddToHateList($client, 1);
			quest::emote("sees that his timer is ticking 6");
			}
		if ($guard_two) 
			{
			quest::emote("sees that his timer is ticking 7");
			my $hate_guard_two = $guard_two->CastToNPC();
			$hate_guard_two->AddToHateList($client, 1);
			}
		if ($guard_three) 
			{
			quest::emote("sees that his timer is ticking 8");
			my $hate_guard_three = $guard_three->CastToNPC();
			$hate_guard_three->AddToHateList($client, 1);
			}
		if ($guard_four) 
			{
			quest::emote("sees that his timer is ticking 9");
			my $hate_guard_four = $guard_four->CastToNPC();
			$hate_guard_four->AddToHateList($client, 1);
			}
		quest::emote("sees that his timer is ticking 10");
		quest::stoptimer("aggro");
		}
	}
Since it's not making it to "ticking 6," I assume the problem is with the object $hate_guard_one->AddToHateList($client, 1); . I have used this in its exact form in another quest script where it works just fine (in fact, I simply copied and pasted it), so I am at a loss as to why it is not working. The only difference is that the working script is a "player.pl" whereas the non-working one is an NPC script that references other mobs and the client. But this seems to be identical to the Cazic Thule and Tunare scripts (both of those add the client to third-party mob hatelists), so I don't understand why it's not working here.
Reply With Quote
  #2  
Old 12-01-2008, 04:10 AM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

I don't think sub EVENT_TIMER exports $client, because it's not triggered by a client, where sub EVENT_AGGRO (from the Tunare script) does (the client that aggroed it).

I think you might be able to define a variable outside of the subs so that all of them have access to it, set it to $client in EVENT_SAY, and then reference it in EVENT_TIMER. However, I'm pretty sure if a 2nd person talks to the NPC, it will overwrite your variable, unless you check to see if it's already being done.

I guess I'm thinking something like this (untested):
Code:
my $client_hating = false;

sub EVENT_SAY
{
	if($text=~/accept/i)
	{
		if (!$client_hating)
		{
			quest::say("Very well, here it is. But have a care, $name, and treat it with caution. It has magical properties that can help or hinder the bearer. Go and practice your new skills.");
			$client_hating = $client;
			quest::settimer("aggro",10);
			quest::summonitem(13732);
			$client->Message(257, "A strange, unsettled feeling falls upon you.");
			$client->Message(257, "You feel . . . heavy.");
		} else {
			quest::say("Wait your turn, jerk!");
		}
	}
}

sub EVENT_TIMER 
{
	quest::emote("sees that his timer is ticking 1");
	if($timer eq "aggro")
	{
		quest::emote("sees that his timer is ticking 2");
		quest::rebind(183,21,36,8);

		my $guard_one = $entity_list->GetMobByNpcTypeID(999287);
		my $guard_two = $entity_list->GetMobByNpcTypeID(999288);
		my $guard_three = $entity_list->GetMobByNpcTypeID(999289);
		my $guard_four = $entity_list->GetMobByNpcTypeID(999290);
		quest::emote("sees that his timer is ticking 3");
					
		if ($guard_one) 
		{
			quest::emote("sees that his timer is ticking 4");
			my $hate_guard_one = $guard_one->CastToNPC();
			quest::emote("sees that his timer is ticking 5");
			$hate_guard_one->AddToHateList($client_hating, 1);
			quest::emote("sees that his timer is ticking 6");
		}
		if ($guard_two) 
		{
			quest::emote("sees that his timer is ticking 7");
			my $hate_guard_two = $guard_two->CastToNPC();
			$hate_guard_two->AddToHateList($client_hating, 1);
		}
		if ($guard_three) 
		{
			quest::emote("sees that his timer is ticking 8");
			my $hate_guard_three = $guard_three->CastToNPC();
			$hate_guard_three->AddToHateList($client_hating, 1);
		}
		if ($guard_four) 
		{
			quest::emote("sees that his timer is ticking 9");
			my $hate_guard_four = $guard_four->CastToNPC();
			$hate_guard_four->AddToHateList($client_hating, 1);
		}
		quest::emote("sees that his timer is ticking 10");
		quest::stoptimer("aggro");
		quest::emote("sees that his timer is ticking 11");
		$client_hating = false;
	}
}
On a side note, can't we simplify this
Code:
			my $hate_guard_one = $guard_one->CastToNPC();
			$hate_guard_one->AddToHateList($client, 1);
to this
Code:
$guard_one->CastToNPC()->AddToHateList($client, 1);
or even better yet, just do everything on 1 line?
Code:
$entity_list->GetMobByNpcTypeID(999287)->CastToNPC()->AddToHateList($client, 1);
Since we're not really evaluating whether or not something's happening, you can just put your checks in-between them:
Code:
sub EVENT_TIMER 
{
	quest::emote("sees that his timer is ticking 1");
	if($timer eq "aggro")
	{
		quest::emote("sees that his timer is ticking 2");
		quest::rebind(183,21,36,8);

		quest::emote("sees that his timer is ticking 3");
		$entity_list->GetMobByNpcTypeID(999287)->CastToNPC()->AddToHateList($client_hating, 1);

		quest::emote("sees that his timer is ticking 4");
		$entity_list->GetMobByNpcTypeID(999288)->CastToNPC()->AddToHateList($client_hating, 1);

		quest::emote("sees that his timer is ticking 5");
		$entity_list->GetMobByNpcTypeID(999289)->CastToNPC()->AddToHateList($client_hating, 1);

		quest::emote("sees that his timer is ticking 6");
		$entity_list->GetMobByNpcTypeID(999290)->CastToNPC()->AddToHateList($client_hating, 1);

		quest::emote("sees that his timer is ticking 10");
		quest::stoptimer("aggro");
	}
}
Hope this helps at least point you in the right direction.
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Reply With Quote
  #3  
Old 12-01-2008, 11:37 PM
Neiv
Hill Giant
 
Join Date: May 2008
Location: Colorado
Posts: 238
Default

Wow. It works like a charm now. I'm impressed. Thanks AndMetal!
Reply With Quote
  #4  
Old 12-02-2008, 01:00 AM
Neiv
Hill Giant
 
Join Date: May 2008
Location: Colorado
Posts: 238
Default

Well, it worked at least the first time I tried it; then it broke and now gives me only the "wait your turn" message (I'm the only one in the world).
Reply With Quote
  #5  
Old 12-04-2008, 08:11 AM
Neiv
Hill Giant
 
Join Date: May 2008
Location: Colorado
Posts: 238
Default

I decided just to add an additional zone, have the main npc port me there, and transfer the aggro script to my player.pl in the new zone, triggered by an ENTERZONE event. It's working now.
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 12:08 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