Packet |
04-26-2011 02:28 PM |
Cleaned it up a 'little bit'. This is all experimentation for me and I am posting the final script for reference if anyone ever needs help searching for an array of items in a players inventory. If I knew anything about creating a hash and literal array, this script probably would have been a lot smaller and less cluttered. Anyways, here it is.
If anyone has critisism and cares to elaborate, I would be deeply grateful. :)
Code:
#Packet Loss
#This is my experimentation with inventory checks via proximity and say event.
#each of these items id's are just place holders - they run through the hasitem checks in all player inventory slots (incl. bank)
my $fitem = 9991;
my $qsitem = 9992;
my $hitem = 9993;
my $eitem = 9994;
my $gitem = 1079;
my $feitem = 9996;
my $nitem = 9997;
my $kitem = 9998;
my $gritem = 9999;
my $oitem = 10000;
my $ritem = 10001;
my $aitem = 10002;
sub EVENT_SPAWN {
$x = $npc->GetX();
$y = $npc->GetY();
$range = 70;
#ty akkadius - the $range makes setting proximity easily.
quest::set_proximity($x - $range, $x + $range, $y - $range, $y + $range);
}
sub EVENT_ENTER {
if($ulevel == 1) {
quest::movepc(152, -200, 36, -55, -125);
$client->Message(15, "You have not become attuned yet. Speak with Gharj at the top of the platform.");
}
if((plugin::check_hasitem($client, $fitem) || plugin::check_hasitem($client, $qsitem) || plugin::check_hasitem($client, $hitem) || plugin::check_hasitem($client, $eitem) || plugin::check_hasitem($client, $gitem) || plugin::check_hasitem($client, $feitem) || plugin::check_hasitem($client, $nitem) || plugin::check_hasitem($client, $kitem) || plugin::check_hasitem($client, $gritem) || plugin::check_hasitem($client, $oitem) || plugin::check_hasitem($client, $ritem) || plugin::check_hasitem($client, $aitem)))
{
quest::me("Thiddian waves at you.");
quest::doanim(29);
}
else
{
if($ulevel == 2) {
$npc->SendAppearanceEffect(180);
quest::doanim(66);
quest::say("Hey, you! $name! Come over here... You cannot use the portal without a [shard]!!");
}
if($ulevel >= 3) {
quest::say("Hey ther $name! Could I interest you in a [shard]? I see that you do not have one!");
quest::doanim(29);
}
}
}
sub EVENT_SAY {
my $fvar = quest::saylink("Freeport");
my $qvar = quest::saylink("Qeynos");
my $hvar = quest::saylink("Halas");
my $evar = quest::saylink("Erudin");
my $gvar = quest::saylink("GreaterFaydark");
my $fevar = quest::saylink("Felwithe");
my $nvar = quest::saylink("Neriak");
my $kvar = quest::saylink("Kaladim");
my $grvar = quest::saylink("Grobb");
my $ovar = quest::saylink("Oggok");
my $rvar = quest::saylink("Rivervale");
my $akvar = quest::saylink("Akanon");
#my $hresp = ("Here you go!");
#my $hresp = quest::ChooseRandom("Here you go!", "There!", "Here, take this.");
#second option for random responses. Both vars disabled by default
if((plugin::check_hasitem($client, $fitem) || plugin::check_hasitem($client, $qsitem) || plugin::check_hasitem($client, $hitem) || plugin::check_hasitem($client, $eitem) || plugin::check_hasitem($client, $gitem) || plugin::check_hasitem($client, $feitem) || plugin::check_hasitem($client, $nitem) || plugin::check_hasitem($client, $kitem) || plugin::check_hasitem($client, $gritem) || plugin::check_hasitem($client, $oitem) || plugin::check_hasitem($client, $ritem) || plugin::check_hasitem($client, $aitem)))
{
quest::say("You already have a shard. Hand it back to me if you would like to change your destination.");
}
else
{
#first time getting a shard.
if($text=~/hail/i && $ulevel == 2)
{
quest::say("Greetings, $name! I am Thiddian and I have the [shards] necessary for you to travel back home. There are rifts throughout Norrath that only those whom have been attuned can see. Simply walk into one and you can return here.");
}
if($text=~/hail/i && $ulevel >= 3) {
quest::say("Welcome back $name! Could I interest you in a [shard]?");
}
#newb shard response
if($text=~/shard/i && $ulevel == 2) {
quest::doanim(70);
quest::say("Ehhh.. ehm... The shards are what allow us to travel through these soul portals. The thing is, you can only have one. No one has ever stepped into the rift with two shards and I dont think we should try. Anyways, thats enough babbling from me... Please choose your land.");
$client->Message(15, "Select only ONE of the following:");
$client->Message(15, "[$fvar]-[$qvar]-[$hvar]-[$evar]-[$gvar]-[$fevar]-[$nvar]-[$kvar]-[$grvar]-[$ovar]-[$rvar]-[$akvar]");
}
#no more explanations needed - greet!
if($text=~/shard/i && $ulevel >= 3) {
quest::doanim(67);
$client->Message(15, "Select only ONE of the following:");
$client->Message(15, "[$fvar]-[$qvar]-[$hvar]-[$evar]-[$gvar]-[$fevar]-[$nvar]-[$kvar]-[$grvar]-[$ovar]-[$rvar]-[$akvar]");
}
if($text=~/Freeport/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($fitem);
}
if($text=~/Qeynos/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($qsitem);
}
if($text=~/Halas/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($hitem);
}
if($text=~/Erudin/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($eitem);
}
if($text=~/Greater/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($gitem);
}
if($text=~/Felwithe/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($feitem);
}
if($text=~/Neriak/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($nitem);
}
if($text=~/Kaladim/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($kitem);
}
if($text=~/Grobb/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($gritem);
}
if($text=~/Oggok/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($oitem);
}
if($text=~/Rivervale/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($ritem);
}
if($text=~/anon/i) {
#quest::say($hresp);
quest::doanim(43);
$npc->SendAppearanceEffect(180);
quest::summonitem($aitem);
}
}
}
The point of this script is to keep players from having multiple items in the list without using global variables (may have been wise to use gbvar but I don't know anything about that yet. Still a little confused on that concept.
|