// TMW2 scripts. // Authors: // Jesusalva, Fedja // Description: // Allows to create your own fish/plushroom/croconut box - script Empty Box#it NPC_HIDDEN,{ close; OnUse: // qty, itemID, boxItemId setarray .@boxMatrix, 50, Aquada, AquadaBox, 20, CommonCarp, FishBox, 8, Croconut, CroconutBox, 7, GrassCarp, FishBox, 87, Plushroom, PlushroomBox, 200, TolchiArrow, TolchiAmmoBox, 200, TrainingArrow, TrainingAmmoBox, 200, Arrow, ArrowAmmoBox, 200, IronArrow, IronAmmoBox, 200, CursedArrow, CursedAmmoBox, 200, PoisonArrow, PoisonAmmoBox, 200, ThornArrow, ThornAmmoBox, 200, BoneArrow, BoneAmmoBox; // Strings presented to player, indexes must match above. setarray .@boxStrings, l("50 Aquadas"), l("20 Common Carps"), l("8 Croconuts"), l("7 Grass Carps"), l("87 Plushrooms"), l("200 tolchi arrows"), l("200 training arrows"), l("200 normal arrows"), l("200 iron arrows"), l("200 cursed arrows"), l("200 poison arrows"), l("200 thorn arrows"), l("200 bone arrows"); if (getarraysize(.@boxStrings) * 3 != getarraysize(.@boxMatrix)) Exception("Invalid array size: "+getarraysize(.@boxStrings) +"*3 !="+getarraysize(.@boxMatrix), RB_DEFAULT|RB_ISFATAL); mesn; mesc l("You can fill this box with the following items:"); setarray .@menuOptions$, l("Don't fill"), "-1"; //freeloop(true); for (.@index = 0; .@index < getarraysize(.@boxStrings); .@index++) { .@matrixIndex = 3 * .@index; .@amount = .@boxMatrix[.@matrixIndex]; .@itemID = .@boxMatrix[.@matrixIndex + 1]; mesc l("- %03d %s", .@amount, getitemlink(.@itemID)); if (countitem(.@itemID) >= .@amount) { array_push(.@menuOptions$, .@boxStrings[.@index]); array_push(.@menuOptions$, str(.@index)); } } //freeloop(false); // Do the request mes ""; mesc l("Fill with what?"); menuint2(.@menuOptions$); deletearray(.@menuOptions$); mes ""; if (@menuret >= 0) { .@matrixIndex = 3 * .@menuret; .@amount = .@boxMatrix[.@matrixIndex]; .@itemID = .@boxMatrix[.@matrixIndex + 1]; .@boxID = .@boxMatrix[.@matrixIndex + 2]; inventoryplace .@boxID, 1; delitem EmptyBox, 1; delitem .@itemID, .@amount; getitem .@boxID, 1; } closedialog; close; }