summaryrefslogtreecommitdiff
path: root/npc/functions/bank.txt
blob: d9ed5b948366370910b6c0c890b7dca857a48e76 (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
// Evol scripts.
// Authors:
//    gumi
//    Reid

function	script	MerchantGuild_Bank	{
    do
    {
        if (#MerchantBank > 0)
        {
            speech 1 | 4,
                    l("You currently have @@ Esperin on your bank account.",
                        format_number(#MerchantBank)),
                    l("What do you want to do with your money?");
        }
        else
        {
            speech 1 | 4,
                l("What do you want to do with your money?");
        }

        select
            rif(Zeny > 0, l("Deposit.")),
            rif(#MerchantBank > 0, l("Withdraw.")),
            l("I'm done.");

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

                menuint
                    l("Other."), -1,
                    rif(Zeny >= 5000, format_number(5000) + " E."), 5000,
                    rif(Zeny >= 10000, format_number(10000) + " E."), 10000,
                    rif(Zeny >= 25000, format_number(25000) + " E."), 25000,
                    rif(Zeny >= 50000, format_number(50000) + " E."), 50000,
                    rif(Zeny >= 100000, format_number(100000) + " E."), 100000,
                    rif(Zeny >= 250000, format_number(250000) + " E."), 250000,
                    rif(Zeny >= 500000, format_number(500000) + " E."), 500000,
                    rif(Zeny >= 1000000, format_number(1000000) + " E."), 1000000,
                    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 1 | 4,
                            l("You do not have enough Esperin on yourself.");
                        break;
                    }

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

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

                        speech 1 | 4,
                            l("You made a cash deposit of @@ E.", format_number(.@deposit));
                    }
                }
                break;

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

                menuint
                    l("Other."), -1,
                    rif(#MerchantBank >= 5000, format_number(5000) + " E."), 5000,
                    rif(#MerchantBank >= 10000, format_number(10000) + " E."), 10000,
                    rif(#MerchantBank >= 25000, format_number(25000) + " E."), 25000,
                    rif(#MerchantBank >= 50000, format_number(50000) + " E."), 50000,
                    rif(#MerchantBank >= 100000, format_number(100000) + " E."), 100000,
                    rif(#MerchantBank >= 250000, format_number(250000) + " E."), 250000,
                    rif(#MerchantBank >= 500000, format_number(500000) + " E."), 500000,
                    rif(#MerchantBank >= 1000000, format_number(1000000) + " E."), 1000000,
                    l("All of my money."), -2,
                    l("I changed my mind."), -3;

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

                if (@menuret > 0)
                {
                    if (@menuret > #MerchantBank)
                    {
                        speech 1 | 4,
                            l("You do not have enough Esperin on your bank account.");
                        break;
                    }

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

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

                        speech 1 | 4,
                            l("You withdrew a total of @@ E.", format_number(.@withdrawal));
                    }
                }
                break;

            default: return;
        }
    } while (true);
}