PDA

View Full Version : Plane of Time Instance Handler


zippzipp
02-13-2013, 11:18 PM
I was having issues in plane of time with the way instances were handled. It made it tough for people to add people to their instance later. I was also running into issues with people in same raid getting 2 different instances.

I ended up disabling the clicks and creating an NPC named A Timeless Magus. This magus has the ability to create an instance, destroy an instance, add you to an existing instance, and send you to the specific trial you want. It also allows you to create time instances with a Raid, Group, or Individual.


Here is the code for it:


# A_Timeless_Magus instance handler for plane of time b.

sub EVENT_SAY{
my $instance = quest::saylink("instance",1);
my $add = quest::saylink("add",1);
my $send = quest::saylink("send",1);
my $remove = quest::saylink("remove",1);
my $fire = quest::saylink("fire",1);
my $water = quest::saylink("water",1);
my $undead = quest::saylink("undead",1);
my $air = quest::saylink("air",1);
my $earth = quest::saylink("earth",1);


$InstID = quest::GetInstanceID("potimeb",0);
if ($text =~/Hail/i){
quest::say("I allow passage to the plane of time. We must free Zebuxoruk. I can start a new [$instance], [$send] you to an existing instance, [$add] you to an existing instance, or [$remove] you from your current instance.");
return;
}
if($text =~/instance$/i){
CREATEINSTANCE();
return;
}
if($text =~/add$/i){
quest::say("Ask the leader of the instance you wish to join to give you the instance ID. Tell me that ID and I will add you to their party.");
return;
}
if($text =~/send$/i){
quest::say("Which trial would you like to go to: [$fire], [$water], [$undead], [$air], or [$earth]?");
return;
}
if($text =~/remove$/i){
quest::DestroyInstance($InstID);
quest::say("It is done. You and your travelers are no longer in any instances.");
return;
}
if($text =~/fire$/i){
if($InstID){ quest::MovePCInstance(223,$InstID,-23.1,576.6,493.6); }
else { quest::say("You are not part of an instance."); }
return;
}
if($text =~/water$/i){
if($InstID){ quest::MovePCInstance(223,$InstID,-23.1,853,493.6); }
else { quest::say("You are not part of an instance."); }
return;
}
if($text =~/undead$/i){
if($InstID){ quest::MovePCInstance(223,$InstID,-23.1,1112,493.6); }
else { quest::say("You are not part of an instance.");}
return;
}
if($text =~/air$/i){
if($InstID){ quest::MovePCInstance(223,$InstID,-23.1,1358,493.6); }
else { quest::say("You are not part of an instance.");}
return;
}
if($text =~/earth$/i){
if($InstID){ quest::MovePCInstance(223,$InstID,-23.1,1595,493.6); }
else { quest::say("You are not part of an instance."); }
return;
}

#check if response is a number if so attempt to assign that person to the specified instance.
if ($text =~ /^[+-]?\d+$/ ) {
quest::AssignToInstance($text);
quest::say("I have attempted to assign you to instance: $text. If you gave me a bogus number shame on you.");
} else {
quest::say("I allow passage to the plane of time. We must free Zubuxoruk. I can start a new [$Instance], [$Send] you to an existing instance, [$add] you to an existing instance, or [$Remove] you from your current instance.");
}
}


sub CREATEINSTANCE
{
$running = quest::GetInstanceID("potimeb", 0);
$raid = $client->GetRaid();

if ($raid)
{
if (defined($qglobals{potimeLockout}) || defined($qglobals{potime_canzone}))
{
$client->Message(13, "You are not ready to start a new instance. You may be locked out.");
}
elsif ($running == 0 && !(defined($qglobals{potimeLockout}) || defined($qglobals{potime_canzone})))
{
$instance = quest::CreateInstance("potimeb", 0, 232000);
quest::say("Your instance has been created. Your instance ID is: [$instance]. Keep track of this number as this is the number needed to add others to your instance later.");
quest::AssignRaidToInstance($instance);
}
}
else
{
$group = $client->GetGroup();
if($group){
if (defined($qglobals{potimeLockout}) || defined($qglobals{potime_canzone})) {
$client->Message(13, "You are not ready to start a new instance. You may be locked out.");
}
elsif ($running == 0 && !(defined($qglobals{potimeLockout}) || defined($qglobals{potime_canzone})))
{
$instance = quest::CreateInstance("potimeb", 0, 232000);
quest::say("Your instance has been created. Your instance ID is: [$instance]. Keep track of this number as this is the number needed to add others to your instance later.");
quest::AssignGroupToInstance($instance);
}
} else {
if (defined($qglobals{potimeLockout}) || defined($qglobals{potime_canzone})) {
$client->Message(13, "You are not ready to start a new instance. You may be locked out.");
}
elsif ($running == 0 && !(defined($qglobals{potimeLockout}) || defined($qglobals{potime_canzone})))
{
$instance = quest::CreateInstance("potimeb", 0, 232000);
quest::say("You are very brave to journey to time alone. Your instance has been created. Your instance ID is: [$instance]. Keep track of this number as this is the number needed to add others to your instance later.");
quest::AssignToInstance($instance);
}
}
}
}