summaryrefslogtreecommitdiff
path: root/npc/functions/bank.txt
blob: 00ca148a910e77d5c4b863e3400fba195f6a4efe (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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
// TMW2 Script
// Modified by Jesusalva
// Evol scripts.
// Authors:
//    gumi
//    Reid

function	script	Banking	{
    do
    {
        if (BankVault > 0) {
            speech S_FIRST_BLANK_LINE | S_LAST_NEXT,
                    l("You currently have @@ GP on your bank account.",
                        format_number(BankVault)),
                    l("What do you want to do with your money?");
        } else {
            speech S_FIRST_BLANK_LINE | S_LAST_NEXT,
                l("What do you want to do with your money?");
        }

        select
            rif(Zeny > 0, l("Deposit.")),
            rif(BankVault > 0, l("Withdraw.")),
            l("Buy a Housing Letter"),
            l("I'm done.");

        switch (@menu)
        {
            case 1:
                speech S_FIRST_BLANK_LINE | S_LAST_NEXT,
                    l("How much do you want to deposit?");

                menuint
                    l("Other."), -1,
                    rif(Zeny >= 1000, format_number(1000) + " GP."), 1000,
                    rif(Zeny >= 2500, format_number(2500) + " GP."), 2500,
                    rif(Zeny >= 5000, format_number(5000) + " GP."), 5000,
                    rif(Zeny >= 10000, format_number(10000) + " GP."), 10000,
                    rif(Zeny >= 25000, format_number(25000) + " GP."), 25000,
                    rif(Zeny >= 50000, format_number(50000) + " GP."), 50000,
                    rif(Zeny >= 100000, format_number(100000) + " GP."), 100000,
                    l("All of my money."), -2,
                    l("I changed my mind."), -3;

                switch (@menuret) {
                    case -1:
                        input @menuret;
                        break;
                    case -2:
                        @menuret = Zeny;
                }

                if (@menuret > 0) {
                    if (@menuret > Zeny) {
                        speech S_FIRST_BLANK_LINE | S_LAST_NEXT,
                            l("You do not have enough Gold on yourself.");
                        break;
                    }

                    @menuret = min(MAX_BANK_ZENY, @menuret); // make sure the variable can't overflow
                    .@before = BankVault; // amount before the deposit
                    .@max = MAX_BANK_ZENY - BankVault; // maximum possible deposit
                    .@deposit = min(.@max, @menuret); // actual deposit

                    if (.@deposit > 0) {
                        BankVault += .@deposit; // add to bank
                        Zeny -= .@deposit; // remove from inventory

                        speech S_FIRST_BLANK_LINE | S_LAST_NEXT,
                            l("You made a cash deposit of @@ GP.", format_number(.@deposit));
                    }
                }
                break;

            case 2:
                speech S_FIRST_BLANK_LINE | S_LAST_NEXT,
                    l("How much do you want to withdraw?");

                menuint
                    l("Other."), -1,
                    rif(BankVault >= 1000, format_number(1000) + " GP."), 1000,
                    rif(BankVault >= 2500, format_number(2500) + " GP."), 2500,
                    rif(BankVault >= 5000, format_number(5000) + " GP."), 5000,
                    rif(BankVault >= 10000, format_number(10000) + " GP."), 10000,
                    rif(BankVault >= 25000, format_number(25000) + " GP."), 25000,
                    rif(BankVault >= 50000, format_number(50000) + " GP."), 50000,
                    rif(BankVault >= 100000, format_number(100000) + " GP."), 100000,
                    l("All of my money."), -2,
                    l("I changed my mind."), -3;

                switch (@menuret)
                {
                    case -1:
                        input @menuret;
                        break;
                    case -2:
                        @menuret = BankVault;
                }

                if (@menuret > 0) {
                    if (@menuret > BankVault) {
                        speech S_FIRST_BLANK_LINE | S_LAST_NEXT,
                            l("You do not have enough Gold Pieces on your bank account.");
                        break;
                    }

                    @menuret = min(MAX_ZENY, @menuret); // make sure the variable can't overflow
                    .@before = Zeny; // amount before the withdrawal
                    .@max = MAX_ZENY - Zeny; // maximum possible withdrawal
                    .@withdrawal = min(.@max, @menuret); // actual withdrawal

                    if (.@withdrawal > 0) {
                        Zeny += .@withdrawal; // add to inventory
                        BankVault -= .@withdrawal; // remove from bank

                        speech S_FIRST_BLANK_LINE | S_LAST_NEXT,
                            l("You withdrew a total of @@ GP.", format_number(.@withdrawal));
                    }
                }
                break;

            case 3:
                .@gp=REAL_ESTATE_CREDITS+Zeny;
                mesc l("You currently have @@ mobiliary credits + GP at your disposal.", format_number(.@gp));
                mesc l("@@ - @@ - @@", getitemlink(HousingLetterI), getitemlink(HousingLetterII), getitemlink(HousingLetterIII));
                next;
                select
                    l("Nothing"),
                    rif(.@gp >= 11000, l("Housing Letter I for 11,000 GP")),
                    rif(.@gp >= 101000, l("Housing Letter II for 101,000 GP")),
                    rif(.@gp >= 1001000, l("Housing Letter III for 1,001,000 GP"));
                mes "";
                switch (@menu) {
                    case 2:
                        realestate_payment(11000);
                        getitem HousingLetterI, 1;
                        break;
                    case 3:
                        realestate_payment(101000);
                        getitem HousingLetterII, 1;
                        break;
                    case 4:
                        realestate_payment(1001000);
                        getitem HousingLetterIII, 1;
                        break;
                }
                break;
            default: return;
        }
    } while (true);
}

function	script	BKInfo	{
    speech S_LAST_NEXT,
        l("We organize some auction and we help local merchants to launch their businesses."),
        l("We also feature some services like a storage and a bank for members."),
        l("Registration is open to everybody, but newcomers need to pay a fee for all of the paperwork."),
        l("If you have... references, we may also be able to offer you... premium storing.");

    narrator S_FIRST_BLANK_LINE,
        l("The bank and item storage is shared between all characters within a same account."),
        l("With it, you can safely move items and funds between your characters."),
        l("The Premium and Deluxe Storages are only available for characters which were reborn at least once.");
    return;
}

// name, city, price, ID
function	script	BKReg	{
    .@price=max(2000, getarg(2)-#BankP);
    .@id=getarg(3, 1);
    @menu=3;
    do
    {
        mesn getarg(0);
        mesq l("Register fee is @@.", .@price);
        mesc l("The fee only need to be paid once and will work in every town.");
        next;
        select
            rif(Zeny >= .@price, l("Register")),
            l("Not at the moment"),
            l("Information");
        mes "";
        if (@menu == 1) {
            Zeny=Zeny-.@price;
            setq General_Banker, .@id;
            #BankP=#BankP+(rand2(150,400)*(.@id**2));
            mesn getarg(0);
            mesq l("Registered! You can now use any banking service, of any town!");
        } else if (@menu == 3) {
            BKInfo();
        }
    } while (@menu == 3);
    return;
}

// name, city, price (defaults to 10k)
function	script	Banker	{
    mesn getarg(0);
    mesq l("Welcome! My name is @@, I am a representative of the Merchant Guild on @@.", getarg(0), getarg(1));
    next;

    if (getq(General_Banker) == 0) {
        BKReg(getarg(0), getarg(1), getarg(2,10000));
    } else {
        do
        {
            select
                l("I would like to store some items."),
                l("I would like to perform money transactions."),
                l("Did I received any mail?"),
                rif(REBIRTH || is_sponsor(), l("I would like to use the Premium Storage.")),
                rif(REBIRTH, l("I would like to use the Deluxe Storage.")),
                rif(getcharid(2) > 0, l("I would like to use the Guild Storage.")),
                l("What is this guild for?"),
                l("Bye.");

            switch (@menu) {
                case 1:
                    closeclientdialog;
                    openstorage;
                    close;
                    break;
                case 2:
                    Banking();
                    break;
                case 3:
                    // NOTE: This value is HARDCODED, do not try changing it!
                    mesc l("Note: Transfering items on mail cost @@ GP/item", 500);
                    mesc l("Money transference by mail is, however, free.");
                    next;
                    closeclientdialog;
                    openmail();
                    close;
                    break;
                case 4:
                    if (getq(General_Banker) < 2) {
                        mesn;
                        mesq l("The Premium Storage is available to all our sponsors and anyone with... references. Such as yourself!");
                        next;
                        .@price=25000;
                        mesn;
                        mesq l("It will allow you to store %d extra items, with unlimited weight or size limit, for only %s GP! Although premium clients such as yourself... deserve a discount!", 300, fnum(.@price));
                        next;
                        BKReg(getarg(0), getarg(1), .@price, 2);
                    }
                    if (getq(General_Banker) >= 2) {
                        closeclientdialog;
                        openstorage 4;
                        close;
                    }
                    break;
                case 5:
                    if (getq(General_Banker) < 2) {
                        mesn;
                        mesq l("This option is not yet available for you; Please purchase the Premium Storage first, and then we can get started on the deluxe.");
                        break;
                    }
                    if (getq(General_Banker) < 3) {
                        mesn;
                        mesq l("The Deluxe Storage is available only to our best customers, and how lucky you! YOU are eligible!");
                        next;
                        .@price=100000;
                        mesn;
                        mesq l("It will allow you to store %d extra items, with unlimited weight or size limit, for only %s GP! Although premium clients such as yourself... deserve a discount!", 500, fnum(.@price));
                        next;
                        BKReg(getarg(0), getarg(1), .@price, 3);
                    }
                    if (getq(General_Banker) >= 3) {
                        closeclientdialog;
                        openstorage 5;
                        close;
                    }
                    break;
                case 6:
                    // FIXME: Raises a console warning of invalid map
                    closeclientdialog;
                    doevent "Guild Storage::OnStorage";
                    close;
                    break;
                case 7:
                    mes "";
                    BKInfo();
                    break;
            }
            if (@menu != 8) {
                speech S_FIRST_BLANK_LINE | S_LAST_NEXT | S_NO_NPC_NAME,
                    l("Something else?");
            }
        } while (@menu != 8);
    }
    closedialog;
    goodbye;
    close;

}