Guest User

Untitled

a guest
Dec 11th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.60 KB | None | 0 0
  1. sub CheckLoot {
  2.     my $client = plugin::val('client');
  3.     my $item = shift;
  4.     my %item_stats = (
  5.     "hp" => ["Health", $client->GetItemStat($item, "hp")],
  6.     "mana" => ["Mana", $client->GetItemStat($item, "mana")],
  7.     "endur" => ["Endurance", $client->GetItemStat($item, "endur")],
  8.     "ac" => ["Armor Class", $client->GetItemStat($item, "ac")],
  9.     );
  10.     my $classes = $client->GetItemStat($item, "classes");
  11.     my $races = $client->GetItemStat($item, "races");
  12.     my $slots = $client->GetItemStat($item, "slots");
  13.     my $hp = $client->GetItemStat($item, "hp");
  14.     my $ac = $client->GetItemStat($item, "ac");
  15.     my $type = defined $_[1] ? $_[1] : "hp";
  16.     if ($races == 0) { return; }
  17.     if ($classes == 0) { return; }
  18.     if ($slots == 0) { return; }
  19.     my $dbh = plugin::LoadMysql();
  20.     $sth = $dbh->prepare(
  21.     "SELECT items.`id` FROM `items`
  22.    WHERE items.`id` IN (SELECT `item_id` FROM `item_list` WHERE `item_id` = items.`id`) AND
  23.    `classes` & 1 << " . $client->GetClass() .
  24.     " AND `slots` & $slots
  25.    AND `$type` BETWEEN " . ($item_stats{$type}[1] * .75) .
  26.     " AND " . ($item_stats{$type}[1] * 1.25) . "
  27.    ORDER BY `$type` DESC LIMIT 1");
  28.     $sth->execute();
  29.     if ($sth->rows() > 0) {
  30.         my @data = $sth->fetchrow_array();
  31.         my $item_id = $data[0];
  32.         quest::popup("Suggested Upgrades", "You have looted an item!<br>
  33.        A similar item with better $item_stats{$type}[0] has been located:<br>
  34.        " . plugin::PWHyperLink("http://raidaddicts.org/Allah/?a=item&id=$item_id", "Click here!"));
  35.     }
  36.     $sth->finish();
  37.     $dbh->disconnect();
  38. }
Add Comment
Please, Sign In to add comment