Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub CheckLoot {
- my $client = plugin::val('client');
- my $item = shift;
- my %item_stats = (
- "hp" => ["Health", $client->GetItemStat($item, "hp")],
- "mana" => ["Mana", $client->GetItemStat($item, "mana")],
- "endur" => ["Endurance", $client->GetItemStat($item, "endur")],
- "ac" => ["Armor Class", $client->GetItemStat($item, "ac")],
- );
- my $classes = $client->GetItemStat($item, "classes");
- my $races = $client->GetItemStat($item, "races");
- my $slots = $client->GetItemStat($item, "slots");
- my $hp = $client->GetItemStat($item, "hp");
- my $ac = $client->GetItemStat($item, "ac");
- my $type = defined $_[1] ? $_[1] : "hp";
- if ($races == 0) { return; }
- if ($classes == 0) { return; }
- if ($slots == 0) { return; }
- my $dbh = plugin::LoadMysql();
- $sth = $dbh->prepare(
- "SELECT items.`id` FROM `items`
- WHERE items.`id` IN (SELECT `item_id` FROM `item_list` WHERE `item_id` = items.`id`) AND
- `classes` & 1 << " . $client->GetClass() .
- " AND `slots` & $slots
- AND `$type` BETWEEN " . ($item_stats{$type}[1] * .75) .
- " AND " . ($item_stats{$type}[1] * 1.25) . "
- ORDER BY `$type` DESC LIMIT 1");
- $sth->execute();
- if ($sth->rows() > 0) {
- my @data = $sth->fetchrow_array();
- my $item_id = $data[0];
- quest::popup("Suggested Upgrades", "You have looted an item!<br>
- A similar item with better $item_stats{$type}[0] has been located:<br>
- " . plugin::PWHyperLink("http://raidaddicts.org/Allah/?a=item&id=$item_id", "Click here!"));
- }
- $sth->finish();
- $dbh->disconnect();
- }
Add Comment
Please, Sign In to add comment