summaryrefslogtreecommitdiff
path: root/npc/functions/casino.txt
blob: 87b71a4d464c4975e0cc71f1334c32ce884c24de (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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
// TMW2 Scripts
// Author:
//    Jesusalva
// Description:
//    Slot Machines, Blackjack, other crap for npc duplication
// Contents:
//    "Slot Machine"
//    "High Lower"

// SLOT MACHINE - You'll get PRIZE if you roll a 777!
// PRIZE must be numeric INT, AegisName won't get parsed.
// Slot Machine#map_prize
// Slot Machine#map
// Slot Machine#_prize
-	script	Slot Machine	NPC_HIDDEN,{
    function symbol {
        switch (getarg(0)) {
        case 1:
            mesn "%%A";
            break;
        case 2:
            mesn "%%B";
            break;
        case 3:
            mesn "%%C";
            break;
        case 4:
            mesn "%%D";
            break;
        case 5:
            mesn "%%E";
            break;
        case 6:
            mesn "%%F";
            break;
        case 7:
            mesn "7";
            break;
        default:
            mesn "%%@";
            break;
        }
    }

L_Menu:
    mesn;
    mesc l("Spin three symbols, and jackpot great rewards!");
    mesc l("Just one coin for spin.");
    next;
    menu
        rif(countitem(.coinid) >= 1, l("Spin!")), L_Spin,
        l("Prizes"), L_Info,
        l("Leave"), -;
    close;

L_Info:
    mes "";
    mesc l("Prizes:");
    mes l("##9 777: @@.", getitemlink(.itemid));
    mesc l("Three equal: @@.", "18 casino coins");
    mesc l("Two equal: 1 casino coin.");
    next;
    goto L_Menu;


L_Spin:
    mesc l("Spinning...");
    next;
    delitem .coinid, 1;
    .@a=rand2(1,7);
    .@b=rand2(1,7);
    .@c=rand2(1,7);
    symbol(.@a);
    symbol(.@b);
    symbol(.@c);
    next;
    mesn;
    if (.@a == .@b && .@a == .@c && .@a == 7) {
        getitem .itemid, 1;
        mesc l("Jackpot! You got a(n) %s!", getitemlink(.itemid)), 3;
    } else if (.@a == .@b && .@a == .@c) {
        getitem .coinid, 18;
        mesc l("Congrats! A pity it was not 777..."), 3;
    } else if (.@a == .@b || .@a == .@c || .@b == .@c) {
        getitem .coinid, 1;
        mesc l("Lucky! You got the coin back!"), 3;
    } else {
        mesc l("It wasn't this time..."), 3;
    }
    next;
    goto L_Menu;

OnInit:
    // "Next-Generation" parsing system
    // To replace default item, name NPC like this:
    // Slot Machine#_1212
    // Where "1212" is the item ID
    .@n$=strnpcinfo(0, "_0");
    explode(.@ni$, .@n$, "_");
    if (getarraysize(.@n$) > 0)
        .itemid=atoi(.@ni$[1]);
    else
        .itemid=0;

    // If item ID was not provided
    if (.itemid < 1) {
        //.itemid=Monocle;
        .itemid=BrownBowlerHat;
    }

    // Coin ID
    //.coinid=CasinoCoins;
    .coinid=CoinBag;

    .sex = G_OTHER;
    .distance = 4;
    end;
}


// HIGH LOWER - Guess if the next card will be HIGHER or LOWER!
// (No arguments)
-	script	High Lower	NPC_HIDDEN,{
    function cardname {
        switch (getarg(0)) {
        case 0:
            return "A"; break;
        case 10:
            return "J"; break;
        case 11:
            return "Q"; break;
        case 12:
            return "K"; break;
        case 13:
            return l("Joker"); break;
        default:
            return getarg(0)+1;
        }
    }

    goto L_Menu;

L_Menu:
    showavatar;
    mesn;
    mesc l("Hey, I am flopped. Do you want to gamble?");
    mesc l("You need a %s. I'll flip one card, and you'll need to decide if next draw will be HIGHER or LOWER.", getitemlink(.coinid));
    mesc l("If a tie happens, I'll give your coin back.");
    next;
    menu
        rif(countitem(.coinid) >= 1, l("Let's play!")), L_Spin,
        l("Information"), L_Info,
        l("Leave"), L_Quit;

L_Info:
    mes "";
    mesc l("Rules:");
    mesc l("A card will be flipped, you'll need to decide if next flip will be HIGHER or LOWER.");
    mesc l("Cards are ranked on this priority: A - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - J - Q - K - Joker");
    next;
    mesc l("Prizes:");
    mesc l("If you're right, you'll get at least %d GP!", .minprize);
    mesc l("If a tie happens, you'll get your coin back.");
    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 room.");
    next;
    mesc l("Winning Strike Prizes:");
    mesc l("Every seven successive right guesses, you'll get a %s!", getitemlink(Acorn)); // 7.14%
    //mesc l("Every fifteen successive right guesses, you'll get a %s!", getitemlink(SilverGift)); // 3.33%
    //mesc l("Every fifty successive right guesses, you'll get a %s!", getitemlink(GoldenGift)); // 1.00%
    //mesc l("Every 101 successive right guesses, you'll get a %s!", getitemlink(PrismGift)); // 0.50%
    next;
    goto L_Menu;


L_Spin:
    showavatar AVATAR_CARD_COVER;
    mesc l("I'll draw a card now!");
    next;
    delitem .coinid, 1;
    // First card will never be an edge card (Ace or Joker), so you can ALWAYS guess wrong.
    .@card1=rand2(1, 12);
    showavatar 1000+.@card1;
    mesn;
    mesc l("It's a @@!", cardname(.@card1));
    mesc l("Will next draw be HIGHER or LOWER?!");
    next;
    mesc l("Cards are ranked on this priority: A - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - J - Q - K - Joker");
    select
        l("HIGHER!"),
        l("LOWER!");
    mes "";

    // Flip Flop!
    .@card2=rand2(0, 13);
    showavatar 1000+.@card2;
    mesn;
    mesc l("It's a @@!", cardname(.@card2));

    if (.@card1 == .@card2) {
        mesc l("It's a tie!");
        getitem .coinid, 1;
        .@bypass=1;
    } else if (.@card2 < .@card1 && @menu == 2) {
        mesc l("It's lower! That's right!");
        Zeny=Zeny+.minprize;
        @gambler_winstreak+=1;
    } else if (.@card2 > .@card1 && @menu == 1) {
        mesc l("It's higher! That's right!");
        Zeny=Zeny+.minprize;
        @gambler_winstreak+=1;
    } else {
        mesc l("You were wrong!");
        @gambler_winstreak=0;
    }

    // Winning Streak
    if (!.@bypass && @gambler_winstreak) {
        if (@gambler_winstreak % 7 == 0)
            getitem Acorn, 1;
        /*
        if (@gambler_winstreak % 15 == 0)
            getitem SilverGift, 1;
        if (@gambler_winstreak % 50 == 0)
            getitem GoldenGift, 1;
        if (@gambler_winstreak % 101 == 0)
            getitem PrismGift, 1;
        */
        mesc l("Your current win streak is @@!", @gambler_winstreak);
        Zeny+=min(((@gambler_winstreak-1)*.gpbonus), .minprize); // Never 2x
    } else {
        .@bypass=0;
    }
    next;
    goto L_Menu;

L_Quit:
    close;

OnInit:
    // Gambling configuration
    .minprize=180;
    .gpbonus=10;

    // Coin ID
    //.coinid=CasinoCoins;
    .coinid=CoinBag;

    .sex = G_OTHER;
    .distance = 4;
    end;

}