summaryrefslogtreecommitdiff
path: root/npc/functions/treasure.txt
blob: 20771d0fa95954f060b414bf03b2c83e80250cfe (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
// TMW2 functions.
// Author:
//    Jesusalva
// Description:
//    Random Treasure Box Utils

function	script	TreasureBox	{
        .@id=getnpcid();
        if (RNGTREASURE_DATE[.@id] > gettimetick(2)) {
            mesc l("The chest is unlocked and empty.");
            close;
        }

        mesc l("Open the chest?");
        mesc l("Cost: 1 @@", getitemlink(TreasureKey)), 1;
        if (!countitem(TreasureKey))
            close;
        next;
        if (askyesno() == ASK_NO)
            close;

        delitem TreasureKey, 1;
        mesc l("You open the chest!");
        RNGTREASURE_DATE[.@id]=gettimetick(2)+60*4; // Minimum 4 hours

        .@empty=getvariableofnpc(.empty, strnpcinfo(0));
        if (!.@empty) {
            TREASURE_OPEN=TREASURE_OPEN+1;
            .@t=TREASURE_OPEN;
            .@r=rand(0,10000)-readparam(bLuk);

            // Select treasure list
            // You're warranted an ultra rare (0.1%) every 149 open chests
            // You're warranted a super rare (1%) every 50 open chests
            // There's also rares (9%), uncommons (30%) and commons (60%)
            .@ur_rate=min(10, (TREASURE_OPEN/10));
            if (.@t % 149 == 0 || .@r < .@ur_rate)
                .@loot=any(AtroposMixture, GoldenApple, DivineApple, MercBoxA, SilverGift, Shemagh, EverburnPowder, IridiumOre, PlatinumOre);
            else if (.@t % 50 == 0 || .@r < 100)
                .@loot=any(Grenade, SnakeEgg, LachesisBrew, ArrowAmmoBox, CoinBag, BronzeGift, TerraniteOre, LeadOre, TinOre, SilverOre, GoldOre, TitaniumOre, FluoPowder);
            else if (.@r < 1000 || .@t == 0)
                .@loot=any(MoubooSteak, ClothoLiquor, Coal, SmallMushroom, HastePotion, StrengthPotion, Dagger, StrangeCoin, IronOre, CopperOre);
            else if (.@r < 4000)
                .@loot=any(Croconut, Potatoz, MoubooSteak, ClothoLiquor, Coal, SmallMushroom, HastePotion, StrengthPotion, Beer);
            else
                .@loot=any(FatesPotion, ChocolateBar, Plushroom, Chagashroom, RawLog, LeatherPatch, BugLeg, ScorpionStinger, SmallKnife, StrangeCoin);


            inventoryplace .@loot, 1;
            mesc l("You find @@ inside!", getitemlink(.@loot));
            getitem .@loot, 1;
        } else {
            mesc l("You find @@ inside!", l("nothing"));
        }

}