Advertisement
Paldail

GMGEARME

May 16th, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 9.65 KB | None | 0 0
  1. sub gmgearme2 {
  2.     my $client = plugin::val('$client');
  3.     my $text = plugin::val('$text');
  4.     my $ulevel = $client->GetLevel();
  5.     my $items_list;
  6.    
  7.     my $do_target = $_[0];
  8.     my $do_augs = $_[1];
  9.    
  10.     if ($client->GetTarget() && $client->GetTarget()->IsClient() && $client->GetTarget()->GetName() eq "$do_target") {
  11.         $client->Message(335, "Now gearing up $do_target");
  12.         $client = $client->GetTarget()->CastToClient();
  13.         $ulevel = $client->GetLevel();
  14.     }
  15.    
  16.         my %racelist = (
  17.         1 => 1,
  18.         2 => 2,
  19.         3 => 4,
  20.         4 => 8,
  21.         5 => 16,
  22.         6 => 32,
  23.         7 => 64,
  24.         8 => 128,
  25.         9 => 256,
  26.         10 => 512,
  27.         11 => 1024,
  28.         12 => 2048,
  29.         128 => 4096,
  30.         130 => 8192,
  31.         330 => 16384,
  32.         522 => 65535
  33.         );
  34.         my %slots = (
  35.         0 => 1,
  36.         1 => 18,
  37.         2 => 4,
  38.         3 => 8,
  39.         4 => 18,
  40.         5 => 32,
  41.         6 => 64,
  42.         7 => 128,
  43.         8 => 256,
  44.         9 => 1536,
  45.         10 => 1536,
  46.         11 => 2048,
  47.         12 => 4096,
  48.         13 => 8192,
  49.         14 => 16384,
  50.         15 => 98304,
  51.         16 => 98304,
  52.         17 => 131072,
  53.         18 => 262144,
  54.         19 => 524288,
  55.         20 => 1048576
  56.         );
  57.         my %classes = (
  58.         1 => 1,
  59.         2 => 2,
  60.         3 => 4,
  61.         4 => 8,
  62.         5 => 16,
  63.         6 => 32,
  64.         7 => 64,
  65.         8 => 128,
  66.         9 => 256,
  67.         10 => 512,
  68.         11 => 1024,
  69.         12 => 2048,
  70.         13 => 4096,
  71.         14 => 8192,
  72.         15 => 16384,
  73.         16 => 32768
  74.         );
  75.         my %AUGTYPES = (
  76.         1 => 1,
  77.         2 => 2,
  78.         3 => 4,
  79.         4 => 8,
  80.         5 => 16,
  81.         6 => 32,
  82.         7 => 64,
  83.         8 => 128,
  84.         9 => 256,
  85.         10 => 512,
  86.         11 => 1024,
  87.         12 => 2048,
  88.         13 => 4096,
  89.         14 => 8192,
  90.         15 => 16384,
  91.         16 => 32768,
  92.         17 => 65536,
  93.         18 => 131072,
  94.         19 => 262144,
  95.         20 => 524288,
  96.         21 => 1048576,
  97.         22 => 2097152,
  98.         23 => 4194304,
  99.         24 => 8388608,
  100.         25 => 16777216,
  101.         26 => 33554432,
  102.         27 => 67108864,
  103.         28 => 134217728,
  104.         29 => 268435456,
  105.         30 => 536870912
  106.         );
  107.         my $dbh = plugin::LoadMysql();
  108.        
  109.         my $SCLASS = $classes{$client->GetClass()};
  110.         my $SRACE = $racelist{$client->GetBaseRace()};
  111.         my $query = "SELECT id, slots, hp, augslot1type, augslot2type, augslot3type, augslot4type, augslot5type, augslot1visible, augslot2visible, augslot3visible, augslot4visible, augslot5visible FROM items i WHERE
  112.                     classes & $SCLASS
  113.                     and hp > 0
  114.                     and aagi >= 0
  115.                     and acha >= 0
  116.                     and adex >= 0
  117.                     and aint >= 0
  118.                     and asta >= 0
  119.                     and astr >= 0
  120.                     and awis >= 0
  121.                     and i.reqlevel <= $ulevel
  122.                     and i.reclevel <= $ulevel
  123.                     and i.norent >= 1
  124.                     and i.itemtype != 54
  125.                     and races & $SRACE
  126.                     and deity = 0
  127.                     and charmfileid = 0 ".
  128.                     #"and source like '%custom%' ".
  129.                     #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)
  130.                     "Order by hp desc";
  131.        
  132.             $sth = $dbh->prepare($query);
  133.             $sth->execute();
  134.             my $rank = 0;
  135.             while (@row = $sth->fetchrow_array())
  136.             {
  137.                 $items_list[$rank] = [@row];
  138.                 $rank++;
  139.             }
  140.         my $query2 = "SELECT id, slots, hp, augtype FROM items i WHERE " .
  141.                      "classes & $SCLASS " .
  142.                      "and hp > 0 " .
  143.                      "and i.reqlevel <= $ulevel " .
  144.                      "and i.reclevel <= $ulevel " .
  145.                      "and i.norent >= 1 " .
  146.                      "and i.itemtype = 54 " .
  147.                      "and races & $SRACE " .
  148.                      "and deity = 0 " .
  149.                      "and charmfileid = 0 ".
  150.                      "Order by hp desc";
  151.             $sth = $dbh->prepare($query2);
  152.             $sth->execute();
  153.             my $rank2 = 0;
  154.             while (@row = $sth->fetchrow_array())
  155.             {
  156.                 $aug_list[$rank2] = [@row];
  157.                 $rank2++;
  158.             }
  159.        
  160.             OUTER: for my $i ( 0 .. 20) {
  161.                 $bestitem = 0;
  162.                
  163.                 INNER: for my $g ( 0 .. $rank) {
  164.                     if($items_list[$g][0] > 0) {
  165.                         if($items_list[$g][2] > $client->GetItemStat($client->GetItemIDAt($i), "hp") && $slots{$i} & $items_list[$g][1]) {
  166.                             if($items_list[$g][0] == $client->GetItemIDAt($i)) {
  167.                                 next OUTER;
  168.                             } #already have this item in this slot..
  169.                             if(plugin::check_hasitem($client, $items_list[$g][0]) && $client->GetItemStat($items_list[$g][0], "loregroup") != 0) {
  170.                                 $client->Message(335, "Already have it is LORE " . quest::varlink($items_list[$g][0]));
  171.                                 next INNER;
  172.                             } else {
  173.                                 $bestitem = $items_list[$g][0];
  174.                                 if ($bestitem > 0) {
  175.                                     #ADD BEST ITEM?
  176.                                     my $augslot1, $augslot2, $augslot3, $augslot4, $augslot5 = 0;
  177.                                     my @augarray = ();
  178.                                    
  179.                                     if ($do_augs == 1) {
  180.                                         #aug 1
  181.                                         if ($items_list[$g][3] > 0) { #Slot is active
  182.                                             AUG1: for my $p ( 0 .. $rank2) {
  183.                                                 if ($slots{$i} & $aug_list[$p][1] ) { #This matches the slot..
  184.                                                     if((plugin::check_hasitem($client, $aug_list[$p][0]) || grep { $aug_list[$p][0] } @augarray) && $client->GetItemStat($aug_list[$p][0], "loregroup") != 0) {
  185.                                                         #We have this item already.. and its lore
  186.                                                         next AUG1;
  187.                                                     }
  188.                                                     if ($aug_list[$p][3] & $AUGTYPES{$items_list[$g][3]}) { #the aug matches augtype..
  189.                                                         $augslot1 = $aug_list[$p][0];
  190.                                                         push(@augarray, $aug_list[$p][0]);
  191.                                                         last AUG1;
  192.                                                     }
  193.                                                 }
  194.                                             }
  195.                                         }
  196.                                         #aug 2
  197.                                         if ($items_list[$g][4] > 0) { #Slot is active
  198.                                             AUG2: for my $p ( 0 .. $rank2) {
  199.                                                 if ($slots{$i} & $aug_list[$p][1] ) { #This matches the slot..
  200.                                                     if((plugin::check_hasitem($client, $aug_list[$p][0]) || grep { $aug_list[$p][0] } @augarray) && $client->GetItemStat($aug_list[$p][0], "loregroup") != 0) {
  201.                                                         #We have this item already.. and its lore
  202.                                                         next AUG2;
  203.                                                     }
  204.                                                     if ($aug_list[$p][4] & $AUGTYPES{$items_list[$g][4]}) { #the aug matches augtype..
  205.                                                         $augslot2 = $aug_list[$p][0];
  206.                                                         push(@augarray, $aug_list[$p][0]);
  207.                                                         last AUG2;
  208.                                                     }
  209.                                                 }
  210.                                             }
  211.                                         }
  212.                                         #aug 3
  213.                                         if ($items_list[$g][5] > 0) { #Slot is active
  214.                                             AUG3: for my $p ( 0 .. $rank2) {
  215.                                                 if ($slots{$i} & $aug_list[$p][1] ) { #This matches the slot..
  216.                                                     if((plugin::check_hasitem($client, $aug_list[$p][0]) || grep { $aug_list[$p][0] } @augarray) && $client->GetItemStat($aug_list[$p][0], "loregroup") != 0) {
  217.                                                         #We have this item already.. and its lore
  218.                                                         next AUG3;
  219.                                                     }
  220.                                                     if ($aug_list[$p][5] & $AUGTYPES{$items_list[$g][5]}) { #the aug matches augtype..
  221.                                                         $augslot3 = $aug_list[$p][0];
  222.                                                         push(@augarray, $aug_list[$p][0]);
  223.                                                         last AUG3;
  224.                                                     }
  225.                                                 }
  226.                                             }
  227.                                         }
  228.                                         #aug 4
  229.                                         if ($items_list[$g][6] > 0) { #Slot is active
  230.                                             AUG4: for my $p ( 0 .. $rank2) {
  231.                                                 if ($slots{$i} & $aug_list[$p][1] ) { #This matches the slot..
  232.                                                     if((plugin::check_hasitem($client, $aug_list[$p][0]) || grep { $aug_list[$p][0] } @augarray) && $client->GetItemStat($aug_list[$p][0], "loregroup") != 0) {
  233.                                                         #We have this item already.. and its lore
  234.                                                         next AUG4;
  235.                                                     }
  236.                                                     if ($aug_list[$p][6] & $AUGTYPES{$items_list[$g][6]}) { #the aug matches augtype..
  237.                                                         $augslot3 = $aug_list[$p][0];
  238.                                                         push(@augarray, $aug_list[$p][0]);
  239.                                                         last AUG4;
  240.                                                     }
  241.                                                 }
  242.                                             }
  243.                                         }
  244.                                         #aug 5
  245.                                         if ($items_list[$g][7] > 0) { #Slot is active
  246.                                             AUG5: for my $p ( 0 .. $rank2) {
  247.                                                 if ($slots{$i} & $aug_list[$p][1] ) { #This matches the slot..
  248.                                                     if((plugin::check_hasitem($client, $aug_list[$p][0]) || grep { $aug_list[$p][0] } @augarray) && $client->GetItemStat($aug_list[$p][0], "loregroup") != 0) {
  249.                                                         #We have this item already.. and its lore
  250.                                                         next AUG5;
  251.                                                     }
  252.                                                     if ($aug_list[$p][7] & $AUGTYPES{$items_list[$g][7]}) { #the aug matches augtype..
  253.                                                         $augslot3 = $aug_list[$p][0];
  254.                                                         push(@augarray, $aug_list[$p][0]);
  255.                                                         last AUG5;
  256.                                                     }
  257.                                                 }
  258.                                             }
  259.                                         }
  260.                                     }
  261.                                    
  262.                                    
  263.                                     $client->SummonItem($bestitem, 1, 0, $augslot1, $augslot2, $augslot3, $augslot4, $augslot5, $i);
  264.                                     $client->Message(315, "Now equipping : ". quest::varlink($bestitem) . " into slot $i.");
  265.                                 }
  266.                                 next OUTER;
  267.                             }
  268.                            
  269.                         }
  270.                     }
  271.                 }
  272.             }  
  273.         if ($sth) { $sth->finish(); }
  274.         $dbh->disconnect();
  275.         $client->Message(335, "FINISHED!");
  276. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement