Advertisement
NatedogServer

Stupid item crap

Sep 9th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 4.60 KB | None | 0 0
  1. sub gmgearme2 {
  2.     my $client = plugin::val('$client');
  3.     my $text = plugin::val('$text');
  4.     my $ulevel = plugin::val('$ulevel');
  5.     my $class = plugin::val('$class');
  6.     my $items_list;
  7.         my %racelist = (
  8.         1 => 1,
  9.         2 => 2,
  10.         3 => 4,
  11.         4 => 8,
  12.         5 => 16,
  13.         6 => 32,
  14.         7 => 64,
  15.         8 => 128,
  16.         9 => 256,
  17.         10 => 512,
  18.         11 => 1024,
  19.         12 => 2048,
  20.         128 => 4096,
  21.         130 => 8192,
  22.         330 => 16384,
  23.         522 => 65535
  24.         );
  25.         my %slots = (
  26.         0 => 1,
  27.         1 => 18,
  28.         2 => 4,
  29.         3 => 8,
  30.         4 => 18,
  31.         5 => 32,
  32.         6 => 64,
  33.         7 => 128,
  34.         8 => 256,
  35.         9 => 1536,
  36.         10 => 1536,
  37.         11 => 2048,
  38.         12 => 4096,
  39.         13 => 8192,
  40.         14 => 16384,
  41.         15 => 98304,
  42.         16 => 98304,
  43.         17 => 131072,
  44.         18 => 262144,
  45.         19 => 524288,
  46.         20 => 1048576
  47.         );
  48.         my %classes = (
  49.         1 => 1,
  50.         2 => 2,
  51.         3 => 4,
  52.         4 => 8,
  53.         5 => 16,
  54.         6 => 32,
  55.         7 => 64,
  56.         8 => 128,
  57.         9 => 256,
  58.         10 => 512,
  59.         11 => 1024,
  60.         12 => 2048,
  61.         13 => 4096,
  62.         14 => 8192,
  63.         15 => 16384,
  64.         16 => 32768
  65.         );
  66.         my %AUGTYPES = (
  67.         1 => 1,
  68.         2 => 2,
  69.         3 => 4,
  70.         4 => 8,
  71.         5 => 16,
  72.         6 => 32,
  73.         7 => 64,
  74.         8 => 128,
  75.         9 => 256,
  76.         10 => 512,
  77.         11 => 1024,
  78.         12 => 2048,
  79.         13 => 4096,
  80.         14 => 8192,
  81.         15 => 16384,
  82.         16 => 32768,
  83.         17 => 65536,
  84.         18 => 131072,
  85.         19 => 262144,
  86.         20 => 524288,
  87.         21 => 1048576,
  88.         22 => 2097152,
  89.         23 => 4194304,
  90.         24 => 8388608,
  91.         25 => 16777216,
  92.         26 => 33554432,
  93.         27 => 67108864,
  94.         28 => 134217728,
  95.         29 => 268435456,
  96.         30 => 536870912
  97.         );
  98.         my $dbh = plugin::LoadMysql();
  99.        
  100.         my $SCLASS = $classes{$client->GetClass()};
  101.         my $SRACE = $racelist{$client->GetBaseRace()};
  102.         $query = "SELECT id, slots, hp, augslot1type, augslot2type, augslot3type, augslot4type, augslot5type, augslot1visible, augslot2visible, augslot3visible, augslot4visible, augslot5visible FROM items i WHERE
  103.                     classes & $SCLASS
  104.                     and hp > 0
  105.                     and aagi >= 0
  106.                     and acha >= 0
  107.                     and adex >= 0
  108.                     and aint >= 0
  109.                     and asta >= 0
  110.                     and astr >= 0
  111.                     and awis >= 0
  112.                     and i.reqlevel <= $ulevel
  113.                     and i.reclevel <= $ulevel
  114.                     and i.norent >= 1
  115.                     and i.itemtype != 54
  116.                     and races & $SRACE
  117.                     and deity = 0
  118.                     and charmfileid = 0
  119.                     and id IN (109051,109432,109451,50459,50629,50221,50631,50226,50227,50229,50622,50627,50617,50625,50234,50232,50235,50236,50237,50623,50618,50217,50213,50216,50220,50218,50219,50215,50214,50630,50620,50621,50243,50241,50246,50242,50244,50239,50619,50626,109416,109032,109016,50449,50628,50225,50228,50223,50233,50224,50238,50245,50222,50231,50624,110460,110419,110293,110291,110456,110433,110412,110422,110430,110416,110401,110449,110440,110409,110452,110443,110406,110425,110447,50230,110009,110060,110012,110437,110019,109950,109550,109902,109810,109799,109789,109807,109938,109800,109793,109531,109918,109931,109518,109804,109502,109538,109456,109056,109287,110442,110400,110413,110418,110294,110448,110428,110455,110010,110410,110421,110426,110018,110048,110451,110458,110408,110004,109802,109785,109515,109797,109794,109919,109805,109791,109788,109532,109539,109808,109915,109932,50577,50592,109500,109939,109900,109519,109801,109516,109540,109927,109787,109809,109792,109803,109806,109936,109527,109796,109536,109940,109501,109901,1624,109947,109766,109547,109916,109544,109944,109739,110454,110405,110411,110292,110431,110415,110450,110402,110441,110438,110435,110235,110007,111305,111521,49656,50240,111304,111312,111516,111351,111350,111306,111327,111313,111356,111511,110444,110417,110407,110295,110423,110427,110420,110457,110257,110017,110788,110787,110786,110785,110434,110296,110414,110445,110459,110285,110453,110424,110429,110403,110029,110271,110244,110014,110789,110794,110793,110795,110768,110766,110958,110748,110558,110944,110544,110739,110525,110756,110925,110745)
  120.                     Order by hp desc";
  121.        
  122.             $sth = $dbh->prepare($query);
  123.             $sth->execute();
  124.             while (@row = $sth->fetchrow_array())
  125.             {
  126.                 $items_list[$row[0]] = [@row];
  127.             }
  128.            
  129.             for $i ( 0 .. 20) {
  130.                 $bestitem = 0;
  131.                 for my $ref (@items_list) {
  132.                     for my $item_id (@$ref) {
  133.                         if($items_list[$item_id][0] > 0) {
  134.                             if($items_list[$item_id][2] > $client->GetItemStat($client->GetItemIDAt($i), "hp") && $slots{$i} & $items_list[$item_id][1]) {
  135.                                 $bestitem = $items_list[$item_id][0];
  136.                             }
  137.                             last; #We got the item... (BREAK THE FUCK OUT)
  138.                         }
  139.                     }
  140.                 }
  141.                 if ($bestitem > 0) {
  142.                     #ADD BEST ITEM?
  143.                         $client->SummonItem($bestitem, 1, 0, 0, 0, 0, 0, 0, $i);
  144.                         $client->Message(315, "Now equipping : ". quest::varlink($bestitem) . " into slot $i.");
  145.                 }
  146.             }
  147.        
  148.         if ($sth) { $sth->finish(); }
  149.         $dbh->disconnect();
  150.         $client->Message(335, "FINISHED!");
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement