summaryrefslogtreecommitdiff
path: root/npc/017-3/gambler.txt
blob: 5f914ea7a4bc0b939c6e9356a8134414a336d3b7 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// TMW2 Scripts
// Author:
//    Jesusalva
// Description:
//    Gambler: Can you remember the sequence?

017-3,23,38,0	script	Gambler#017-3	NPC_PLAYER,{
    function colorname {
        switch (getarg(0)) {
        case 1:
            return "Green"; break;
        case 2:
            return "Blue"; break;
        case 3:
            return "Red"; break;
        case 4:
            return "Yellow"; break;
        case 5:
            return "Exit"; break;
        default:
            return l("ERROR: %d", getarg(0));
        }
    }

    goto L_Menu;

L_Menu:
    showavatar NPC_FLOPPED_NOBLEMAN;
    mesn;
    mesc l("Gambling is for the weak, I offer you a true game!");
    mesc l("You need %d %s. I'll start showing you sequences of colors.", .price, getitemlink(CasinoCoins));
    mesc l("The farther you go on the sequence, the better the payout!");
    next;
    menu
        rif(countitem(CasinoCoins) >= .price, l("Let's play!")), L_Start,
        l("Information"), L_Info,
        l("Leave"), -;
    close;

L_Info:
    mes "";
    mesc l("Rules:");
    mesc l("A color sequence will be displayed on the avatar frame.");
    mesc l("You must then repeat the sequence at the board which will show.");
    next;
    mesc l("Prizes:");
    mesc l("You'll get %d GP every time you finish the sequence.", .prize);
    next;
    mesc l("Winning Strike Prizes:");
    mesc l("Every %d sequences, you'll get a %s!", 10, getitemlink(StrangeCoin));
    mesc l("If you get %d sequence, you'll get a %s!", 30, getitemlink(BronzeGift));
    mesc l("If you get %d sequence, you'll get a %s!", 50, getitemlink(SilverGift));
    //mesc l("If you get %d sequence, you'll get a %s!", 50, getitemlink(GoldenGift));
    next;
    goto L_Menu;


L_Start:
    showavatar AVATAR_SEQBOARD;
    mesc l("Pay attention to the sequence!");
    next;
    delitem CasinoCoins, .price;
    deletearray(@sequence);
    @streak=0;

L_Sequence:
    // Configure
    setnpcdialogtitle l("Memorize the sequence!");
    array_push(@sequence, 1+rand2(4));
    sleep2(1000);

    // Display
    freeloop(true);
    for (.@i=0;.@i < getarraysize(@sequence);.@i++) {
        showavatar 1200+@sequence[.@i];
        sleep2(1200-(@streak*20));
    }
    freeloop(false);

    // Request
    setnpcdialogtitle l("What was the sequence?");
    showavatar AVATAR_SEQBOARD;
    sleep2(500);

    for (.@i=0;.@i < getarraysize(@sequence);.@i++) {
        setskin "seqboard";
        select
            l("Green"),
            l("Blue"),
            l("Red"),
            l("Yellow"),
            l("Exit");
        .@ans=@menu;
        setskin "";
        mes "";
        mes l("%s", colorname(.@ans));
        //next;
        setnpcdialogtitle strnpcinfo(1);

        // Exit
        if (.@ans == 5)
            goto L_Close;

        // Wrong reply
        if (.@ans != @sequence[.@i])
            goto L_Wrong;
        // Correct!
    }
    mes "";

    // Seems like everything is/was correct
    mesn;
    mesq l("Congratulations! Everything was correct!");
    Zeny+=.prize;
    @streak+=1;

    // Winning Streak
    if (@streak % 10 == 0)
        getitem StrangeCoin, 1;
    if (@streak == 30)
        getitem BronzeGift, 1;
    if (@streak == 50)
        getitem SilverGift, 1;
    mesc l("Your current win streak is @@!", @streak);
    next;
    // Game over
    if (@streak == 50)
        goto L_Close;
    // Otherwise, go ahead
    mesn;
    mesc l("Continue?"), 1;
    next;
    if (askyesno() == ASK_YES)
        goto L_Sequence;
    goto L_Close;

L_Wrong:
    mesn;
    mesq l("Oh no... That is wrong! %%3");
    next;
    mesn;
    mesq l("Better luck next time!");
    close;

L_Close:
    mesn;
    mesq l("Thanks for playing!");
    close;

OnInit:
    .@npcId = getnpcid(.name$);
    setunitdata(.@npcId, UDT_HEADTOP, TopHat);
    setunitdata(.@npcId, UDT_HEADMIDDLE, CreasedShirt);
    setunitdata(.@npcId, UDT_HEADBOTTOM, JeansShorts);

    .sex = G_MALE;
    .distance = 4;
    .price = 5;
    .prize = 50;
    npcsit;
    end;
}