summaryrefslogblamecommitdiff
path: root/npc/007-1/treasure.txt
blob: 0f839765176ec5a973e90160ebd6e895bd1fa68a (plain) (tree)




















                                                                                     

                                                                                



                              


                            






















                                                                          
                                                                                                                                             
                                                
                                                                                                                                                                           



















                                                                                                                                                 



                                                              
     
          














                                                         

            
            
            


                                                                             
                        
                                                    
     
                        













                                                 
// TMW2 scripts.
// Author:
//    Jesusalva
// Description:
//    Fishing and Treasure Box

007-1,155,163,0	script	#fishing_00710	NPC_WATER_SPLASH,{

    .@regen_time=200;
    fishing(2, CommonCarp, RustyKnife,
               ScorpionStinger, FatesPotion, GrassCarp); // begin or continue fishing
    close;

OnInit:
    .sex = G_OTHER;
    .distance = 4;
    .cooldown = 200;
    end;
}

/*
007-1,x,y,0	duplicate(#fishing_00710)	#fishing_00711	NPC_WATER_SPLASH
007-1,x,y,0	duplicate(#fishing_00710)	#fishing_00712	NPC_WATER_SPLASH
*/

// Animation code by Evol Team
// 4144, gumi, Hal9000, Reid
// (Random) Treasure Chest
//  Authored by Jesusalva
// Regenerates every 6 hours
007-1,0,0,0	script	#chest_00710	NPC_CHEST,{

   if (!.busy && !.empty) {
        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!");
        if (!.empty) {
            TREASURE_OPEN=TREASURE_OPEN+1;
            .@t=TREASURE_OPEN;
            .@r=rand(0,10000);

            // Select treasure list
            // You're warranted an ultra rare (0.1%) every 99 open chests
            // You're warranted a super rare (1%) every 50 open chests
            // There's also rares (10%), uncommons (40%) and commons (60%)
            if (.@t % 99 == 0 || .@r < 10)
                .@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)
                .@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, StrangeCoin);
            else
                .@loot=any(FatesPotion, ChocolateBar, Plushroom, Chagashroom, RawLog, LeatherPatch);


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

        .empty=true;
        specialeffect(.dir == 0 ? 24 : 25, AREA, getnpcid()); // closed ? opening : closing
        .dir = .dir == 0 ? 2 : 6; // closed ? opening : closing
        .busy = true; // lock until available again
        initnpctimer;
    } else if (!.busy) {
        mesc l("Someone looted this treasure box already...");
    } else {
        end;
    }
    close;

OnTimer160:
    .dir = .dir == 6 ? 0 : 4; // closing ? closed : open
    end;

OnTimer500:
    .busy = false; // unlock
    if (.dir == 0 || .dir == 4)
        stopnpctimer; // stop here if the chest is closed
    end;

OnInit:
    .busy = false;
    .distance = 2;
    .empty = false;

OnClock0156:
OnClock0756:
OnClock1356:
OnClock1956:
    // Try to warp randomly to a walkable spot, up to 20 attempts
    // Otherwise, it'll stay where it already is (but will close and refill).
    .@e=0; .@x=0; .@y=0;
   while (!checkcell(.map$, .@x, .@y, cell_chkpass))
    {
        if (.@e == 20) {
            .@x=.x;
            .@y=.y;
            break;
        }
        // Remember the +20 -20 margin adjustment
        .@x = rand(20, 185);
        .@y = rand(20, 180);
        ++.@e;
    }
    .busy=false;
    .empty=false;
    movenpc .name$, .@x, .@y, 0;
    end;
}