summaryrefslogtreecommitdiff
path: root/npc/items/emptybox.txt
blob: f2f6dc8bff6dfbf7522f657fe1e9d56f0b58e474 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// 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;
}