summaryrefslogtreecommitdiff
path: root/npc/000-1/chest.txt
blob: 511023e0cc222efe8d4b7b999f1c8fad0b9c56d0 (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
// Evol scripts.
// Authors:
//    4144
//    gumi
//    Hal9000
//    Reid
// Description:
//    A treasure chest, with... Treasures inside!
// Variable:
//    x   ShipQuests_TreasureChest
// Values:
//    0   Treasure Chest has not been opened yet.
//    1   Treasure Chest has been opened.

000-1,83,70,0	script	Chest#000-1	NPC_CHEST,3,3,{

   if (.busy == false)
    {
        if (getq(ShipQuests_TreasureChest) == 0)
        {
            inventoryplace OldBook, 1;
            setq ShipQuests_TreasureChest, 1;
            npctalk3 l("Chest opened.");
            Zeny += 100;
            getitem OldBook, 1;
        }

        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;
    }
    end;

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

OnTimer500:
    .busy = false; // unlock

    if (.dir == 0)
    {
        stopnpctimer; // stop here if the chest is closed
    }
    end;

OnUnTouch:
    if (getareausers(.x - 3, .y - 3, .x + 3, .y + 3) > 0 || .dir == 0)
    {
        end;
    }
OnTimer30000:
    .busy = true;
    .dir = 6; // closing
    specialeffect(25, AREA, getnpcid()); // closing
    setnpctimer 0;
OnTouch:
    end;


OnInit:
    .distance = 2;
    end;
}