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.