Advertisement
Angst

TStone [+10] v5

Dec 16th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.93 KB | None | 0 0
  1. //===================================================================================================
  2. //  Tier Stone Refining
  3. //  v5  -Some If statements had the wrong comparison operators.
  4. //  v4  -Added "Merge all stones to highest possible Tier" menu option.
  5. //  v3  -Changed rates from 3 to 2 stones required per Tier. 10 fragments required for T1.
  6. //===================================================================================================
  7. function    script  AMRA    {
  8.     set .@id, getarg(0);
  9.     if (.@id == 32100 && countitem(.@id) < 9) {
  10.         message strcharinfo(0), "Unable to start merging process: " + (10 - countitem(.@id)) + " " + getitemname(.@id) + "'s are needed.";
  11.         end;
  12.     }
  13.     if (.@id == 32100 && countitem(.@id) == 9) {
  14.         message strcharinfo(0), "Unable to start merging process: " + (10 - countitem(.@id)) + " " + getitemname(.@id) + " is needed.";
  15.         end;
  16.     }
  17.     if (.@id == 32100) {
  18.         getitem (1 + .@id), (countitem(.@id)/10);
  19.         delitem .@id, ((countitem(.@id)/10)*10);
  20.         if (countitem(.@id) == 1) {
  21.             message strcharinfo(0), "One " + getitemname(.@id) + " could not merge.";
  22.         }
  23.         close;
  24.     }
  25.     if (.@id >= 32101 && .@id <= 32109) {
  26.         prompt "Merge all stones to highest possible Tier.","Merge ^000077" + getitemname(.@id) + "^000000 to ^000077" + getitemname(.@id + 1) + "^000000.","Apply ^000077" + getitemname(.@id) + "^000000 to Equipment.";
  27.         if (@menu == 1) {
  28.             if (.@id >= 32101 && .@id <= 32109 && countitem(.@id) == 1) {
  29.                 message strcharinfo(0), "Unable to start merging process: One more " + getitemname(.@id) + " is needed.";
  30.                 end;
  31.             }
  32.             set .@amt, countitem(.@id);
  33.             set .@id2, .@id;
  34.             set .@repeat, (9 - (.@id2 - 32100));
  35.             set .@getcnt, .@amt;
  36.             set .@amt2, ((.@amt / 2) * 2);
  37.             while (.@r <= .@repeat) {
  38.                 // tier calc
  39.                 set .@r, .@r + 1;
  40.                 set .@getid, .@id2 + 1;
  41.                 set .@getcnt, .@amt / 2;
  42.                 set .@del1, .@id2;
  43.                 set .@del2, ((.@amt / 2) * 2);
  44.                 set .@amt, .@amt / 2;
  45.                 set .@id2, .@id2 + 1;
  46.                 if (.@amt == 1) {
  47.                     set .@r, .@r + .@repeat;
  48.                 }
  49.             }
  50.             switch (.@id) {
  51.                 case 32101:
  52.                     if (countitem(.@id) >= 512) {
  53.                         delitem .@id, 512;
  54.                         getitem .@getid, .@getcnt;
  55.                     }
  56.                     redo:
  57.                     if (.@id == 32110) {
  58.                         break;
  59.                     }
  60.                     if (countitem(.@id) >= 2) {
  61.                         getitem (1 + .@id), (countitem(.@id)/2);
  62.                         delitem .@id, ((countitem(.@id)/2)*2);
  63.                         if (countitem(.@id + 1) >= 2) {
  64.                             set .@id, .@id + 1;
  65.                             goto redo;
  66.                         }
  67.                     }
  68.                     break;
  69.                 case 32102:
  70.                     if (countitem(.@id) >= 256) {
  71.                         set .@got, 1;
  72.                         delitem .@id, 256;
  73.                         getitem .@getid, .@getcnt;
  74.                     }
  75.                     goto redo;
  76.                     break;
  77.                 case 32103:
  78.                     if (countitem(.@id) >= 128) {
  79.                         delitem .@id, 128;
  80.                         getitem .@getid, .@getcnt;
  81.                     }
  82.                     goto redo;
  83.                     break;
  84.                 case 32104:
  85.                     if (countitem(.@id) >= 64) {
  86.                         delitem .@id, 64;
  87.                         getitem .@getid, .@getcnt;
  88.                     }
  89.                     goto redo;
  90.                     break;
  91.                 case 32105:
  92.                     if (countitem(.@id) >= 32) {
  93.                         delitem .@id, 32;
  94.                         getitem .@getid, .@getcnt;
  95.                     }
  96.                     goto redo;
  97.                     break;
  98.                 case 32106:
  99.                     if (countitem(.@id) >= 16) {
  100.                         delitem .@id, 16;
  101.                         getitem .@getid, .@getcnt;
  102.                     }
  103.                     goto redo;
  104.                     break;
  105.                 case 32107:
  106.                     if (countitem(.@id) >= 8) {
  107.                         delitem .@id, 8;
  108.                         getitem .@getid, .@getcnt;
  109.                     }
  110.                     goto redo;
  111.                     break;
  112.                 case 32108:
  113.                     if (countitem(.@id) >= 4) {
  114.                         delitem .@id, 4;
  115.                         getitem .@getid, .@getcnt;
  116.                     }
  117.                     goto redo;
  118.                     break;
  119.                 case 32109:
  120.                     if (countitem(.@id) >= 2) {
  121.                         delitem .@id, 2;
  122.                         getitem .@getid, .@getcnt;
  123.                     }
  124.                     goto redo;
  125.                     break;
  126.             }
  127.             setarray .@err[1],  (countitem(32101) == 1 ? 1 : 0),
  128.                     (countitem(32102) == 1 ? 1 : 0),
  129.                     (countitem(32103) == 1 ? 1 : 0),
  130.                     (countitem(32104) == 1 ? 1 : 0),
  131.                     (countitem(32105) == 1 ? 1 : 0),
  132.                     (countitem(32106) == 1 ? 1 : 0),
  133.                     (countitem(32107) == 1 ? 1 : 0),
  134.                     (countitem(32108) == 1 ? 1 : 0),
  135.                     (countitem(32109) == 1 ? 1 : 0);
  136.             setarray .@err$[1],"One","Two","Three","Four","Five","Six","Seven","Eight","Nine";
  137.             set .@err2, (.@err[1] + .@err[2] + .@err[3] + .@err[4] + .@err[5] + .@err[6] + .@err[7] + .@err[8] + .@err[9]);
  138.             if (.@err2 == 1) {
  139.                 message strcharinfo(0), .@err$[.@err2] +" Amra Stone not fully merged.";
  140.             }
  141.             if (.@err2 > 1) {
  142.                 message strcharinfo(0), .@err$[.@err2] +" Amra Stones not fully merged.";
  143.             }
  144.             close;
  145.             end;
  146.         }
  147.         if (@menu == 2) {
  148.             if (.@id >= 32101 && .@id <= 32109 && countitem(.@id) == 1) {
  149.                 message strcharinfo(0), "Unable to start merging process: One more " + getitemname(.@id) + " is needed.";
  150.                 end;
  151.             }
  152.             getitem (1 + .@id), (countitem(.@id)/2);
  153.             delitem .@id, ((countitem(.@id)/2)*2);
  154.             close;
  155.         }
  156.         if (@menu == 3) {
  157.             callfunc "AMRACOMB",.@id;
  158.         }
  159.     }
  160.     if (.@id == 32110) {
  161.         prompt "Apply to Equipment";
  162.         if (@menu == 1) {
  163.             callfunc "AMRACOMB",.@id;
  164.         }
  165.     }
  166. }
  167.  
  168. function    script  AMRACOMB    {
  169.     set .@id, getarg(0);
  170.     mes "Select what you wish to refine.";
  171.     mes " ";
  172.     mes "You can refine an item up to  +" + (.@id - 32100) + " using this stone.";
  173.     setarray .@position$[1], "Head (Upper)","Armor","Left hand","Right hand","Robe","Shoes","Accessory (Left)","Accessory (Right)","Head (Mid)","Head (Lower)";
  174.     set .@menu$,"";
  175.     for (set .@i, 1; .@i <= 10; set .@i, .@i + 1) {
  176.         if (getequipisequiped(.@i))
  177.             if (getequiprefinerycnt(.@i) > 0) {
  178.                 set .@menu$, .@menu$ + .@position$[.@i] + " - " + "[ + " + getequiprefinerycnt(.@i) + " " + getequipname(.@i) + "]";
  179.             } else {
  180.                 set .@menu$, .@menu$ + .@position$[.@i] + " - " + "[" + getequipname(.@i) + "]";
  181.             }
  182.         set .@menu$, .@menu$ + ":";
  183.     }
  184.     set .@part, select(.@menu$);
  185.     if (!getequipisequiped(.@part)) {
  186.         close2;
  187.         message strcharinfo(0), "Nothing equipped in that slot.";
  188.         end;
  189.     }
  190.     if (!getequipisenableref(.@part)) {
  191.         close2;
  192.         message strcharinfo(0), "This item is not refineable.";
  193.         end;
  194.     }
  195.     if (!getequipisidentify(.@part)) {
  196.         close2;
  197.         message strcharinfo(0), "This has not been identified. Please identify it before attempting to refine.";
  198.         end;
  199.     }
  200.     if (getequiprefinerycnt(.@part) >= 10) {
  201.         close2;
  202.         message strcharinfo(0), "Max level reached, the process has failed.";
  203.         end;
  204.     }
  205.     close2;
  206.     if (.@id >= 1) {
  207.         set .@refineitemid, getequipid(.@part);//       save id of the item
  208.         set .@refinerycnt, getequiprefinerycnt(.@part); //  save refinery count
  209.         if(getequipisequiped(.@part) == 0) {//      hacker has removed the item (not changed, why?)
  210.             mes "Equipment removal detected, refinement canceled.";
  211.             close;
  212.         }
  213.         if(getequiprefinerycnt(.@part) != .@refinerycnt || getequipid(.@part) != .@refineitemid) {//    hacker has changed the item
  214.             mes "Equipment switch detected, refinement canceled.";
  215.             close;
  216.         }
  217.         if (.@part == 1) { set .@reflvl, 256; }
  218.         if (.@part == 2) { set .@reflvl, 16; }
  219.         if (.@part == 3) { set .@reflvl, 32; }
  220.         if (.@part == 4) { set .@reflvl, 2; }
  221.         if (.@part == 5) { set .@reflvl, 4; }
  222.         if (.@part == 6) { set .@reflvl, 64; }
  223.         if (.@part == 7) { set .@reflvl, 8; }
  224.         if (.@part == 8) { set .@reflvl, 128; }
  225.         if (.@part == 9) { set .@reflvl, 512; }
  226.         if (.@part == 10) { set .@reflvl, 1; }
  227.         set .@tlevel, (.@id - 32100);
  228.         set .@currefine, getequiprefinerycnt(.@part);
  229.         if (getequiprefinerycnt(.@part) > 0) {
  230.             if (.@currefine == .@tlevel) {
  231.                 mes "You cannot use this stone on your " + getequipname(.@part) + ".";
  232.                 mes "Current equipment's refinement is equal to the stone's power.";
  233.                 close;
  234.             }
  235.             if (.@currefine > .@tlevel) {
  236.                 mes "You cannot use this stone on your " + getequipname(.@part) + ".";
  237.                 mes "Current equipment's refinement is higher than the stone's power.";
  238.                 close;
  239.             }
  240.             if (.@currefine < .@tlevel) {
  241.                 delitem .@id, 1;
  242.                 atcommand "@refine " + .@reflvl + " " + (.@tlevel - .@currefine);
  243.             }
  244.  
  245.         }
  246.         if (getequiprefinerycnt(.@part) == 0) {
  247.             delitem .@id, 1;
  248.             atcommand "@refine " + .@reflvl + " " + .@tlevel + "";
  249.         }
  250.  
  251.  
  252.     }
  253. return;
  254. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement