summaryrefslogtreecommitdiff
path: root/npc/009-8/gambler.txt
blob: 6de6fc4554ad5f5e60c7f0c500d9ad2439cf06df (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
// TMW2 Scripts
// Author:
//    Jesusalva
// Description:
//    The Illegal Gambler

009-8,37,34,0	script	Illegal Gambler#009-8	NPC_PLAYER,{
    .@showMenu=true;
    goto L_Menu;

L_Menu:
    if (.@showMenu) {
        mesn;
        mesc l("Hey, welcome to Halinarzo's illegal Casino! Everything here is illegal, even the prizes, so don't blame anyone if you get scammed!");
        next;
        mesn;
        mesc l("So, do you want to play a game of Creps?!"); // ;-- TRANSLATORS, wordplay of "Craps"
        next;
        .@showMenu=false;
    }
    menu
        rif(countitem(CasinoCoins) >= 1, l("Let's play!")), L_Spin,
        l("Information"), L_Info,
        l("Leave"), L_Quit;

L_Info:
    mes "";
    mesn;
    mesc l("Chill, Creps is very similar to Craps! I'll throw two dices and you have to bet if I'll win or lose!");
    mesc l("If I get a 7 or 11 (natural) I win, and if I get a 2, 3 or 12 I lose (craps).");
    mesc l("If I get anything else, the number is my point, and rules change: Getting that number I win (point), getting a 7 I lose (craps).");
    mes "";
    mesc l("Prizes:");
    mesc l("If you guess right, you'll win 70 GP!");
    mesc l("If you're wrong, your winning streak is reset.");
    mesc l("Winning Streak is also reset on logout or when you leave the Inn.");
    mesc l("If you get %d successive right guesses, you'll get a %s!", 7, getitemlink(VneckJumper));
    mes "";
    mesc l("Sure, in regular Craps you can bet for the roll results and whatnot, but this is not Craps, this is Creps! So, are you going to play?");
    next;
    goto L_Menu;


L_Spin:
    mes "";
    mesc l("So how will ya bet, champ?!");
    select
        l("I bet on your victory!"),
        l("I bet on your defeat!");
    mes "";
    .@lose = @menu - 1;
    delitem CasinoCoins, 1;
    .@point = 0; .@result = -1;

    // Loop
    do
    {
        mesc l("Roll the dices!");
        next;
        .@c$ = any("", "red_");
        .@d1 = rand2(1,6);
        .@d2 = rand2(1,6);
        .@sc = .@d1 + .@d2;
        img(sprintf("dice/%s%d", .@c$, .@d1));
        img(sprintf("dice/%s%d", .@c$, .@d2));
        mesc l("I rolled a %d!", .@sc);

        if (!.@point) {
            // Classic rules
            if (.@sc == 7 || .@sc == 11) {
                mesc l("A natural! I win!"), 2;
                .@result = true;
            } else if (.@sc == 2 || .@sc == 3 || .@sc == 12) {
                mesc l("Craps! I lose!"), 1;
                .@result = false;
            } else {
                .@point = .@sc;
                mesc l("My point is %d!", .@point), 3;
            }
        } else {
            // Point rules
            if (.@sc == 7) {
                mesc l("Craps! I lose!"), 1;
                .@result = false;
            } else if (.@sc == .@point) {
                mesc l("I made my point! I win!"), 2;
                .@result = true;
            } // No else clause, keep rolling the dice
        }
    } while (.@result == -1);

    // Check if you won your bet
    if ((.@result && !.@lose) || (!.@result && .@lose)) {
        mesc b(l("I guess you guessed correctly!"));
        Zeny += 70;
        @craps_winstreak += 1;
        // Streak reward
        if (@craps_winstreak == 7)
            getitem VneckJumper, 1;
        // Christmas Event
        if (@craps_winstreak == 2)
            X24Event(X24_GROUP1, X24_G1_CRAPS);
        // Maybe you want another game?
        next;
        if (countitem(CasinoCoins))
            mesc l("New game?");
        else
            goto L_Quit;
        if (askyesno() == ASK_YES)
            goto L_Spin;
        goto L_Quit;
    } else {
        mesc b(l("Luck wasn't on your side today!")), 1;
        @craps_winstreak = 0;
    }
    dnext;
    goto L_Menu;

L_Quit:
    closeclientdialog;
    close;

OnInit:
    .sex = G_MALE;
    .distance = 4;
    .@npcId = getnpcid(.name$);
    setunitdata(.@npcId, UDT_HEADTOP,    TopHat);
    setunitdata(.@npcId, UDT_HEADMIDDLE, CopperArmor);
    setunitdata(.@npcId, UDT_HEADBOTTOM, JeansShorts);
    npcsit;
    end;

}