Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===================================================================================================
- // Tier Stone Refining
- // v5 -Some If statements had the wrong comparison operators.
- // v4 -Added "Merge all stones to highest possible Tier" menu option.
- // v3 -Changed rates from 3 to 2 stones required per Tier. 10 fragments required for T1.
- //===================================================================================================
- function script AMRA {
- set .@id, getarg(0);
- if (.@id == 32100 && countitem(.@id) < 9) {
- message strcharinfo(0), "Unable to start merging process: " + (10 - countitem(.@id)) + " " + getitemname(.@id) + "'s are needed.";
- end;
- }
- if (.@id == 32100 && countitem(.@id) == 9) {
- message strcharinfo(0), "Unable to start merging process: " + (10 - countitem(.@id)) + " " + getitemname(.@id) + " is needed.";
- end;
- }
- if (.@id == 32100) {
- getitem (1 + .@id), (countitem(.@id)/10);
- delitem .@id, ((countitem(.@id)/10)*10);
- if (countitem(.@id) == 1) {
- message strcharinfo(0), "One " + getitemname(.@id) + " could not merge.";
- }
- close;
- }
- if (.@id >= 32101 && .@id <= 32109) {
- 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.";
- if (@menu == 1) {
- if (.@id >= 32101 && .@id <= 32109 && countitem(.@id) == 1) {
- message strcharinfo(0), "Unable to start merging process: One more " + getitemname(.@id) + " is needed.";
- end;
- }
- set .@amt, countitem(.@id);
- set .@id2, .@id;
- set .@repeat, (9 - (.@id2 - 32100));
- set .@getcnt, .@amt;
- set .@amt2, ((.@amt / 2) * 2);
- while (.@r <= .@repeat) {
- // tier calc
- set .@r, .@r + 1;
- set .@getid, .@id2 + 1;
- set .@getcnt, .@amt / 2;
- set .@del1, .@id2;
- set .@del2, ((.@amt / 2) * 2);
- set .@amt, .@amt / 2;
- set .@id2, .@id2 + 1;
- if (.@amt == 1) {
- set .@r, .@r + .@repeat;
- }
- }
- switch (.@id) {
- case 32101:
- if (countitem(.@id) >= 512) {
- delitem .@id, 512;
- getitem .@getid, .@getcnt;
- }
- redo:
- if (.@id == 32110) {
- break;
- }
- if (countitem(.@id) >= 2) {
- getitem (1 + .@id), (countitem(.@id)/2);
- delitem .@id, ((countitem(.@id)/2)*2);
- if (countitem(.@id + 1) >= 2) {
- set .@id, .@id + 1;
- goto redo;
- }
- }
- break;
- case 32102:
- if (countitem(.@id) >= 256) {
- set .@got, 1;
- delitem .@id, 256;
- getitem .@getid, .@getcnt;
- }
- goto redo;
- break;
- case 32103:
- if (countitem(.@id) >= 128) {
- delitem .@id, 128;
- getitem .@getid, .@getcnt;
- }
- goto redo;
- break;
- case 32104:
- if (countitem(.@id) >= 64) {
- delitem .@id, 64;
- getitem .@getid, .@getcnt;
- }
- goto redo;
- break;
- case 32105:
- if (countitem(.@id) >= 32) {
- delitem .@id, 32;
- getitem .@getid, .@getcnt;
- }
- goto redo;
- break;
- case 32106:
- if (countitem(.@id) >= 16) {
- delitem .@id, 16;
- getitem .@getid, .@getcnt;
- }
- goto redo;
- break;
- case 32107:
- if (countitem(.@id) >= 8) {
- delitem .@id, 8;
- getitem .@getid, .@getcnt;
- }
- goto redo;
- break;
- case 32108:
- if (countitem(.@id) >= 4) {
- delitem .@id, 4;
- getitem .@getid, .@getcnt;
- }
- goto redo;
- break;
- case 32109:
- if (countitem(.@id) >= 2) {
- delitem .@id, 2;
- getitem .@getid, .@getcnt;
- }
- goto redo;
- break;
- }
- setarray .@err[1], (countitem(32101) == 1 ? 1 : 0),
- (countitem(32102) == 1 ? 1 : 0),
- (countitem(32103) == 1 ? 1 : 0),
- (countitem(32104) == 1 ? 1 : 0),
- (countitem(32105) == 1 ? 1 : 0),
- (countitem(32106) == 1 ? 1 : 0),
- (countitem(32107) == 1 ? 1 : 0),
- (countitem(32108) == 1 ? 1 : 0),
- (countitem(32109) == 1 ? 1 : 0);
- setarray .@err$[1],"One","Two","Three","Four","Five","Six","Seven","Eight","Nine";
- set .@err2, (.@err[1] + .@err[2] + .@err[3] + .@err[4] + .@err[5] + .@err[6] + .@err[7] + .@err[8] + .@err[9]);
- if (.@err2 == 1) {
- message strcharinfo(0), .@err$[.@err2] +" Amra Stone not fully merged.";
- }
- if (.@err2 > 1) {
- message strcharinfo(0), .@err$[.@err2] +" Amra Stones not fully merged.";
- }
- close;
- end;
- }
- if (@menu == 2) {
- if (.@id >= 32101 && .@id <= 32109 && countitem(.@id) == 1) {
- message strcharinfo(0), "Unable to start merging process: One more " + getitemname(.@id) + " is needed.";
- end;
- }
- getitem (1 + .@id), (countitem(.@id)/2);
- delitem .@id, ((countitem(.@id)/2)*2);
- close;
- }
- if (@menu == 3) {
- callfunc "AMRACOMB",.@id;
- }
- }
- if (.@id == 32110) {
- prompt "Apply to Equipment";
- if (@menu == 1) {
- callfunc "AMRACOMB",.@id;
- }
- }
- }
- function script AMRACOMB {
- set .@id, getarg(0);
- mes "Select what you wish to refine.";
- mes " ";
- mes "You can refine an item up to +" + (.@id - 32100) + " using this stone.";
- setarray .@position$[1], "Head (Upper)","Armor","Left hand","Right hand","Robe","Shoes","Accessory (Left)","Accessory (Right)","Head (Mid)","Head (Lower)";
- set .@menu$,"";
- for (set .@i, 1; .@i <= 10; set .@i, .@i + 1) {
- if (getequipisequiped(.@i))
- if (getequiprefinerycnt(.@i) > 0) {
- set .@menu$, .@menu$ + .@position$[.@i] + " - " + "[ + " + getequiprefinerycnt(.@i) + " " + getequipname(.@i) + "]";
- } else {
- set .@menu$, .@menu$ + .@position$[.@i] + " - " + "[" + getequipname(.@i) + "]";
- }
- set .@menu$, .@menu$ + ":";
- }
- set .@part, select(.@menu$);
- if (!getequipisequiped(.@part)) {
- close2;
- message strcharinfo(0), "Nothing equipped in that slot.";
- end;
- }
- if (!getequipisenableref(.@part)) {
- close2;
- message strcharinfo(0), "This item is not refineable.";
- end;
- }
- if (!getequipisidentify(.@part)) {
- close2;
- message strcharinfo(0), "This has not been identified. Please identify it before attempting to refine.";
- end;
- }
- if (getequiprefinerycnt(.@part) >= 10) {
- close2;
- message strcharinfo(0), "Max level reached, the process has failed.";
- end;
- }
- close2;
- if (.@id >= 1) {
- set .@refineitemid, getequipid(.@part);// save id of the item
- set .@refinerycnt, getequiprefinerycnt(.@part); // save refinery count
- if(getequipisequiped(.@part) == 0) {// hacker has removed the item (not changed, why?)
- mes "Equipment removal detected, refinement canceled.";
- close;
- }
- if(getequiprefinerycnt(.@part) != .@refinerycnt || getequipid(.@part) != .@refineitemid) {// hacker has changed the item
- mes "Equipment switch detected, refinement canceled.";
- close;
- }
- if (.@part == 1) { set .@reflvl, 256; }
- if (.@part == 2) { set .@reflvl, 16; }
- if (.@part == 3) { set .@reflvl, 32; }
- if (.@part == 4) { set .@reflvl, 2; }
- if (.@part == 5) { set .@reflvl, 4; }
- if (.@part == 6) { set .@reflvl, 64; }
- if (.@part == 7) { set .@reflvl, 8; }
- if (.@part == 8) { set .@reflvl, 128; }
- if (.@part == 9) { set .@reflvl, 512; }
- if (.@part == 10) { set .@reflvl, 1; }
- set .@tlevel, (.@id - 32100);
- set .@currefine, getequiprefinerycnt(.@part);
- if (getequiprefinerycnt(.@part) > 0) {
- if (.@currefine == .@tlevel) {
- mes "You cannot use this stone on your " + getequipname(.@part) + ".";
- mes "Current equipment's refinement is equal to the stone's power.";
- close;
- }
- if (.@currefine > .@tlevel) {
- mes "You cannot use this stone on your " + getequipname(.@part) + ".";
- mes "Current equipment's refinement is higher than the stone's power.";
- close;
- }
- if (.@currefine < .@tlevel) {
- delitem .@id, 1;
- atcommand "@refine " + .@reflvl + " " + (.@tlevel - .@currefine);
- }
- }
- if (getequiprefinerycnt(.@part) == 0) {
- delitem .@id, 1;
- atcommand "@refine " + .@reflvl + " " + .@tlevel + "";
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement